diff --git a/Admin/Install/db.json b/Admin/Install/db.json index b539b7e..969bfb0 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -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", diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 5d1434a..2fb0298 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -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')); diff --git a/Models/Contract.php b/Models/Contract.php index f334b7a..4168f1a 100755 --- a/Models/Contract.php +++ b/Models/Contract.php @@ -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(); } /** diff --git a/Models/ContractMapper.php b/Models/ContractMapper.php index 653ae15..86cdf5e 100755 --- a/Models/ContractMapper.php +++ b/Models/ContractMapper.php @@ -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', + ], ]; /** diff --git a/Theme/Backend/contract-list.tpl.php b/Theme/Backend/contract-list.tpl.php index 50eec30..5332b60 100755 --- a/Theme/Backend/contract-list.tpl.php +++ b/Theme/Backend/contract-list.tpl.php @@ -36,6 +36,18 @@ echo $this->getData('nav')->render(); ?> getHtml('Title'); ?> + + + + getHtml('Account'); ?> getHtml('End'); ?> -