diff --git a/Admin/Activate.php b/Admin/Activate.php new file mode 100644 index 0000000..fff7124 --- /dev/null +++ b/Admin/Activate.php @@ -0,0 +1,44 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Admin; + + +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Module\ActivateAbstract; +use phpOMS\Module\InfoManager; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Activate extends ActivateAbstract +{ + + /** + * {@inheritdoc} + */ + public static function activate(DatabasePool $dbPool, InfoManager $info) + { + parent::activate($dbPool, $info); + } +} diff --git a/Admin/Deactivate.php b/Admin/Deactivate.php new file mode 100644 index 0000000..8ae2bfa --- /dev/null +++ b/Admin/Deactivate.php @@ -0,0 +1,44 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Admin; + + +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Module\DeactivateAbstract; +use phpOMS\Module\InfoManager; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Deactivate extends DeactivateAbstract +{ + + /** + * {@inheritdoc} + */ + public static function deactivate(DatabasePool $dbPool, InfoManager $info) + { + parent::deactivate($dbPool, $info); + } +} diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json new file mode 100644 index 0000000..bd1d74f --- /dev/null +++ b/Admin/Install/Navigation.install.json @@ -0,0 +1,79 @@ +[ + { + "id": 1001101001, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 1, + "subtype": 1, + "name": "Tasks", + "uri": "/{/lang}/backend/task/dashboard?{?}", + "target": "self", + "icon": "fa fa-bolt", + "order": 15, + "from": "Tasks", + "permission": null, + "parent": 0, + "children": [ + { + "id": 1001102001, + "pid": "43ec7cda8be033d7b20996708a2fca644e5dde86", + "type": 3, + "subtype": 1, + "name": "List", + "uri": "/{/lang}/backend/task/dashboard?{?}", + "target": "self", + "icon": null, + "order": 1, + "from": "Tasks", + "permission": null, + "parent": 1001101001, + "children": [ + { + "id": 1001102101, + "pid": "43ec7cda8be033d7b20996708a2fca644e5dde86", + "type": 0, + "subtype": 1, + "name": "Tasks", + "uri": "/{/lang}/backend/task/single?{?}", + "target": "self", + "icon": null, + "order": 1, + "from": "Tasks", + "permission": null, + "parent": 1001102001, + "children": [] + } + ] + }, + { + "id": 1001103001, + "pid": "43ec7cda8be033d7b20996708a2fca644e5dde86", + "type": 3, + "subtype": 1, + "name": "Create", + "uri": "/{/lang}/backend/task/create?{?}", + "target": "self", + "icon": null, + "order": 10, + "from": "Tasks", + "permission": null, + "parent": 1001101001, + "children": [] + }, + { + "id": 1001104001, + "pid": "43ec7cda8be033d7b20996708a2fca644e5dde86", + "type": 3, + "subtype": 1, + "name": "Analysis", + "uri": "/{/lang}/backend/task/analysis?{?}", + "target": "self", + "icon": null, + "order": 20, + "from": "Tasks", + "permission": null, + "parent": 1001101001, + "children": [] + } + ] + } +] diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php new file mode 100644 index 0000000..2a574b0 --- /dev/null +++ b/Admin/Install/Navigation.php @@ -0,0 +1,40 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Admin\Install; +use phpOMS\DataStorage\Database\DatabasePool; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Navigation +{ + public static function install(string $path, DatabasePool $dbPool) + { + $navData = json_decode(file_get_contents(__DIR__ . '/Navigation.install.json'), true); + + $class = '\\Modules\\Navigation\\Admin\\Installer'; + /** @var $class \Modules\Navigation\Admin\Installer */ + $class::installExternal($dbPool, $navData); + } +} diff --git a/Admin/Installer.php b/Admin/Installer.php new file mode 100644 index 0000000..5594d54 --- /dev/null +++ b/Admin/Installer.php @@ -0,0 +1,153 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Admin; + +use phpOMS\DataStorage\Database\DatabaseType; +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Module\InfoManager; +use phpOMS\Module\InstallerAbstract; + +/** + * Tasks install class. + * + * @category Modules + * @package Modules\Tasks + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Installer extends InstallerAbstract +{ + + /** + * {@inheritdoc} + */ + public static function install(string $path, DatabasePool $dbPool, InfoManager $info) + { + parent::install($path, $dbPool, $info); + + switch ($dbPool->get('core')->getType()) { + case DatabaseType::MYSQL: + $dbPool->get('core')->con->beginTransaction(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'task` ( + `task_id` int(11) NOT NULL AUTO_INCREMENT, + `task_title` varchar(60) DEFAULT NULL, + `task_desc` text NOT NULL, + `task_type` tinyint(1) NOT NULL, + `task_status` tinyint(1) NOT NULL, + `task_due` datetime NOT NULL, + `task_done` datetime DEFAULT NULL, + `task_schedule` int(11) DEFAULT NULL, + `task_created_by` int(11) NOT NULL, + `task_created_at` datetime NOT NULL, + PRIMARY KEY (`task_id`), + KEY `task_schedule` (`task_schedule`), + KEY `task_created_by` (`task_created_by`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'task` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'task_ibfk_1` FOREIGN KEY (`task_schedule`) REFERENCES `' . $dbPool->get('core')->prefix . 'schedule` (`schedule_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'task_ibfk_2` FOREIGN KEY (`task_created_by`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'task_media` ( + `task_media_id` int(11) NOT NULL AUTO_INCREMENT, + `task_media_src` int(11) NULL, + `task_media_dst` int(11) NULL, + PRIMARY KEY (`task_media_id`), + KEY `task_media_src` (`task_media_src`), + KEY `task_media_dst` (`task_media_dst`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'task_media` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'task_media_ibfk_1` FOREIGN KEY (`task_media_src`) REFERENCES `' . $dbPool->get('core')->prefix . 'task` (`task_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'task_media_ibfk_2` FOREIGN KEY (`task_media_dst`) REFERENCES `' . $dbPool->get('core')->prefix . 'media` (`media_id`);' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'task_account` ( + `task_account_id` int(11) NOT NULL AUTO_INCREMENT, + `task_account_task` int(11) NOT NULL, + `task_account_seen` tinyint(1) NOT NULL, + `task_account_account` int(11) NOT NULL, + `task_account_type` tinyint(1) NOT NULL, + PRIMARY KEY (`task_account_id`), + KEY `task_account_task` (`task_account_task`), + KEY `task_account_account` (`task_account_account`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'task_account` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'task_account_ibfk_1` FOREIGN KEY (`task_account_task`) REFERENCES `' . $dbPool->get('core')->prefix . 'task` (`task_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'task_account_ibfk_2` FOREIGN KEY (`task_account_account`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'task_element` ( + `task_element_id` int(11) NOT NULL AUTO_INCREMENT, + `task_element_desc` text NOT NULL, + `task_element_task` int(11) NOT NULL, + `task_element_created_by` int(11) NOT NULL, + `task_element_status` tinyint(1) NOT NULL, + `task_element_due` datetime NOT NULL, + `task_element_forwarded` int(11) DEFAULT NULL, + `task_element_created_at` datetime NOT NULL, + PRIMARY KEY (`task_element_id`), + KEY `task_element_task` (`task_element_task`), + KEY `task_element_created_by` (`task_element_created_by`), + KEY `task_element_forwarded` (`task_element_forwarded`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'task_element` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'task_element_ibfk_1` FOREIGN KEY (`task_element_task`) REFERENCES `' . $dbPool->get('core')->prefix . 'task` (`task_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'task_element_ibfk_2` FOREIGN KEY (`task_element_created_by`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'task_element_ibfk_3` FOREIGN KEY (`task_element_forwarded`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'task_element_media` ( + `task_element_media_id` int(11) NOT NULL AUTO_INCREMENT, + `task_element_media_src` int(11) NULL, + `task_element_media_dst` int(11) NULL, + PRIMARY KEY (`task_element_media_id`), + KEY `task_element_media_src` (`task_element_media_src`), + KEY `task_element_media_dst` (`task_element_media_dst`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'task_element_media` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'task_element_media_ibfk_1` FOREIGN KEY (`task_element_media_src`) REFERENCES `' . $dbPool->get('core')->prefix . 'task_element` (`task_element_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'task_element_media_ibfk_2` FOREIGN KEY (`task_element_media_dst`) REFERENCES `' . $dbPool->get('core')->prefix . 'media` (`media_id`);' + )->execute(); + + $dbPool->get('core')->con->commit(); + break; + } + } +} diff --git a/Admin/Routes/Web/Api.php b/Admin/Routes/Web/Api.php new file mode 100644 index 0000000..1e24e36 --- /dev/null +++ b/Admin/Routes/Web/Api.php @@ -0,0 +1,18 @@ + [ + [ + 'dest' => '\Modules\Tasks\Controller:apiTaskCreate', + 'verb' => RouteVerb::SET, + ], + ], + '^.*/api/task/element.*$' => [ + [ + 'dest' => '\Modules\Tasks\Controller:apiTaskElementCreate', + 'verb' => RouteVerb::SET, + ], + ], +]; diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php new file mode 100644 index 0000000..a407d12 --- /dev/null +++ b/Admin/Routes/Web/Backend.php @@ -0,0 +1,30 @@ + [ + [ + 'dest' => '\Modules\Tasks\Controller:viewTaskDashboard', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/task/single.*$' => [ + [ + 'dest' => '\Modules\Tasks\Controller:viewTaskView', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/task/create.*$' => [ + [ + 'dest' => '\Modules\Tasks\Controller:viewTaskCreate', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/task/analysis.*$' => [ + [ + 'dest' => '\Modules\Tasks\Controller:viewTaskAnalysis', + 'verb' => RouteVerb::GET, + ], + ], +]; diff --git a/Admin/Routes/console.php b/Admin/Routes/console.php new file mode 100644 index 0000000..1ecbfac --- /dev/null +++ b/Admin/Routes/console.php @@ -0,0 +1,3 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Admin; + + +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\DataStorage\Database\Schema\Builder; +use phpOMS\Module\InfoManager; +use phpOMS\Module\UninstallAbstract; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Uninstall extends UninstallAbstract +{ + + /** + * {@inheritdoc} + */ + public static function uninstall(DatabasePool $dbPool, InfoManager $info) + { + parent::uninstall($dbPool, $info); + + $query = new Builder($dbPool->get()); + + $query->prefix($dbPool->get('core')->getPrefix())->drop( + 'task_element', + 'task_account', + 'task' + ); + + $dbPool->get()->con->prepare($query->toSql())->execute(); + } +} diff --git a/Admin/Update.php b/Admin/Update.php new file mode 100644 index 0000000..32818b2 --- /dev/null +++ b/Admin/Update.php @@ -0,0 +1,47 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Admin; + + +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Module\InfoManager; +use phpOMS\Module\UpdateAbstract; +use phpOMS\System\File\Directory; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Update extends UpdateAbstract +{ + + /** + * {@inheritdoc} + */ + public static function update(DatabasePool $dbPool, InfoManager $info) + { + Directory::deletePath(__DIR__ . '/Update'); + mkdir('Update'); + parent::update($dbPool, $info); + } +} diff --git a/Controller.php b/Controller.php new file mode 100644 index 0000000..8f6ba14 --- /dev/null +++ b/Controller.php @@ -0,0 +1,279 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks; + +use Model\Message\FormValidation; +use Model\Message\Redirect; +use Model\Message\Reload; +use Modules\Tasks\Models\Task; +use Modules\Tasks\Models\TaskElement; +use Modules\Tasks\Models\TaskElementMapper; +use Modules\Tasks\Models\TaskMapper; +use Modules\Tasks\Models\TaskStatus; +use Modules\Tasks\Models\TaskType; +use phpOMS\Message\RequestAbstract; +use phpOMS\Message\ResponseAbstract; +use phpOMS\Module\ModuleAbstract; +use phpOMS\Module\WebInterface; +use phpOMS\Uri\UriFactory; +use phpOMS\Views\View; + +/** + * Task class. + * + * @category Modules + * @package Modules\Tasks + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Controller extends ModuleAbstract implements WebInterface +{ + + /** + * Module path. + * + * @var string + * @since 1.0.0 + */ + /* public */ const MODULE_PATH = __DIR__; + + /** + * Module version. + * + * @var string + * @since 1.0.0 + */ + /* public */ const MODULE_VERSION = '1.0.0'; + + /** + * Module name. + * + * @var string + * @since 1.0.0 + */ + /* public */ const MODULE_NAME = 'Tasks'; + + /** + * Providing. + * + * @var string + * @since 1.0.0 + */ + protected static $providing = [ + 'Navigation' + ]; + + /** + * Dependencies. + * + * @var string + * @since 1.0.0 + */ + protected static $dependencies = [ + ]; + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return \Serializable + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewTaskDashboard(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Tasks/Theme/Backend/task-dashboard'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001101001, $request, $response)); + + $tasks = TaskMapper::getNewest(25); + $view->addData('tasks', $tasks); + + return $view; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return \Serializable + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewTaskView(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Tasks/Theme/Backend/task-single'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001101001, $request, $response)); + + $task = TaskMapper::get((int) $request->getData('id')); + $view->addData('task', $task); + + return $view; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return \Serializable + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewTaskCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Tasks/Theme/Backend/task-create'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001101001, $request, $response)); + + return $view; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return \Serializable + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewTaskAnalysis(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Tasks/Theme/Backend/task-analysis'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001101001, $request, $response)); + + return $view; + } + + private function validateTaskCreate(RequestAbstract $request) : array + { + $val = []; + if ( + ($val['title'] = empty($request->getData('title'))) + || ($val['description'] = empty($request->getData('description'))) + || ($val['due'] = !((bool)strtotime($request->getData('due')))) + || ($val['forward'] = !(is_numeric($request->getData('forward') ?? 0))) + ) { + return $val; + } + + return []; + } + + public function openNav(int $account) : int + { + return TaskMapper::countUnread($account); + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return \Serializable + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function apiTaskCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + if (!empty($val = $this->validateTaskCreate($request))) { + $response->set('task_create', new FormValidation($val)); + + return; + } + + $task = new Task(); + $task->setTitle($request->getData('title') ?? ''); + $task->setDescription($request->getData('description') ?? ''); + $task->setCreatedBy($request->getAccount()); + $task->setCreatedAt(new \DateTime('now')); + $task->setDue(new \DateTime($request->getData('due') ?? 'now')); + $task->setStatus(TaskStatus::OPEN); + $task->setType(TaskType::SINGLE); + + $element = new TaskElement(); + $element->setForwarded($request->getData('forward') ?? $request->getAccount()); + $element->setCreatedAt($task->getCreatedAt()); + $element->setCreatedBy($task->getCreatedBy()); + $element->setDue($task->getDue()); + $element->setStatus(TaskStatus::OPEN); + + $task->addElement($element); + + TaskMapper::create($task); + $response->set($request->__toString(), $task->jsonSerialize()); + } + + private function validateTaskElementCreate(RequestAbstract $request) : array + { + $val = []; + if ( + ($val['status'] = !TaskStatus::isValidValue((int) $request->getData('status'))) + || ($val['due'] = !((bool)strtotime($request->getData('due')))) + || ($val['task'] = !(is_numeric($request->getData('task')))) + || ($val['forward'] = !(is_numeric(empty($request->getData('forward')) ? $request->getAccount() : $request->getData('forward')))) + ) { // todo: validate correct task + return $val; + } + + return []; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return \Serializable + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function apiTaskElementCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + if (!empty($val = $this->validateTaskElementCreate($request))) { + $response->set('task_element_create', new FormValidation($val)); + + return; + } + + $element = new TaskElement(); + $element->setForwarded($request->getData('forward') ?? $request->getAccount()); + $element->setCreatedAt(new \DateTime('now')); + $element->setCreatedBy($request->getAccount()); + $element->setDue(new \DateTime($request->getData('due') ?? 'now')); + $element->setStatus($request->getData('status')); + $element->setTask($request->getData('task')); + $element->setDescription($request->getData('description')); + + TaskElementMapper::create($element); + $response->set($request->__toString(), $element->jsonSerialize()); + } + +} diff --git a/Models/NullTask.php b/Models/NullTask.php new file mode 100644 index 0000000..6af2107 --- /dev/null +++ b/Models/NullTask.php @@ -0,0 +1,34 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Models; + + + +/** + * Task class. + * + * @category Modules + * @package Framework + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class NullTask extends Task +{ + +} diff --git a/Models/NullTaskElement.php b/Models/NullTaskElement.php new file mode 100644 index 0000000..81d52ba --- /dev/null +++ b/Models/NullTaskElement.php @@ -0,0 +1,34 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Models; + + + +/** + * Task class. + * + * @category Modules + * @package Framework + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class NullTaskElement extends TaskElement +{ + +} diff --git a/Models/Stats.php b/Models/Stats.php new file mode 100644 index 0000000..e69de29 diff --git a/Models/Task.php b/Models/Task.php new file mode 100644 index 0000000..2483db3 --- /dev/null +++ b/Models/Task.php @@ -0,0 +1,447 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Models; +use Modules\Calendar\Models\Schedule; +use phpOMS\Datatypes\Exception\InvalidEnumValue; + +/** + * Task class. + * + * @category Tasks + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Task implements \JsonSerializable +{ + + /** + * ID. + * + * @var int + * @since 1.0.0 + */ + protected $id = 0; + + /** + * Title. + * + * @var string + * @since 1.0.0 + */ + protected $title = ''; + + /** + * Creator. + * + * @var int + * @since 1.0.0 + */ + protected $createdBy = 0; + + /** + * Created. + * + * @var \DateTime + * @since 1.0.0 + */ + protected $createdAt = null; + + /** + * Description. + * + * @var string + * @since 1.0.0 + */ + protected $description = ''; + + /** + * Type. + * + * @var TaskType + * @since 1.0.0 + */ + protected $type = TaskType::SINGLE; + + /** + * Status. + * + * @var TaskStatus + * @since 1.0.0 + */ + protected $status = TaskStatus::OPEN; + + /** + * Due. + * + * @var \DateTime + * @since 1.0.0 + */ + protected $due = null; + + /** + * Done. + * + * @var \DateTime + * @since 1.0.0 + */ + protected $done = null; + + /** + * Task elements. + * + * @var TaskElement[] + * @since 1.0.0 + */ + protected $taskElements = []; + + /** + * Schedule + * + * @var Schedule + * @since 1.0.0 + */ + protected $schedule = null; + + protected $media = []; + + /** + * Constructor. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function __construct() + { + $this->createdAt = new \DateTime('now'); + $this->due = new \DateTime('now'); + $this->due->modify('+1 day'); + $this->schedule = new Schedule(); + } + + /** + * Adding new task element. + * + * @param TaskElement $element Task element + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function addElement(TaskElement $element) : int + { + $this->taskElements[] = $element; + + end($this->taskElements); + $key = key($this->taskElements); + reset($this->taskElements); + + return $key; + } + + /** + * @return \DateTime + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getCreatedAt() : \DateTime + { + return $this->createdAt ?? new \DateTime(); + } + + /** + * @param \DateTime $created + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setCreatedAt(\DateTime $created) + { + $this->createdAt = $created; + } + + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getCreatedBy() : int + { + return $this->createdBy; + } + + /** + * @param int $id + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setCreatedBy(int $id) + { + $this->createdBy = $id; + $this->schedule->setCreatedBy($id); + } + + /** + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getDescription() : string + { + return $this->description; + } + + /** + * @param string $description + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setDescription(string $description) + { + $this->description = $description; + } + + /** + * @return \DateTime + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getDone() : \DateTime + { + return $this->done ?? new \DateTime('now'); + } + + /** + * @param \DateTime $done + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setDone(\DateTime $done) + { + $this->done = $done;; + } + + /** + * @return \DateTime + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getDue() : \DateTime + { + return $this->due; + } + + /** + * @param \DateTime $due + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setDue(\DateTime $due) + { + $this->due = $due; + } + + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getId() : int + { + return $this->id; + } + + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getStatus() : int + { + return $this->status; + } + + /** + * @param int $status + * + * @throws InvalidEnumValue + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setStatus(int $status) + { + if(!TaskStatus::isValidValue($status)) { + throw new InvalidEnumValue($status); + } + + $this->status = $status; + } + + /** + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getTitle() : string + { + return $this->title; + } + + /** + * @param string $title + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setTitle(string $title) + { + $this->title = $title; + } + + /** + * Remove Element from list. + * + * @param int $id Task element + * + * @return bool + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function removeElement($id) : bool + { + if (isset($this->taskElements[$id])) { + unset($this->taskElements[$id]); + + return true; + } + + return false; + } + + /** + * Get task elements. + * + * @return TaskElement[] + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getTaskElements() : array + { + return $this->taskElements; + } + + /** + * Get task elements. + * + * @param int $id Element id + * + * @return TaskElement + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getTaskElement(int $id) : TaskElement + { + return $this->taskElements[$id] ?? new NullTaskElement(); + } + + /** + * Get task type. + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getType() : int + { + return $this->type; + } + + /** + * Set task type. + * + * @param int $type Task type + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setType(int $type = TaskType::SINGLE) + { + $this->type = $type; + } + + /** + * Get schedule. + * + * @return Schedule + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getSchedule() : Schedule { + return $this->schedule; + } + + private function toArray() : array + { + return [ + 'id' => $this->id, + 'createdBy' => $this->createdBy, + 'createdAt' => $this->createdAt, + 'title' => $this->title, + 'description' => $this->description, + 'status' => $this->status, + 'type' => $this->type, + 'type' => $this->type, + 'due' => $this->due->format('Y-m-d H:i:s'), + 'done' => (!isset($this->done) ? null : $this->done->format('Y-m-d H:i:s')), + ]; + } + + /** + * Specify data which should be serialized to JSON + * @link http://php.net/manual/en/jsonserializable.jsonserialize.php + * @return mixed data which can be serialized by json_encode, + * which is a value of any type other than a resource. + * @since 5.4.0 + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/Models/TaskElement.php b/Models/TaskElement.php new file mode 100644 index 0000000..1c0c9f7 --- /dev/null +++ b/Models/TaskElement.php @@ -0,0 +1,317 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Models; +use phpOMS\Datatypes\Exception\InvalidEnumValue; + +/** + * Task class. + * + * @category Modules + * @package Framework + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class TaskElement implements \JsonSerializable +{ + + /** + * Id. + * + * @var int + * @since 1.0.0 + */ + private $id = 0; + + /** + * Description. + * + * @var string + * @since 1.0.0 + */ + private $description = ''; + + /** + * Task. + * + * @var int + * @since 1.0.0 + */ + private $task = 0; + + /** + * Creator. + * + * @var int + * @since 1.0.0 + */ + private $createdBy = 0; + + /** + * Created. + * + * @var \DateTime + * @since 1.0.0 + */ + private $createdAt = null; + + /** + * Status. + * + * @var int + * @since 1.0.0 + */ + private $status = TaskStatus::OPEN; + + /** + * Due. + * + * @var \DateTime + * @since 1.0.0 + */ + private $due = null; + + /** + * Forwarded to. + * + * @var int + * @since 1.0.0 + */ + private $forwarded = 0; + + private $media = []; + + /** + * Constructor. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function __construct() + { + $this->due = new \DateTime('now'); + $this->due->modify('+1 day'); + $this->createdAt = new \DateTime('now'); + } + + /** + * @return \DateTime + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getCreatedAt() : \DateTime + { + return $this->createdAt; + } + + /** + * @param \DateTime $created + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setCreatedAt(\DateTime $created) + { + $this->createdAt = $created; + } + + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getCreatedBy() : int + { + return $this->createdBy; + } + + /** + * @param int $creator + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setCreatedBy(int $creator) + { + $this->createdBy = $creator; + + if($this->forwarded === 0) { + $this->setForwarded($this->createdBy); + } + } + + /** + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getDescription() : string + { + return $this->description; + } + + /** + * @param string $description + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setDescription(string $description) + { + $this->description = $description; + } + + /** + * @return \DateTime + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getDue() : \DateTime + { + return $this->due; + } + + /** + * @param \DateTime $due + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setDue(\DateTime $due) + { + $this->due = $due; + } + + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getForwarded() : int + { + return $this->forwarded; + } + + /** + * @param int $forwarded + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setForwarded(int $forwarded) + { + $this->forwarded = $forwarded; + } + + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getId() : int + { + return $this->id; + } + + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getStatus() : int + { + return $this->status; + } + + /** + * @param int $status + * + * @return void + * + * @throws InvalidEnumValue + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setStatus(int $status) + { + if(!TaskStatus::isValidValue($status)) { + throw new InvalidEnumValue($status); + } + + $this->status = $status; + } + + /** + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getTask() : int + { + return $this->task; + } + + /** + * @param int $task + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setTask(int $task) + { + $this->task = $task; + } + + public function toArray() : array { + return [ + 'id' => $this->id, + 'task' => $this->task, + 'createdBy' => $this->createdBy, + 'createdAt' => $this->createdAt, + 'description' => $this->description, + 'status' => $this->status, + 'forward' => $this->forwarded, + 'due' => isset($this->due) ? $this->due->format('Y-m-d H:i:s') : null, + ]; + } + + public function jsonSerialize() { + return $this->toArray(); + } +} diff --git a/Models/TaskElementMapper.php b/Models/TaskElementMapper.php new file mode 100644 index 0000000..22ac3b9 --- /dev/null +++ b/Models/TaskElementMapper.php @@ -0,0 +1,115 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Models; + +use Modules\Media\Models\MediaMapper; +use phpOMS\DataStorage\Database\DataMapperAbstract; +use phpOMS\DataStorage\Database\RelationType; + +/** + * Mapper class. + * + * @category Tasks + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class TaskElementMapper extends DataMapperAbstract +{ + + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + protected static $columns = [ + 'task_element_id' => ['name' => 'task_element_id', 'type' => 'int', 'internal' => 'id'], + 'task_element_desc' => ['name' => 'task_element_desc', 'type' => 'string', 'internal' => 'description'], + 'task_element_status' => ['name' => 'task_element_status', 'type' => 'int', 'internal' => 'status'], + 'task_element_due' => ['name' => 'task_element_due', 'type' => 'DateTime', 'internal' => 'due'], + 'task_element_forwarded' => ['name' => 'task_element_forwarded', 'type' => 'int', 'internal' => 'forwarded'], + 'task_element_task' => ['name' => 'task_element_task', 'type' => 'int', 'internal' => 'task'], + 'task_element_created_by' => ['name' => 'task_element_created_by', 'type' => 'int', 'internal' => 'createdBy'], + 'task_element_created_at' => ['name' => 'task_element_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + protected static $hasMany = [ + 'media' => [ + 'mapper' => MediaMapper::class, + 'table' => 'task_element_media', + 'dst' => 'task_element_media_dst', + 'src' => 'task_element_media_src', + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static $table = 'task_element'; + + /** + * Created at. + * + * @var string + * @since 1.0.0 + */ + protected static $createdAt = 'task_created_at'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static $primaryField = 'task_element_id'; + + /** + * Create object. + * + * @param mixed $obj Object + * @param int $relations Behavior for relations creation + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function create($obj, int $relations = RelationType::ALL) + { + try { + $objId = parent::create($obj, $relations); + } catch (\Exception $e) { + var_dump($e->getMessage()); + + return false; + } + + return $objId; + } +} diff --git a/Models/TaskMapper.php b/Models/TaskMapper.php new file mode 100644 index 0000000..e850db2 --- /dev/null +++ b/Models/TaskMapper.php @@ -0,0 +1,202 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Models; + +use Modules\Calendar\Models\ScheduleMapper; +use Modules\Media\Models\MediaMapper; +use Modules\Tasks\Models\TaskElementMapper; +use phpOMS\DataStorage\Database\DataMapperAbstract; +use phpOMS\DataStorage\Database\Query\Builder; +use phpOMS\DataStorage\Database\Query\Column; +use phpOMS\DataStorage\Database\RelationType; + +/** + * Mapper class. + * + * @category Tasks + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class TaskMapper extends DataMapperAbstract +{ + + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + protected static $columns = [ + 'task_id' => ['name' => 'task_id', 'type' => 'int', 'internal' => 'id'], + 'task_title' => ['name' => 'task_title', 'type' => 'string', 'internal' => 'title'], + 'task_desc' => ['name' => 'task_desc', 'type' => 'string', 'internal' => 'description'], + 'task_type' => ['name' => 'task_type', 'type' => 'int', 'internal' => 'type'], + 'task_status' => ['name' => 'task_status', 'type' => 'int', 'internal' => 'status'], + 'task_due' => ['name' => 'task_due', 'type' => 'DateTime', 'internal' => 'due'], + 'task_done' => ['name' => 'task_done', 'type' => 'DateTime', 'internal' => 'done'], + 'task_schedule' => ['name' => 'task_schedule', 'type' => 'int', 'internal' => 'schedule'], + 'task_created_by' => ['name' => 'task_created_by', 'type' => 'int', 'internal' => 'createdBy'], + 'task_created_at' => ['name' => 'task_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + protected static $hasMany = [ + 'taskElements' => [ + 'mapper' => TaskElementMapper::class, + 'table' => 'task_element', + 'dst' => 'task_element_task', + 'src' => null, + ], + 'media' => [ // todo: maybe make this a has one and then link to collection instead of single media files! + 'mapper' => MediaMapper::class, + 'table' => 'task_media', + 'dst' => 'task_media_dst', + 'src' => 'task_media_src', + ], + ]; + + /** + * Has one relation. + * + * @var array + * @since 1.0.0 + */ + protected static $ownsOne = [ + 'schedule' => [ + 'mapper' => ScheduleMapper::class, + 'src' => 'task_schedule', + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static $table = 'task'; + + /** + * Created at. + * + * @var string + * @since 1.0.0 + */ + protected static $createdAt = 'task_created_at'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static $primaryField = 'task_id'; + + /** + * Create object. + * + * @param mixed $obj Object + * @param int $relations Behavior for relations creation + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function create($obj, int $relations = RelationType::ALL) + { + try { + $objId = parent::create($obj, $relations); + $query = new Builder(self::$db); + + $query->prefix(self::$db->getPrefix()) + ->insert( + 'account_permission_account', + 'account_permission_from', + 'account_permission_for', + 'account_permission_id1', + 'account_permission_id2', + 'account_permission_r', + 'account_permission_w', + 'account_permission_m', + 'account_permission_d', + 'account_permission_p' + ) + ->into('account_permission') + ->values($obj->getCreatedBy(), 'task', 'task', 1, $objId, 1, 1, 1, 1, 1); + + self::$db->con->prepare($query->toSql())->execute(); + } catch (\Exception $e) { + var_dump($e->getMessage()); + + return false; + } + + return $objId; + } + + public static function countUnread(int $user) : int + { + try { + $query = new Builder(self::$db); + + $query->prefix(self::$db->getPrefix()) + ->count() + ->from(self::$table) + ->where(self::$table . '.task_created_by', '=', $user) + ->where(self::$table . '.task_status', '=', TaskStatus::OPEN, 'and'); + + $sth = self::$db->con->prepare($query->toSql()); + $sth->execute(); + + $count = $sth->fetchAll()[0][0] ?? 0; + } catch (\Exception $e) { + var_dump($e->getMessage()); + + return false; + } + + return $count; + } + + /** + * Find. + * + * @param array $columns Columns to select + * + * @return Builder + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function find(...$columns) : Builder + { + return parent::find(...$columns)->from('account_permission') + ->where('account_permission.account_permission_for', '=', 'task') + ->where('account_permission.account_permission_id1', '=', 1) + ->where('task.task_id', '=', new Column('account_permission.account_permission_id2')) + ->where('account_permission.account_permission_r', '=', 1); + } +} diff --git a/Models/TaskPriority.php b/Models/TaskPriority.php new file mode 100644 index 0000000..d462548 --- /dev/null +++ b/Models/TaskPriority.php @@ -0,0 +1,42 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Models; + +use phpOMS\Datatypes\Enum; + +/** + * Task priority enum. + * + * @category Tasks + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +abstract class TaskPriority extends Enum +{ + /* public */ const VLOW = 1; + + /* public */ const LOW = 2; + + /* public */ const MEDIUM = 3; + + /* public */ const HIGH = 4; + + /* public */ const VHIGH = 5; +} diff --git a/Models/TaskStatus.php b/Models/TaskStatus.php new file mode 100644 index 0000000..4864fec --- /dev/null +++ b/Models/TaskStatus.php @@ -0,0 +1,44 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Models; + +use phpOMS\Datatypes\Enum; + +/** + * Task status enum. + * + * @category Tasks + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +abstract class TaskStatus extends Enum +{ + /* public */ const OPEN = 1; + + /* public */ const WORKING = 2; + + /* public */ const SUSPENDED = 3; + + /* public */ const CANCELED = 4; + + /* public */ const DONE = 5; + + /* public */ const CLOSED = 6; +} diff --git a/Models/TaskTemplate.php b/Models/TaskTemplate.php new file mode 100644 index 0000000..59362c1 --- /dev/null +++ b/Models/TaskTemplate.php @@ -0,0 +1,38 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Models; + +/** + * Task class. + * + * @category Modules + * @package Tasks + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class TaskTemplate extends Task +{ + /** + * Type. + * + * @var TaskType + * @since 1.0.0 + */ + private $type = TaskType::TEMPLATE; +} diff --git a/Models/TaskType.php b/Models/TaskType.php new file mode 100644 index 0000000..c6adc46 --- /dev/null +++ b/Models/TaskType.php @@ -0,0 +1,36 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Models; + +use phpOMS\Datatypes\Enum; + +/** + * Task type enum. + * + * @category Tasks + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +abstract class TaskType extends Enum +{ + /* public */ const TEMPLATE = 1; + /* public */ const SINGLE = 2; + /* public */ const HIDDEN = 3; +} diff --git a/Models/TaskVisibility.php b/Models/TaskVisibility.php new file mode 100644 index 0000000..8ad63ba --- /dev/null +++ b/Models/TaskVisibility.php @@ -0,0 +1,36 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Tasks\Models; + +use phpOMS\Datatypes\Enum; + +/** + * Task status enum. + * + * @category Tasks + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +abstract class TaskVisibility extends Enum +{ + /* public */ const TO = 1; + /* public */ const CC = 2; + /* public */ const BCC = 3; +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..3f8e3b3 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Tasks # diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php new file mode 100644 index 0000000..1c2d179 --- /dev/null +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -0,0 +1,20 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +return ['Navigation' => [ + 'Analysis' => 'Analysis', + 'Create' => 'Create', + 'Tasks' => 'Tasks', +]]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php new file mode 100644 index 0000000..91b8553 --- /dev/null +++ b/Theme/Backend/Lang/en.lang.php @@ -0,0 +1,67 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +return ['Tasks' => [ + 'Account' => 'Account', + 'All' => 'All', + 'AverageProcessTime' => 'Avg. Process Time', + 'AverageAmount' => 'Average Amount', + 'BCC' => 'BCC', + 'CC' => 'CC', + 'Created' => 'Created', + 'Creator' => 'Creator', + 'Default' => 'Default', + 'Day' => 'Day', + 'Due' => 'Due', + 'Forwarded' => 'Forwarded', + 'From' => 'From', + 'Group' => 'Group', + 'History' => 'History', + 'Interval' => 'Interval', + 'InTime' => 'In Time', + 'Message' => 'Message', + 'Media' => 'Media', + 'Month' => 'Month', + 'Name' => 'Name', + 'New' => 'New', + 'Open' => 'Open', + 'Person' => 'Person', + 'Priority' => 'Priority', + 'Received' => 'Received', + 'Redirected' => 'Redirected', + 'Select' => 'Select', + 'Settings' => 'Settings', + 'SharedVisibility' => 'Visibility is shared across all', + 'Size' => 'Size', + 'Statistics' => 'Statistics', + 'Status' => 'Status', + 'Task' => 'Task', + 'Tasks' => 'Tasks', + 'Template' => 'Template', + 'Time' => 'Time', + 'Title' => 'Title', + 'To' => 'To', + 'Today' => 'Today', + 'Type' => 'Type', + 'Upload' => 'Upload', + 'Week' => 'Week', + 'Year' => 'Year', + 'S1' => 'Open', + 'S2' => 'Working', + 'S3' => 'Suspended', + 'S4' => 'Canceled', + 'S5' => 'Done', + 'S6' => 'Closed', +]]; diff --git a/Theme/Backend/dashboard-task.tpl.php b/Theme/Backend/dashboard-task.tpl.php new file mode 100644 index 0000000..f01d870 --- /dev/null +++ b/Theme/Backend/dashboard-task.tpl.php @@ -0,0 +1,3 @@ +
+Task +
\ No newline at end of file diff --git a/Theme/Backend/task-analysis.tpl.php b/Theme/Backend/task-analysis.tpl.php new file mode 100644 index 0000000..6777ad5 --- /dev/null +++ b/Theme/Backend/task-analysis.tpl.php @@ -0,0 +1,66 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ +echo $this->getData('nav')->render(); ?> + +
+
+
+

getText('Account'); ?>

+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+

getText('Statistics'); ?>

+
+ +
getText('Received'); ?>0 +
getText('Created'); ?>0 +
getText('Forwarded'); ?>0 +
getText('AverageAmount'); ?>0 +
getText('AverageProcessTime'); ?>0 +
getText('InTime'); ?>0 +
+
+
+
+
+ +
+
+
+

getText('History'); ?>

+
+
+
+
+
diff --git a/Theme/Backend/task-create.tpl.php b/Theme/Backend/task-create.tpl.php new file mode 100644 index 0000000..e8b7bb1 --- /dev/null +++ b/Theme/Backend/task-create.tpl.php @@ -0,0 +1,66 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ +echo $this->getData('nav')->render(); ?> + +
+
+
+

getText('Task'); ?>

+ +
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+

getText('Media'); ?>

+ +
+
+ + +
+
+
+
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/Theme/Backend/task-dashboard.tpl.php b/Theme/Backend/task-dashboard.tpl.php new file mode 100644 index 0000000..a23365b --- /dev/null +++ b/Theme/Backend/task-dashboard.tpl.php @@ -0,0 +1,90 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + * @var \Modules\Tasks\Models\Task[] $tasks + */ +$tasks = $this->getData('tasks'); +echo $this->getData('nav')->render(); ?> + +
+
+
+ + + + + + $task) : $c++; + $url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/task/single?{?}&id=' . $task->getId()); + $color = 'darkred'; + if($task->getStatus() === \Modules\Tasks\Models\TaskStatus::DONE) { $color = 'green'; } + elseif($task->getStatus() === \Modules\Tasks\Models\TaskStatus::OPEN) { $color = 'darkblue'; } + elseif($task->getStatus() === \Modules\Tasks\Models\TaskStatus::WORKING) { $color = 'purple'; } + elseif($task->getStatus() === \Modules\Tasks\Models\TaskStatus::CANCELED) { $color = 'red'; } + elseif($task->getStatus() === \Modules\Tasks\Models\TaskStatus::SUSPENDED) { $color = 'yellow'; } ;?> + +
getText('Tasks'); ?>
getText('Status'); ?> + getText('Due'); ?> + getText('Title'); ?> + getText('Creator'); ?> + getText('Created'); ?> +
getText('S' . $task->getStatus()); ?> + getDue()->format('Y-m-d H:i'); ?> + getTitle(); ?> + getCreatedBy(); ?> + getCreatedAt()->format('Y-m-d H:i'); ?> + +
getText('Empty', 0, 0); ?> + +
+
+
+ +
+
+

getText('Settings'); ?>

+
+
+ +
+
+
+
+
+
+ +
+

getText('Settings'); ?>

+
+ +
getText('Received'); ?>0 +
getText('Created'); ?>0 +
getText('Forwarded'); ?>0 +
getText('AverageAmount'); ?>0 +
getText('AverageProcessTime'); ?>0 +
getText('InTime'); ?>0 +
+
+
+
+
\ No newline at end of file diff --git a/Theme/Backend/task-single.tpl.php b/Theme/Backend/task-single.tpl.php new file mode 100644 index 0000000..d421a09 --- /dev/null +++ b/Theme/Backend/task-single.tpl.php @@ -0,0 +1,115 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + * @var \Modules\Tasks\Models\Task $task + */ +$task = $this->getData('task'); +$elements = $task->getTaskElements(); +$cElements = count($elements); + +if($task->getStatus() === \Modules\Tasks\Models\TaskStatus::DONE) { $color = 'green'; } +elseif($task->getStatus() === \Modules\Tasks\Models\TaskStatus::OPEN) { $color = 'darkblue'; } +elseif($task->getStatus() === \Modules\Tasks\Models\TaskStatus::WORKING) { $color = 'purple'; } +elseif($task->getStatus() === \Modules\Tasks\Models\TaskStatus::CANCELED) { $color = 'red'; } +elseif($task->getStatus() === \Modules\Tasks\Models\TaskStatus::SUSPENDED) { $color = 'yellow'; } + +echo $this->getData('nav')->render(); ?> + +
+
+
+

getTitle(); ?>

+
+
Due getDue()->format('Y-m-d H:i'); ?>
+
Created getCreatedAt()->format('Y-m-d H:i'); ?>
+
+
+
+ getDescription(); ?> +
+
+
+
+
Created getCreatedBy(); ?>
+ getText('S' . $task->getStatus()); ?> +
+
+
+ + $element) : $c++; + if($element->getStatus() === \Modules\Tasks\Models\TaskStatus::DONE) { $color = 'green'; } + elseif($element->getStatus() === \Modules\Tasks\Models\TaskStatus::OPEN) { $color = 'darkblue'; } + elseif($element->getStatus() === \Modules\Tasks\Models\TaskStatus::WORKING) { $color = 'purple'; } + elseif($element->getStatus() === \Modules\Tasks\Models\TaskStatus::CANCELED) { $color = 'red'; } + elseif($element->getStatus() === \Modules\Tasks\Models\TaskStatus::SUSPENDED) { $color = 'yellow'; } ?> +
+
+
getCreatedBy(); ?> - getCreatedAt()->format('Y-m-d H:i'); ?>
+ getText('S' . $element->getStatus()); ?> +
+ + getDescription() !== '') : ?> +
+
+ getDescription(); ?> +
+
+ + +
+ getForwarded() !== 0) : ?> +
Forwarded getForwarded(); ?>
+ + getStatus() !== \Modules\Tasks\Models\TaskStatus::CANCELED || + $element->getStatus() !== \Modules\Tasks\Models\TaskStatus::DONE || + $element->getStatus() !== \Modules\Tasks\Models\TaskStatus::SUSPENDED || $c != $cElements + ) : ?> +
Due getDue()->format('Y-m-d H:i'); ?>
+ +
+ + +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Views/TaskCreate.php b/Views/TaskCreate.php new file mode 100644 index 0000000..e69de29 diff --git a/img/module_teaser_small.png b/img/module_teaser_small.png new file mode 100644 index 0000000..f56e6ff Binary files /dev/null and b/img/module_teaser_small.png differ diff --git a/info.json b/info.json new file mode 100644 index 0000000..8e4d1f4 --- /dev/null +++ b/info.json @@ -0,0 +1,55 @@ +{ + "name": { + "id": 1001100000, + "internal": "Tasks", + "external": "OMS Tasks" + }, + "version": "1.0.0", + "requirements": { + "phpOMS": "1.0.0", + "phpOMS-db": "1.0.0" + }, + "creator": { + "name": "Orange Management", + "website": "www.spl1nes.com" + }, + "description": "Tasks module.", + "directory": "Tasks", + "dependencies": { + "Admin" : "1.0.0", + "Calendar" : "1.0.0", + "Media" : "1.0.0" + }, + "providing": { + "Navigation": "*" + }, + "load": [ + { + "pid": [ + "43ec7cda8be033d7b20996708a2fca644e5dde86" + ], + "type": 4, + "for": 0, + "from": "Tasks", + "file": "Tasks" + }, + { + "pid": [ + "754a08ddf8bcb1cf22f310f09206dd783d42f7dd" + ], + "type": 4, + "from": "Tasks", + "for": "Navigation", + "file": "Tasks" + }, + { + "pid": [ + "754a08ddf8bcb1cf22f310f09206dd783d42f7dd" + ], + "type": 5, + "from": "Tasks", + "for": "Navigation", + "file": "Navigation" + } + ] +}