template fixes + bug fixes + style fixes

This commit is contained in:
Dennis Eichhorn 2024-04-02 21:40:47 +00:00
parent d888ff5574
commit 9bedfce9a7
9 changed files with 315 additions and 119 deletions

View File

@ -58,6 +58,37 @@
"from": "InvestmentManagement", "from": "InvestmentManagement",
"permission": { "permission": 2, "category": null, "element": null }, "permission": { "permission": 2, "category": null, "element": null },
"parent": 1003401001, "parent": 1003401001,
"children": [] "children": [
{
"id": 1007104001,
"pid": "/private/investment",
"type": 3,
"subtype": 1,
"name": "List",
"uri": "{/base}/private/investment/list?{?}",
"target": "self",
"icon": null,
"order": 1,
"from": "InvestmentManagement",
"permission": { "permission": 2, "type": null, "element": null },
"parent": 1007103001,
"children": []
},
{
"id": 1007104002,
"pid": "/private/investment",
"type": 3,
"subtype": 1,
"name": "Create",
"uri": "{/base}/private/investment/create?{?}",
"target": "self",
"icon": null,
"order": 5,
"from": "InvestmentManagement",
"permission": { "permission": 2, "type": null, "element": null },
"parent": 1007103001,
"children": []
}
]
} }
] ]

View File

