(Draft) Create risk management models

Also fix some belongsTo in other mappers.
This commit is contained in:
Dennis Eichhorn 2017-07-09 10:42:02 +02:00
parent d41dd11069
commit a236608e57
17 changed files with 254 additions and 12 deletions

View File

@ -242,7 +242,7 @@ class Installer extends InstallerAbstract
`riskmngmt_cause_probability` smallint(6) NOT NULL,
`riskmngmt_cause_department` int(11) DEFAULT NULL,
`riskmngmt_cause_category` int(11) DEFAULT NULL,
`riskmngmt_cause_risk` int(11) NOT NULL,
`riskmngmt_cause_risk` int(11) DEFAULT NULL,
PRIMARY KEY (`riskmngmt_cause_id`),
KEY `riskmngmt_cause_department` (`riskmngmt_cause_department`),
KEY `riskmngmt_cause_category` (`riskmngmt_cause_category`),
@ -265,8 +265,8 @@ class Installer extends InstallerAbstract
`riskmngmt_solution_descriptionraw` text NOT NULL,
`riskmngmt_solution_probability` smallint(6) NOT NULL,
`riskmngmt_solution_effect` decimal(11,4) DEFAULT NULL,
`riskmngmt_solution_cause` int(11) NOT NULL,
`riskmngmt_solution_risk` int(11) NOT NULL,
`riskmngmt_solution_cause` int(11) DEFAULT NULL,
`riskmngmt_solution_risk` int(11) DEFAULT NULL,
PRIMARY KEY (`riskmngmt_solution_id`),
KEY `riskmngmt_solution_cause` (`riskmngmt_solution_cause`),
KEY `riskmngmt_solution_risk` (`riskmngmt_solution_risk`)

View File

@ -25,6 +25,13 @@ use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\WebInterface;
use phpOMS\Views\View;
use phpOMS\Views\ViewLayout;
use Modules\RiskManagement\Models\SolutionMapper;
use Modules\RiskManagement\Models\CauseMapper;
use Modules\RiskManagement\Models\RiskMapper;
use Modules\RiskManagement\Models\DepartmentMapper;
use Modules\RiskManagement\Models\CategoryMapper;
use Modules\RiskManagement\Models\ProjectMapper;
use Modules\RiskManagement\Models\ProcessMapper;
/**
* Risk Management class.
@ -117,6 +124,9 @@ class Controller extends ModuleAbstract implements WebInterface
$view->setTemplate('/Modules/RiskManagement/Theme/Backend/risk-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003001001, $request, $response));
$risks = RiskMapper::getAll();
$view->addData('risks', $risks);
return $view;
}
@ -155,6 +165,9 @@ class Controller extends ModuleAbstract implements WebInterface
$view->setTemplate('/Modules/RiskManagement/Theme/Backend/cause-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003001001, $request, $response));
$causes = CauseMapper::getAll();
$view->addData('causes', $causes);
return $view;
}
@ -174,6 +187,9 @@ class Controller extends ModuleAbstract implements WebInterface
$view->setTemplate('/Modules/RiskManagement/Theme/Backend/solution-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003001001, $request, $response));
$solutions = SolutionMapper::getAll();
$view->addData('solutions', $solutions);
return $view;
}
@ -212,6 +228,9 @@ class Controller extends ModuleAbstract implements WebInterface
$view->setTemplate('/Modules/RiskManagement/Theme/Backend/department-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003001001, $request, $response));
$departments = DepartmentMapper::getAll();
$view->addData('departments', $departments);
return $view;
}
@ -231,6 +250,9 @@ class Controller extends ModuleAbstract implements WebInterface
$view->setTemplate('/Modules/RiskManagement/Theme/Backend/category-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003001001, $request, $response));
$categories = CategoryMapper::getAll();
$view->addData('categories', $categories);
return $view;
}
@ -250,6 +272,9 @@ class Controller extends ModuleAbstract implements WebInterface
$view->setTemplate('/Modules/RiskManagement/Theme/Backend/project-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003001001, $request, $response));
$projects = ProjectMapper::getAll();
$view->addData('projects', $projects);
return $view;
}
@ -269,6 +294,9 @@ class Controller extends ModuleAbstract implements WebInterface
$view->setTemplate('/Modules/RiskManagement/Theme/Backend/process-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003001001, $request, $response));
$processes = ProcessMapper::getAll();
$view->addData('processes', $processes);
return $view;
}

View File

@ -118,6 +118,6 @@ class CategoryMapper extends DataMapperAbstract
*/
public static function get($primaryKey, int $relations = RelationType::ALL, $fill = null)
{
return parent::get((int) $primaryKey, $relations, $fill);
return parent::get($primaryKey, $relations, $fill);
}
}

