oms-Workflow/Controller/BackendController.php

172 lines
7.5 KiB
PHP

<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Workflow
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Workflow\Controller;
use phpOMS\Contract\RenderableInterface;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Views\View;
/**
* Workflow class.
*
* @package Modules\Workflow
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*
* @todo Orange-Management/Modules#20
* The workflow module can be used by other modules to register a workflow.
* The article management module for example could register a workflow for generating articles.
* This way multiple employees have to insert data and only after everything is done the article will be generated by the system itself.
* User permissions for creating an article would now get disabled and only allowed through this module.
* Other things that could be changing prices, customers etc. (essential tool for SOX and ISO and maybe even IFRS)
* This module would also make use of the task module to notify users that they have a task.
* At the same time actions such as changing a price could also create a workflow.
* If a user changes a price a workflow element for price changes gets triggered which now needs to be approved by authorized employees.
* Such modules now should add an additional tab for workflow steps.
* In this list a log of all workflows is displayed (pending, done, canceled).
* This way changes/events get forwarded to the workflow module and later the workflow decides what to do with these information
* (e.g. inserting these information into other modules etc).
* Instead of actually doing changes this can be extended further to only request something.
* E.g. a user could request a unlocking of a customer for invoicing by a simple button click and a credit manager only has to approve it.
* The workflow module now knows that the approval means to unlock the customer (maybe for only one invoice, limited time, value etc).
*
* @todo Orange-Management/Modules#22
* Implement a way to support template settings.
* Different templates require different settings such as different type of permissions, default values, etc.
* Letting the user write config files would not be a problem (e.g. direct modification of json files) but how would this work with a settings ui where also predefined options are selectable.
* Many templates may be provided by other modules or 3rd party and not by inhouse developers.
* One solution could be to define a config layout where you can define predefined values, regex for validation etc?
* This would require a form builder that could build forms based on json objects. This however would be one large form and not split nicely over multiple forms.
* One more outer array could be used to create multiple forms.
* At the same time the application would have to register a form view/template at the beginning that could be used.
*
* @todo Orange-Management/Modules#23
* Request/approval workflow
* For many things a request/approval workflow should be implemented.
* Users should be able to request permission changes which then have to be approved by group/department managers or the IT.
* Upon approval the workflow automatically grants these permissions and informs the user.
* This should be a selectable workflow from the template list but also get integrated into the modules.
* Modules should inform the user that he doesn't have sufficient permissions to perform certain tasks upon which he gets provided with a direct link for requesting these permissions.
*/
final class BackendController extends Controller
{
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewWorkflowTemplates(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$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;
}
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewWorkflowTemplate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$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;
}
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewWorkflowSingle(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$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;
}
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewWorkflowTemplateCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$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;
}
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewWorkflowDashboard(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$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;
}
}