mirror of
https://github.com/Karaka-Management/oms-ClientManagement.git
synced 2026-02-12 23:08:42 +00:00
org -> unit change, some new functionality
This commit is contained in:
parent
09f3ba7c68
commit
6d53baa29e
|
|
@ -46,7 +46,53 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 1003103001,
|
"id": 1003101001,
|
||||||
|
"pid": "/",
|
||||||
|
"type": 2,
|
||||||
|
"subtype": 1,
|
||||||
|
"name": "Attributes",
|
||||||
|
"uri": "{/lang}/{/app}/sales/client/attribute/type/list?{?}",
|
||||||
|
"target": "self",
|
||||||
|
"icon": null,
|
||||||
|
"order": 5,
|
||||||
|
"from": "ClientManagement",
|
||||||
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
|
"parent": 1001601001,
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": 1003101101,
|
||||||
|
"pid": "/sales",
|
||||||
|
"type": 3,
|
||||||
|
"subtype": 1,
|
||||||
|
"name": "Types",
|
||||||
|
"uri": "{/lang}/{/app}/sales/client/attribute/type/list?{?}",
|
||||||
|
"target": "self",
|
||||||
|
"icon": null,
|
||||||
|
"order": 15,
|
||||||
|
"from": "ClientManagement",
|
||||||
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
|
"parent": 1003101001,
|
||||||
|
"children": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1003101201,
|
||||||
|
"pid": "/sales",
|
||||||
|
"type": 3,
|
||||||
|
"subtype": 1,
|
||||||
|
"name": "Values",
|
||||||
|
"uri": "{/lang}/{/app}/sales/client/attribute/value/list?{?}",
|
||||||
|
"target": "self",
|
||||||
|
"icon": null,
|
||||||
|
"order": 15,
|
||||||
|
"from": "ClientManagement",
|
||||||
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
|
"parent": 1003101001,
|
||||||
|
"children": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1003104001,
|
||||||
"pid": "/sales/analysis",
|
"pid": "/sales/analysis",
|
||||||
"type": 3,
|
"type": 3,
|
||||||
"subtype": 1,
|
"subtype": 1,
|
||||||
|
|
@ -54,14 +100,14 @@
|
||||||
"uri": "{/lang}/{/app}/sales/analysis/client?{?}",
|
"uri": "{/lang}/{/app}/sales/analysis/client?{?}",
|
||||||
"target": "self",
|
"target": "self",
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 2,
|
"order": 10,
|
||||||
"from": "ClientManagement",
|
"from": "ClientManagement",
|
||||||
"permission": { "permission": 2, "category": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1001602001,
|
"parent": 1001602001,
|
||||||
"children": []
|
"children": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 1003103002,
|
"id": 1003105001,
|
||||||
"pid": "/sales/analysis",
|
"pid": "/sales/analysis",
|
||||||
"type": 3,
|
"type": 3,
|
||||||
"subtype": 1,
|
"subtype": 1,
|
||||||
|
|
@ -69,14 +115,14 @@
|
||||||
"uri": "{/lang}/{/app}/sales/analysis/region?{?}",
|
"uri": "{/lang}/{/app}/sales/analysis/region?{?}",
|
||||||
"target": "self",
|
"target": "self",
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 3,
|
"order": 15,
|
||||||
"from": "ClientManagement",
|
"from": "ClientManagement",
|
||||||
"permission": { "permission": 2, "category": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1001602001,
|
"parent": 1001602001,
|
||||||
"children": []
|
"children": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 1003103003,
|
"id": 1003106001,
|
||||||
"pid": "/sales/analysis",
|
"pid": "/sales/analysis",
|
||||||
"type": 3,
|
"type": 3,
|
||||||
"subtype": 1,
|
"subtype": 1,
|
||||||
|
|
@ -84,7 +130,7 @@
|
||||||
"uri": "{/lang}/{/app}/sales/analysis/rep?{?}",
|
"uri": "{/lang}/{/app}/sales/analysis/rep?{?}",
|
||||||
"target": "self",
|
"target": "self",
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 4,
|
"order": 20,
|
||||||
"from": "ClientManagement",
|
"from": "ClientManagement",
|
||||||
"permission": { "permission": 2, "category": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1001602001,
|
"parent": 1001602001,
|
||||||
|
|
|
||||||
48
Admin/Install/Workflow.install.json
Normal file
48
Admin/Install/Workflow.install.json
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
{
|
||||||
|
"triggers": [
|
||||||
|
"PRE:Module:client-create",
|
||||||
|
"POST:Module:client-create",
|
||||||
|
"PRE:Module:client-update",
|
||||||
|
"POST:Module:client-update",
|
||||||
|
"PRE:Module:client-delete",
|
||||||
|
"POST:Module:client-delete"
|
||||||
|
],
|
||||||
|
"actions": {
|
||||||
|
"1003100001": {
|
||||||
|
"name": "",
|
||||||
|
"function": "",
|
||||||
|
"settings": {
|
||||||
|
"name1": {
|
||||||
|
"type": "select",
|
||||||
|
"subtype": null,
|
||||||
|
"title": {
|
||||||
|
"en": "",
|
||||||
|
"de": ""
|
||||||
|
},
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"value": 1,
|
||||||
|
"text": {
|
||||||
|
"en": "",
|
||||||
|
"de": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"name2": {
|
||||||
|
"type": "input",
|
||||||
|
"subtype": "text",
|
||||||
|
"title": {
|
||||||
|
"en": "",
|
||||||
|
"de": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"unique_id": {
|
||||||
|
"name": "",
|
||||||
|
"function": "",
|
||||||
|
"settings": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
170
Admin/Install/attributes.json
Normal file
170
Admin/Install/attributes.json
Normal file
|
|
@ -0,0 +1,170 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "abc_class",
|
||||||
|
"l11n": {
|
||||||
|
"en": "Rating",
|
||||||
|
"de": "Bewertung"
|
||||||
|
},
|
||||||
|
"value_type": 2,
|
||||||
|
"is_custom_allowed": true,
|
||||||
|
"validation_pattern": "",
|
||||||
|
"is_required": false,
|
||||||
|
"default_value": "",
|
||||||
|
"values": [
|
||||||
|
{
|
||||||
|
"value": "A",
|
||||||
|
"l11n": {
|
||||||
|
"en": "A",
|
||||||
|
"de": "A"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "B",
|
||||||
|
"l11n": {
|
||||||
|
"en": "B",
|
||||||
|
"de": "B"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "C",
|
||||||
|
"l11n": {
|
||||||
|
"en": "C",
|
||||||
|
"de": "C"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "D",
|
||||||
|
"l11n": {
|
||||||
|
"en": "D",
|
||||||
|
"de": "D"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "E",
|
||||||
|
"l11n": {
|
||||||
|
"en": "E",
|
||||||
|
"de": "E"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "F",
|
||||||
|
"l11n": {
|
||||||
|
"en": "F",
|
||||||
|
"de": "F"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "group",
|
||||||
|
"l11n": {
|
||||||
|
"en": "Group",
|
||||||
|
"de": "Gruppe"
|
||||||
|
},
|
||||||
|
"value_type": 1,
|
||||||
|
"is_custom_allowed": false,
|
||||||
|
"validation_pattern": "",
|
||||||
|
"is_required": true,
|
||||||
|
"default_value": "",
|
||||||
|
"values": [
|
||||||
|
{
|
||||||
|
"value": 1,
|
||||||
|
"l11n": {
|
||||||
|
"en": "Group 1",
|
||||||
|
"de": "Gruppe 1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "vat_id",
|
||||||
|
"l11n": {
|
||||||
|
"en": "VAT Id",
|
||||||
|
"de": "USt IdNr."
|
||||||
|
},
|
||||||
|
"value_type": 2,
|
||||||
|
"is_custom_allowed": true,
|
||||||
|
"validation_pattern": "",
|
||||||
|
"is_required": false,
|
||||||
|
"default_value": "",
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tax_id",
|
||||||
|
"l11n": {
|
||||||
|
"en": "Tax Id",
|
||||||
|
"de": "Steuernummer"
|
||||||
|
},
|
||||||
|
"value_type": 2,
|
||||||
|
"is_custom_allowed": true,
|
||||||
|
"validation_pattern": "",
|
||||||
|
"is_required": false,
|
||||||
|
"default_value": "",
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "legal_form",
|
||||||
|
"l11n": {
|
||||||
|
"en": "Legal form",
|
||||||
|
"de": "Rechtsform"
|
||||||
|
},
|
||||||
|
"value_type": 2,
|
||||||
|
"is_custom_allowed": true,
|
||||||
|
"validation_pattern": "",
|
||||||
|
"is_required": false,
|
||||||
|
"default_value": "",
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "credit_rating",
|
||||||
|
"l11n": {
|
||||||
|
"en": "Credit rating",
|
||||||
|
"de": "Bonität"
|
||||||
|
},
|
||||||
|
"value_type": 2,
|
||||||
|
"is_custom_allowed": true,
|
||||||
|
"validation_pattern": "",
|
||||||
|
"is_required": false,
|
||||||
|
"default_value": "",
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "line_of_credit",
|
||||||
|
"l11n": {
|
||||||
|
"en": "Line of credit",
|
||||||
|
"de": "Kreditlimit"
|
||||||
|
},
|
||||||
|
"value_type": 1,
|
||||||
|
"is_custom_allowed": true,
|
||||||
|
"validation_pattern": "",
|
||||||
|
"is_required": false,
|
||||||
|
"default_value": "",
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "order_limit",
|
||||||
|
"l11n": {
|
||||||
|
"en": "Order limit",
|
||||||
|
"de": "Bestelllimit"
|
||||||
|
},
|
||||||
|
"value_type": 1,
|
||||||
|
"is_custom_allowed": true,
|
||||||
|
"validation_pattern": "",
|
||||||
|
"is_required": false,
|
||||||
|
"default_value": "",
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "minimum_order",
|
||||||
|
"l11n": {
|
||||||
|
"en": "MOQ",
|
||||||
|
"de": "Mindestbestellmenge"
|
||||||
|
},
|
||||||
|
"value_type": 1,
|
||||||
|
"is_custom_allowed": true,
|
||||||
|
"validation_pattern": "",
|
||||||
|
"is_required": false,
|
||||||
|
"default_value": "",
|
||||||
|
"values": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -60,8 +60,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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -205,6 +205,27 @@
|
||||||
"type": "DATETIME",
|
"type": "DATETIME",
|
||||||
"null": true,
|
"null": true,
|
||||||
"default": null
|
"default": null
|
||||||
|
},
|
||||||
|
"clientmgmt_attr_value_unit": {
|
||||||
|
"name": "clientmgmt_attr_value_unit",
|
||||||
|
"type": "VARCHAR(255)",
|
||||||
|
"null": false
|
||||||
|
},
|
||||||
|
"clientmgmt_attr_value_deptype": {
|
||||||
|
"name": "clientmgmt_attr_value_deptype",
|
||||||
|
"type": "INT(11)",
|
||||||
|
"null": true,
|
||||||
|
"default": null,
|
||||||
|
"foreignTable": "clientmgmt_attr_type",
|
||||||
|
"foreignKey": "clientmgmt_attr_type_id"
|
||||||
|
},
|
||||||
|
"clientmgmt_attr_value_depvalue": {
|
||||||
|
"name": "clientmgmt_attr_value_depvalue",
|
||||||
|
"type": "INT(11)",
|
||||||
|
"null": true,
|
||||||
|
"default": null,
|
||||||
|
"foreignTable": "clientmgmt_attr_value",
|
||||||
|
"foreignKey": "clientmgmt_attr_value_id"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
3
Admin/Install/localizations.json
Normal file
3
Admin/Install/localizations.json
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
[
|
||||||
|
|
||||||
|
]
|
||||||
|
|
@ -14,7 +14,13 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\ClientManagement\Admin;
|
namespace Modules\ClientManagement\Admin;
|
||||||
|
|
||||||
|
use phpOMS\Application\ApplicationAbstract;
|
||||||
|
use phpOMS\Config\SettingsInterface;
|
||||||
|
use phpOMS\Message\Http\HttpRequest;
|
||||||
|
use phpOMS\Message\Http\HttpResponse;
|
||||||
use phpOMS\Module\InstallerAbstract;
|
use phpOMS\Module\InstallerAbstract;
|
||||||
|
use phpOMS\Module\ModuleInfo;
|
||||||
|
use phpOMS\Uri\HttpUri;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installer class.
|
* Installer class.
|
||||||
|
|
@ -33,4 +39,211 @@ final class Installer extends InstallerAbstract
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public const PATH = __DIR__;
|
public const PATH = __DIR__;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function install(ApplicationAbstract $app, ModuleInfo $info, SettingsInterface $cfgHandler) : void
|
||||||
|
{
|
||||||
|
parent::install($app, $info, $cfgHandler);
|
||||||
|
|
||||||
|
/* Attributes */
|
||||||
|
$fileContent = \file_get_contents(__DIR__ . '/Install/attributes.json');
|
||||||
|
if ($fileContent === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$attributes = \json_decode($fileContent, true);
|
||||||
|
$attrTypes = self::createClientAttributeTypes($app, $attributes);
|
||||||
|
$attrValues = self::createClientAttributeValues($app, $attrTypes, $attributes);
|
||||||
|
|
||||||
|
/* Localizations */
|
||||||
|
$fileContent = \file_get_contents(__DIR__ . '/Install/localizations.json');
|
||||||
|
if ($fileContent === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$localizations = \json_decode($fileContent, true);
|
||||||
|
$l11nTypes = self::createClientL11nTypes($app, $localizations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install default l11n types
|
||||||
|
*
|
||||||
|
* @param ApplicationAbstract $app Application
|
||||||
|
* @param array $l11ns Attribute definition
|
||||||
|
*
|
||||||
|
* @return array<array>
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private static function createClientL11nTypes(ApplicationAbstract $app, array $l11ns) : array
|
||||||
|
{
|
||||||
|
/** @var array<string, array> $l11nTypes */
|
||||||
|
$l11nTypes = [];
|
||||||
|
|
||||||
|
/** @var \Modules\ClientManagement\Controller\ApiController $module */
|
||||||
|
$module = $app->moduleManager->getModuleInstance('ClientManagement');
|
||||||
|
|
||||||
|
foreach ($l11ns as $l11n) {
|
||||||
|
$response = new HttpResponse();
|
||||||
|
$request = new HttpRequest(new HttpUri(''));
|
||||||
|
|
||||||
|
$request->header->account = 1;
|
||||||
|
$request->setData('title', $l11n['name']);
|
||||||
|
$request->setData('is_required', $l11n['is_required'] ?? false);
|
||||||
|
|
||||||
|
$module->apiClientL11nTypeCreate($request, $response);
|
||||||
|
|
||||||
|
$responseData = $response->get('');
|
||||||
|
if (!\is_array($responseData)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$l11nTypes[] = !\is_array($responseData['response'])
|
||||||
|
? $responseData['response']->toArray()
|
||||||
|
: $responseData['response'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $l11nTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install default attribute types
|
||||||
|
*
|
||||||
|
* @param ApplicationAbstract $app Application
|
||||||
|
* @param array<array{name:string, l11n?:array<string, string>, is_required?:bool, is_custom_allowed?:bool, validation_pattern?:string, value_type?:string, values?:array<string, mixed>}> $attributes Attribute definition
|
||||||
|
*
|
||||||
|
* @return array<string, array>
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private static function createClientAttributeTypes(ApplicationAbstract $app, array $attributes) : array
|
||||||
|
{
|
||||||
|
/** @var array<string, array> $clientAttrType */
|
||||||
|
$clientAttrType = [];
|
||||||
|
|
||||||
|
/** @var \Modules\ClientManagement\Controller\ApiController $module */
|
||||||
|
$module = $app->moduleManager->getModuleInstance('ClientManagement');
|
||||||
|
|
||||||
|
/** @var array $attribute */
|
||||||
|
foreach ($attributes as $attribute) {
|
||||||
|
$response = new HttpResponse();
|
||||||
|
$request = new HttpRequest(new HttpUri(''));
|
||||||
|
|
||||||
|
$request->header->account = 1;
|
||||||
|
$request->setData('name', $attribute['name'] ?? '');
|
||||||
|
$request->setData('title', \reset($attribute['l11n']));
|
||||||
|
$request->setData('language', \array_keys($attribute['l11n'])[0] ?? 'en');
|
||||||
|
$request->setData('is_required', $attribute['is_required'] ?? false);
|
||||||
|
$request->setData('is_custom_allowed', $attribute['is_custom_allowed'] ?? false);
|
||||||
|
$request->setData('validation_pattern', $attribute['validation_pattern'] ?? '');
|
||||||
|
$request->setData('datatype', (int) $attribute['value_type']);
|
||||||
|
|
||||||
|
$module->apiClientAttributeTypeCreate($request, $response);
|
||||||
|
|
||||||
|
$responseData = $response->get('');
|
||||||
|
if (!\is_array($responseData)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$clientAttrType[$attribute['name']] = !\is_array($responseData['response'])
|
||||||
|
? $responseData['response']->toArray()
|
||||||
|
: $responseData['response'];
|
||||||
|
|
||||||
|
$isFirst = true;
|
||||||
|
foreach ($attribute['l11n'] as $language => $l11n) {
|
||||||
|
if ($isFirst) {
|
||||||
|
$isFirst = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = new HttpResponse();
|
||||||
|
$request = new HttpRequest(new HttpUri(''));
|
||||||
|
|
||||||
|
$request->header->account = 1;
|
||||||
|
$request->setData('title', $l11n);
|
||||||
|
$request->setData('language', $language);
|
||||||
|
$request->setData('type', $clientAttrType[$attribute['name']]['id']);
|
||||||
|
|
||||||
|
$module->apiClientAttributeTypeL11nCreate($request, $response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $clientAttrType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create default attribute values for types
|
||||||
|
*
|
||||||
|
* @param ApplicationAbstract $app Application
|
||||||
|
* @param array $clientAttrType Attribute types
|
||||||
|
* @param array<array{name:string, l11n?:array<string, string>, is_required?:bool, is_custom_allowed?:bool, validation_pattern?:string, value_type?:string, values?:array<string, mixed>}> $attributes Attribute definition
|
||||||
|
*
|
||||||
|
* @return array<string, array>
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private static function createClientAttributeValues(ApplicationAbstract $app, array $clientAttrType, array $attributes) : array
|
||||||
|
{
|
||||||
|
/** @var array<string, array> $clientAttrValue */
|
||||||
|
$clientAttrValue = [];
|
||||||
|
|
||||||
|
/** @var \Modules\ClientManagement\Controller\ApiController $module */
|
||||||
|
$module = $app->moduleManager->getModuleInstance('ClientManagement');
|
||||||
|
|
||||||
|
foreach ($attributes as $attribute) {
|
||||||
|
$clientAttrValue[$attribute['name']] = [];
|
||||||
|
|
||||||
|
/** @var array $value */
|
||||||
|
foreach ($attribute['values'] as $value) {
|
||||||
|
$response = new HttpResponse();
|
||||||
|
$request = new HttpRequest(new HttpUri(''));
|
||||||
|
|
||||||
|
$request->header->account = 1;
|
||||||
|
$request->setData('value', $value['value'] ?? '');
|
||||||
|
$request->setData('unit', $value['unit'] ?? '');
|
||||||
|
$request->setData('default', isset($attribute['values']) && !empty($attribute['values']));
|
||||||
|
$request->setData('attributetype', $clientAttrType[$attribute['name']]['id']);
|
||||||
|
|
||||||
|
if (isset($value['l11n']) && !empty($value['l11n'])) {
|
||||||
|
$request->setData('title', \reset($value['l11n']));
|
||||||
|
$request->setData('language', \array_keys($value['l11n'])[0] ?? 'en');
|
||||||
|
}
|
||||||
|
|
||||||
|
$module->apiClientAttributeValueCreate($request, $response);
|
||||||
|
|
||||||
|
$responseData = $response->get('');
|
||||||
|
if (!\is_array($responseData)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$attrValue = !\is_array($responseData['response'])
|
||||||
|
? $responseData['response']->toArray()
|
||||||
|
: $responseData['response'];
|
||||||
|
|
||||||
|
$clientAttrValue[$attribute['name']][] = $attrValue;
|
||||||
|
|
||||||
|
$isFirst = true;
|
||||||
|
foreach (($value['l11n'] ?? []) as $language => $l11n) {
|
||||||
|
if ($isFirst) {
|
||||||
|
$isFirst = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = new HttpResponse();
|
||||||
|
$request = new HttpRequest(new HttpUri(''));
|
||||||
|
|
||||||
|
$request->header->account = 1;
|
||||||
|
$request->setData('title', $l11n);
|
||||||
|
$request->setData('language', $language);
|
||||||
|
$request->setData('value', $attrValue['id']);
|
||||||
|
|
||||||
|
$module->apiClientAttributeValueL11nCreate($request, $response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $clientAttrValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,28 @@ use phpOMS\Account\PermissionType;
|
||||||
use phpOMS\Router\RouteVerb;
|
use phpOMS\Router\RouteVerb;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
'^.*/sales/client/attribute/type/list.*$' => [
|
||||||
|
[
|
||||||
|
'dest' => '\Modules\ClientManagement\Controller\BackendController:viewClientManagementAttributeTypeList',
|
||||||
|
'verb' => RouteVerb::GET,
|
||||||
|
'permission' => [
|
||||||
|
'module' => BackendController::NAME,
|
||||||
|
'type' => PermissionType::READ,
|
||||||
|
'state' => PermissionCategory::CLIENT,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'^.*/sales/client/attribute/type\?.*$' => [
|
||||||
|
[
|
||||||
|
'dest' => '\Modules\ClientManagement\Controller\BackendController:viewClientManagementAttributeType',
|
||||||
|
'verb' => RouteVerb::GET,
|
||||||
|
'permission' => [
|
||||||
|
'module' => BackendController::NAME,
|
||||||
|
'type' => PermissionType::READ,
|
||||||
|
'state' => PermissionCategory::CLIENT,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
'^.*/sales/client/list.*$' => [
|
'^.*/sales/client/list.*$' => [
|
||||||
[
|
[
|
||||||
'dest' => '\Modules\ClientManagement\Controller\BackendController:viewClientManagementClientList',
|
'dest' => '\Modules\ClientManagement\Controller\BackendController:viewClientManagementClientList',
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ declare(strict_types=1);
|
||||||
namespace Modules\ClientManagement\Controller;
|
namespace Modules\ClientManagement\Controller;
|
||||||
|
|
||||||
use Modules\Billing\Models\SalesBillMapper;
|
use Modules\Billing\Models\SalesBillMapper;
|
||||||
|
use Modules\ClientManagement\Models\ClientAttributeTypeMapper;
|
||||||
|
use Modules\ClientManagement\Models\ClientAttributeValueMapper;
|
||||||
use Modules\ClientManagement\Models\ClientMapper;
|
use Modules\ClientManagement\Models\ClientMapper;
|
||||||
use phpOMS\Asset\AssetType;
|
use phpOMS\Asset\AssetType;
|
||||||
use phpOMS\Contract\RenderableInterface;
|
use phpOMS\Contract\RenderableInterface;
|
||||||
|
|
@ -38,6 +40,94 @@ use phpOMS\Views\View;
|
||||||
*/
|
*/
|
||||||
final class BackendController extends Controller
|
final class BackendController extends Controller
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Routing end-point for application behaviour.
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param ResponseAbstract $response Response
|
||||||
|
* @param mixed $data Generic data
|
||||||
|
*
|
||||||
|
* @return RenderableInterface
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function viewClientManagementAttributeTypeList(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
|
||||||
|
{
|
||||||
|
$view = new View($this->app->l11nManager, $request, $response);
|
||||||
|
$view->setTemplate('/Modules/ClientManagement/Theme/Backend/attribute-type-list');
|
||||||
|
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response));
|
||||||
|
|
||||||
|
/** @var \Modules\ClientManagement\Models\ClientAttributeType[] $attributes */
|
||||||
|
$attributes = ClientAttributeTypeMapper::getAll()
|
||||||
|
->with('l11n')
|
||||||
|
->where('l11n/language', $response->getLanguage())
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$view->addData('attributes', $attributes);
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Routing end-point for application behaviour.
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param ResponseAbstract $response Response
|
||||||
|
* @param mixed $data Generic data
|
||||||
|
*
|
||||||
|
* @return RenderableInterface
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function viewClientManagementAttributeValues(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
|
||||||
|
{
|
||||||
|
$view = new View($this->app->l11nManager, $request, $response);
|
||||||
|
$view->setTemplate('/Modules/ClientManagement/Theme/Backend/attribute-value-list');
|
||||||
|
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response));
|
||||||
|
|
||||||
|
/** @var \Modules\ClientManagement\Models\ClientAttributeValue[] $attributes */
|
||||||
|
$attributes = ClientAttributeValueMapper::getAll()
|
||||||
|
->with('l11n')
|
||||||
|
->where('l11n/language', $response->getLanguage())
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$view->addData('attributes', $attributes);
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Routing end-point for application behaviour.
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param ResponseAbstract $response Response
|
||||||
|
* @param mixed $data Generic data
|
||||||
|
*
|
||||||
|
* @return RenderableInterface
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function viewClientManagementAttributeType(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
|
||||||
|
{
|
||||||
|
$view = new View($this->app->l11nManager, $request, $response);
|
||||||
|
$view->setTemplate('/Modules/ClientManagement/Theme/Backend/attribute-type');
|
||||||
|
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response));
|
||||||
|
|
||||||
|
/** @var \Modules\ClientManagement\Models\ClientAttributeType $attribute */
|
||||||
|
$attribute = ClientAttributeTypeMapper::get()
|
||||||
|
->with('l11n')
|
||||||
|
->where('id', (int) $request->getData('id'))
|
||||||
|
->where('l11n/language', $response->getLanguage())
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$view->addData('attribute', $attribute);
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Routing end-point for application behaviour.
|
* Routing end-point for application behaviour.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ final class ClientAttributeTypeMapper extends DataMapperFactory
|
||||||
'mapper' => ClientAttributeTypeL11nMapper::class,
|
'mapper' => ClientAttributeTypeL11nMapper::class,
|
||||||
'table' => 'clientmgmt_attr_type_l11n',
|
'table' => 'clientmgmt_attr_type_l11n',
|
||||||
'self' => 'clientmgmt_attr_type_l11n_type',
|
'self' => 'clientmgmt_attr_type_l11n_type',
|
||||||
'column' => 'title',
|
'column' => 'content',
|
||||||
'external' => null,
|
'external' => null,
|
||||||
],
|
],
|
||||||
'defaults' => [
|
'defaults' => [
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,22 @@ class ClientAttributeValue implements \JsonSerializable
|
||||||
*/
|
*/
|
||||||
protected int $id = 0;
|
protected int $id = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Depending attribute type
|
||||||
|
*
|
||||||
|
* @var null|int
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public ?int $dependingAttributeType = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Depending attribute value
|
||||||
|
*
|
||||||
|
* @var null|int
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public ?int $dependingAttributeValue = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Int value
|
* Int value
|
||||||
*
|
*
|
||||||
|
|
@ -77,6 +93,14 @@ class ClientAttributeValue implements \JsonSerializable
|
||||||
*/
|
*/
|
||||||
public bool $isDefault = false;
|
public bool $isDefault = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit of the value
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public string $unit = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Localization
|
* Localization
|
||||||
*
|
*
|
||||||
|
|
@ -146,7 +170,10 @@ class ClientAttributeValue implements \JsonSerializable
|
||||||
{
|
{
|
||||||
if ($datatype === AttributeValueType::_STRING) {
|
if ($datatype === AttributeValueType::_STRING) {
|
||||||
$this->valueStr = (string) $value;
|
$this->valueStr = (string) $value;
|
||||||
} elseif ($datatype === AttributeValueType::_INT) {
|
} elseif ($datatype === AttributeValueType::_INT
|
||||||
|
|| $datatype === AttributeValueType::_FLOAT_INT
|
||||||
|
|| $datatype === AttributeValueType::_BOOL
|
||||||
|
) {
|
||||||
$this->valueInt = (int) $value;
|
$this->valueInt = (int) $value;
|
||||||
} elseif ($datatype === AttributeValueType::_FLOAT) {
|
} elseif ($datatype === AttributeValueType::_FLOAT) {
|
||||||
$this->valueDec = (float) $value;
|
$this->valueDec = (float) $value;
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,9 @@ final class ClientAttributeValueMapper extends DataMapperFactory
|
||||||
'clientmgmt_attr_value_valueInt' => ['name' => 'clientmgmt_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'],
|
'clientmgmt_attr_value_valueInt' => ['name' => 'clientmgmt_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'],
|
||||||
'clientmgmt_attr_value_valueDec' => ['name' => 'clientmgmt_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'],
|
'clientmgmt_attr_value_valueDec' => ['name' => 'clientmgmt_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'],
|
||||||
'clientmgmt_attr_value_valueDat' => ['name' => 'clientmgmt_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'],
|
'clientmgmt_attr_value_valueDat' => ['name' => 'clientmgmt_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'],
|
||||||
|
'clientmgmt_attr_value_unit' => ['name' => 'clientmgmt_attr_value_unit', 'type' => 'string', 'internal' => 'unit'],
|
||||||
|
'clientmgmt_attr_value_deptype' => ['name' => 'clientmgmt_attr_value_deptype', 'type' => 'int', 'internal' => 'dependingAttributeType'],
|
||||||
|
'clientmgmt_attr_value_depvalue' => ['name' => 'clientmgmt_attr_value_depvalue', 'type' => 'int', 'internal' => 'dependingAttributeValue'],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -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