View File

@ -133,6 +133,6 @@ class CauseMapper extends DataMapperAbstract
*/
public static function get($primaryKey, int $relations = RelationType::ALL, $fill = null)
{
return parent::get((int) $primaryKey, $relations, $fill);
return parent::get($primaryKey, $relations, $fill);
}
}

View File

@ -128,6 +128,6 @@ class DepartmentMapper extends DataMapperAbstract
*/
public static function get($primaryKey, int $relations = RelationType::ALL, $fill = null)
{
return parent::get((int) $primaryKey, $relations, $fill);
return parent::get($primaryKey, $relations, $fill);
}
}

View File

@ -131,6 +131,6 @@ class ProcessMapper extends DataMapperAbstract
*/
public static function get($primaryKey, int $relations = RelationType::ALL, $fill = null)
{
return parent::get((int) $primaryKey, $relations, $fill);
return parent::get($primaryKey, $relations, $fill);
}
}

View File

@ -128,6 +128,6 @@ class ProjectMapper extends DataMapperAbstract
*/
public static function get($primaryKey, int $relations = RelationType::ALL, $fill = null)
{
return parent::get((int) $primaryKey, $relations, $fill);
return parent::get($primaryKey, $relations, $fill);
}
}

View File

@ -66,6 +66,18 @@ class RiskMapper extends DataMapperAbstract
'dst' => 'riskmngmt_risk_object_risk',
'src' => null,
],
'causes' => [
'mapper' => CauseMapper::class,
'table' => 'riskmngmt_cause',
'dst' => 'riskmngmt_cause_risk',
'src' => null,
],
'solutions' => [
'mapper' => SolutionMapper::class,
'table' => 'riskmngmt_solution',
'dst' => 'riskmngmt_solution_risk',
'src' => null,
],
];
protected static $belongsTo = [
@ -177,6 +189,6 @@ class RiskMapper extends DataMapperAbstract
*/
public static function get($primaryKey, int $relations = RelationType::ALL, $fill = null)
{
return parent::get((int) $primaryKey, $relations, $fill);
return parent::get($primaryKey, $relations, $fill);
}
}

View File

@ -124,6 +124,6 @@ class RiskObjectMapper extends DataMapperAbstract
*/
public static function get($primaryKey, int $relations = RelationType::ALL, $fill = null)
{
return parent::get((int) $primaryKey, $relations, $fill);
return parent::get($primaryKey, $relations, $fill);
}
}

View File

