create draft

This commit is contained in:
Dennis Eichhorn 2021-06-24 00:04:58 +02:00
parent 4b2a771ddd
commit 8b33381d0c
16 changed files with 1282 additions and 0 deletions

View File

@ -15,6 +15,10 @@ declare(strict_types=1);
namespace Modules\ContractManagement\Controller;
use Modules\Admin\Models\NullAccount;
use Modules\ContractManagement\Models\ContractType;
use Modules\ContractManagement\Models\ContractTypeMapper;
use Modules\ContractManagement\Models\ContractTypeL11n;
use Modules\ContractManagement\Models\ContractTypeL11nMapper;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Message\NotificationLevel;
@ -22,6 +26,11 @@ use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Model\Message\FormValidation;
use phpOMS\Utils\Parser\Markdown\Markdown;
use phpOMS\Message\Http\HttpRequest;
use Modules\Media\Models\PathSettings;
use Modules\ContractManagement\Models\Contract;
use Modules\ContractManagement\Models\NullContractType;
use Modules\ContractManagement\Models\ContractMapper;
/**
* Api controller for the contracts module.
@ -33,4 +42,256 @@ use phpOMS\Utils\Parser\Markdown\Markdown;
*/
final class ApiController extends Controller
{
/**
* Api method to create a contract
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiContractCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
if (!empty($val = $this->validateContractCreate($request))) {
$response->set('contract_create', new FormValidation($val));
$response->header->status = RequestStatusCode::R_400;
return;
}
$contract = $this->createContractFromRequest($request);
$this->createModel($request->header->account, $contract, ContractMapper::class, 'contract', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Contract', 'Contract successfully created', $contract);
}
/**
* Validate contract create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateContractCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['title'] = empty($request->getData('title')))
|| ($val['start'] = empty($request->getData('start')))
|| ($val['duration'] = empty($request->getData('duration')))
|| ($val['type'] = empty($request->getData('type')))
) {
return $val;
}
return [];
}
/**
* Method to create item l11n from request.
*
* @param RequestAbstract $request Request
*
* @return Contract
*
* @since 1.0.0
*/
private function createContractFromRequest(RequestAbstract $request) : Contract
{
$contract = new Contract();
$contract->title = (string) ($request->getData('title') ?? '');
$contract->description = (string) ($request->getData('description') ?? '');
$contract->type = new NullContractType((int) ($request->getData('type') ?? 0));
$contract->start = new \DateTime($request->getData('start') ?? 'now');
if (!empty($request->getData('end'))) {
$contract->end = new \DateTime($request->getData('end'));
}
return $contract;
}
/**
* Api method to create a contract document
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiContractDocumentCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
$uploadedFiles = $request->getFiles() ?? [];
if (empty($uploadedFiles)) {
$this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Contract', 'Invalid contract image', $uploadedFiles);
$response->header->status = RequestStatusCode::R_400;
return;
}
$uploaded = $this->app->moduleManager->get('Media')->uploadFiles(
$request->getData('name') ?? '',
$uploadedFiles,
$request->header->account,
__DIR__ . '/../../../Modules/Media/Files/Modules/ContractManagement/Contracts/' . ($request->getData('contract_title') ?? '0'),
'/Modules/ContractManagement/Contracts/' . ($request->getData('contract_title') ?? '0'),
$request->getData('type') ?? '',
'',
'',
PathSettings::FILE_PATH
);
$this->createModelRelation(
$request->header->account,
(int) $request->getData('contract'),
\reset($uploaded)->getId(),
ContractMapper::class, 'files', '', $request->getOrigin()
);
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Image', 'Image successfully updated', $uploaded);
}
/**
* Api method to create item attribute type
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiContractTypeCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
if (!empty($val = $this->validateContractTypeCreate($request))) {
$response->set('contract_type_create', new FormValidation($val));
$response->header->status = RequestStatusCode::R_400;
return;
}
$contractType = $this->createContractTypeFromRequest($request);
$contractType->setL11n($request->getData('title'), $request->getData('language'));
$this->createModel($request->header->account, $contractType, ContractTypeMapper::class, 'contract_type', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Contract type', 'Contract type successfully created', $contractType);
}
/**
* Method to create item attribute from request.
*
* @param RequestAbstract $request Request
*
* @return ContractType
*
* @since 1.0.0
*/
private function createContractTypeFromRequest(RequestAbstract $request) : ContractType
{
$contractType = new ContractType();
$contractType->name = (string) ($request->getData('name') ?? '');
return $contractType;
}
/**
* Validate item attribute create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateContractTypeCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['name'] = empty($request->getData('name')))
|| ($val['title'] = empty($request->getData('title')))
) {
return $val;
}
return [];
}
/**
* Api method to create item l11n type
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiContractTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
if (!empty($val = $this->validateContractTypeL11nCreate($request))) {
$response->set('contract_type_create', new FormValidation($val));
$response->header->status = RequestStatusCode::R_400;
return;
}
$itemL11nType = $this->createContractTypeL11nFromRequest($request);
$this->createModel($request->header->account, $itemL11nType, ContractTypeL11nMapper::class, 'contract_type', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Contract type', 'Contract localization type successfully created', $itemL11nType);
}
/**
* Method to create item l11n type from request.
*
* @param RequestAbstract $request Request
*
* @return ContractTypeL11n
*
* @since 1.0.0
*/
private function createContractTypeL11nFromRequest(RequestAbstract $request) : ContractTypeL11n
{
$typeL11n = new ContractTypeL11n(
(int) ($request->getData('type') ?? 0),
(string) ($request->getData('title') ?? ''),
$request->getData('language') ?? $request->getLanguage()
);
return $typeL11n;
}
/**
* Validate item l11n type create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateContractTypeL11nCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['title'] = empty($request->getData('title')))) {
return $val;
}
return [];
}
}

View File

@ -22,6 +22,7 @@ use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Views\View;
use Modules\ContractManagement\Models\ContractMapper;
/**
* Backend controller for the contracts module.
@ -35,4 +36,69 @@ use phpOMS\Views\View;
*/
final class BackendController extends Controller
{
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewContractList(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/ContractManagement/Theme/Backend/contract-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1007901001, $request, $response));
if ($request->getData('ptype') === 'p') {
$view->setData('contracts',
ContractMapper::with('language', $response->getLanguage())
::getBeforePivot((int) ($request->getData('id') ?? 0), null, 25)
);
} elseif ($request->getData('ptype') === 'n') {
$view->setData('contracts',
ContractMapper::with('language', $response->getLanguage())
::getAfterPivot((int) ($request->getData('id') ?? 0), null, 25)
);
} else {
$view->setData('contracts',
ContractMapper::with('language', $response->getLanguage())
::getAfterPivot(0, null, 25)
);
}
return $view;
}
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewContract(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/ContractManagement/Theme/Backend/contract-single');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1007901001, $request, $response));
$view->addData('contract', ContractMapper::get((int) $request->getData('id')));
$editor = new \Modules\Editor\Theme\Backend\Components\Editor\BaseView($this->app->l11nManager, $request, $response);
$view->addData('editor', $editor);
return $view;
}
}

