diff --git a/Admin/Activate.php b/Admin/Activate.php new file mode 100644 index 0000000..b3fa30f --- /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\Workflow\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..d47cf80 --- /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\Workflow\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..7bd6452 --- /dev/null +++ b/Admin/Install/Navigation.install.json @@ -0,0 +1,63 @@ +[ + { + "id": 1005501001, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 2, + "subtype": 1, + "name": "Workflows", + "uri": "/{/lang}/backend/workflow/dashboard?{?}", + "target": "self", + "icon": null, + "order": 40, + "from": "Wokflow", + "permission": null, + "parent": 1003301001, + "children": [ + { + "id": 1005502001, + "pid": "ac3d9bdf783c7963f449488e33c60133b3dbe6f8", + "type": 3, + "subtype": 1, + "name": "Dashboard", + "uri": "/{/lang}/backend/workflow/dashboard?{?}", + "target": "self", + "icon": null, + "order": 1, + "from": "Wokflow", + "permission": null, + "parent": 1005501001, + "children": [] + }, + { + "id": 1005503001, + "pid": "ac3d9bdf783c7963f449488e33c60133b3dbe6f8", + "type": 3, + "subtype": 1, + "name": "Templates", + "uri": "/{/lang}/backend/workflow/template/list?{?}", + "target": "self", + "icon": null, + "order": 5, + "from": "Wokflow", + "permission": null, + "parent": 1005501001, + "children": [] + }, + { + "id": 1005504001, + "pid": "ac3d9bdf783c7963f449488e33c60133b3dbe6f8", + "type": 3, + "subtype": 1, + "name": "Create", + "uri": "/{/lang}/backend/workflow/template/create?{?}", + "target": "self", + "icon": null, + "order": 10, + "from": "Wokflow", + "permission": null, + "parent": 1005501001, + "children": [] + } + ] + } +] diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php new file mode 100644 index 0000000..9c337be --- /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\Workflow\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..a7a9ad6 --- /dev/null +++ b/Admin/Installer.php @@ -0,0 +1,140 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Workflow\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->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'workflow` ( + `workflow_id` int(11) NOT NULL AUTO_INCREMENT, + `workflow_name` varchar(50) NOT NULL, + `workflow_status` int(11) NOT NULL, + `workflow_desc` varchar(100) DEFAULT NULL, + `workflow_created` datetime DEFAULT NULL, + `workflow_created_by` int(11) DEFAULT NULL, + PRIMARY KEY (`workflow_id`), + KEY `workflow_created_by` (`workflow_created_by`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'workflow` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'workflow_ibfk_1` FOREIGN KEY (`workflow_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 . 'workflow_media` ( + `workflow_media_id` int(11) NOT NULL AUTO_INCREMENT, + `workflow_media_media` int(11) NOT NULL, + `workflow_media_workflow` int(11) NOT NULL, + `workflow_media_type` int(3) DEFAULT NULL, + PRIMARY KEY (`workflow_media_id`), + KEY `workflow_media_media` (`workflow_media_media`), + KEY `workflow_media_workflow` (`workflow_media_workflow`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'workflow_media` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'workflow_media_ibfk_1` FOREIGN KEY (`workflow_media_media`) REFERENCES `' . $dbPool->get('core')->prefix . 'media` (`media_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'workflow_media_ibfk_2` FOREIGN KEY (`workflow_media_workflow`) REFERENCES `' . $dbPool->get('core')->prefix . 'workflow` (`workflow_id`);' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'workflow_element` ( + `workflow_element_id` int(11) NOT NULL AUTO_INCREMENT, + `workflow_element_name` varchar(50) NOT NULL, + `workflow_element_status` int(11) NOT NULL, + `workflow_element_data` text NOT NULL, + `workflow_element_desc` varchar(100) DEFAULT NULL, + `workflow_element_created` datetime DEFAULT NULL, + `workflow_element_created_by` int(11) DEFAULT NULL, + `workflow_element_workflow` int(11) DEFAULT NULL, + PRIMARY KEY (`workflow_element_id`), + KEY `workflow_element_created_by` (`workflow_element_created_by`), + KEY `workflow_element_workflow` (`workflow_element_workflow`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'workflow_element` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'workflow_element_ibfk_1` FOREIGN KEY (`workflow_element_created_by`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'workflow_element_ibfk_2` FOREIGN KEY (`workflow_element_workflow`) REFERENCES `' . $dbPool->get('core')->prefix . 'workflow` (`workflow_id`);' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'workflow_element_media` ( + `workflow_element_media_id` int(11) NOT NULL AUTO_INCREMENT, + `workflow_element_media_media` int(11) NOT NULL, + `workflow_element_media_workflow_element` int(11) NOT NULL, + PRIMARY KEY (`workflow_element_media_id`), + KEY `workflow_element_media_media` (`workflow_element_media_media`), + KEY `workflow_element_media_workflow_element` (`workflow_element_media_workflow_element`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'workflow_element_media` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'workflow_element_media_ibfk_1` FOREIGN KEY (`workflow_element_media_media`) REFERENCES `' . $dbPool->get('core')->prefix . 'media` (`media_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'workflow_element_media_ibfk_2` FOREIGN KEY (`workflow_element_media_workflow_element`) REFERENCES `' . $dbPool->get('core')->prefix . 'workflow_element` (`workflow_element_id`);' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'workflow_element_task` ( + `workflow_element_task_id` int(11) NOT NULL AUTO_INCREMENT, + `workflow_element_task_task` int(11) NOT NULL, + `workflow_element_task_workflow_element` int(11) NOT NULL, + PRIMARY KEY (`workflow_element_task_id`), + KEY `workflow_element_task_task` (`workflow_element_task_task`), + KEY `workflow_element_task_workflow_element` (`workflow_element_task_workflow_element`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'workflow_element_task` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'workflow_element_task_ibfk_1` FOREIGN KEY (`workflow_element_task_task`) REFERENCES `' . $dbPool->get('core')->prefix . 'task` (`media_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'workflow_element_task_ibfk_2` FOREIGN KEY (`workflow_element_task_workflow_element`) REFERENCES `' . $dbPool->get('core')->prefix . 'workflow_element` (`workflow_element_id`);' + )->execute(); + break; + } + } +} diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php new file mode 100644 index 0000000..2ac473e --- /dev/null +++ b/Admin/Routes/Web/Backend.php @@ -0,0 +1,36 @@ + [ + [ + 'dest' => '\Modules\Workflow\Controller:viewWorkflowTemplates', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/workflow/template/single.*$' => [ + [ + 'dest' => '\Modules\Workflow\Controller:viewWorkflowTemplate', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/workflow/template/create.*$' => [ + [ + 'dest' => '\Modules\Workflow\Controller:viewWorkflowTemplateCreate', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/workflow/dashboard.*$' => [ + [ + 'dest' => '\Modules\Workflow\Controller:viewWorkflowDashboard', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/workflow/single.*$' => [ + [ + 'dest' => '\Modules\Workflow\Controller:viewWorkflowSingle', + '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\Workflow\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..fcc9d39 --- /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\Workflow\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..012cea6 --- /dev/null +++ b/Controller.php @@ -0,0 +1,174 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Workflow; + +use phpOMS\Message\RequestAbstract; +use phpOMS\Message\ResponseAbstract; +use phpOMS\Module\ModuleAbstract; +use phpOMS\Module\WebInterface; +use phpOMS\Views\View; + +/** + * Task class. + * + * @category Modules + * @package Modules\Workflow + * @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 = 'Workflow'; + + /** + * Providing. + * + * @var string + * @since 1.0.0 + */ + protected static $providing = []; + + /** + * 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 viewWorkflowTemplates(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Workflow/Theme/Backend/workflow-template-list'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005501001, $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 viewWorkflowTemplate(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Workflow/Theme/Backend/task-single'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005501001, $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 viewWorkflowSingle(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Workflow/Theme/Backend/task-create'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005501001, $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 viewWorkflowTemplateCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Workflow/Theme/Backend/workflow-template-create'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005501001, $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 viewWorkflowDashboard(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Workflow/Theme/Backend/workflow-dashboard'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005501001, $request, $response)); + + return $view; + } + +} diff --git a/Docs/workflow_components.md b/Docs/workflow_components.md new file mode 100644 index 0000000..2326e8e --- /dev/null +++ b/Docs/workflow_components.md @@ -0,0 +1,17 @@ +# Workflow Components + +Every workflow has to provide a set of components in order to work. Other files are optional but can be used in order to enhance the experience. Additional files may be provided for better templating or for additional models but are not a necessety. + +## Template + +The `template.tpl.php` file contains the UI of the workflow. + +## States + +A `States.php` file contains all workflow states. This is especially important in order to show different content inside of the `template.tpl.php` depending on the state or in order to trigger state depended actions. + +## Workflow + +The `Workflow.php` file is the heart of every workflow. This file is responsible for executing state driven actions and it can also be seen as the API for a workflow. All workflow related actions will be forwarded to this file and can be handled inside including database queries. + +## \ No newline at end of file diff --git a/Models/Template.php b/Models/Template.php new file mode 100644 index 0000000..4ddffdc --- /dev/null +++ b/Models/Template.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\Workflow\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 Template +{ + +} diff --git a/Models/WorkflowInterface.php b/Models/WorkflowInterface.php new file mode 100644 index 0000000..f93c698 --- /dev/null +++ b/Models/WorkflowInterface.php @@ -0,0 +1,32 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Workflow\Models; + +/** + * Task status enum. + * + * @category Workflow + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +interface WorkflowInterface +{ + +} \ No newline at end of file diff --git a/Models/WorkflowStatus.php b/Models/WorkflowStatus.php new file mode 100644 index 0000000..7739c64 --- /dev/null +++ b/Models/WorkflowStatus.php @@ -0,0 +1,39 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Workflow\Models; + +use phpOMS\Datatypes\Enum; + +/** + * Task status enum. + * + * @category Workflow + * @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 WorkflowStatus 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/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Templates/Permission/PermissionStatus.php b/Templates/Permission/PermissionStatus.php new file mode 100644 index 0000000..9e9c539 --- /dev/null +++ b/Templates/Permission/PermissionStatus.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\Workflow\Templates\Permission; + +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 PermissionStatus extends Enum +{ + /* public */ const PENDING = 1; + /* public */ const APPROVED = 2; + /* public */ const DISMISSED = 3; +} diff --git a/Templates/Permission/States.php b/Templates/Permission/States.php new file mode 100644 index 0000000..ff06f5d --- /dev/null +++ b/Templates/Permission/States.php @@ -0,0 +1,37 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Workflow\Templates\Permission; + +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 States extends Enum +{ + /* public */ const DEFAULT = 0; + /* public */ const PENDING = 1; + /* public */ const APPROVED = 2; + /* public */ const DISMISSED = 3; +} diff --git a/Templates/Permission/Workflow.php b/Templates/Permission/Workflow.php new file mode 100644 index 0000000..711fe42 --- /dev/null +++ b/Templates/Permission/Workflow.php @@ -0,0 +1,77 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Media; + +use Modules\Workflow\Models\WorkflowInterface; +use Modules\Workflow\Templates\Permission\States; +use phpOMS\DataStorage\Database\Connection\ConnectionAbstract; + +/** + * Media class. + * + * @category Modules + * @package Modules\Media + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Workflow implements WorkflowInterface +{ + private $id = 0; + private $state = 0; + private $con = null; + + public function __construct(ConnectionAbstract $con) + { + $this->con = $con; + } + + public function run($data) : int + { + switch ($this->state) { + case States::DEFAULT: + $this->state = $this->runRequest($data); + break; + case States::PENDING: + $this->state = $this->runPending($data); + break; + default: + + } + + return $this->state; + } + + public function runRequest($data) + { + // todo: create workflow + // todo: create task + // todo: set state + } + + public function runPending($data) + { + // todo: approve?! + // todo: + } + + public function getState() : int + { + return $this->state; + } +} \ No newline at end of file diff --git a/Templates/Permission/permission-info.tpl.php b/Templates/Permission/permission-info.tpl.php new file mode 100644 index 0000000..e69de29 diff --git a/Templates/Permission/template.tpl.php b/Templates/Permission/template.tpl.php new file mode 100644 index 0000000..e69de29 diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php new file mode 100644 index 0000000..cf33391 --- /dev/null +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -0,0 +1,22 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +return ['Navigation' => [ + 'Create' => 'Create', + 'Dashboard' => 'Dashboard', + 'Templates' => 'Templates', + 'Workflows' => 'Workflows', + 'Workflow' => 'Workflow', +]]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php new file mode 100644 index 0000000..51449fe --- /dev/null +++ b/Theme/Backend/Lang/en.lang.php @@ -0,0 +1,24 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +return ['Workflow' => [ + 'Created' => 'Created', + 'Creator' => 'Creator', + 'Next' => 'Next', + 'Status' => 'Status', + 'Title' => 'Title', + 'Workflow' => 'Workflow', + 'Workflows' => 'Workflows', +]]; diff --git a/Theme/Backend/workflow-create.tpl.php b/Theme/Backend/workflow-create.tpl.php new file mode 100644 index 0000000..6b87196 --- /dev/null +++ b/Theme/Backend/workflow-create.tpl.php @@ -0,0 +1,60 @@ + + * @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/workflow-dashboard.tpl.php b/Theme/Backend/workflow-dashboard.tpl.php new file mode 100644 index 0000000..ff6e97b --- /dev/null +++ b/Theme/Backend/workflow-dashboard.tpl.php @@ -0,0 +1,52 @@ + + * @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 + */ +$workflows = []; + +echo $this->getData('nav')->render(); ?> + +
+ + + + + + $workflow) : $c++; + $url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/task/single?{?}&id=' . $workflow->getId()); + $color = 'darkred'; + if($workflow->getStatus() === \Modules\Workflow\Models\WorkflowStatus::DONE) { $color = 'green'; } + elseif($workflow->getStatus() === \Modules\Workflow\Models\WorkflowStatus::OPEN) { $color = 'darkblue'; } + elseif($workflow->getStatus() === \Modules\Workflow\Models\WorkflowStatus::WORKING) { $color = 'purple'; } + elseif($workflow->getStatus() === \Modules\Workflow\Models\WorkflowStatus::CANCELED) { $color = 'red'; } + elseif($workflow->getStatus() === \Modules\Workflow\Models\WorkflowStatus::SUSPENDED) { $color = 'yellow'; } ;?> + +
getText('Workflow'); ?>
getText('Status'); ?> + getText('Next'); ?> + getText('Title'); ?> + getText('Creator'); ?> + getText('Created'); ?> +
getText('S' . $workflow->getStatus()); ?> + getDue()->format('Y-m-d H:i'); ?> + getTitle(); ?> + getCreatedBy(); ?> + getCreatedAt()->format('Y-m-d H:i'); ?> + +
getText('Empty', 0, 0); ?> + +
+
\ No newline at end of file diff --git a/Theme/Backend/workflow-single.tpl.php b/Theme/Backend/workflow-single.tpl.php new file mode 100644 index 0000000..ee35254 --- /dev/null +++ b/Theme/Backend/workflow-single.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 $task + */ +$task = $this->getData('task'); +$elements = $task->getTaskElements(); +$cElements = count($elements); + +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(); ?>
+
Status 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'; } ?> +
+
getText('S' . $element->getStatus()); ?>
+
getCreatedBy(); ?> - getCreatedAt()->format('Y-m-d H:i'); ?>
+
+ getDescription() !== '') : ?> +
+
+
+ getDescription(); ?> +
+
+
+ +
+ 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'); ?>
+ + getForwarded() !== 0) : ?> +
Forwarded getForwarded(); ?>
+ +
+ + +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Theme/Backend/workflow-template-create.tpl.php b/Theme/Backend/workflow-template-create.tpl.php new file mode 100644 index 0000000..9e3f926 --- /dev/null +++ b/Theme/Backend/workflow-template-create.tpl.php @@ -0,0 +1,19 @@ + + * @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(); ?> diff --git a/Theme/Backend/workflow-template-list.tpl.php b/Theme/Backend/workflow-template-list.tpl.php new file mode 100644 index 0000000..2404c47 --- /dev/null +++ b/Theme/Backend/workflow-template-list.tpl.php @@ -0,0 +1,22 @@ + + * @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(); ?> + 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..a642254 --- /dev/null +++ b/info.json @@ -0,0 +1,45 @@ +{ + "name": { + "id": 1005500000, + "internal": "Workflow", + "external": "OMS Workflow" + }, + "version": "1.0.0", + "requirements": { + "phpOMS": "1.0.0", + "phpOMS-db": "1.0.0" + }, + "creator": { + "name": "Orange Management", + "website": "www.spl1nes.com" + }, + "description": "Workflow module.", + "directory": "Workflow", + "dependencies": { + "Admin" : "1.0.0", + "Calendar" : "1.0.0" + }, + "providing": { + "Navigation": "*" + }, + "load": [ + { + "pid": [ + "ac3d9bdf783c7963f449488e33c60133b3dbe6f8" + ], + "type": 4, + "for": 0, + "from": "Workflow", + "file": "Workflow" + }, + { + "pid": [ + "754a08ddf8bcb1cf22f310f09206dd783d42f7dd" + ], + "type": 5, + "from": "Workflow", + "for": "Navigation", + "file": "Navigation" + } + ] +}