diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 0ad2bfa..3f63d53 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -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 + * + * @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 + * + * @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 + * + * @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 + * + * @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 []; + } } diff --git a/Docs/Dev/img/er.png b/Docs/Dev/img/er.png new file mode 100644 index 0000000..0f4cb0b Binary files /dev/null and b/Docs/Dev/img/er.png differ diff --git a/Models/AttributeValueType.php b/Models/AttributeValueType.php new file mode 100755 index 0000000..7761f52 --- /dev/null +++ b/Models/AttributeValueType.php @@ -0,0 +1,36 @@ +id = $id; + } +} diff --git a/Models/NullTicketAttributeType.php b/Models/NullTicketAttributeType.php new file mode 100755 index 0000000..774ec24 --- /dev/null +++ b/Models/NullTicketAttributeType.php @@ -0,0 +1,38 @@ +id = $id; + } +} diff --git a/Models/NullTicketAttributeTypeL11n.php b/Models/NullTicketAttributeTypeL11n.php new file mode 100755 index 0000000..53c7120 --- /dev/null +++ b/Models/NullTicketAttributeTypeL11n.php @@ -0,0 +1,38 @@ +id = $id; + } +} diff --git a/Models/NullTicketAttributeValue.php b/Models/NullTicketAttributeValue.php new file mode 100755 index 0000000..dc6303a --- /dev/null +++ b/Models/NullTicketAttributeValue.php @@ -0,0 +1,38 @@ +id = $id; + } +} diff --git a/Models/Ticket.php b/Models/Ticket.php index 6e67121..8383a7c 100755 --- a/Models/Ticket.php +++ b/Models/Ticket.php @@ -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; + } } diff --git a/Models/TicketAttribute.php b/Models/TicketAttribute.php new file mode 100755 index 0000000..09a560c --- /dev/null +++ b/Models/TicketAttribute.php @@ -0,0 +1,88 @@ +id; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return []; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/Models/TicketAttributeMapper.php b/Models/TicketAttributeMapper.php new file mode 100755 index 0000000..955661f --- /dev/null +++ b/Models/TicketAttributeMapper.php @@ -0,0 +1,74 @@ + + * @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 + * @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'; +} diff --git a/Models/TicketAttributeType.php b/Models/TicketAttributeType.php new file mode 100755 index 0000000..882a513 --- /dev/null +++ b/Models/TicketAttributeType.php @@ -0,0 +1,180 @@ +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(); + } +} diff --git a/Models/TicketAttributeTypeL11n.php b/Models/TicketAttributeTypeL11n.php new file mode 100755 index 0000000..453d942 --- /dev/null +++ b/Models/TicketAttributeTypeL11n.php @@ -0,0 +1,147 @@ +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(); + } +} diff --git a/Models/TicketAttributeTypeL11nMapper.php b/Models/TicketAttributeTypeL11nMapper.php new file mode 100755 index 0000000..014a65a --- /dev/null +++ b/Models/TicketAttributeTypeL11nMapper.php @@ -0,0 +1,57 @@ + + * @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'; +} diff --git a/Models/TicketAttributeTypeMapper.php b/Models/TicketAttributeTypeMapper.php new file mode 100755 index 0000000..4b7e4d8 --- /dev/null +++ b/Models/TicketAttributeTypeMapper.php @@ -0,0 +1,83 @@ + + * @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 + * @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'; +} diff --git a/Models/TicketAttributeValue.php b/Models/TicketAttributeValue.php new file mode 100755 index 0000000..cb6ab53 --- /dev/null +++ b/Models/TicketAttributeValue.php @@ -0,0 +1,221 @@ +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(); + } +} diff --git a/Models/TicketAttributeValueMapper.php b/Models/TicketAttributeValueMapper.php new file mode 100755 index 0000000..8816af7 --- /dev/null +++ b/Models/TicketAttributeValueMapper.php @@ -0,0 +1,62 @@ + + * @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'; +} diff --git a/Models/TicketElement.php b/Models/TicketElement.php index bd87f89..3b3b0b8 100644 --- a/Models/TicketElement.php +++ b/Models/TicketElement.php @@ -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(); + } } \ No newline at end of file diff --git a/Models/TicketElementMapper.php b/Models/TicketElementMapper.php index 4955d8f..2b7e318 100644 --- a/Models/TicketElementMapper.php +++ b/Models/TicketElementMapper.php @@ -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'], ]; diff --git a/Models/TicketMapper.php b/Models/TicketMapper.php index 3fc13a3..3812f03 100755 --- a/Models/TicketMapper.php +++ b/Models/TicketMapper.php @@ -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, + ], ]; /** diff --git a/Theme/Backend/support-ticket.tpl.php b/Theme/Backend/support-ticket.tpl.php index 4d98718..df3b9dd 100755 --- a/Theme/Backend/support-ticket.tpl.php +++ b/Theme/Backend/support-ticket.tpl.php @@ -97,7 +97,7 @@ echo $this->getData('nav')->render(); ?> getPriority() === TaskPriority::NONE) : ?> getHtml('Due'); ?>: printHtml($task->due->format('Y/m/d H:i')); ?> - getHtml('Priority'); ?>: getHtml('P' . $task->getPriority()); ?> + getHtml('Priority'); ?>: getHtml('P' . $task->getPriority(), 'Tasks'); ?> getTags(); foreach ($tags as $tag) : ?> @@ -200,7 +200,7 @@ echo $this->getData('nav')->render(); ?> $element->createdAt->format('Y-m-d H:i') ); ?> - getHtml('P' . $element->getPriority()); ?> + getHtml('P' . $element->getPriority(), 'Tasks'); ?> @@ -265,7 +265,7 @@ echo $this->getData('nav')->render(); ?> ) : ?> getHtml('Due'); ?>: printHtml($element->due->format('Y/m/d H:i')); ?> getPriority() !== $element->getPriority()) : ?> - getHtml('Priority'); ?>: getHtml('P' . $element->getPriority()); ?> + getHtml('Priority'); ?>: getHtml('P' . $element->getPriority(), 'Tasks'); ?> @@ -358,12 +358,12 @@ echo $this->getData('nav')->render(); ?>