mirror of
https://github.com/Karaka-Management/oms-Support.git
synced 2026-01-11 17:18:40 +00:00
implement todos
This commit is contained in:
parent
394b6d326e
commit
993dfa9dc6
|
|
@ -32,6 +32,17 @@ use phpOMS\Message\RequestAbstract;
|
|||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Model\Message\FormValidation;
|
||||
use phpOMS\Utils\Parser\Markdown\Markdown;
|
||||
use Modules\Support\Models\AttributeValueType;
|
||||
use Modules\Support\Models\TicketAttribute;
|
||||
use Modules\Support\Models\TicketAttributeMapper;
|
||||
use Modules\Support\Models\TicketAttributeType;
|
||||
use Modules\Support\Models\TicketAttributeTypeL11n;
|
||||
use Modules\Support\Models\TicketAttributeTypeL11nMapper;
|
||||
use Modules\Support\Models\TicketAttributeTypeMapper;
|
||||
use Modules\Support\Models\TicketAttributeValue;
|
||||
use Modules\Support\Models\TicketAttributeValueMapper;
|
||||
use Modules\Support\Models\NullTicketAttributeType;
|
||||
use Modules\Support\Models\NullTicketAttributeValue;
|
||||
|
||||
/**
|
||||
* Api controller for the tickets module.
|
||||
|
|
@ -221,7 +232,7 @@ final class ApiController extends Controller
|
|||
$element = $this->createTicketElementFromRequest($request, $ticket);
|
||||
$ticket->task->setStatus($element->taskElement->getStatus());
|
||||
$ticket->task->setPriority($element->taskElement->getPriority());
|
||||
$ticket->task->setDue($element->taskElement->due);
|
||||
$ticket->task->due = $element->taskElement->due;
|
||||
|
||||
$this->createModel($request->header->account, $element, TicketElementMapper::class, 'ticketelement', $request->getOrigin());
|
||||
$this->updateModel($request->header->account, $ticket, $ticket, TicketMapper::class, 'ticket', $request->getOrigin());
|
||||
|
|
@ -232,7 +243,7 @@ final class ApiController extends Controller
|
|||
* Method to create ticket element from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param Ticket $ticket Ticket
|
||||
* @param Ticket $ticket Ticket
|
||||
*
|
||||
* @return TicketElement Returns the ticket created from the request
|
||||
*
|
||||
|
|
@ -240,7 +251,7 @@ final class ApiController extends Controller
|
|||
*/
|
||||
private function createTicketElementFromRequest(RequestAbstract $request, Ticket $ticket) : TicketElement
|
||||
{
|
||||
$taskElement = $this->app->moduleManager->get('Tasks')->createTaskElementFromRequest($request);
|
||||
$taskElement = $this->app->moduleManager->get('Tasks')->createTaskElementFromRequest($request, $ticket->task);
|
||||
|
||||
$ticketElement = new TicketElement($taskElement);
|
||||
$ticketElement->time = (int) $request->getData('time') ?? 0;
|
||||
|
|
@ -296,17 +307,17 @@ final class ApiController extends Controller
|
|||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return TaskElement Returns the updated ticket element from the request
|
||||
* @return TicketElementMapper Returns the updated ticket element from the request
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function updateTicketElementFromRequest(RequestAbstract $request) : TaskElement
|
||||
private function updateTicketElementFromRequest(RequestAbstract $request) : TicketElementMapper
|
||||
{
|
||||
$element = TicketElementMapper::get((int) ($request->getData('id')));
|
||||
$element->setDue(new \DateTime((string) ($request->getData('due') ?? $element->getDue()->format('Y-m-d H:i:s'))));
|
||||
$element->setStatus((int) ($request->getData('status') ?? $element->getStatus()));
|
||||
$element->description = Markdown::parse((string) ($request->getData('plain') ?? $element->descriptionRaw));
|
||||
$element->descriptionRaw = (string) ($request->getData('plain') ?? $element->descriptionRaw);
|
||||
$element->taskElement->due = new \DateTime((string) ($request->getData('due') ?? $element->getDue()->format('Y-m-d H:i:s')));
|
||||
$element->taskElement->setStatus((int) ($request->getData('status') ?? $element->taskElement->getStatus()));
|
||||
$element->taskElement->description = Markdown::parse((string) ($request->getData('plain') ?? $element->taskElement->descriptionRaw));
|
||||
$element->taskElement->descriptionRaw = (string) ($request->getData('plain') ?? $element->taskElement->descriptionRaw);
|
||||
|
||||
$tos = $request->getData('to') ?? $request->header->account;
|
||||
if (!\is_array($tos)) {
|
||||
|
|
@ -319,11 +330,11 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
foreach ($tos as $to) {
|
||||
$element->addTo($to);
|
||||
$element->taskElement->addTo($to);
|
||||
}
|
||||
|
||||
foreach ($ccs as $cc) {
|
||||
$element->addCC($cc);
|
||||
$element->taskElement->addCC($cc);
|
||||
}
|
||||
|
||||
return $element;
|
||||
|
|
@ -392,4 +403,314 @@ final class ApiController extends Controller
|
|||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create ticket attribute
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiTicketAttributeCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateTicketAttributeCreate($request))) {
|
||||
$response->set('attribute_create', new FormValidation($val));
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@todo: If value data is in attribute create, create attribute value
|
||||
|
||||
if () {
|
||||
$attrValue = $this->createTicketAttributeValueFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrValue, TicketAttributeValueMapper::class, 'attr_value', $request->getOrigin());
|
||||
}*/
|
||||
|
||||
$attribute = $this->createTicketAttributeFromRequest($request);
|
||||
$this->createModel($request->header->account, $attribute, TicketAttributeMapper::class, 'attribute', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute', 'Attribute successfully created', $attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create ticket attribute from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return TicketAttribute
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createTicketAttributeFromRequest(RequestAbstract $request) : TicketAttribute
|
||||
{
|
||||
$attribute = new TicketAttribute();
|
||||
$attribute->ticket = (int) $request->getData('ticket');
|
||||
$attribute->type = new NullTicketAttributeType((int) $request->getData('type'));
|
||||
$attribute->value = new NullTicketAttributeValue((int) $request->getData('value'));
|
||||
|
||||
return $attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ticket attribute create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateTicketAttributeCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['type'] = empty($request->getData('type')))
|
||||
|| ($val['value'] = empty($request->getData('value')))
|
||||
|| ($val['ticket'] = empty($request->getData('ticket')))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create ticket attribute l11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiTicketAttributeTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateTicketAttributeTypeL11nCreate($request))) {
|
||||
$response->set('attr_type_l11n_create', new FormValidation($val));
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attrL11n = $this->createTicketAttributeTypeL11nFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrL11n, TicketAttributeTypeL11nMapper::class, 'attr_type_l11n', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute type localization', 'Attribute type localization successfully created', $attrL11n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create ticket attribute l11n from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return TicketAttributeTypeL11n
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createTicketAttributeTypeL11nFromRequest(RequestAbstract $request) : TicketAttributeTypeL11n
|
||||
{
|
||||
$attrL11n = new TicketAttributeTypeL11n();
|
||||
$attrL11n->setType((int) ($request->getData('type') ?? 0));
|
||||
$attrL11n->setLanguage((string) (
|
||||
$request->getData('language') ?? $request->getLanguage()
|
||||
));
|
||||
$attrL11n->title = (string) ($request->getData('title') ?? '');
|
||||
|
||||
return $attrL11n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ticket attribute l11n create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateTicketAttributeTypeL11nCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['title'] = empty($request->getData('title')))
|
||||
|| ($val['type'] = empty($request->getData('type')))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create ticket attribute type
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiTicketAttributeTypeCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateTicketAttributeTypeCreate($request))) {
|
||||
$response->set('attr_type_create', new FormValidation($val));
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attrType = $this->createTicketAttributeTypeFromRequest($request);
|
||||
$attrType->setL11n($request->getData('title'), $request->getData('language'));
|
||||
$this->createModel($request->header->account, $attrType, TicketAttributeTypeMapper::class, 'attr_type', $request->getOrigin());
|
||||
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute type', 'Attribute type successfully created', $attrType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create ticket attribute from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return TicketAttributeType
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createTicketAttributeTypeFromRequest(RequestAbstract $request) : TicketAttributeType
|
||||
{
|
||||
$attrType = new TicketAttributeType();
|
||||
$attrType->name = (string) ($request->getData('name') ?? '');
|
||||
$attrType->setFields((int) ($request->getData('fields') ?? 0));
|
||||
$attrType->setCustom((bool) ($request->getData('custom') ?? false));
|
||||
|
||||
return $attrType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ticket attribute create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateTicketAttributeTypeCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['name'] = empty($request->getData('name')))
|
||||
|| ($val['title'] = empty($request->getData('title')))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create ticket attribute value
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiTicketAttributeValueCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateTicketAttributeValueCreate($request))) {
|
||||
$response->set('attr_value_create', new FormValidation($val));
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attrValue = $this->createTicketAttributeValueFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrValue, TicketAttributeValueMapper::class, 'attr_value', $request->getOrigin());
|
||||
|
||||
if ($attrValue->isDefault) {
|
||||
$this->createModelRelation(
|
||||
$request->header->account,
|
||||
(int) $request->getData('attributetype'),
|
||||
$attrValue->getId(),
|
||||
TicketAttributeTypeMapper::class, 'defaults', '', $request->getOrigin()
|
||||
);
|
||||
}
|
||||
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute value', 'Attribute value successfully created', $attrValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create ticket attribute value from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return TicketAttributeValue
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createTicketAttributeValueFromRequest(RequestAbstract $request) : TicketAttributeValue
|
||||
{
|
||||
$attrValue = new TicketAttributeValue();
|
||||
|
||||
$type = $request->getData('type') ?? 0;
|
||||
if ($type === AttributeValueType::_INT) {
|
||||
$attrValue->valueInt = (int) $request->getData('value');
|
||||
} elseif ($type === AttributeValueType::_STRING) {
|
||||
$attrValue->valueStr = (string) $request->getData('value');
|
||||
} elseif ($type === AttributeValueType::_FLOAT) {
|
||||
$attrValue->valueDec = (float) $request->getData('value');
|
||||
} elseif ($type === AttributeValueType::_DATETIME) {
|
||||
$attrValue->valueDat = new \DateTime($request->getData('value') ?? '');
|
||||
}
|
||||
|
||||
$attrValue->type = $type;
|
||||
$attrValue->isDefault = (bool) ($request->getData('default') ?? false);
|
||||
|
||||
if ($request->hasData('language')) {
|
||||
$attrValue->setLanguage((string) ($request->getData('language') ?? $request->getLanguage()));
|
||||
}
|
||||
|
||||
if ($request->hasData('country')) {
|
||||
$attrValue->setCountry((string) ($request->getData('country') ?? $request->header->l11n->getCountry()));
|
||||
}
|
||||
|
||||
return $attrValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ticket attribute value create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateTicketAttributeValueCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['type'] = empty($request->getData('type')))
|
||||
|| ($val['value'] = empty($request->getData('value')))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
Docs/Dev/img/er.png
Normal file
BIN
Docs/Dev/img/er.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 238 KiB |
36
Models/AttributeValueType.php
Executable file
36
Models/AttributeValueType.php
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
/**
|
||||
* Attribute value type enum.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class AttributeValueType extends Enum
|
||||
{
|
||||
public const _INT = 1;
|
||||
|
||||
public const _STRING = 2;
|
||||
|
||||
public const _FLOAT = 3;
|
||||
|
||||
public const _DATETIME = 4;
|
||||
}
|
||||
38
Models/NullTicketAttribute.php
Executable file
38
Models/NullTicketAttribute.php
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullTicketAttribute extends TicketAttribute
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
38
Models/NullTicketAttributeType.php
Executable file
38
Models/NullTicketAttributeType.php
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullTicketAttributeType extends TicketAttributeType
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
38
Models/NullTicketAttributeTypeL11n.php
Executable file
38
Models/NullTicketAttributeTypeL11n.php
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullTicketAttributeTypeL11n extends TicketAttributeTypeL11n
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
38
Models/NullTicketAttributeValue.php
Executable file
38
Models/NullTicketAttributeValue.php
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullTicketAttributeValue extends TicketAttributeValue
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
|
@ -44,6 +44,14 @@ class Ticket
|
|||
|
||||
public ?Account $for = null;
|
||||
|
||||
/**
|
||||
* Attributes.
|
||||
*
|
||||
* @var int[]|ItemAttribute[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $attributes = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
|
@ -145,4 +153,30 @@ class Ticket
|
|||
{
|
||||
return $this->ticketElements[$id] ?? new NullTicketElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attribute to item
|
||||
*
|
||||
* @param ItemAttribute $attribute Note
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addAttribute(ItemAttribute $attribute) : void
|
||||
{
|
||||
$this->attributes[] = $attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attributes
|
||||
*
|
||||
* @return ItemAttribute[]
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getAttributes() : array
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
88
Models/TicketAttribute.php
Executable file
88
Models/TicketAttribute.php
Executable file
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
|
||||
/**
|
||||
* Ticket class.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class TicketAttribute implements \JsonSerializable, ArrayableInterface
|
||||
{
|
||||
/**
|
||||
* Id.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Ticket this attribute belongs to
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $ticket = 0;
|
||||
|
||||
/**
|
||||
* Attribute type the attribute belongs to
|
||||
*
|
||||
* @var TicketAttributeType
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public TicketAttributeType $type;
|
||||
|
||||
/**
|
||||
* Attribute value the attribute belongs to
|
||||
*
|
||||
* @var TicketAttributeValue
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public TicketAttributeValue $value;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
74
Models/TicketAttributeMapper.php
Executable file
74
Models/TicketAttributeMapper.php
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Ticket mapper class.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class TicketAttributeMapper 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 = [
|
||||
'support_ticket_attr_id' => ['name' => 'support_ticket_attr_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_ticket_attr_ticket' => ['name' => 'support_ticket_attr_ticket', 'type' => 'int', 'internal' => 'ticket'],
|
||||
'support_ticket_attr_type' => ['name' => 'support_ticket_attr_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'support_ticket_attr_value' => ['name' => 'support_ticket_attr_value', 'type' => 'int', 'internal' => 'value'],
|
||||
];
|
||||
|
||||
/**
|
||||
* 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' => TicketAttributeTypeMapper::class,
|
||||
'external' => 'support_ticket_attr_type',
|
||||
],
|
||||
'value' => [
|
||||
'mapper' => TicketAttributeValueMapper::class,
|
||||
'external' => 'support_ticket_attr_value',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'support_ticket_attr';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'support_ticket_attr_id';
|
||||
}
|
||||
180
Models/TicketAttributeType.php
Executable file
180
Models/TicketAttributeType.php
Executable file
|
|
@ -0,0 +1,180 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Ticket Attribute Type class.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class TicketAttributeType 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?!)
|
||||
|
||||
/**
|
||||
* Which field data type is required (string, int, ...) in the value
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $fields = 0;
|
||||
|
||||
/**
|
||||
* Is a custom value allowed (e.g. custom string)
|
||||
*
|
||||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected bool $custom = false;
|
||||
|
||||
public string $validationPattern = '';
|
||||
|
||||
public bool $isRequired = false;
|
||||
|
||||
/**
|
||||
* Localization
|
||||
*
|
||||
* @var TicketAttributeTypeL11n
|
||||
*/
|
||||
protected string|TicketAttributeTypeL11n $l11n;
|
||||
|
||||
/**
|
||||
* Possible default attribute values
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected array $defaults = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name Name/identifier of the attribute type
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(string $name = '')
|
||||
{
|
||||
$this->setL11n($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set l11n
|
||||
*
|
||||
* @param string|TicketAttributeTypeL11n $l11n Tag article l11n
|
||||
* @param string $lang Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setL11n(string | TicketAttributeTypeL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||
{
|
||||
if ($l11n instanceof TicketAttributeTypeL11n) {
|
||||
$this->l11n = $l11n;
|
||||
} elseif (isset($this->l11n) && $this->l11n instanceof TicketAttributeTypeL11n) {
|
||||
$this->l11n->title = $l11n;
|
||||
} else {
|
||||
$this->l11n = new TicketAttributeTypeL11n();
|
||||
$this->l11n->title = $l11n;
|
||||
$this->l11n->setLanguage($lang);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getL11n() : string
|
||||
{
|
||||
return $this->l11n instanceof TicketAttributeTypeL11n ? $this->l11n->title : $this->l11n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set fields
|
||||
*
|
||||
* @param int $fields Fields
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setFields(int $fields) : void
|
||||
{
|
||||
$this->fields = $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom
|
||||
*
|
||||
* @param bool $custom FieldsCustom
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setCustom(bool $custom) : void
|
||||
{
|
||||
$this->custom = $custom;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
147
Models/TicketAttributeTypeL11n.php
Executable file
147
Models/TicketAttributeTypeL11n.php
Executable file
|
|
@ -0,0 +1,147 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Ticket class.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class TicketAttributeTypeL11n implements \JsonSerializable, ArrayableInterface
|
||||
{
|
||||
/**
|
||||
* ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Ticket ID.
|
||||
*
|
||||
* @var int|TicketAttributeType
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int |
|
||||
|
||||
TicketAttributeType $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|TicketAttributeType $type Attribute type
|
||||
* @param string $title Localized title
|
||||
* @param string $language Language
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int | TicketAttributeType $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|TicketAttributeType
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getType() : int | TicketAttributeType
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
57
Models/TicketAttributeTypeL11nMapper.php
Executable file
57
Models/TicketAttributeTypeL11nMapper.php
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Ticket mapper class.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class TicketAttributeTypeL11nMapper 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 = [
|
||||
'support_attr_type_l11n_id' => ['name' => 'support_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_attr_type_l11n_title' => ['name' => 'support_attr_type_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
|
||||
'support_attr_type_l11n_type' => ['name' => 'support_attr_type_l11n_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'support_attr_type_l11n_lang' => ['name' => 'support_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'support_attr_type_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'support_attr_type_l11n_id';
|
||||
}
|
||||
83
Models/TicketAttributeTypeMapper.php
Executable file
83
Models/TicketAttributeTypeMapper.php
Executable file
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Ticket mapper class.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class TicketAttributeTypeMapper 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 = [
|
||||
'support_attr_type_id' => ['name' => 'support_attr_type_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_attr_type_name' => ['name' => 'support_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
||||
'support_attr_type_fields' => ['name' => 'support_attr_type_fields', 'type' => 'int', 'internal' => 'fields'],
|
||||
'support_attr_type_custom' => ['name' => 'support_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'],
|
||||
'support_attr_type_pattern' => ['name' => 'support_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'],
|
||||
'support_attr_type_required' => ['name' => 'support_attr_type_required', 'type' => 'bool', 'internal' => 'isRequired'],
|
||||
];
|
||||
|
||||
/**
|
||||
* 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' => TicketAttributeTypeL11nMapper::class,
|
||||
'table' => 'support_attr_type_l11n',
|
||||
'self' => 'support_attr_type_l11n_type',
|
||||
'column' => 'title',
|
||||
'conditional' => true,
|
||||
'external' => null,
|
||||
],
|
||||
'defaults' => [
|
||||
'mapper' => TicketAttributeValueMapper::class,
|
||||
'table' => 'support_ticket_attr_default',
|
||||
'self' => 'support_ticket_attr_default_type',
|
||||
'external' => 'support_ticket_attr_default_value',
|
||||
'conditional' => false,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'support_attr_type';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'support_attr_type_id';
|
||||
}
|
||||
221
Models/TicketAttributeValue.php
Executable file
221
Models/TicketAttributeValue.php
Executable file
|
|
@ -0,0 +1,221 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
use phpOMS\Localization\ISO3166TwoEnum;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Ticket attribute value class.
|
||||
*
|
||||
* The relation with the type/ticket is defined in the TicketAttribute class.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class TicketAttributeValue implements \JsonSerializable, ArrayableInterface
|
||||
{
|
||||
/**
|
||||
* Id
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Type of the attribute
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $type = 0;
|
||||
|
||||
/**
|
||||
* Int value
|
||||
*
|
||||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?int $valueInt = null;
|
||||
|
||||
/**
|
||||
* String value
|
||||
*
|
||||
* @var null|string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?string $valueStr = null;
|
||||
|
||||
/**
|
||||
* Decimal value
|
||||
*
|
||||
* @var null|float
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?float $valueDec = null;
|
||||
|
||||
/**
|
||||
* DateTime value
|
||||
*
|
||||
* @var null|\DateTimeInterface
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?\DateTimeInterface $valueDat = null;
|
||||
|
||||
/**
|
||||
* Is a default value which can be selected
|
||||
*
|
||||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public bool $isDefault = false;
|
||||
|
||||
/**
|
||||
* Language
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected string $language = ISO639x1Enum::_EN;
|
||||
|
||||
/**
|
||||
* Country
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected string $country = ISO3166TwoEnum::_USA;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $type Type
|
||||
* @param mixed $value Value
|
||||
* @param string $language Language
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $type = 0, $value = '', string $language = ISO639x1Enum::_EN)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->language = $language;
|
||||
|
||||
$this->setValue($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param int|string|float|\DateTimeInterface $value Value
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setValue($value) : void
|
||||
{
|
||||
if (\is_string($value)) {
|
||||
$this->valueStr = $value;
|
||||
} elseif (\is_int($value)) {
|
||||
$this->valueInt = $value;
|
||||
} elseif (\is_float($value)) {
|
||||
$this->valueDec = $value;
|
||||
} elseif ($value instanceof \DateTimeInterface) {
|
||||
$this->valueDat = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value
|
||||
*
|
||||
* @return null|int|string|float|\DateTimeInterface
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getValue() : mixed
|
||||
{
|
||||
if (!empty($this->valueStr)) {
|
||||
return $this->valueStr;
|
||||
} elseif (!empty($this->valueInt)) {
|
||||
return $this->valueInt;
|
||||
} elseif (!empty($this->valueDec)) {
|
||||
return $this->valueDec;
|
||||
} elseif ($this->valueDat instanceof \DateTimeInterface) {
|
||||
return $this->valueDat;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set language
|
||||
*
|
||||
* @param string $language Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setLanguage(string $language) : void
|
||||
{
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set country
|
||||
*
|
||||
* @param string $country Country
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setCountry(string $country) : void
|
||||
{
|
||||
$this->country = $country;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
62
Models/TicketAttributeValueMapper.php
Executable file
62
Models/TicketAttributeValueMapper.php
Executable file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https: //orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Ticket mapper class.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https: //orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class TicketAttributeValueMapper 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 = [
|
||||
'support_attr_value_id' => ['name' => 'support_attr_value_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_attr_value_default' => ['name' => 'support_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'],
|
||||
'support_attr_value_type' => ['name' => 'support_attr_value_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'support_attr_value_valueStr' => ['name' => 'support_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'],
|
||||
'support_attr_value_valueInt' => ['name' => 'support_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'],
|
||||
'support_attr_value_valueDec' => ['name' => 'support_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'],
|
||||
'support_attr_value_valueDat' => ['name' => 'support_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'],
|
||||
'support_attr_value_lang' => ['name' => 'support_attr_value_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
'support_attr_value_country' => ['name' => 'support_attr_value_country', 'type' => 'string', 'internal' => 'country'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'support_attr_value';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'support_attr_value_id';
|
||||
}
|
||||
|
|
@ -53,6 +53,7 @@ class TicketElement implements \JsonSerializable
|
|||
/**
|
||||
* Task element
|
||||
*
|
||||
* @var TaskElement
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public TaskElement $taskElement;
|
||||
|
|
@ -77,4 +78,20 @@ class TicketElement implements \JsonSerializable
|
|||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return $this->taskElement->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ final class TicketElementMapper extends DataMapperAbstract
|
|||
*/
|
||||
protected static array $columns = [
|
||||
'support_ticket_element_id' => ['name' => 'support_ticket_element_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_ticket_element_task_element' => ['name' => 'support_ticket_element_task_element', 'type' => 'int', 'internal' => 'task'],
|
||||
'support_ticket_element_task_element' => ['name' => 'support_ticket_element_task_element', 'type' => 'int', 'internal' => 'taskElement'],
|
||||
'support_ticket_element_time' => ['name' => 'support_ticket_element_time', 'type' => 'int', 'internal' => 'time'],
|
||||
'support_ticket_element_ticket' => ['name' => 'support_ticket_element_ticket', 'type' => 'int', 'internal' => 'ticket'],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -67,6 +67,13 @@ final class TicketMapper extends DataMapperAbstract
|
|||
'self' => 'support_ticket_element_ticket',
|
||||
'external' => null,
|
||||
],
|
||||
'attributes' => [
|
||||
'mapper' => TicketAttributeMapper::class,
|
||||
'table' => 'support_ticket_attr',
|
||||
'self' => 'support_ticket_attr_ticket',
|
||||
'conditional' => true,
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<?php if ($task->getPriority() === TaskPriority::NONE) : ?>
|
||||
<?= $this->getHtml('Due'); ?>: <?= $this->printHtml($task->due->format('Y/m/d H:i')); ?>
|
||||
<?php else : ?>
|
||||
<?= $this->getHtml('Priority'); ?>: <?= $this->getHtml('P' . $task->getPriority()); ?>
|
||||
<?= $this->getHtml('Priority'); ?>: <?= $this->getHtml('P' . $task->getPriority(), 'Tasks'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $tags = $task->getTags(); foreach ($tags as $tag) : ?>
|
||||
|
|
@ -200,7 +200,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
$element->createdAt->format('Y-m-d H:i')
|
||||
); ?>
|
||||
<span class="tag task-priority-<?= $element->getPriority(); ?>">
|
||||
<?= $this->getHtml('P' . $element->getPriority()); ?>
|
||||
<?= $this->getHtml('P' . $element->getPriority(), 'Tasks'); ?>
|
||||
</span>
|
||||
</div>
|
||||
</section>
|
||||
|
|
@ -265,7 +265,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
) : ?>
|
||||
<?= $this->getHtml('Due'); ?>: <?= $this->printHtml($element->due->format('Y/m/d H:i')); ?>
|
||||
<?php elseif ($previous !== null && $previous->getPriority() !== $element->getPriority()) : ?>
|
||||
<?= $this->getHtml('Priority'); ?>: <?= $this->getHtml('P' . $element->getPriority()); ?>
|
||||
<?= $this->getHtml('Priority'); ?>: <?= $this->getHtml('P' . $element->getPriority(), 'Tasks'); ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
|
@ -358,12 +358,12 @@ echo $this->getData('nav')->render(); ?>
|
|||
<div class="form-group">
|
||||
<label for="iPriority"><?= $this->getHtml('Priority'); ?></label>
|
||||
<select id="iPriority" name="priority">
|
||||
<option value="<?= TaskPriority::NONE; ?>"<?= $task->getPriority() === TaskPriority::NONE ? ' selected' : '';?>><?= $this->getHtml('P0'); ?>
|
||||
<option value="<?= TaskPriority::VLOW; ?>"<?= $task->getPriority() === TaskPriority::VLOW ? ' selected' : '';?>><?= $this->getHtml('P1'); ?>
|
||||
<option value="<?= TaskPriority::LOW; ?>"<?= $task->getPriority() === TaskPriority::LOW ? ' selected' : '';?>><?= $this->getHtml('P2'); ?>
|
||||
<option value="<?= TaskPriority::MEDIUM; ?>"<?= $task->getPriority() === TaskPriority::MEDIUM ? ' selected' : '';?>><?= $this->getHtml('P3'); ?>
|
||||
<option value="<?= TaskPriority::HIGH; ?>"<?= $task->getPriority() === TaskPriority::HIGH ? ' selected' : '';?>><?= $this->getHtml('P4'); ?>
|
||||
<option value="<?= TaskPriority::VHIGH; ?>"<?= $task->getPriority() === TaskPriority::VHIGH ? ' selected' : '';?>><?= $this->getHtml('P5'); ?>
|
||||
<option value="<?= TaskPriority::NONE; ?>"<?= $task->getPriority() === TaskPriority::NONE ? ' selected' : '';?>><?= $this->getHtml('P0', 'Tasks'); ?>
|
||||
<option value="<?= TaskPriority::VLOW; ?>"<?= $task->getPriority() === TaskPriority::VLOW ? ' selected' : '';?>><?= $this->getHtml('P1', 'Tasks'); ?>
|
||||
<option value="<?= TaskPriority::LOW; ?>"<?= $task->getPriority() === TaskPriority::LOW ? ' selected' : '';?>><?= $this->getHtml('P2', 'Tasks'); ?>
|
||||
<option value="<?= TaskPriority::MEDIUM; ?>"<?= $task->getPriority() === TaskPriority::MEDIUM ? ' selected' : '';?>><?= $this->getHtml('P3', 'Tasks'); ?>
|
||||
<option value="<?= TaskPriority::HIGH; ?>"<?= $task->getPriority() === TaskPriority::HIGH ? ' selected' : '';?>><?= $this->getHtml('P4', 'Tasks'); ?>
|
||||
<option value="<?= TaskPriority::VHIGH; ?>"<?= $task->getPriority() === TaskPriority::VHIGH ? ' selected' : '';?>><?= $this->getHtml('P5', 'Tasks'); ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user