add account reference in order to assign a contract to an account

This commit is contained in:
Dennis Eichhorn 2021-08-17 13:40:08 +02:00
parent 24c9ae4bcc
commit eb184b72de
5 changed files with 36 additions and 4 deletions

View File

@ -67,6 +67,13 @@
"type": "TEXT",
"null": false
},
"contractmgmt_contract_account": {
"name": "contractmgmt_contract_account",
"type": "INT",
"null": true,
"foreignTable": "account",
"foreignKey": "account_id"
},
"contractmgmt_contract_start": {
"name": "contractmgmt_contract_start",
"type": "DATETIME",

View File

@ -108,6 +108,7 @@ final class ApiController extends Controller
$contract->description = (string) ($request->getData('description') ?? '');
$contract->type = new NullContractType((int) ($request->getData('type') ?? 0));
$contract->start = new \DateTime($request->getData('start') ?? 'now');
$contract->account = new NullAccount((int) $request->getData('account'));
if (!empty($request->getData('end'))) {
$contract->end = new \DateTime($request->getData('end'));

View File

@ -16,6 +16,8 @@ namespace Modules\ContractManagement\Models;
use Modules\Media\Models\Media;
use Modules\Media\Models\NullMedia;
use Modules\Admin\Models\Account;
use Modules\Admin\Models\NullAccount;
use phpOMS\Localization\Money;
/**
@ -58,6 +60,8 @@ class Contract
public ?int $responsible = null;
public Account $account;
/**
* Created at.
*
@ -78,6 +82,7 @@ class Contract
public function __construct()
{
$this->createdAt = new \DateTimeImmutable('now');
$this->account = new NullAccount();
}
/**

View File

@ -16,6 +16,7 @@ namespace Modules\ContractManagement\Models;
use Modules\Editor\Models\EditorDocMapper;
use Modules\Media\Models\MediaMapper;
use Modules\Admin\Models\AccountMapper;
use phpOMS\DataStorage\Database\DataMapperAbstract;
/**
@ -38,6 +39,7 @@ final class ContractMapper extends DataMapperAbstract
'contractmgmt_contract_id' => ['name' => 'contractmgmt_contract_id', 'type' => 'int', 'internal' => 'id'],
'contractmgmt_contract_title' => ['name' => 'contractmgmt_contract_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
'contractmgmt_contract_description' => ['name' => 'contractmgmt_contract_description', 'type' => 'string', 'internal' => 'description'],
'contractmgmt_contract_accouunt' => ['name' => 'contractmgmt_contract_accouunt', 'type' => 'int', 'internal' => 'accouunt'],
'contractmgmt_contract_costs' => ['name' => 'contractmgmt_contract_costs', 'type' => 'Serializable', 'internal' => 'costs'],
'contractmgmt_contract_duration' => ['name' => 'contractmgmt_contract_duration', 'type' => 'int', 'internal' => 'duration'],
'contractmgmt_contract_warning' => ['name' => 'contractmgmt_contract_warning', 'type' => 'int', 'internal' => 'warning'],
@ -83,6 +85,10 @@ final class ContractMapper extends DataMapperAbstract
'mapper' => ContractTypeMapper::class,
'external' => 'contractmgmt_contract_type',
],
'account' => [
'mapper' => AccountMapper::class,
'external' => 'contractmgmt_contract_account',
],
];
/**

View File

@ -36,6 +36,18 @@ echo $this->getData('nav')->render(); ?>
<thead>
<tr>
<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 fa fa-chevron-up"></i>
</label>
<label for="contractList-sort-2">
<input type="radio" name="contractList-sort" id="contractList-sort-2">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td class="wf-100"><?= $this->getHtml('Account'); ?>
<label for="contractList-sort-3">
<input type="radio" name="contractList-sort" id="contractList-sort-3">
<i class="sort-asc fa fa-chevron-up"></i>
@ -48,12 +60,12 @@ echo $this->getData('nav')->render(); ?>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('End'); ?>
<label for="contractList-sort-3">
<input type="radio" name="contractList-sort" id="contractList-sort-3">
<label for="contractList-sort-5">
<input type="radio" name="contractList-sort" id="contractList-sort-5">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="contractList-sort-4">
<input type="radio" name="contractList-sort" id="contractList-sort-4">
<label for="contractList-sort-6">
<input type="radio" name="contractList-sort" id="contractList-sort-6">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
@ -76,6 +88,7 @@ echo $this->getData('nav')->render(); ?>
?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('Title'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->title); ?></a>
<td class="content" data-label="<?= $this->getHtml('Account'); ?>"><a href="<?= UriFactory::build('{/prefix}profile/single?{?}&for=' . $value->account->getId()); ?>"><?= $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; ?>
</table>