mirror of
https://github.com/Karaka-Management/oms-Admin.git
synced 2026-01-25 03:38:39 +00:00
Template, comment and path fixes
This commit is contained in:
parent
3ccfaf607a
commit
4c0fc1ec38
|
|
@ -17,6 +17,8 @@ namespace Modules\Admin;
|
|||
|
||||
use Model\Message\FormValidation;
|
||||
use Modules\Admin\Models\Account;
|
||||
use phpOMS\Account\AccountStatus;
|
||||
use phpOMS\Account\AccountType;
|
||||
use Modules\Admin\Models\AccountMapper;
|
||||
use Modules\Admin\Models\Group;
|
||||
use Modules\Admin\Models\GroupMapper;
|
||||
|
|
@ -356,11 +358,37 @@ class Controller extends ModuleAbstract implements WebInterface
|
|||
$response->set('account', AccountMapper::getByRequest($request));
|
||||
}
|
||||
|
||||
private function validateAccountCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (
|
||||
($val['name'] = empty($request->getData('name')))
|
||||
|| ($val['name1'] = empty($request->getData('name1')))
|
||||
|| ($val['type'] = !AccountType::isValidValue((int) $request->getData('type')))
|
||||
|| ($val['status'] = !AccountStatus::isValidValue((int) $request->getData('status')))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function apiAccountCreate(RequestAbstract $request, ResponseAbstract $response, $data = null)
|
||||
{
|
||||
if (!empty($val = $this->validateAccountCreate($request))) {
|
||||
$response->set('account_create', new FormValidation($val));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$account = new Account();
|
||||
$account->setStatus($request->getData('status'));
|
||||
$account->setType($request->getData('type'));
|
||||
$account->setName($request->getData('name'));
|
||||
$account->setDescription($request->getData('desc'));
|
||||
$account->setName1($request->getData('name1'));
|
||||
$account->setName2($request->getData('name2'));
|
||||
$account->setName3($request->getData('name3'));
|
||||
$account->setEmail($request->getData('email'));
|
||||
|
||||
AccountMapper::create($account);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@
|
|||
*/
|
||||
namespace Modules\Admin\Models;
|
||||
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Query\Builder;
|
||||
use phpOMS\DataStorage\Database\Query\Column;
|
||||
use phpOMS\DataStorage\Database\RelationType;
|
||||
|
||||
class AccountMapper extends DataMapperAbstract
|
||||
|
|
@ -66,6 +69,49 @@ class AccountMapper extends DataMapperAbstract
|
|||
*/
|
||||
protected static $createdAt = 'account_created_at';
|
||||
|
||||
/**
|
||||
* Create object.
|
||||
*
|
||||
* @param mixed $obj Object
|
||||
* @param int $relations Behavior for relations creation
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function create($obj, int $relations = RelationType::ALL)
|
||||
{
|
||||
try {
|
||||
$objId = parent::create($obj, $relations);
|
||||
$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(1, 'account', 'account', 1, $objId, 1, 1, 1, 1, 1);
|
||||
|
||||
self::$db->con->prepare($query->toSql())->execute();
|
||||
} catch (\Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get object.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -18,20 +18,20 @@ echo $this->getData('nav')->render(); ?>
|
|||
<section class="box w-66 floatLeft">
|
||||
<header><h1><?= $this->getText('Account') ?></h1></header>
|
||||
<div class="inner">
|
||||
<form action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/admin/account'); ?>" method="post">
|
||||
<form id="fAccount" action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/admin/account'); ?>" method="put">
|
||||
<table class="layout wf-100">
|
||||
<tbody>
|
||||
<tr><td><label for="iType"><?= $this->getText('Type') ?></label>
|
||||
<tr><td><select id="iType" name="type">
|
||||
<option><?= $this->getText('Person') ?>
|
||||
<option><?= $this->getText('Organization') ?>
|
||||
<option value="<?= \phpOMS\Account\AccountType::USER; ?>"><?= $this->getText('Person') ?>
|
||||
<option value="<?= \phpOMS\Account\AccountType::GROUP; ?>"><?= $this->getText('Organization') ?>
|
||||
</select>
|
||||
<tr><td><label for="iStatus"><?= $this->getText('Status') ?></label>
|
||||
<tr><td><select id="iStatus" name="status">
|
||||
<option><?= $this->getText('Active') ?>
|
||||
<option><?= $this->getText('Inactive') ?>
|
||||
<option><?= $this->getText('Timeout') ?>
|
||||
<option><?= $this->getText('Banned') ?>
|
||||
<option value="<?= \phpOMS\Account\AccountStatus::ACTIVE; ?>"><?= $this->getText('Active') ?>
|
||||
<option value="<?= \phpOMS\Account\AccountStatus::INACTIVE; ?>"><?= $this->getText('Inactive') ?>
|
||||
<option value="<?= \phpOMS\Account\AccountStatus::TIMEOUT; ?>"><?= $this->getText('Timeout') ?>
|
||||
<option value="<?= \phpOMS\Account\AccountStatus::BANNED; ?>"><?= $this->getText('Banned') ?>
|
||||
</select>
|
||||
<tr><td><label for="iUsername"><?= $this->getText('Username') ?></label>
|
||||
<tr><td><input id="iUsername" name="name" type="text" placeholder=" Fred">
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ echo $this->getData('nav')->render();
|
|||
<?php $c = 0; foreach ($this->getData('list:elements') as $key => $value) : $c++;
|
||||
$url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/admin/account/settings?id=' . $value->getId()); ?>
|
||||
<tr>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getStatus(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getId(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getStatus(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getName1(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getLastActive()->format('Y-m-d H:i:s'); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getCreatedAt()->format('Y-m-d H:i:s'); ?></a>
|
||||
|
|
|
|||
|
|
@ -18,20 +18,20 @@ echo $this->getData('nav')->render(); ?>
|
|||
<section class="box w-66 floatLeft">
|
||||
<header><h1><?= $this->getText('Account') ?></h1></header>
|
||||
<div class="inner">
|
||||
<form action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/admin/account'); ?>" method="post">
|
||||
<form id="fAccount" action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/admin/account'); ?>" method="put">
|
||||
<table class="layout wf-100">
|
||||
<tbody>
|
||||
<tr><td><label for="iType"><?= $this->getText('Type') ?></label>
|
||||
<tr><td><select id="iType" name="type">
|
||||
<option><?= $this->getText('Person') ?>
|
||||
<option><?= $this->getText('Organization') ?>
|
||||
<option value="<?= \phpOMS\Account\AccountType::USER; ?>"><?= $this->getText('Person') ?>
|
||||
<option value="<?= \phpOMS\Account\AccountType::GROUP; ?>"><?= $this->getText('Organization') ?>
|
||||
</select>
|
||||
<tr><td><label for="iStatus"><?= $this->getText('Status') ?></label>
|
||||
<tr><td><select id="iStatus" name="status">
|
||||
<option><?= $this->getText('Active') ?>
|
||||
<option><?= $this->getText('Inactive') ?>
|
||||
<option><?= $this->getText('Timeout') ?>
|
||||
<option><?= $this->getText('Banned') ?>
|
||||
<option value="<?= \phpOMS\Account\AccountStatus::ACTIVE; ?>"><?= $this->getText('Active') ?>
|
||||
<option value="<?= \phpOMS\Account\AccountStatus::INACTIVE; ?>"><?= $this->getText('Inactive') ?>
|
||||
<option value="<?= \phpOMS\Account\AccountStatus::TIMEOUT; ?>"><?= $this->getText('Timeout') ?>
|
||||
<option value="<?= \phpOMS\Account\AccountStatus::BANNED; ?>"><?= $this->getText('Banned') ?>
|
||||
</select>
|
||||
<tr><td><label for="iUsername"><?= $this->getText('Username') ?></label>
|
||||
<tr><td><input id="iUsername" name="name" type="text" placeholder=" Fred">
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ echo $this->getData('nav')->render();
|
|||
<?php $c = 0; foreach ($this->getData('list:elements') as $key => $value) : $c++;
|
||||
$url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/admin/account/settings?id=' . $value->getId()); ?>
|
||||
<tr>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getStatus(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getId(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getStatus(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getName1(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getLastActive()->format('Y-m-d H:i:s'); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getCreatedAt()->format('Y-m-d H:i:s'); ?></a>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user