From a236608e570fe3f0ec81308b21fe1080628951b4 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 9 Jul 2017 10:42:02 +0200 Subject: [PATCH] (Draft) Create risk management models Also fix some belongsTo in other mappers. --- Admin/Installer.php | 6 ++--- Controller.php | 28 +++++++++++++++++++++++ Models/CategoryMapper.php | 2 +- Models/CauseMapper.php | 2 +- Models/DepartmentMapper.php | 2 +- Models/ProcessMapper.php | 2 +- Models/ProjectMapper.php | 2 +- Models/RiskMapper.php | 14 +++++++++++- Models/RiskObjectMapper.php | 2 +- Models/SolutionMapper.php | 4 ++-- Theme/Backend/category-list.tpl.php | 27 ++++++++++++++++++++++ Theme/Backend/cause-list.tpl.php | 29 +++++++++++++++++++++++ Theme/Backend/department-list.tpl.php | 27 ++++++++++++++++++++++ Theme/Backend/process-list.tpl.php | 27 ++++++++++++++++++++++ Theme/Backend/project-list.tpl.php | 27 ++++++++++++++++++++++ Theme/Backend/risk-list.tpl.php | 33 +++++++++++++++++++++++++++ Theme/Backend/solution-list.tpl.php | 32 ++++++++++++++++++++++++++ 17 files changed, 254 insertions(+), 12 deletions(-) diff --git a/Admin/Installer.php b/Admin/Installer.php index 23ae48c..aec0aa2 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -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`) diff --git a/Controller.php b/Controller.php index e832d5d..fff7b94 100644 --- a/Controller.php +++ b/Controller.php @@ -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; } diff --git a/Models/CategoryMapper.php b/Models/CategoryMapper.php index 9ce8d30..558e9fd 100644 --- a/Models/CategoryMapper.php +++ b/Models/CategoryMapper.php @@ -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); } } diff --git a/Models/CauseMapper.php b/Models/CauseMapper.php index 897f51d..bffd88a 100644 --- a/Models/CauseMapper.php +++ b/Models/CauseMapper.php @@ -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); } } diff --git a/Models/DepartmentMapper.php b/Models/DepartmentMapper.php index 62a88f7..5f4b3ee 100644 --- a/Models/DepartmentMapper.php +++ b/Models/DepartmentMapper.php @@ -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); } } diff --git a/Models/ProcessMapper.php b/Models/ProcessMapper.php index ba2b0f0..4cf9256 100644 --- a/Models/ProcessMapper.php +++ b/Models/ProcessMapper.php @@ -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); } } diff --git a/Models/ProjectMapper.php b/Models/ProjectMapper.php index a6a638c..0cd6dac 100644 --- a/Models/ProjectMapper.php +++ b/Models/ProjectMapper.php @@ -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); } } diff --git a/Models/RiskMapper.php b/Models/RiskMapper.php index 9567f4e..f1a28e6 100644 --- a/Models/RiskMapper.php +++ b/Models/RiskMapper.php @@ -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); } } diff --git a/Models/RiskObjectMapper.php b/Models/RiskObjectMapper.php index 594a6f3..755df52 100644 --- a/Models/RiskObjectMapper.php +++ b/Models/RiskObjectMapper.php @@ -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); } } diff --git a/Models/SolutionMapper.php b/Models/SolutionMapper.php index de7d8e8..502e75d 100644 --- a/Models/SolutionMapper.php +++ b/Models/SolutionMapper.php @@ -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); } } diff --git a/Theme/Backend/category-list.tpl.php b/Theme/Backend/category-list.tpl.php index 01c1a1e..d3da135 100644 --- a/Theme/Backend/category-list.tpl.php +++ b/Theme/Backend/category-list.tpl.php @@ -13,4 +13,31 @@ * @version 1.0.0 * @link http://orange-management.com */ +$categories = $this->getData('categories'); echo $this->getData('nav')->render(); ?> + +
+
+
+ + + + + + + $value) : $c++; + $url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/riskmanagement/category/single?{?}&id=' . $value->getId()); ?> + +
getText('Causes'); ?>
getText('ID', 0, 0); ?> + getText('Title'); ?> +
+
getId(); ?> + getTitle(); ?> + + +
getText('Empty', 0, 0); ?> + +
+
+
+
\ No newline at end of file diff --git a/Theme/Backend/cause-list.tpl.php b/Theme/Backend/cause-list.tpl.php index 01c1a1e..863ca96 100644 --- a/Theme/Backend/cause-list.tpl.php +++ b/Theme/Backend/cause-list.tpl.php @@ -13,4 +13,33 @@ * @version 1.0.0 * @link http://orange-management.com */ +$causes = $this->getData('causes'); echo $this->getData('nav')->render(); ?> + +
+
+
+ + + + + + + $value) : $c++; + $url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/riskmanagement/cause/single?{?}&id=' . $value->getId()); ?> + +
getText('Causes'); ?>
getText('ID', 0, 0); ?> + getText('Title'); ?> + getText('Risk'); ?> +
+
getId(); ?> + getTitle(); ?> + getRisk()->getName(); ?> + + +
getText('Empty', 0, 0); ?> + +
+
+
+
\ No newline at end of file diff --git a/Theme/Backend/department-list.tpl.php b/Theme/Backend/department-list.tpl.php index 01c1a1e..be2ece7 100644 --- a/Theme/Backend/department-list.tpl.php +++ b/Theme/Backend/department-list.tpl.php @@ -13,4 +13,31 @@ * @version 1.0.0 * @link http://orange-management.com */ +$departments = $this->getData('departments'); echo $this->getData('nav')->render(); ?> + +
+
+
+ + + + + + + $value) : $c++; + $url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/riskmanagement/department/single?{?}&id=' . $value->getId()); ?> + +
getText('Causes'); ?>
getText('ID', 0, 0); ?> + getText('Title'); ?> +
+
getId(); ?> + getDepartment()->getName(); ?> + + +
getText('Empty', 0, 0); ?> + +
+
+
+
\ No newline at end of file diff --git a/Theme/Backend/process-list.tpl.php b/Theme/Backend/process-list.tpl.php index 01c1a1e..323f6c2 100644 --- a/Theme/Backend/process-list.tpl.php +++ b/Theme/Backend/process-list.tpl.php @@ -13,4 +13,31 @@ * @version 1.0.0 * @link http://orange-management.com */ +$processes = $this->getData('processes'); echo $this->getData('nav')->render(); ?> + +
+
+
+ + + + + + + $value) : $c++; + $url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/riskmanagement/process/single?{?}&id=' . $value->getId()); ?> + +
getText('Causes'); ?>
getText('ID', 0, 0); ?> + getText('Title'); ?> +
+
getId(); ?> + getTitle(); ?> + + +
getText('Empty', 0, 0); ?> + +
+
+
+
\ No newline at end of file diff --git a/Theme/Backend/project-list.tpl.php b/Theme/Backend/project-list.tpl.php index 01c1a1e..6982db6 100644 --- a/Theme/Backend/project-list.tpl.php +++ b/Theme/Backend/project-list.tpl.php @@ -13,4 +13,31 @@ * @version 1.0.0 * @link http://orange-management.com */ +$projects = $this->getData('projects'); echo $this->getData('nav')->render(); ?> + +
+
+
+ + + + + + + $value) : $c++; + $url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/riskmanagement/project/single?{?}&id=' . $value->getId()); ?> + +
getText('Causes'); ?>
getText('ID', 0, 0); ?> + getText('Title'); ?> +
+
getId(); ?> + getProject()->getName(); ?> + + +
getText('Empty', 0, 0); ?> + +
+
+
+
\ No newline at end of file diff --git a/Theme/Backend/risk-list.tpl.php b/Theme/Backend/risk-list.tpl.php index 01c1a1e..27b4199 100644 --- a/Theme/Backend/risk-list.tpl.php +++ b/Theme/Backend/risk-list.tpl.php @@ -13,4 +13,37 @@ * @version 1.0.0 * @link http://orange-management.com */ +$risks = $this->getData('risks'); echo $this->getData('nav')->render(); ?> + +
+
+
+ + + + + + + $value) : $c++; + $url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/riskmanagement/cause/single?{?}&id=' . $value->getId()); ?> + +
getText('Causes'); ?>
getText('ID', 0, 0); ?> + getText('Title'); ?> + getText('Causes'); ?> + getText('Solutions'); ?> + getText('Risk Objects'); ?> +
+
getId(); ?> + getName(); ?> + getCauses()) ?> + getSolutions()) ?> + getRiskObjects()) ?> + + +
getText('Empty', 0, 0); ?> + +
+
+
+
\ No newline at end of file diff --git a/Theme/Backend/solution-list.tpl.php b/Theme/Backend/solution-list.tpl.php index 01c1a1e..d06b1f7 100644 --- a/Theme/Backend/solution-list.tpl.php +++ b/Theme/Backend/solution-list.tpl.php @@ -13,4 +13,36 @@ * @version 1.0.0 * @link http://orange-management.com */ +$solutions = $this->getData('solutions'); + echo $this->getData('nav')->render(); ?> + +
+
+
+ + + + + + + $value) : $c++; + $url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/riskmanagement/solution/single?{?}&id=' . $value->getId()); ?> + +
getText('Solutions'); ?>
getText('ID', 0, 0); ?> + getText('Title'); ?> + getText('Risk'); ?> + getText('Cause'); ?> +
+
getId(); ?> + getTitle(); ?> + getRisk()->getName(); ?> + getCause()->getTitle(); ?> + + +
getText('Empty', 0, 0); ?> + +
+
+
+
\ No newline at end of file