diff --git a/.directory b/.directory deleted file mode 100755 index 12730b6..0000000 --- a/.directory +++ /dev/null @@ -1,6 +0,0 @@ -[Dolphin] -Timestamp=2021,5,23,18,50,7 -Version=4 - -[Settings] -HiddenFilesShown=true diff --git a/Admin/Install/Admin.install.php b/Admin/Install/Admin.install.php new file mode 100644 index 0000000..bbddc43 --- /dev/null +++ b/Admin/Install/Admin.install.php @@ -0,0 +1,25 @@ + 'setting', + 'name' => SettingsEnum::CONTRACT_RENEWAL_WARNING, + 'content' => '7776000', + 'module' => ApiController::NAME, + ] +]; diff --git a/Admin/Install/Media.install.json b/Admin/Install/Media.install.json new file mode 100644 index 0000000..ab03a33 --- /dev/null +++ b/Admin/Install/Media.install.json @@ -0,0 +1,16 @@ +[ + { + "type": "type", + "name": "contract", + "l11n": [ + { + "title": "Contract", + "lang": "en" + }, + { + "title": "Vertrag", + "lang": "de" + } + ] + } +] \ No newline at end of file diff --git a/Admin/Install/Media.php b/Admin/Install/Media.php new file mode 100644 index 0000000..d086eab --- /dev/null +++ b/Admin/Install/Media.php @@ -0,0 +1,43 @@ + __DIR__ . '/Media.install.json']); + } +} diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 526b00c..0028a7c 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -86,6 +86,16 @@ "null": true, "default": null }, + "contractmgmt_contract_renewal": { + "name": "contractmgmt_contract_renewal", + "type": "INT", + "null": false + }, + "contractmgmt_contract_autorenewal": { + "name": "contractmgmt_contract_autorenewal", + "type": "INT", + "null": false + }, "contractmgmt_contract_duration": { "name": "contractmgmt_contract_duration", "type": "INT", @@ -103,6 +113,14 @@ "foreignTable": "contractmgmt_type", "foreignKey": "contractmgmt_type_id" }, + "contractmgmt_contract_unit": { + "name": "contractmgmt_contract_unit", + "type": "INT", + "null": true, + "default": null, + "foreignTable": "organization_unit", + "foreignKey": "organization_unit_id" + }, "contractmgmt_contract_responsible": { "name": "contractmgmt_contract_responsible", "type": "INT", diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 6fe1c12..37a88ec 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -107,6 +107,9 @@ final class ApiController extends Controller $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') ?? 0)); + $contract->renewal = (int) ($request->getData('renewal') ?? 0); + $contract->autoRenewal = (bool) ($request->getData('autorenewal') ?? false); + $contract->unit = $request->getData('unit', 'int') ?? null; if (!empty($request->getData('end'))) { $contract->end = new \DateTime($request->getData('end')); diff --git a/Models/Contract.php b/Models/Contract.php index 615542b..7329763 100755 --- a/Models/Contract.php +++ b/Models/Contract.php @@ -17,6 +17,7 @@ namespace Modules\ContractManagement\Models; use Modules\Admin\Models\Account; use Modules\Admin\Models\NullAccount; use Modules\Media\Models\Media; +use Modules\Organization\Models\Unit; use phpOMS\Localization\Money; /** @@ -53,6 +54,15 @@ class Contract public ?\DateTime $end = null; + /** + * Months until end of contract + * + * The renewal sometimes can be done up until the end of the contract and sometimes x-months prior to the contract end. + */ + public int $renewal = 0; + + public bool $autoRenewal = false; + public int $duration = 0; public int $warning = 0; @@ -73,6 +83,8 @@ class Contract public ContractType $type; + public ?Unit $unit = null; + /** * Constructor. * diff --git a/Models/ContractMapper.php b/Models/ContractMapper.php index 345379e..ada2412 100755 --- a/Models/ContractMapper.php +++ b/Models/ContractMapper.php @@ -1,4 +1,5 @@ ['name' => 'contractmgmt_contract_description', 'type' => 'string', 'internal' => 'description'], 'contractmgmt_contract_account' => ['name' => 'contractmgmt_contract_account', 'type' => 'int', 'internal' => 'account'], 'contractmgmt_contract_costs' => ['name' => 'contractmgmt_contract_costs', 'type' => 'Serializable', 'internal' => 'costs'], + 'contractmgmt_contract_renewal' => ['name' => 'contractmgmt_contract_renewal', 'type' => 'int', 'internal' => 'renewal'], + 'contractmgmt_contract_autorenewal' => ['name' => 'contractmgmt_contract_autorenewal', 'type' => 'int', 'internal' => 'autoRenewal'], 'contractmgmt_contract_duration' => ['name' => 'contractmgmt_contract_duration', 'type' => 'int', 'internal' => 'duration'], 'contractmgmt_contract_warning' => ['name' => 'contractmgmt_contract_warning', 'type' => 'int', 'internal' => 'warning'], 'contractmgmt_contract_start' => ['name' => 'contractmgmt_contract_start', 'type' => 'DateTime', 'internal' => 'start'], 'contractmgmt_contract_end' => ['name' => 'contractmgmt_contract_end', 'type' => 'DateTime', 'internal' => 'end'], 'contractmgmt_contract_responsible' => ['name' => 'contractmgmt_contract_responsible', 'type' => 'int', 'internal' => 'responsible'], + 'contractmgmt_contract_unit' => ['name' => 'contractmgmt_contract_unit', 'type' => 'int', 'internal' => 'unit'], 'contractmgmt_contract_type' => ['name' => 'contractmgmt_contract_type', 'type' => 'int', 'internal' => 'type'], 'contractmgmt_contract_created_at' => ['name' => 'contractmgmt_contract_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt'], ]; @@ -88,6 +93,10 @@ final class ContractMapper extends DataMapperAbstract 'mapper' => AccountMapper::class, 'external' => 'contractmgmt_contract_account', ], + 'unit' => [ + 'mapper' => UnitMapper::class, + 'external' => 'contractmgmt_contract_unit', + ], ]; /** diff --git a/Models/SettingsEnum.php b/Models/SettingsEnum.php new file mode 100644 index 0000000..51032ae --- /dev/null +++ b/Models/SettingsEnum.php @@ -0,0 +1,30 @@ +