Created basic auditor template structure

This commit is contained in:
Dennis Eichhorn 2017-09-06 15:31:24 +02:00
parent 36434d3efa
commit c94966f501
15 changed files with 572 additions and 12 deletions

View File

@ -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": []
}
]
}

View File

@ -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,
],
],
];

View File

@ -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);

View File

@ -0,0 +1,128 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types=1);
namespace Modules\Auditor\Models;
class Audit
{
private $id = 0;
private $type = 0;
private $subtype = 0;
private $module = null;
private $ref = '';
private $content = '';
private $old = '';
private $new = '';
private $createdBy = 0;
private $createdAt = null;
public function __construct()
{
$this->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;
}
}

View File

@ -0,0 +1,121 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types=1);
namespace Modules\Auditor\Models;
use Modules\Admin\Models\AccountMapper;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\Query\Builder;
use phpOMS\DataStorage\Database\Query\Column;
use phpOMS\DataStorage\Database\RelationType;
class AuditMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array
* @since 1.0.0
*/
static protected $columns = [
'auditor_audit_id' => ['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;
}
}

View File

@ -15,5 +15,8 @@ return ['Navigation' => [
'Create' => 'Create',
'Auditor' => 'Auditor',
'Audit' => 'Audit',
'Audits' => 'Audits',
'List' => 'List',
'Modules' => 'Modules',
'Accounts' => 'Accounts',
]];

View File

@ -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',
]];

View File

@ -0,0 +1,45 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright 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(); ?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="table red">
<caption><?= $this->getHtml('Audits') ?></caption>
<thead>
<tr>
<td><?= $this->getHtml('ID', 0, 0); ?>
<td class="wf-100"><?= $this->getHtml('Name') ?>
<td class="wf-100"><?= $this->getHtml('Date') ?>
<tfoot>
<tr>
<td colspan="3">
<tbody>
<?php $count = 0; foreach($audits as $key => $audit) : $count++;
$url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/admin/audit/single?{?}&id=' . $audit->getId()); ?>
<tr data-href="<?= $url; ?>">
<td>
<?php endforeach; ?>
<?php if($count === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getHtml('Empty', 0, 0); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -0,0 +1,18 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright 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,51 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
/**
* @var \phpOMS\Views\View $this
*/
$audits = $this->getData('audits') ?? [];
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="table red">
<caption><?= $this->getHtml('Audits') ?></caption>
<thead>
<tr>
<td><?= $this->getHtml('ID', 0, 0); ?>
<td class="wf-100"><?= $this->getHtml('Module') ?>
<td class="wf-100"><?= $this->getHtml('Type') ?>
<td class="wf-100"><?= $this->getHtml('Subtype') ?>
<td class="wf-100"><?= $this->getHtml('Old') ?>
<td class="wf-100"><?= $this->getHtml('New') ?>
<td class="wf-100"><?= $this->getHtml('Content') ?>
<td class="wf-100"><?= $this->getHtml('By') ?>
<td class="wf-100"><?= $this->getHtml('Date') ?>
<tfoot>
<tr>
<td colspan="9">
<tbody>
<?php $count = 0; foreach($audits as $key => $audit) : $count++;
$url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/admin/audit/single?{?}&id=' . $audit->getId()); ?>
<tr data-href="<?= $url; ?>">
<td>
<?php endforeach; ?>
<?php if($count === 0) : ?>
<tr><td colspan="9" class="empty"><?= $this->getHtml('Empty', 0, 0); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -0,0 +1,18 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright 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,45 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright 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(); ?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="table red">
<caption><?= $this->getHtml('Audits') ?></caption>
<thead>
<tr>
<td><?= $this->getHtml('ID', 0, 0); ?>
<td class="wf-100"><?= $this->getHtml('Name') ?>
<td class="wf-100"><?= $this->getHtml('Date') ?>
<tfoot>
<tr>
<td colspan="3">
<tbody>
<?php $count = 0; foreach($audits as $key => $audit) : $count++;
$url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/admin/audit/single?{?}&id=' . $audit->getId()); ?>
<tr data-href="<?= $url; ?>">
<td>
<?php endforeach; ?>
<?php if($count === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getHtml('Empty', 0, 0); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -0,0 +1,18 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright 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(); ?>