From c94966f50109501666576a41ca409b6e2b0e8c33 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 6 Sep 2017 15:31:24 +0200 Subject: [PATCH] Created basic auditor template structure --- Admin/Install/Navigation.install.json | 38 ++++++- Admin/Routes/Web/Backend.php | 28 ++++- Controller.php | 59 +++++++++- Models/Audit.php | 128 ++++++++++++++++++++++ Models/AuditMapper.php | 121 ++++++++++++++++++++ Theme/Backend/Lang/Navigation.en.lang.php | 3 + Theme/Backend/Lang/en.lang.php | 12 +- Theme/Backend/account-list.tpl.php | 45 ++++++++ Theme/Backend/account-single.tpl.php | 18 +++ Theme/Backend/audit-list.tpl.php | 51 +++++++++ Theme/Backend/audit-single.tpl.php | 18 +++ Theme/Backend/auditor-list.tpl.php | 0 Theme/Backend/autitor-single.tpl.php | 0 Theme/Backend/module-list.tpl.php | 45 ++++++++ Theme/Backend/module-single.tpl.php | 18 +++ 15 files changed, 572 insertions(+), 12 deletions(-) create mode 100644 Theme/Backend/account-list.tpl.php create mode 100644 Theme/Backend/account-single.tpl.php create mode 100644 Theme/Backend/audit-list.tpl.php create mode 100644 Theme/Backend/audit-single.tpl.php delete mode 100644 Theme/Backend/auditor-list.tpl.php delete mode 100644 Theme/Backend/autitor-single.tpl.php create mode 100644 Theme/Backend/module-list.tpl.php create mode 100644 Theme/Backend/module-single.tpl.php diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json index 94bcc10..64db233 100644 --- a/Admin/Install/Navigation.install.json +++ b/Admin/Install/Navigation.install.json @@ -5,7 +5,7 @@ "type": 2, "subtype": 1, "name": "Auditor", - "uri": "{/base}/{/lang}/backend/admin/aduit/list?{?}", + "uri": "{/base}/{/lang}/backend/admin/audit/list?{?}", "target": "self", "icon": null, "order": 75, @@ -15,11 +15,11 @@ "children": [ { "id": 1006202001, - "pid": "dbc72ec850137bfcf6cb862625c680ae0ee6def2", + "pid": "f305944200a78b878dae7d978d2a0c372a9cb200", "type": 3, "subtype": 1, - "name": "List", - "uri": "{/base}/{/lang}/backend/admin/aduit/list?{?}", + "name": "Audits", + "uri": "{/base}/{/lang}/backend/admin/audit/list?{?}", "target": "self", "icon": null, "order": 1, @@ -27,6 +27,36 @@ "permission": null, "parent": 1006201001, "children": [] + }, + { + "id": 1006203001, + "pid": "f305944200a78b878dae7d978d2a0c372a9cb200", + "type": 3, + "subtype": 1, + "name": "Modules", + "uri": "{/base}/{/lang}/backend/admin/audit/module/list?{?}", + "target": "self", + "icon": null, + "order": 5, + "from": "Auditor", + "permission": null, + "parent": 1006201001, + "children": [] + }, + { + "id": 1006204001, + "pid": "f305944200a78b878dae7d978d2a0c372a9cb200", + "type": 3, + "subtype": 1, + "name": "Accounts", + "uri": "{/base}/{/lang}/backend/admin/audit/account/list?{?}", + "target": "self", + "icon": null, + "order": 10, + "from": "Auditor", + "permission": null, + "parent": 1006201001, + "children": [] } ] } diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index f53037c..f9077fd 100644 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -3,16 +3,40 @@ use phpOMS\Router\RouteVerb; return [ - '^.*/backend/admin/auditor/list.*$' => [ + '^.*/backend/admin/audit/list.*$' => [ [ 'dest' => '\Modules\Auditor\Controller:viewAuditorList', 'verb' => RouteVerb::GET, ], ], - '^.*/backend/admin/auditor/single.*$' => [ + '^.*/backend/admin/audit/single.*$' => [ [ 'dest' => '\Modules\Auditor\Controller:viewAuditorSingle', 'verb' => RouteVerb::GET, ], ], + '^.*/backend/admin/audit/module/list.*$' => [ + [ + 'dest' => '\Modules\Auditor\Controller:viewAuditorModuleList', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/admin/audit/module/single.*$' => [ + [ + 'dest' => '\Modules\Auditor\Controller:viewAuditorModuleSingle', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/admin/audit/account/list.*$' => [ + [ + 'dest' => '\Modules\Auditor\Controller:viewAuditorAccountList', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/admin/audit/account/single.*$' => [ + [ + 'dest' => '\Modules\Auditor\Controller:viewAuditorAccountSingle', + 'verb' => RouteVerb::GET, + ], + ], ]; diff --git a/Controller.php b/Controller.php index 2d82f0a..02315f5 100644 --- a/Controller.php +++ b/Controller.php @@ -23,6 +23,9 @@ use phpOMS\Module\WebInterface; use phpOMS\Views\View; use phpOMS\Views\ViewLayout; +use Modules\Auditor\Models\AuditMapper; +use Modules\Auditor\Models\Audit; + /** * Calendar controller class. * @@ -79,8 +82,8 @@ class Controller extends ModuleAbstract implements WebInterface public function viewAuditorList(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable { $view = new View($this->app, $request, $response); - $view->setTemplate('/Modules/Auditor/Theme/Backend/auditor-list'); - $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005801001, $request, $response)); + $view->setTemplate('/Modules/Auditor/Theme/Backend/audit-list'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006201001, $request, $response)); $list = AuditMapper::getNewest(50); $view->setData('audits', $list); @@ -91,8 +94,56 @@ class Controller extends ModuleAbstract implements WebInterface public function viewAuditorSingle(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable { $view = new View($this->app, $request, $response); - $view->setTemplate('/Modules/Auditor/Theme/Backend/auditor-single'); - $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005801001, $request, $response)); + $view->setTemplate('/Modules/Auditor/Theme/Backend/audit-single'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006201001, $request, $response)); + + $list = AuditMapper::get(50); + $view->setData('audits', $list); + + return $view; + } + + public function viewAuditorModuleList(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Auditor/Theme/Backend/module-list'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006201001, $request, $response)); + + $list = AuditMapper::getNewest(50); + $view->setData('audits', $list); + + return $view; + } + + public function viewAuditorModuleSingle(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Auditor/Theme/Backend/module-single'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006201001, $request, $response)); + + $list = AuditMapper::get(50); + $view->setData('audits', $list); + + return $view; + } + + public function viewAuditorAccountList(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Auditor/Theme/Backend/account-list'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006201001, $request, $response)); + + $list = AuditMapper::getNewest(50); + $view->setData('audits', $list); + + return $view; + } + + public function viewAuditorAccountSingle(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Auditor/Theme/Backend/account-single'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006201001, $request, $response)); $list = AuditMapper::get(50); $view->setData('audits', $list); diff --git a/Models/Audit.php b/Models/Audit.php index e69de29..d84ab63 100644 --- a/Models/Audit.php +++ b/Models/Audit.php @@ -0,0 +1,128 @@ +createdAt = new DateTime('now'); + } + + public function setType(int $type) /* : void */ + { + $this->type = $type; + } + + public function getType() : int + { + return $this->type; + } + + public function setSubType(int $subtype) /* : void */ + { + $this->subtype = $subtype; + } + + public function getSubType() : int + { + return $this->subtype; + } + + public function setModule(int $module) /* : void */ + { + $this->module = $module; + } + + public function getModule() : int + { + return $this->module; + } + + public function setRef(string $ref) /* : void */ + { + $this->ref = $ref; + } + + public function getRef() : string + { + return $this->ref; + } + + public function setContent(string $content) /* : void */ + { + $this->content = $content; + } + + public function getContent() : string + { + return $this->content; + } + + public function setOld(string $old) /* : void */ + { + $this->old = $old; + } + + public function getOld() : string + { + return $this->old; + } + + public function setNew(string $new) /* : void */ + { + $this->new = $new; + } + + public function getNew() : string + { + return $this->new; + } + + public function setCreatedBy($createdBy) /* : void */ + { + $this->createdBy = $createdBy; + } + + public function getCreatedBy() + { + return $this->createdBy; + } + + public function getCreatedAt() : \DateTime + { + return $this->createdAt; + } +} diff --git a/Models/AuditMapper.php b/Models/AuditMapper.php index e69de29..a1a5f59 100644 --- a/Models/AuditMapper.php +++ b/Models/AuditMapper.php @@ -0,0 +1,121 @@ + ['name' => 'auditor_audit_id', 'type' => 'int', 'internal' => 'id'], + 'auditor_audit_created_by' => ['name' => 'auditor_audit_created_by', 'type' => 'int', 'internal' => 'createdBy'], + 'auditor_audit_created_at' => ['name' => 'auditor_audit_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'], + 'auditor_audit_ip' => ['name' => 'auditor_audit_ip', 'type' => 'int', 'internal' => 'ip'], + 'auditor_audit_module' => ['name' => 'auditor_audit_module', 'type' => 'int', 'internal' => 'module'], + 'auditor_audit_ref' => ['name' => 'auditor_audit_ref', 'type' => 'string', 'internal' => 'ref'], + 'auditor_audit_type' => ['name' => 'auditor_audit_type', 'type' => 'int', 'internal' => 'type'], + 'auditor_audit_subtype' => ['name' => 'auditor_audit_subtype', 'type' => 'int', 'internal' => 'subtype'], + 'auditor_audit_content' => ['name' => 'auditor_audit_content', 'type' => 'string', 'internal' => 'content'], + 'auditor_audit_old' => ['name' => 'auditor_audit_old', 'type' => 'string', 'internal' => 'old'], + 'auditor_audit_new' => ['name' => 'auditor_audit_new', 'type' => 'string', 'internal' => 'new'], + ]; + + static protected $belongsTo = [ + 'createdBy' => [ + 'mapper' => AccountMapper::class, + 'src' => 'auditor_audit_created_by', + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static $table = 'auditor_audit'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static $primaryField = 'auditor_audit'; + + /** + * Created at. + * + * @var string + * @since 1.0.0 + */ + protected static $createdAt = 'auditor_audit_created_at'; + + /** + * Create object. + * + * @param mixed $obj Object + * @param int $relations Behavior for relations creation + * + * @return mixed + * + * @since 1.0.0 + */ + public static function create($obj, int $relations = RelationType::ALL) + { + try { + $objId = parent::create($obj, $relations); + + if($objId === null || !is_scalar($objId)) { + return $objId; + } + + $query = new Builder(self::$db); + $query->prefix(self::$db->getPrefix()) + ->insert( + 'account_permission_account', + 'account_permission_from', + 'account_permission_for', + 'account_permission_id1', + 'account_permission_id2', + 'account_permission_r', + 'account_permission_w', + 'account_permission_m', + 'account_permission_d', + 'account_permission_p' + ) + ->into('account_permission') + ->values($obj->getCreatedBy(), 'auditor_audit', 'auditor_audit', 1, $objId, 1, 1, 1, 1, 1); + + self::$db->con->prepare($query->toSql())->execute(); + } catch (\Exception $e) { + return false; + } + + return $objId; + } + +} diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php index a4b23f5..aa0e42c 100644 --- a/Theme/Backend/Lang/Navigation.en.lang.php +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -15,5 +15,8 @@ return ['Navigation' => [ 'Create' => 'Create', 'Auditor' => 'Auditor', 'Audit' => 'Audit', + 'Audits' => 'Audits', 'List' => 'List', + 'Modules' => 'Modules', + 'Accounts' => 'Accounts', ]]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index a686b30..48339b7 100644 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -12,8 +12,16 @@ * @link http://orange-management.com */ return ['Auditor' => [ - 'Created' => 'Created', - 'Creator' => 'Creator', + 'By' => 'By', 'Auditor' => 'Auditor', 'Audit' => 'Audit', + 'Audits' => 'Audits', + 'Date' => 'Date', + 'Content' => 'Content', + 'Old' => 'Old', + 'New' => 'New', + 'Type' => 'Type', + 'Subtype' => 'Subtype', + 'Module' => 'Module', + 'Name' => 'Name', ]]; diff --git a/Theme/Backend/account-list.tpl.php b/Theme/Backend/account-list.tpl.php new file mode 100644 index 0000000..4e92f79 --- /dev/null +++ b/Theme/Backend/account-list.tpl.php @@ -0,0 +1,45 @@ +getData('nav')->render(); ?> + +
+
+
+ + + + + + + + $audit) : $count++; + $url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/admin/audit/single?{?}&id=' . $audit->getId()); ?> + +
getHtml('Audits') ?>
getHtml('ID', 0, 0); ?> + getHtml('Name') ?> + getHtml('Date') ?> +
+
+ + +
getHtml('Empty', 0, 0); ?> + +
+
+
+
\ No newline at end of file diff --git a/Theme/Backend/account-single.tpl.php b/Theme/Backend/account-single.tpl.php new file mode 100644 index 0000000..d515f93 --- /dev/null +++ b/Theme/Backend/account-single.tpl.php @@ -0,0 +1,18 @@ +getData('nav')->render(); ?> \ No newline at end of file diff --git a/Theme/Backend/audit-list.tpl.php b/Theme/Backend/audit-list.tpl.php new file mode 100644 index 0000000..d5ae73b --- /dev/null +++ b/Theme/Backend/audit-list.tpl.php @@ -0,0 +1,51 @@ +getData('audits') ?? []; +echo $this->getData('nav')->render(); ?> + +
+
+
+ + + + + + + + $audit) : $count++; + $url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/admin/audit/single?{?}&id=' . $audit->getId()); ?> + +
getHtml('Audits') ?>
getHtml('ID', 0, 0); ?> + getHtml('Module') ?> + getHtml('Type') ?> + getHtml('Subtype') ?> + getHtml('Old') ?> + getHtml('New') ?> + getHtml('Content') ?> + getHtml('By') ?> + getHtml('Date') ?> +
+
+ + +
getHtml('Empty', 0, 0); ?> + +
+
+
+
diff --git a/Theme/Backend/audit-single.tpl.php b/Theme/Backend/audit-single.tpl.php new file mode 100644 index 0000000..d515f93 --- /dev/null +++ b/Theme/Backend/audit-single.tpl.php @@ -0,0 +1,18 @@ +getData('nav')->render(); ?> \ No newline at end of file diff --git a/Theme/Backend/auditor-list.tpl.php b/Theme/Backend/auditor-list.tpl.php deleted file mode 100644 index e69de29..0000000 diff --git a/Theme/Backend/autitor-single.tpl.php b/Theme/Backend/autitor-single.tpl.php deleted file mode 100644 index e69de29..0000000 diff --git a/Theme/Backend/module-list.tpl.php b/Theme/Backend/module-list.tpl.php new file mode 100644 index 0000000..4e92f79 --- /dev/null +++ b/Theme/Backend/module-list.tpl.php @@ -0,0 +1,45 @@ +getData('nav')->render(); ?> + +
+
+
+ + + + + + + + $audit) : $count++; + $url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/admin/audit/single?{?}&id=' . $audit->getId()); ?> + +
getHtml('Audits') ?>
getHtml('ID', 0, 0); ?> + getHtml('Name') ?> + getHtml('Date') ?> +
+
+ + +
getHtml('Empty', 0, 0); ?> + +
+
+
+
\ No newline at end of file diff --git a/Theme/Backend/module-single.tpl.php b/Theme/Backend/module-single.tpl.php new file mode 100644 index 0000000..d515f93 --- /dev/null +++ b/Theme/Backend/module-single.tpl.php @@ -0,0 +1,18 @@ +getData('nav')->render(); ?> \ No newline at end of file