136
Models/Contract.php Normal file
View File

@ -0,0 +1,136 @@
<?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 Modules\Media\Models\Media;
use Modules\Media\Models\NullMedia;
use phpOMS\Localization\Money;
/**
* Account class.
*
* @package Modules\ContractManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class Contract
{
/**
* ID.
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
/**
* Files.
*
* @var Media[]
* @since 1.0.0
*/
private array $files = [];
public string $title = '';
public string $description = '';
public \DateTime $start;
public ?\DateTime $end = null;
public int $duration = 0;
public int $warning = 0;
public ?int $responsible = null;
/**
* Created at.
*
* @var \DateTimeImmutable
* @since 1.0.0
*/
public \DateTimeImmutable $createdAt;
public ?Money $costs = null;
public ContractType $type;
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct()
{
$this->createdAt = new \DateTimeImmutable('now');
}
/**
* Get id
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Get files
*
* @return Media[]
*
* @since 1.0.0
*/
public function getFiles() : array
{
return $this->files;
}
/**
* Add media to item
*
* @param Media $media Media
*
* @return void
*
* @since 1.0.0
*/
public function addFile(Media $media) : void
{
$this->files[] = $media;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize()
{
return $this->toArray();
}
}

102
Models/ContractMapper.php Normal file
View File

@ -0,0 +1,102 @@
<?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 Modules\Editor\Models\EditorDocMapper;
use Modules\Media\Models\MediaMapper;
use phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Contract mapper class.
*
* @package Modules\ContractManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class ContractMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'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_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'],
'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_type' => ['name' => 'contractmgmt_contract_type', 'type' => 'int', 'internal' => 'type'],
'contractmgmt_contract_created_at' => ['name' => 'contractmgmt_contract_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt'],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'contractmgmt_contract';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'contractmgmt_contract_id';
/**
* Created at.
*
* @var string
* @since 1.0.0
*/
protected static string $createdAt = 'contractmgmt_contract_created_at';
/**
* Has one relation.
*
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
* @since 1.0.0
*/
protected static array $ownsOne = [
'type' => [
'mapper' => ContractTypeMapper::class,
'external' => 'contractmgmt_contract_type',
],
];
/**
* Has many relation.
*
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
protected static array $hasMany = [
'files' => [
'mapper' => MediaMapper::class, /* mapper of the related object */
'table' => 'contractmgmt_contract_media', /* table of the related object, null if no relation table is used (many->1) */
'external' => 'contractmgmt_contract_media_media',
'self' => 'contractmgmt_contract_media_contract',
],
];
}

