Wrokflow draft

This commit is contained in:
Dennis Eichhorn 2016-07-21 21:06:57 +02:00
parent 0e0dcd3f9b
commit 3510f9a8bc
12 changed files with 246 additions and 142 deletions

View File

@ -89,8 +89,8 @@ class Controller extends ModuleAbstract implements WebInterface
public function viewWorkflowTemplates(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable
{
$view = new View($this->app, $request, $response);
$view->setTemplate('/Modules/Workflow/Theme/Backend/task-dashboard');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001101001, $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;
}
@ -109,7 +109,7 @@ class Controller extends ModuleAbstract implements WebInterface
{
$view = new View($this->app, $request, $response);
$view->setTemplate('/Modules/Workflow/Theme/Backend/task-single');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001101001, $request, $response));
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005501001, $request, $response));
return $view;
}
@ -128,7 +128,7 @@ class Controller extends ModuleAbstract implements WebInterface
{
$view = new View($this->app, $request, $response);
$view->setTemplate('/Modules/Workflow/Theme/Backend/task-create');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001101001, $request, $response));
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005501001, $request, $response));
return $view;
}
@ -146,8 +146,8 @@ class Controller extends ModuleAbstract implements WebInterface
public function viewWorkflowTemplateCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable
{
$view = new View($this->app, $request, $response);
$view->setTemplate('/Modules/Workflow/Theme/Backend/task-analysis');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001101001, $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;
}

View File

@ -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.
##

View File

@ -0,0 +1,32 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 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 <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
interface WorkflowInterface
{
}

View File

@ -0,0 +1,36 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 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 <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
abstract class PermissionStatus extends Enum
{
const PENDING = 1;
const APPROVED = 2;
const DISMISSED = 3;
}

View File

@ -0,0 +1,37 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 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 <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
abstract class States extends Enum
{
const DEFAULT = 0;
const PENDING = 1;
const APPROVED = 2;
const DISMISSED = 3;
}

View File

@ -0,0 +1,77 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 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 <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @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;
}
}

View File

View File

@ -1,86 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 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(); ?>
<div class="box w-75 floatLeft">
<table class="table">
<caption><?= $this->l11n->getText('Tasks', 'Backend', 'Tasks'); ?></caption>
<thead>
<td><?= $this->l11n->getText('Tasks', 'Backend', 'Status'); ?>
<td><?= $this->l11n->getText('Tasks', 'Backend', 'Due'); ?>
<td class="full"><?= $this->l11n->getText('Tasks', 'Backend', 'Title'); ?>
<td><?= $this->l11n->getText('Tasks', 'Backend', 'Creator'); ?>
<td><?= $this->l11n->getText('Tasks', 'Backend', 'Created'); ?>
<tfoot>
<tbody>
<?php $c = 0; foreach($tasks as $key => $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'; } ;?>
<tr>
<td><a href="<?= $url; ?>"><span class="tag <?= $color; ?>"><?= $this->l11n->getText('Tasks', 'Backend', 'S' . $task->getStatus()); ?></span></a>
<td><a href="<?= $url; ?>"><?= $task->getDue()->format('Y-m-d H:i'); ?></a>
<td><a href="<?= $url; ?>"><?= $task->getTitle(); ?></a>
<td><a href="<?= $url; ?>"><?= $task->getCreatedBy(); ?></a>
<td><a href="<?= $url; ?>"><?= $task->getCreatedAt()->format('Y-m-d H:i'); ?></a>
<?php endforeach; if($c == 0) : ?>
<tr><td colspan="6" class="empty"><?= $this->l11n->getText(0, 'Backend', 'Empty'); ?>
<?php endif; ?>
</table>
</div>
<section class="w-25 floatLeft">
<section class="box w-100">
<header><h1><?= $this->l11n->getText('Tasks', 'Backend', 'Settings'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iIntervarl"><?= $this->l11n->getText('Tasks', 'Backend', 'Interval'); ?></label>
<tr><td><select id="iIntervarl" name="interval">
<option><?= $this->l11n->getText('Tasks', 'Backend', 'All'); ?>
<option><?= $this->l11n->getText('Tasks', 'Backend', 'Day'); ?>
<option><?= $this->l11n->getText('Tasks', 'Backend', 'Week'); ?>
<option selected><?= $this->l11n->getText('Tasks', 'Backend', 'Month'); ?>
<option><?= $this->l11n->getText('Tasks', 'Backend', 'Year'); ?>
</select>
</table>
</form>
</div>
</section>
<section class="box w-100">
<header><h1><?= $this->l11n->getText('Tasks', 'Backend', 'Settings'); ?></h1></header>
<div class="inner">
<table class="list">
<tr><th><?= $this->l11n->getText('Tasks', 'Backend', 'Received'); ?><td>0
<tr><th><?= $this->l11n->getText('Tasks', 'Backend', 'Created'); ?><td>0
<tr><th><?= $this->l11n->getText('Tasks', 'Backend', 'Forwarded'); ?><td>0
<tr><th><?= $this->l11n->getText('Tasks', 'Backend', 'AverageAmount'); ?><td>0
<tr><th><?= $this->l11n->getText('Tasks', 'Backend', 'AverageProcessTime'); ?><td>0
<tr><th><?= $this->l11n->getText('Tasks', 'Backend', 'InTime'); ?><td>0
</table>
</div>
</section>
</section>

View File

@ -0,0 +1,19 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 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(); ?>

View File

@ -0,0 +1,22 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 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(); ?>

View File

@ -1,50 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 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(); ?>
<section class="box w-50 floatLeft">
<header><h1><?= $this->l11n->getText('Tasks', 'Backend', 'Account'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iAccount"><?= $this->l11n->getText('Tasks', 'Backend', 'Account'); ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="number" min="1" id="iAccount" name="account" placeholder="&#xf007; Guest" required></span>
<tr><td><label for="iFrom"><?= $this->l11n->getText('Tasks', 'Backend', 'From'); ?></label>
<tr><td><input type="datetime-local" id="iFrom" name="from" value="<?= (new \DateTime('NOW'))->format('Y-m-d\TH:i:s') ?>">
<tr><td><label for="iTo"><?= $this->l11n->getText('Tasks', 'Backend', 'To'); ?></label>
<tr><td><input type="datetime-local" id="iTo" name="to" value="<?= (new \DateTime('NOW'))->format('Y-m-d\TH:i:s') ?>">
<tr><td><input type="submit" value="<?= $this->l11n->getText(0, 'Backend', 'Submit'); ?>">
</table>
</form>
</div>
</section>
<section class="box w-50 floatLeft">
<header><h1><?= $this->l11n->getText('Tasks', 'Backend', 'Statistics'); ?></h1></header>
<div class="inner">
<table class="list wf-100">
<tr><td><?= $this->l11n->getText('Tasks', 'Backend', 'Received'); ?><td>0
<tr><td><?= $this->l11n->getText('Tasks', 'Backend', 'Created'); ?><td>0
<tr><td><?= $this->l11n->getText('Tasks', 'Backend', 'Forwarded'); ?><td>0
<tr><td><?= $this->l11n->getText('Tasks', 'Backend', 'AverageAmount'); ?><td>0
<tr><td><?= $this->l11n->getText('Tasks', 'Backend', 'AverageProcessTime'); ?><td>0
<tr><td><?= $this->l11n->getText('Tasks', 'Backend', 'InTime'); ?><td>0
</table>
</div>
</section>