oms-Workflow/Controller/BackendController.php
2022-02-19 14:25:29 +01:00

154 lines
5.9 KiB
PHP
Executable File

<?php
/**
* Karaka
*
* PHP Version 8.0
*
* @package Modules\Workflow
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://karaka.app
*/
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://karaka.app
* @since 1.0.0
*
* @todo Karaka/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).
*/
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->l11nManager, $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->l11nManager, $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->l11nManager, $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->l11nManager, $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->l11nManager, $request, $response);
$view->setTemplate('/Modules/Workflow/Theme/Backend/workflow-dashboard');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005501001, $request, $response));
return $view;
}
}