129
Models/ContractType.php Normal file
View File

@ -0,0 +1,129 @@
<?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\Contract\ArrayableInterface;
use phpOMS\Localization\ISO639x1Enum;
/**
* Contract Type class.
*
* @package Modules\ContractManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class ContractType implements \JsonSerializable, ArrayableInterface
{
/**
* Id
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
/**
* Name/string identifier by which it can be found/categorized
*
* @var string
* @since 1.0.0
*/
public string $name = ''; // @todo: currently not filled, should be used as identifier or if not required removed (at the moment it seems like it is useless?!)
/**
* Localization
*
* @var ContractTypeL11n
*/
protected string |
ContractTypeL11n $l11n;
/**
* Constructor.
*
* @param string $name Name/identifier of the attribute type
*
* @since 1.0.0
*/
public function __construct(string $name = '')
{
if (!empty($name)) {
$this->setL11n($name);
}
}
/**
* Get id
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Set l11n
*
* @param string|ContractTypeL11n $l11n Tag article l11n
* @param string $lang Language
*
* @return void
*
* @since 1.0.0
*/
public function setL11n($l11n, string $lang = ISO639x1Enum::_EN) : void
{
if ($l11n instanceof ContractTypeL11n) {
$this->l11n = $l11n;
} elseif (\is_string($l11n)) {
$this->l11n = new ContractTypeL11n();
$this->l11n->title = $l11n;
$this->l11n->setLanguage($lang);
} elseif ($this->l11n instanceof ContractTypeL11n && \is_string($l11n)) {
$this->l11n->title = $l11n;
}
}
/**
* @return string
*
* @since 1.0.0
*/
public function getL11n() : string
{
return $this->l11n instanceof ContractTypeL11n ? $this->l11n->title : $this->l11n;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize()
{
return $this->toArray();
}
}

147
Models/ContractTypeL11n.php Normal file
View File

@ -0,0 +1,147 @@
<?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\Contract\ArrayableInterface;
use phpOMS\Localization\ISO639x1Enum;
/**
* Contract type l11n class.
*
* @package Modules\ContractManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class ContractTypeL11n implements \JsonSerializable, ArrayableInterface
{
/**
* ID.
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
/**
* Model ID.
*
* @var int|ContractType
* @since 1.0.0
*/
protected int |
ContractType $type = 0;
/**
* Language.
*
* @var string
* @since 1.0.0
*/
protected string $language = ISO639x1Enum::_EN;
/**
* Title.
*
* @var string
* @since 1.0.0
*/
public string $title = '';
/**
* Constructor.
*
* @param int|ContractType $type Attribute type
* @param string $title Localized title
* @param string $language Language
*
* @since 1.0.0
*/
public function __construct(int | ContractType $type = 0, string $title = '', string $language = ISO639x1Enum::_EN)
{
$this->type = $type;
$this->title = $title;
$this->language = $language;
}
/**
* Get id
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Get attribute type
*
* @return int|ContractType
*
* @since 1.0.0
*/
public function getType() : int | ContractType
{
return $this->type;
}
/**
* Set type.
*
* @param int $type Type id
*
* @return void
*
* @since 1.0.0
*/
public function setType(int $type) : void
{
$this->type = $type;
}
/**
* Set language
*
* @param string $language Language
*
* @return void
*
* @since 1.0.0
*/
public function setLanguage(string $language) : void
{
$this->language = $language;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize()
{
return $this->toArray();
}
}

View File

