todo implementations

This commit is contained in:
Dennis Eichhorn 2021-11-20 17:10:09 +01:00
parent a710da7d2a
commit 747f34fd03
10 changed files with 158 additions and 6 deletions

View File

@ -1,6 +0,0 @@
[Dolphin]
Timestamp=2021,5,23,18,50,7
Version=4
[Settings]
HiddenFilesShown=true

View File

@ -0,0 +1,25 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ContractManagement\Admin
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
use Modules\ContractManagement\Controller\ApiController;
use Modules\ContractManagement\Models\SettingsEnum;
return [
[
'type' => 'setting',
'name' => SettingsEnum::CONTRACT_RENEWAL_WARNING,
'content' => '7776000',
'module' => ApiController::NAME,
]
];

View File

@ -0,0 +1,16 @@
[
{
"type": "type",
"name": "contract",
"l11n": [
{
"title": "Contract",
"lang": "en"
},
{
"title": "Vertrag",
"lang": "de"
}
]
}
]

43
Admin/Install/Media.php Normal file
View File

@ -0,0 +1,43 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ContractManagement\Admin\Install
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\ContractManagement\Admin\Install;
use phpOMS\Application\ApplicationAbstract;
/**
* Media class.
*
* @package Modules\ContractManagement\Admin\Install
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class Media
{
/**
* Install media providing
*
* @param string $path Module path
* @param ApplicationAbstract $app Application
*
* @return void
*
* @since 1.0.0
*/
public static function install(string $path, ApplicationAbstract $app) : void
{
\Modules\Media\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Media.install.json']);
}
}

View File

@ -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",

View File

@ -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'));

View File

@ -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.
*

View File

@ -1,4 +1,5 @@
<?php
/**
* Orange Management
*
@ -10,6 +11,7 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\ContractManagement\Models;
@ -40,11 +42,14 @@ final class ContractMapper extends DataMapperAbstract
'contractmgmt_contract_description' => ['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',
],
];
/**

30
Models/SettingsEnum.php Normal file
View File

@ -0,0 +1,30 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ContractManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\ContractManagement\Models;
use phpOMS\Stdlib\Base\Enum;
/**
* Module settings enum.
*
* @package Modules\ContractManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
abstract class SettingsEnum extends Enum
{
public const CONTRACT_RENEWAL_WARNING = '1007900001';
}

View File

@ -25,6 +25,8 @@
},
"providing": {
"Navigation": "*",
"Admin": "*",
"Media": "*",
"Search": "*"
},
"load": [