This commit is contained in:
Dennis Eichhorn 2024-02-04 20:34:11 +00:00
parent e4ae941cea
commit 863e5cacf6
5 changed files with 103 additions and 11 deletions

View File

@ -44,7 +44,7 @@
"children": []
},
{
"id": 1007903001,
"id": 1007904001,
"pid": "/contract",
"type": 3,
"subtype": 1,

View File

@ -124,6 +124,7 @@ final class ApiController extends Controller
$contract->isTemplate = $request->getDataBool('template') ?? false;
$contract->unit = new NullUnit($request->getDataInt('unit') ?? 0);
$contract->end = $request->getDataDateTime('end');
$contract->parent = $request->getDataInt('parent');
return $contract;
}
@ -159,7 +160,7 @@ final class ApiController extends Controller
$path = $this->createContractDir($contract);
$uploaded = $this->app->moduleManager->get('Media')->uploadFiles(
$uploaded = $this->app->moduleManager->get('Media', 'Api')->uploadFiles(
names: $request->getDataList('names'),
fileNames: $request->getDataList('filenames'),
files: $uploadedFiles,
@ -313,8 +314,6 @@ final class ApiController extends Controller
*
* @return array<string, bool>
*
* @todo Implement API validation function
*
* @since 1.0.0
*/
private function validateContractDelete(RequestAbstract $request) : array

View File

@ -19,6 +19,7 @@ use Modules\ContractManagement\Models\ContractMapper;
use Modules\ContractManagement\Models\ContractTypeMapper;
use Modules\Organization\Models\UnitMapper;
use phpOMS\Contract\RenderableInterface;
use phpOMS\DataStorage\Database\Query\OrderType;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Views\View;
@ -164,10 +165,16 @@ final class BackendController extends Controller
->with('notes')
->where('id', (int) $request->getData('id'))
->where('attributes/type/l11n/language', $response->header->l11n->language)
->sort('files/id', 'DESC')
->sort('files/id', OrderType::DESC)
->execute();
$view->data['contractTypes'] = ContractTypeMapper::getAll()
$view->data['children'] = ContractMapper::getAll()
->with('account')
->where('parent', (int) $request->getData('id'))
->sort('createdAt', OrderType::DESC)
->execute();
$view->data['contractTypes'] = ContractTypeMapper::getAll()
->with('l11n')
->where('l11n/language', $response->header->l11n->language)
->execute();

View File

@ -47,7 +47,7 @@ echo $this->data['nav']->render(); ?>
<label>
<i class="filter g-icon">filter_alt</i>
</label>
<td class="wf-100"><?= $this->getHtml('With'); ?>
<td><?= $this->getHtml('With'); ?>
<label for="contractList-sort-3">
<input type="radio" name="contractList-sort" id="contractList-sort-3">
<i class="sort-asc g-icon">expand_less</i>
@ -72,7 +72,10 @@ echo $this->data['nav']->render(); ?>
<i class="filter g-icon">filter_alt</i>
</label>
<tbody>
<?php foreach ($contracts as $key => $value) :
<?php
$count = 0;
foreach ($contracts as $key => $value) :
++$count;
$url = UriFactory::build('{/base}/contract/view?{?}&id=' . $value->id);
$type = 'ok';
@ -91,6 +94,9 @@ echo $this->data['nav']->render(); ?>
<td data-label="<?= $this->getHtml('Account'); ?>"><a class="content" href="<?= UriFactory::build('{/base}/profile/view?{?}&for=' . $value->account->id); ?>"><?= $this->printHtml($value->account->name1); ?> <?= $this->printHtml($value->account->name2); ?></a>
<td data-label="<?= $this->getHtml('End'); ?>"><a href="<?= $url; ?>"><span class="tag <?= $type; ?>"><?= $value->end !== null ? $value->end->format('Y-m-d') : ''; ?></span></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
<div class="portlet-foot">

View File

@ -12,6 +12,8 @@
*/
declare(strict_types=1);
use phpOMS\Uri\UriFactory;
/**
* @var \phpOMS\Views\View $this
* @var \Modules\ContractManagement\Models\Contract $contract
@ -27,9 +29,7 @@ echo $this->data['nav']->render(); ?>
<li><label for="c-tab-2"><?= $this->getHtml('Files'); ?></label>
<li><label for="c-tab-3"><?= $this->getHtml('Notes', 'Editor', 'Backend'); ?></label>
<li><label for="c-tab-4"><?= $this->getHtml('Attributes', 'Attribute', 'Backend'); ?></label>
<!-- if parrent contract show all parties that use this template/parent contract (e.g. show all customers who have this contract)
<li><label for="c-tab-4"><?= $this->getHtml('Parties'); ?></label>
-->
<li><label for="c-tab-5"><?= $this->getHtml('Parties'); ?></label>
</ul>
</div>
<div class="tab-content">
@ -137,5 +137,85 @@ echo $this->data['nav']->render(); ?>
?>
</div>
</div>
<input type="radio" id="c-tab-5" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-5' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Contracts'); ?><i class="g-icon download btn end-xs">download</i></div>
<div class="slider">
<table id="contractList" class="default sticky">
<thead>
<tr>
<td><?= $this->getHtml('End'); ?>
<label for="contractList-sort-5">
<input type="radio" name="contractList-sort" id="contractList-sort-5">
<i class="sort-asc g-icon">expand_less</i>
</label>
<label for="contractList-sort-6">
<input type="radio" name="contractList-sort" id="contractList-sort-6">
<i class="sort-desc g-icon">expand_more</i>
</label>
<label>
<i class="filter g-icon">filter_alt</i>
</label>
<td><?= $this->getHtml('With'); ?>
<label for="contractList-sort-3">
<input type="radio" name="contractList-sort" id="contractList-sort-3">
<i class="sort-asc g-icon">expand_less</i>
</label>
<label for="contractList-sort-4">
<input type="radio" name="contractList-sort" id="contractList-sort-4">
<i class="sort-desc g-icon">expand_more</i>
</label>
<label>
<i class="filter g-icon">filter_alt</i>
</label>
<td class="wf-100"><?= $this->getHtml('Title'); ?>
<label for="contractList-sort-1">
<input type="radio" name="contractList-sort" id="contractList-sort-1">
<i class="sort-asc g-icon">expand_less</i>
</label>
<label for="contractList-sort-2">
<input type="radio" name="contractList-sort" id="contractList-sort-2">
<i class="sort-desc g-icon">expand_more</i>
</label>
<label>
<i class="filter g-icon">filter_alt</i>
</label>
<tbody>
<?php
$count = 0;
$now = new \DateTime('now');
foreach ($this->data['children'] as $key => $value) :
++$count;
$url = UriFactory::build('{/base}/contract/view?{?}&id=' . $value->id);
$type = 'ok';
if (($value->end->getTimestamp() < $now->getTimestamp() && $value->end->getTimestamp() + 7776000 > $now->getTimestamp())
|| ($value->end->getTimestamp() > $now->getTimestamp() && $value->end->getTimestamp() - 7776000 < $now->getTimestamp())
) {
$type = 'error';
} elseif ($value->end->getTimestamp() < $now->getTimestamp()) {
$type = 'info';
} elseif ($value->end->getTimestamp() + 7776000 < $now->getTimestamp()) {
$type = 'warning';
}
?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('End'); ?>"><a href="<?= $url; ?>"><span class="tag <?= $type; ?>"><?= $value->end !== null ? $value->end->format('Y-m-d') : ''; ?></span></a>
<td data-label="<?= $this->getHtml('Account'); ?>"><a class="content" href="<?= UriFactory::build('{/base}/profile/view?{?}&for=' . $value->account->id); ?>"><?= $this->printHtml($value->account->name1); ?> <?= $this->printHtml($value->account->name2); ?></a>
<td data-label="<?= $this->getHtml('Title'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->title); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>