@ -0,0 +1,57 @@
<?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\DataStorage\Database\DataMapperAbstract;
/**
* Contract type l11n mapper class.
*
* @package Modules\ContractManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class ContractTypeL11nMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'contractmgmt_type_l11n_id' => ['name' => 'contractmgmt_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
'contractmgmt_type_l11n_title' => ['name' => 'contractmgmt_type_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
'contractmgmt_type_l11n_type' => ['name' => 'contractmgmt_type_l11n_type', 'type' => 'int', 'internal' => 'type'],
'contractmgmt_type_l11n_lang' => ['name' => 'contractmgmt_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'contractmgmt_type_l11n';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'contractmgmt_type_l11n_id';
}

View File

@ -0,0 +1,72 @@
<?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\DataStorage\Database\DataMapperAbstract;
/**
* Contract type mapper class.
*
* @package Modules\ContractManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class ContractTypeMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'contractmgmt_type_id' => ['name' => 'contractmgmt_type_id', 'type' => 'int', 'internal' => 'id'],
'contractmgmt_type_name' => ['name' => 'contractmgmt_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
];
/**
* Has many relation.
*
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
protected static array $hasMany = [
'l11n' => [
'mapper' => ContractTypeL11nMapper::class,
'table' => 'contractmgmt_type_l11n',
'self' => 'contractmgmt_type_l11n_type',
'column' => 'title',
'conditional' => true,
'external' => null,
]
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'contractmgmt_type';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'contractmgmt_type_id';
}

39
Models/NullContract.php Normal file
View File

@ -0,0 +1,39 @@
<?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;
/**
* Contract model.
*
* @package Modules\ContractManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class NullContract extends Contract
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
parent::__construct();
}
}

View File

@ -0,0 +1,39 @@
<?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;
/**
* Contract model.
*
* @package Modules\ContractManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class NullContractType extends ContractType
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
parent::__construct();
}
}

View File

@ -0,0 +1,39 @@
<?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;
/**
* Contract model.
*
* @package Modules\ContractManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class NullContractTypeL11n extends ContractTypeL11n
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
parent::__construct();
}
}

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;
/**
* Permision state enum.
*
* @package Modules\ContractManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
abstract class PermissionState extends Enum
{
public const CONTRACT = 1;
}

View File

@ -15,5 +15,6 @@ declare(strict_types=1);
return ['Navigation' => [
'Create' => 'Create',
'Contract' => 'Contract',
'Contracts' => 'Contracts',
'List' => 'List',
]];

View File

@ -0,0 +1,19 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Localization
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
return ['ContractManagement' => [
'Contract' => 'Contract',
'Contracts' => 'Contracts',
'Title' => 'Title',
]];

View File

@ -0,0 +1,99 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ContractManagement
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
use Modules\Media\Models\NullMedia;
use phpOMS\Uri\UriFactory;
/**
* @var \phpOMS\Views\View $this
* @var \Modules\ContractManagement\Models\Contract[] $contracts
*/
$contracts = $this->getData('contracts') ?? [];
$previous = empty($contracts) ? '{/prefix}contract/list' : '{/prefix}contract/list?{?}&id=' . \reset($contracts)->getId() . '&ptype=p';
$next = empty($contracts) ? '{/prefix}contract/list' : '{/prefix}contract/list?{?}&id=' . \end($contracts)->getId() . '&ptype=n';
$now = new \DateTime('now');
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Contracts'); ?><i class="fa fa-download floatRight download btn"></i></div>
<table id="contractList" class="default sticky">
<thead>
<tr>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<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('Title'); ?>
<label for="contractList-sort-3">
<input type="radio" name="contractList-sort" id="contractList-sort-3">
<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">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<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">
<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">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<tbody>
<?php foreach ($contracts as $key => $value) :
$url = UriFactory::build('{/prefix}contract/single?{?}&id=' . $value->getId());
$type = 'ok';
if ($value->end->getTimestamp() < $now->getTimestamp() && $value->end->getTimestamp() + 129600 > $now->getTimestamp()) {
$type = 'error';
} elseif ($value->end->getTimestamp() < $now->getTimestamp()) {
$type = 'info';
} elseif ($value->end->getTimestamp() + 129600 < $now->getTimestamp()) {
$type = 'warning';
}
?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $value->getId(); ?></a>
<td data-label="<?= $this->getHtml('Title'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->title); ?></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>
<div class="portlet-foot">
<a tabindex="0" class="button" href="<?= UriFactory::build($previous); ?>"><?= $this->getHtml('Previous', '0', '0'); ?></a>
<a tabindex="0" class="button" href="<?= UriFactory::build($next); ?>"><?= $this->getHtml('Next', '0', '0'); ?></a>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,46 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ContractManagement
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
use Modules\Media\Models\NullMedia;
use phpOMS\Uri\UriFactory;
/**
* @var \phpOMS\Views\View $this
* @var \Modules\ContractManagement\Models\Contract $contract
*/
$contract = $this->getData('contract');
echo $this->getData('nav')->render(); ?>
<div class="tabview tab-2">
<div class="box wf-100 col-xs-12">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('Overview'); ?></label></li>
<li><label for="c-tab-2"><?= $this->getHtml('Files'); ?></label></li>
</ul>
</div>
<div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
</div>
</div>
<input type="radio" id="c-tab-2" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
</div>
</div>
</div>
</div>