@ -64,7 +64,7 @@ return [
'^/private/investment/list(\?.*$|$)' => [ '^/private/investment/list(\?.*$|$)' => [
[ [
'dest' => '\Modules\InvestmentManagement\Controller\BackendController:viewInvestmentList', 'dest' => '\Modules\InvestmentManagement\Controller\BackendController:viewInvestmentPrivateList',
'verb' => RouteVerb::GET, 'verb' => RouteVerb::GET,
'permission' => [ 'permission' => [
'module' => BackendController::MODULE_NAME, 'module' => BackendController::MODULE_NAME,
@ -73,6 +73,17 @@ return [
], ],
], ],
], ],
'^/private/investment/create(\?.*$|$)' => [
[
'dest' => '\Modules\InvestmentManagement\Controller\BackendController:viewInvestmentPrivateCreate',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::MODULE_NAME,
'type' => PermissionType::CREATE,
'state' => PermissionCategory::INVESTMENT,
],
],
],
'^/private/investment/view(\?.*$|$)' => [ '^/private/investment/view(\?.*$|$)' => [
[ [
'dest' => '\Modules\InvestmentManagement\Controller\BackendController:viewInvestmentView', 'dest' => '\Modules\InvestmentManagement\Controller\BackendController:viewInvestmentView',

View File

@ -487,7 +487,7 @@ final class ApiController extends Controller
// @todo reconsider the following lines. This seems rather complicated. // @todo reconsider the following lines. This seems rather complicated.
if ($request->hasData('amount')) { if ($request->hasData('amount')) {
/** @var BaseStringL11nType[] $types */ /** @var BaseStringL11nType[] $types */
$types = AmountTypeMapper::getAll()->execute(); $types = AmountTypeMapper::getAll()->executeGetArray();
foreach ($types as $type) { foreach ($types as $type) {
if ($type->title === 'costs') { if ($type->title === 'costs') {

View File

@ -15,6 +15,7 @@ declare(strict_types=1);
namespace Modules\InvestmentManagement\Controller; namespace Modules\InvestmentManagement\Controller;
use Modules\InvestmentManagement\Models\InvestmentMapper; use Modules\InvestmentManagement\Models\InvestmentMapper;
use Modules\InvestmentManagement\Models\InvestmentObjectMapper;
use Modules\InvestmentManagement\Models\InvestmentTypeMapper; use Modules\InvestmentManagement\Models\InvestmentTypeMapper;
use Modules\Organization\Models\UnitMapper; use Modules\Organization\Models\UnitMapper;
use phpOMS\Contract\RenderableInterface; use phpOMS\Contract\RenderableInterface;
@ -53,13 +54,62 @@ final class BackendController extends Controller
$list = InvestmentMapper::getAll() $list = InvestmentMapper::getAll()
->with('createdBy') ->with('createdBy')
->sort('id', 'DESC') ->sort('id', 'DESC')
->execute(); ->executeGetArray();
$view->data['investments'] = $list; $view->data['investments'] = $list;
return $view; return $view;
} }
/**
* Routing end-point for application behavior.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewInvestmentPrivateList(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/InvestmentManagement/Theme/Backend/investment-list');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007103001, $request, $response);
$list = InvestmentMapper::getAll()
->with('createdBy')
->sort('id', 'DESC')
->executeGetArray();
$view->data['investments'] = $list;
return $view;
}
/**
* Routing end-point for application behavior.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewInvestmentPrivateCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/InvestmentManagement/Theme/Backend/investment-view');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007103001, $request, $response);
return $view;
}
/** /**
* Routing end-point for application behavior. * Routing end-point for application behavior.
* *
@ -104,17 +154,13 @@ final class BackendController extends Controller
$view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response); $view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response);
$view->data['attributeView']->data['default_localization'] = $this->app->l11nServer; $view->data['attributeView']->data['default_localization'] = $this->app->l11nServer;
$investmentTypes = InvestmentTypeMapper::getAll() $view->data['types'] = InvestmentTypeMapper::getAll()
->with('l11n') ->with('l11n')
->where('l11n/language', $response->header->l11n->language) ->where('l11n/language', $response->header->l11n->language)
->execute(); ->executeGetArray();
$view->data['types'] = $investmentTypes; $view->data['units'] = UnitMapper::getAll()
->executeGetArray();
$units = UnitMapper::getAll()
->execute();
$view->data['units'] = $units;
$view->data['media-upload'] = new \Modules\Media\Theme\Backend\Components\Upload\BaseView($this->app->l11nManager, $request, $response); $view->data['media-upload'] = new \Modules\Media\Theme\Backend\Components\Upload\BaseView($this->app->l11nManager, $request, $response);
$view->data['note'] = new \Modules\Editor\Theme\Backend\Components\Note\BaseView($this->app->l11nManager, $request, $response); $view->data['note'] = new \Modules\Editor\Theme\Backend\Components\Note\BaseView($this->app->l11nManager, $request, $response);
@ -137,7 +183,7 @@ final class BackendController extends Controller
public function viewInvestmentCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface public function viewInvestmentCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{ {
$view = new View($this->app->l11nManager, $request, $response); $view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/InvestmentManagement/Theme/Backend/investment-create'); $view->setTemplate('/Modules/InvestmentManagement/Theme/Backend/investment-view');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007101001, $request, $response); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007101001, $request, $response);
return $view; return $view;
@ -182,6 +228,31 @@ final class BackendController extends Controller
$view->setTemplate('/Modules/InvestmentManagement/Theme/Backend/investment-option-view'); $view->setTemplate('/Modules/InvestmentManagement/Theme/Backend/investment-option-view');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007101001, $request, $response); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007101001, $request, $response);
$view->data['option'] = InvestmentObjectMapper::get()
->with('supplier')
->with('supplier/account')
->with('item')
->with('files')
->with('notes')
->with('amountGroups')
->with('amountGroups/type')
->with('amountGroups/amounts')
->with('attributes')
->with('attributes/type')
->with('attributes/type/l11n')
->with('attributes/value')
->where('id', (int) $request->getData('id'))
->execute();
$view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response);
$view->data['attributeView']->data['default_localization'] = $this->app->l11nServer;
$view->data['units'] = UnitMapper::getAll()
->executeGetArray();
$view->data['media-upload'] = new \Modules\Media\Theme\Backend\Components\Upload\BaseView($this->app->l11nManager, $request, $response);
$view->data['note'] = new \Modules\Editor\Theme\Backend\Components\Note\BaseView($this->app->l11nManager, $request, $response);
return $view; return $view;
} }
} }

View File

@ -64,7 +64,7 @@ class Investment
{ {
$this->createdBy = new NullAccount(); $this->createdBy = new NullAccount();
$this->createdAt = new \DateTimeImmutable('now'); $this->createdAt = new \DateTimeImmutable('now');
$this->performanceDate = new \DateTime('now'); $this->performanceDate = (new \DateTime('now'))->modify('+7 days');
} }
use \Modules\Media\Models\MediaListTrait; use \Modules\Media\Models\MediaListTrait;

View File

@ -34,6 +34,7 @@ final class NullInvestment extends Investment
public function __construct(int $id = 0) public function __construct(int $id = 0)
{ {
$this->id = $id; $this->id = $id;
parent::__construct();
} }
/** /**

View File

@ -0,0 +1,46 @@
<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package Modules\InvestmentManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\InvestmentManagement\Models;
/**
* Null model
*
* @package Modules\InvestmentManagement\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class NullInvestmentObject extends InvestmentObject
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return ['id' => $this->id];
}
}

View File

@ -12,111 +12,136 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Modules\InvestmentManagement\Models\NullInvestmentObject;
use phpOMS\Uri\UriFactory; use phpOMS\Uri\UriFactory;
/** @var \phpOMS\Views\View $this */ /** @var \phpOMS\Views\View $this */
$option = $this->data['option'] ?? new NullInvestmentObject();
$isNew = $option->id === 0;
?> ?>
<div class="row"> <div class="row">
<a class="button" href="<?= UriFactory::build('{/base}/finance/investment/view?id=' . $request->uri->getQuery('id')); ?>"><?= $this->getHtml('Back', '0', '0'); ?></a> <div class="col-xs-12">
</div> <div class="box">
<a class="button" href="<?= UriFactory::build('{/base}/finance/investment/view?id=' . $this->request->uri->getQuery('id')); ?>"><?= $this->getHtml('Back', '0', '0'); ?></a>
<div class="row"> </div>
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Option'); ?> <?= $count; ?></div>
<div class="portlet-body">
<div class="form-group">
<label for="iObjectName-<?= $count; ?>"><?= $this->getHtml('Name'); ?></label>
<input type="text" id="iObjectName-<?= $count; ?>" name="name" value="<?= $this->printHtml($option->name); ?>">
</div>
<div class="form-group">
<label for="iObjectDescription-<?= $count; ?>"><?= $this->getHtml('Description'); ?></label>
<textarea id="iObjectDescription-<?= $count; ?>" name="description"><?= $this->printHtml($option->description); ?></textarea>
</div>
<div class="form-group">
<label for="iObjectLink-<?= $count; ?>"><?= $this->getHtml('Link'); ?></label>
<input type="text" id="iObjectLink-<?= $count; ?>" name="link" value="<?= $this->printHtml($option->link); ?>">
</div>
<div class="form-group">
<span class="checkbox">
<label class="checkbox" for="iApproved-<?= $count; ?>">
<input id="iApproved-<?= $count; ?>" type="checkbox" name="approved" value="1" disabled>
<span class="checkmark"></span>
<?= $this->getHtml('Approved'); ?>
</label>
</span>
</div>
<div class="form-group">
<table class="default">
<thead>
<tr>
<td><?= $this->getHtml('Attributes'); ?>
<tbody>
<?php foreach ($option->attributes as $attribute) : ?>
<tr>
<td>
<?php endforeach; ?>
<?php if (empty($option->attributes)) : ?>
<tr><td colspan="1" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
<div class="form-group">
<table class="default">
<thead>
<tr>
<td><?= $this->getHtml('Amounts'); ?>
<tbody>
<?php foreach ($option->amountGroups as $group) : ?>
<tr>
<td><?= $this->getCurrency($group->sum(), '', 'medium'); ?>
<?php endforeach; ?>
<?php if (empty($option->files)) : ?>
<tr><td colspan="1" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
<div class="form-group">
<table class="default">
<thead>
<tr>
<td><?= $this->getHtml('Files'); ?>
<tbody>
<?php foreach ($option->files as $file) : ?>
<tr>
<td>
<?php endforeach; ?>
<?php if (empty($option->files)) : ?>
<tr><td colspan="1" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
<div class="form-group">
<table class="default">
<thead>
<tr>
<td><?= $this->getHtml('Notes'); ?>
<tbody>
<?php foreach ($option->notes as $note) : ?>
<tr>
<td>
<?php endforeach; ?>
<?php if (empty($option->notes)) : ?>
<tr><td colspan="1" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</div>
<div class="portlet-foot">
<a class="button edit" href="<?= UriFactory::build('{/base}/finance/investment/object?id=' . $option->id); ?>"><?= $this->getHtml('Edit', '0', '0'); ?></a>
</div>
</section>
</div> </div>
</div> </div>
<div class="tabview tab-2">
<?php if (!$isNew) : ?>
<div class="box">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('Option'); ?></label>
<li><label for="c-tab-2"><?= $this->getHtml('Attributes'); ?></label>
<!-- @tood implement
<li><label for="c-tab-3"><?= $this->getHtml('Amounts'); ?></label>
-->
<li><label for="c-tab-4"><?= $this->getHtml('Notes'); ?></label>
<li><label for="c-tab-5"><?= $this->getHtml('Files'); ?></label>
</ul>
</div>
<?php endif; ?>
<div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-2"<?= $isNew || $this->request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="portlet">
<form id="fOption" method="<?= $isNew ? 'PUT' : 'POST'; ?>" action="<?= \phpOMS\Uri\UriFactory::build('{/api}finance/investment/option?{?}&csrf={$CSRF}'); ?>">
<div class="portlet-head"><?= $this->getHtml('Option'); ?></div>
<div class="portlet-body">
<div class="form-group">
<label for="iId"><?= $this->getHtml('ID', '0', '0'); ?></label>
<input type="text" name="id" id="iId" value="<?= $option->id; ?>" disabled>
</div>
<div class="form-group">
<label for="iObjectName"><?= $this->getHtml('Name'); ?></label>
<input type="text" id="iObjectName" name="name" value="<?= $this->printHtml($option->name); ?>">
</div>
<div class="form-group">
<label for="iObjectDescription"><?= $this->getHtml('Description'); ?></label>
<textarea id="iObjectDescription" name="description"><?= $this->printHtml($option->description); ?></textarea>
</div>
<div class="form-group">
<label for="iObjectLink"><?= $this->getHtml('Link'); ?></label>
<input type="text" id="iObjectLink" name="link" value="<?= $this->printHtml($option->link); ?>">
</div>
<div class="form-group">
<label for="iObjectSupplier"><?= $this->getHtml('Supplier'); ?></label>
<div class="flex-line wf-100">
<!-- @todo supplier id
<div>
<input type="text" id="iObjectSupplier" name="supplier" value="<?= $this->printHtml($option->supplier->account->name1); ?>">
</div>
-->
<div>
<input type="text" id="iObjectSupplier" name="suppliername" value="<?= $this->printHtml($option->supplierName); ?>">
</div>
</div>
</div>
<div class="form-group">
<label for="iObjectPrice"><?= $this->getHtml('Price'); ?></label>
<input type="number" step="any" id="iObjectPrice" name="amount" value="">
</div>
<?php if (!$isNew) : ?>
<div class="form-group">
<span class="checkbox">
<label class="checkbox" for="iApproved">
<input id="iApproved" type="checkbox" name="approved" value="1">
<span class="checkmark"></span>
<?= $this->getHtml('Approved'); ?>
</label>
</span>
</div>
<?php endif; ?>
</div>
<div class="portlet-foot">
<?php if ($isNew) : ?>
<input id="iCreateSubmit" type="Submit" value="<?= $this->getHtml('Create', '0', '0'); ?>">
<?php else : ?>
<input id="iSaveSubmit" type="Submit" value="<?= $this->getHtml('Save', '0', '0'); ?>">
<?php endif; ?>
</div>
</form>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-2" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<?= $this->data['attributeView']->render(
$option->attributes,
$this->data['attributeTypes'] ?? [],
$this->data['units'] ?? [],
'{/api}finance/investment/option/attribute?csrf={$CSRF}',
$option->id
);
?>
</div>
</div>
<!--
<input type="radio" id="c-tab-3" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-3' ? ' checked' : ''; ?>>
<div class="tab">
</div>
-->
<input type="radio" id="c-tab-4" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-4' ? ' checked' : ''; ?>>
<div class="tab col-simple">
<?= $this->data['note']->render('option-note', 'notes', $option->notes); ?>
</div>
<input type="radio" id="c-tab-5" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-5' ? ' checked' : ''; ?>>
<div class="tab col-simple">
<?= $this->data['media-upload']->render('option-file', 'files', '', $option->files); ?>
</div>
</div>
</div>

View File

@ -13,30 +13,37 @@
declare(strict_types=1); declare(strict_types=1);
use Modules\InvestmentManagement\Models\InvestmentStatus; use Modules\InvestmentManagement\Models\InvestmentStatus;
use Modules\InvestmentManagement\Models\NullInvestment;
use phpOMS\Uri\UriFactory; use phpOMS\Uri\UriFactory;
/** @var \phpOMS\Views\View $this */ /** @var \phpOMS\Views\View $this */
$investment = $this->data['investment'] ?? null; $investment = $this->data['investment'] ?? new NullInvestment();
$investmentStatus = InvestmentStatus::getConstants(); $investmentStatus = InvestmentStatus::getConstants();
$files = $investment->files; $files = $investment->files;
$investmentTypes = $this->data['types'] ?? []; $investmentTypes = $this->data['types'] ?? [];
$isNew = $investment->id === 0;
echo $this->data['nav']->render(); ?> echo $this->data['nav']->render(); ?>
<div class="tabview tab-2"> <div class="tabview tab-2">
<?php if (!$isNew) : ?>
<div class="box"> <div class="box">
<ul class="tab-links"> <ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('Investment'); ?></label> <li><label for="c-tab-1"><?= $this->getHtml('Investment'); ?></label>
<li><label for="c-tab-2"><?= $this->getHtml('Files'); ?></label> <li><label for="c-tab-2"><?= $this->getHtml('Files'); ?></label>
<li><label for="c-tab-3"><?= $this->getHtml('Notes'); ?></label> <li><label for="c-tab-3"><?= $this->getHtml('Notes'); ?></label>
<li><label for="c-tab-4"><?= $this->getHtml('Options'); ?></label> <li><label for="c-tab-4"><?= $this->getHtml('Options'); ?></label>
</ul> </ul>
</div> </div>
<?php endif; ?>
<div class="tab-content"> <div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>> <input type="radio" id="c-tab-1" name="tabular-2"<?= $isNew || $this->request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
<div class="tab"> <div class="tab">
<div class="row"> <div class="row">
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-6">
<section class="portlet"> <section class="portlet">
<form id="fInvestment" method="<?= $isNew ? 'PUT' : 'POST'; ?>" action="<?= \phpOMS\Uri\UriFactory::build('{/api}finance/investment?{?}&csrf={$CSRF}'); ?>">
<div class="portlet-head"><?= $this->getHtml('Investment'); ?></div> <div class="portlet-head"><?= $this->getHtml('Investment'); ?></div>
<div class="portlet-body"> <div class="portlet-body">
<div class="form-group"> <div class="form-group">
@ -79,9 +86,11 @@ echo $this->data['nav']->render(); ?>
<input id="iSaveSubmit" type="Submit" value="<?= $this->getHtml('Save', '0', '0'); ?>"> <input id="iSaveSubmit" type="Submit" value="<?= $this->getHtml('Save', '0', '0'); ?>">
<?php endif; ?> <?php endif; ?>
</div> </div>
</form>
</section> </section>
</div> </div>
<?php if (!$isNew) : ?>
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-6">
<section class="portlet"> <section class="portlet">
<div class="portlet-head"> <div class="portlet-head">
@ -115,9 +124,11 @@ echo $this->data['nav']->render(); ?>
</div> </div>
</section> </section>
</div> </div>
<?php endif; ?>
</div> </div>
</div> </div>
<?php if (!$isNew) : ?>
<input type="radio" id="c-tab-2" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>> <input type="radio" id="c-tab-2" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
<div class="tab col-simple"> <div class="tab col-simple">
<?= $this->data['media-upload']->render('investment-file', 'files', '', $investment->files); ?> <?= $this->data['media-upload']->render('investment-file', 'files', '', $investment->files); ?>
@ -245,6 +256,6 @@ echo $this->data['nav']->render(); ?>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
</div> </div>
<?php endif; ?>
</div> </div>
</div> </div>