@ -43,7 +43,7 @@ class SolutionMapper extends DataMapperAbstract
protected static $belongsTo = [
'risk' => [
'mapper' => RiskMapper::class,
'dest' => 'riskmngmt_cause_risk',
'dest' => 'riskmngmt_solution_risk',
],
'cause' => [
'mapper' => CauseMapper::class,
@ -129,6 +129,6 @@ class SolutionMapper extends DataMapperAbstract
*/
public static function get($primaryKey, int $relations = RelationType::ALL, $fill = null)
{
return parent::get((int) $primaryKey, $relations, $fill);
return parent::get($primaryKey, $relations, $fill);
}
}

View File

@ -13,4 +13,31 @@
* @version 1.0.0
* @link http://orange-management.com
*/
$categories = $this->getData('categories');
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="table red">
<caption><?= $this->getText('Causes'); ?></caption>
<thead>
<tr>
<td><?= $this->getText('ID', 0, 0); ?>
<td class="wf-100"><?= $this->getText('Title'); ?>
<tfoot>
<tr><td colspan="3">
<tbody>
<?php $c = 0; foreach ($categories as $key => $value) : $c++;
$url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/riskmanagement/category/single?{?}&id=' . $value->getId()); ?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $value->getId(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->getTitle(); ?></a>
<?php endforeach; ?>
<?php if($c === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getText('Empty', 0, 0); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -13,4 +13,33 @@
* @version 1.0.0
* @link http://orange-management.com
*/
$causes = $this->getData('causes');
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="table red">
<caption><?= $this->getText('Causes'); ?></caption>
<thead>
<tr>
<td><?= $this->getText('ID', 0, 0); ?>
<td class="wf-100"><?= $this->getText('Title'); ?>
<td><?= $this->getText('Risk'); ?>
<tfoot>
<tr><td colspan="3">
<tbody>
<?php $c = 0; foreach ($causes as $key => $value) : $c++;
$url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/riskmanagement/cause/single?{?}&id=' . $value->getId()); ?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $value->getId(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->getTitle(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->getRisk()->getName(); ?></a>
<?php endforeach; ?>
<?php if($c === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getText('Empty', 0, 0); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -13,4 +13,31 @@
* @version 1.0.0
* @link http://orange-management.com
*/
$departments = $this->getData('departments');
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="table red">
<caption><?= $this->getText('Causes'); ?></caption>
<thead>
<tr>
<td><?= $this->getText('ID', 0, 0); ?>
<td class="wf-100"><?= $this->getText('Title'); ?>
<tfoot>
<tr><td colspan="3">
<tbody>
<?php $c = 0; foreach ($departments as $key => $value) : $c++;
$url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/riskmanagement/department/single?{?}&id=' . $value->getId()); ?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $value->getId(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->getDepartment()->getName(); ?></a>
<?php endforeach; ?>
<?php if($c === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getText('Empty', 0, 0); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -13,4 +13,31 @@
* @version 1.0.0
* @link http://orange-management.com
*/
$processes = $this->getData('processes');
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="table red">
<caption><?= $this->getText('Causes'); ?></caption>
<thead>
<tr>
<td><?= $this->getText('ID', 0, 0); ?>
<td class="wf-100"><?= $this->getText('Title'); ?>
<tfoot>
<tr><td colspan="3">
<tbody>
<?php $c = 0; foreach ($processes as $key => $value) : $c++;
$url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/riskmanagement/process/single?{?}&id=' . $value->getId()); ?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $value->getId(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->getTitle(); ?></a>
<?php endforeach; ?>
<?php if($c === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getText('Empty', 0, 0); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -13,4 +13,31 @@
* @version 1.0.0
* @link http://orange-management.com
*/
$projects = $this->getData('projects');
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="table red">
<caption><?= $this->getText('Causes'); ?></caption>
<thead>
<tr>
<td><?= $this->getText('ID', 0, 0); ?>
<td class="wf-100"><?= $this->getText('Title'); ?>
<tfoot>
<tr><td colspan="3">
<tbody>
<?php $c = 0; foreach ($projects as $key => $value) : $c++;
$url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/riskmanagement/project/single?{?}&id=' . $value->getId()); ?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $value->getId(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->getProject()->getName(); ?></a>
<?php endforeach; ?>
<?php if($c === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getText('Empty', 0, 0); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -13,4 +13,37 @@
* @version 1.0.0
* @link http://orange-management.com
*/
$risks = $this->getData('risks');
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="table red">
<caption><?= $this->getText('Causes'); ?></caption>
<thead>
<tr>
<td><?= $this->getText('ID', 0, 0); ?>
<td class="wf-100"><?= $this->getText('Title'); ?>
<td><?= $this->getText('Causes'); ?>
<td><?= $this->getText('Solutions'); ?>
<td><?= $this->getText('Risk Objects'); ?>
<tfoot>
<tr><td colspan="3">
<tbody>
<?php $c = 0; foreach ($risks as $key => $value) : $c++;
$url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/riskmanagement/cause/single?{?}&id=' . $value->getId()); ?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $value->getId(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->getName(); ?></a>
<td><a href="<?= $url; ?>"><?= count($value->getCauses()) ?></a>
<td><a href="<?= $url; ?>"><?= count($value->getSolutions()) ?></a>
<td><a href="<?= $url; ?>"><?= count($value->getRiskObjects()) ?></a>
<?php endforeach; ?>
<?php if($c === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getText('Empty', 0, 0); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -13,4 +13,36 @@
* @version 1.0.0
* @link http://orange-management.com
*/
$solutions = $this->getData('solutions');
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="table red">
<caption><?= $this->getText('Solutions'); ?></caption>
<thead>
<tr>
<td><?= $this->getText('ID', 0, 0); ?>
<td class="wf-100"><?= $this->getText('Title'); ?>
<td><?= $this->getText('Risk'); ?>
<td><?= $this->getText('Cause'); ?>
<tfoot>
<tr><td colspan="4">
<tbody>
<?php $c = 0; foreach ($solutions as $key => $value) : $c++;
$url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/riskmanagement/solution/single?{?}&id=' . $value->getId()); ?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $value->getId(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->getTitle(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->getRisk()->getName(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->getCause()->getTitle(); ?></a>
<?php endforeach; ?>
<?php if($c === 0) : ?>
<tr><td colspan="4" class="empty"><?= $this->getText('Empty', 0, 0); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>