mirror of
https://github.com/Karaka-Management/oms-Support.git
synced 2026-01-11 17:18:40 +00:00
org -> unit change, some new functionality
This commit is contained in:
parent
94f065a383
commit
eaca64d28e
|
|
@ -143,7 +143,7 @@ final class Application
|
||||||
$this->app->eventManager = new EventManager($this->app->dispatcher);
|
$this->app->eventManager = new EventManager($this->app->dispatcher);
|
||||||
$this->app->accountManager = new AccountManager($this->app->sessionManager);
|
$this->app->accountManager = new AccountManager($this->app->sessionManager);
|
||||||
$this->app->l11nServer = LocalizationMapper::get()->where('id', 1)->execute();
|
$this->app->l11nServer = LocalizationMapper::get()->where('id', 1)->execute();
|
||||||
$this->app->orgId = $this->getApplicationOrganization($request, $this->config['app']);
|
$this->app->unitId = $this->getApplicationOrganization($request, $this->config['app']);
|
||||||
|
|
||||||
$aid = Auth::authenticate($this->app->sessionManager);
|
$aid = Auth::authenticate($this->app->sessionManager);
|
||||||
$request->header->account = $aid;
|
$request->header->account = $aid;
|
||||||
|
|
@ -174,7 +174,7 @@ final class Application
|
||||||
$pageView = new ShopView($this->app->l11nManager, $request, $response);
|
$pageView = new ShopView($this->app->l11nManager, $request, $response);
|
||||||
$head = new Head();
|
$head = new Head();
|
||||||
|
|
||||||
$pageView->setData('orgId', $this->app->orgId);
|
$pageView->setData('unitId', $this->app->unitId);
|
||||||
$pageView->setData('head', $head);
|
$pageView->setData('head', $head);
|
||||||
$response->set('Content', $pageView);
|
$response->set('Content', $pageView);
|
||||||
|
|
||||||
|
|
@ -213,7 +213,7 @@ final class Application
|
||||||
$request->getData('CSRF'),
|
$request->getData('CSRF'),
|
||||||
$request->getRouteVerb(),
|
$request->getRouteVerb(),
|
||||||
$this->app->appName,
|
$this->app->appName,
|
||||||
$this->app->orgId,
|
$this->app->unitId,
|
||||||
$account,
|
$account,
|
||||||
$request->getData()
|
$request->getData()
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
"type": "INT",
|
"type": "INT",
|
||||||
"default": null,
|
"default": null,
|
||||||
"null": true,
|
"null": true,
|
||||||
"foreignTable": "organization_unit",
|
"foreignTable": "unit",
|
||||||
"foreignKey": "organization_unit_id"
|
"foreignKey": "unit_id"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -33,4 +33,8 @@ abstract class AttributeValueType extends Enum
|
||||||
public const _FLOAT = 3;
|
public const _FLOAT = 3;
|
||||||
|
|
||||||
public const _DATETIME = 4;
|
public const _DATETIME = 4;
|
||||||
|
|
||||||
|
public const _BOOL = 5;
|
||||||
|
|
||||||
|
public const _FLOAT_INT = 6;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Karaka
|
|
||||||
*
|
|
||||||
* PHP Version 8.1
|
|
||||||
*
|
|
||||||
* @package Modules\Support\Models
|
|
||||||
* @copyright Dennis Eichhorn
|
|
||||||
* @license OMS License 1.0
|
|
||||||
* @version 1.0.0
|
|
||||||
* @link https://jingga.app
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Modules\Support\Models;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Null model
|
|
||||||
*
|
|
||||||
* @package Modules\Support\Models
|
|
||||||
* @license OMS License 1.0
|
|
||||||
* @link https://jingga.app
|
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function jsonSerialize() : mixed
|
|
||||||
{
|
|
||||||
return ['id' => $this->id];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,135 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Karaka
|
|
||||||
*
|
|
||||||
* PHP Version 8.1
|
|
||||||
*
|
|
||||||
* @package Modules\Support\Models
|
|
||||||
* @copyright Dennis Eichhorn
|
|
||||||
* @license OMS License 1.0
|
|
||||||
* @version 1.0.0
|
|
||||||
* @link https://jingga.app
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Modules\Support\Models;
|
|
||||||
|
|
||||||
use phpOMS\Localization\ISO639x1Enum;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ticket class.
|
|
||||||
*
|
|
||||||
* @package Modules\Support\Models
|
|
||||||
* @license OMS License 1.0
|
|
||||||
* @link https://jingga.app
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
class TicketAttributeTypeL11n implements \JsonSerializable
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* ID.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
protected int $id = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ticket ID.
|
|
||||||
*
|
|
||||||
* @var int|TicketAttributeType
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public 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 language
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public function getLanguage() : string
|
|
||||||
{
|
|
||||||
return $this->language;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 [
|
|
||||||
'id' => $this->id,
|
|
||||||
'title' => $this->title,
|
|
||||||
'type' => $this->type,
|
|
||||||
'language' => $this->language,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function jsonSerialize() : mixed
|
|
||||||
{
|
|
||||||
return $this->toArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
||||||
namespace Modules\Support\Models;
|
namespace Modules\Support\Models;
|
||||||
|
|
||||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||||
|
use phpOMS\Localization\BaseStringL11n;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ticket mapper class.
|
* Ticket mapper class.
|
||||||
|
|
@ -34,8 +35,8 @@ final class TicketAttributeTypeL11nMapper extends DataMapperFactory
|
||||||
*/
|
*/
|
||||||
public const COLUMNS = [
|
public const COLUMNS = [
|
||||||
'support_attr_type_l11n_id' => ['name' => 'support_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
'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_title' => ['name' => 'support_attr_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
|
||||||
'support_attr_type_l11n_type' => ['name' => 'support_attr_type_l11n_type', 'type' => 'int', 'internal' => 'type'],
|
'support_attr_type_l11n_type' => ['name' => 'support_attr_type_l11n_type', 'type' => 'int', 'internal' => 'ref'],
|
||||||
'support_attr_type_l11n_lang' => ['name' => 'support_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
'support_attr_type_l11n_lang' => ['name' => 'support_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -54,4 +55,12 @@ final class TicketAttributeTypeL11nMapper extends DataMapperFactory
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public const PRIMARYFIELD ='support_attr_type_l11n_id';
|
public const PRIMARYFIELD ='support_attr_type_l11n_id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model to use by the mapper.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public const MODEL = BaseStringL11n::class;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ final class TicketAttributeTypeMapper extends DataMapperFactory
|
||||||
'mapper' => TicketAttributeTypeL11nMapper::class,
|
'mapper' => TicketAttributeTypeL11nMapper::class,
|
||||||
'table' => 'support_attr_type_l11n',
|
'table' => 'support_attr_type_l11n',
|
||||||
'self' => 'support_attr_type_l11n_type',
|
'self' => 'support_attr_type_l11n_type',
|
||||||
'column' => 'title',
|
'column' => 'content',
|
||||||
'external' => null,
|
'external' => null,
|
||||||
],
|
],
|
||||||
'defaults' => [
|
'defaults' => [
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\Support\Models;
|
namespace Modules\Support\Models;
|
||||||
|
|
||||||
|
use phpOMS\Localization\BaseStringL11n;
|
||||||
use phpOMS\Localization\ISO3166TwoEnum;
|
use phpOMS\Localization\ISO3166TwoEnum;
|
||||||
use phpOMS\Localization\ISO639x1Enum;
|
use phpOMS\Localization\ISO639x1Enum;
|
||||||
|
|
||||||
|
|
@ -38,12 +39,20 @@ class TicketAttributeValue implements \JsonSerializable
|
||||||
protected int $id = 0;
|
protected int $id = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of the attribute
|
* Depending attribute type
|
||||||
*
|
*
|
||||||
* @var int
|
* @var null|int
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public int $type = 0;
|
public ?int $dependingAttributeType = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Depending attribute value
|
||||||
|
*
|
||||||
|
* @var null|int
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public ?int $dependingAttributeValue = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Int value
|
* Int value
|
||||||
|
|
@ -86,37 +95,19 @@ class TicketAttributeValue implements \JsonSerializable
|
||||||
public bool $isDefault = false;
|
public bool $isDefault = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language
|
* Unit of the value
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected string $language = ISO639x1Enum::_EN;
|
public string $unit = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Country
|
* Localization
|
||||||
*
|
*
|
||||||
* @var string
|
* @var null|BaseStringL11n
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
*/
|
||||||
protected string $country = ISO3166TwoEnum::_USA;
|
private ?BaseStringL11n $l11n = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* Get id
|
||||||
|
|
@ -175,55 +166,39 @@ class TicketAttributeValue implements \JsonSerializable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set language
|
* Set l11n
|
||||||
*
|
*
|
||||||
* @param string $language Language
|
* @param string|BaseStringL11n $l11n Tag article l11n
|
||||||
|
* @param string $lang Language
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setLanguage(string $language) : void
|
public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||||
{
|
{
|
||||||
$this->language = $language;
|
if ($l11n instanceof BaseStringL11n) {
|
||||||
|
$this->l11n = $l11n;
|
||||||
|
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
|
||||||
|
$this->l11n->content = $l11n;
|
||||||
|
} else {
|
||||||
|
$this->l11n = new BaseStringL11n();
|
||||||
|
$this->l11n->content = $l11n;
|
||||||
|
$this->l11n->ref = $this->id;
|
||||||
|
$this->l11n->setLanguage($lang);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get language
|
* Get localization
|
||||||
*
|
*
|
||||||
* @return string
|
* @return null|string
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getLanguage() : string
|
public function getL11n() : ?string
|
||||||
{
|
{
|
||||||
return $this->language;
|
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set country
|
|
||||||
*
|
|
||||||
* @param string $country Country
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public function setCountry(string $country) : void
|
|
||||||
{
|
|
||||||
$this->country = $country;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get country
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public function getCountry() : string
|
|
||||||
{
|
|
||||||
return $this->country;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -233,14 +208,11 @@ class TicketAttributeValue implements \JsonSerializable
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'type' => $this->type,
|
|
||||||
'valueInt' => $this->valueInt,
|
'valueInt' => $this->valueInt,
|
||||||
'valueStr' => $this->valueStr,
|
'valueStr' => $this->valueStr,
|
||||||
'valueDec' => $this->valueDec,
|
'valueDec' => $this->valueDec,
|
||||||
'valueDat' => $this->valueDat,
|
'valueDat' => $this->valueDat,
|
||||||
'isDefault' => $this->isDefault,
|
'isDefault' => $this->isDefault,
|
||||||
'language' => $this->language,
|
|
||||||
'country' => $this->country,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,15 +35,30 @@ final class TicketAttributeValueMapper extends DataMapperFactory
|
||||||
public const COLUMNS = [
|
public const COLUMNS = [
|
||||||
'support_attr_value_id' => ['name' => 'support_attr_value_id', 'type' => 'int', 'internal' => 'id'],
|
'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_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_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_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_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_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'],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Has many relation.
|
||||||
|
*
|
||||||
|
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
public const HAS_MANY = [
|
||||||
|
'l11n' => [
|
||||||
|
'mapper' => EventAttributeValueL11nMapper::class,
|
||||||
|
'table' => 'task_attr_value_l11n',
|
||||||
|
'self' => 'task_attr_value_l11n_value',
|
||||||
|
'column' => 'content',
|
||||||
|
'external' => null,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Primary table.
|
* Primary table.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
|
||||||
};
|
};
|
||||||
|
|
||||||
$this->app->dbPool = $GLOBALS['dbpool'];
|
$this->app->dbPool = $GLOBALS['dbpool'];
|
||||||
$this->app->orgId = 1;
|
$this->app->unitId = 1;
|
||||||
$this->app->accountManager = new AccountManager($GLOBALS['session']);
|
$this->app->accountManager = new AccountManager($GLOBALS['session']);
|
||||||
$this->app->appSettings = new CoreSettings();
|
$this->app->appSettings = new CoreSettings();
|
||||||
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules/');
|
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules/');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user