From 8dab18e60c2d94cb03329657a6818195961b3267 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 11 Mar 2023 23:38:19 +0100 Subject: [PATCH] too many changes --- Admin/Install/attributes.json | 54 +++ Admin/Installer.php | 153 +++++++ Admin/Routes/Web/Api.php | 12 + Controller/ApiController.php | 508 +++++++++++++++++++++++- Controller/BackendController.php | 1 + Models/AttributeValueType.php | 40 ++ Models/DepartmentMapper.php | 2 +- Models/NullUnitAttribute.php | 47 +++ Models/NullUnitAttributeType.php | 46 +++ Models/NullUnitAttributeValue.php | 46 +++ Models/PositionMapper.php | 2 +- Models/Unit.php | 74 +++- Models/UnitAttribute.php | 102 +++++ Models/UnitAttributeMapper.php | 74 ++++ Models/UnitAttributeType.php | 216 ++++++++++ Models/UnitAttributeTypeL11nMapper.php | 66 +++ Models/UnitAttributeTypeMapper.php | 82 ++++ Models/UnitAttributeValue.php | 230 +++++++++++ Models/UnitAttributeValueL11nMapper.php | 66 +++ Models/UnitAttributeValueMapper.php | 77 ++++ Models/UnitMapper.php | 30 +- Theme/Backend/Lang/en.lang.php | 6 + Theme/Backend/unit-create.tpl.php | 88 +++- Theme/Backend/unit-profile.tpl.php | 101 ++++- composer.json | 2 +- info.json | 2 +- 26 files changed, 2082 insertions(+), 45 deletions(-) create mode 100644 Admin/Install/attributes.json create mode 100755 Models/AttributeValueType.php create mode 100755 Models/NullUnitAttribute.php create mode 100755 Models/NullUnitAttributeType.php create mode 100755 Models/NullUnitAttributeValue.php create mode 100755 Models/UnitAttribute.php create mode 100755 Models/UnitAttributeMapper.php create mode 100755 Models/UnitAttributeType.php create mode 100755 Models/UnitAttributeTypeL11nMapper.php create mode 100755 Models/UnitAttributeTypeMapper.php create mode 100755 Models/UnitAttributeValue.php create mode 100755 Models/UnitAttributeValueL11nMapper.php create mode 100755 Models/UnitAttributeValueMapper.php diff --git a/Admin/Install/attributes.json b/Admin/Install/attributes.json new file mode 100644 index 0000000..9b981b4 --- /dev/null +++ b/Admin/Install/attributes.json @@ -0,0 +1,54 @@ +[ + { + "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": "registration_id", + "l11n": { + "en": "Registration Id", + "de": "Registrationsnummer" + }, + "value_type": 2, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + } +] \ No newline at end of file diff --git a/Admin/Installer.php b/Admin/Installer.php index 1c5efec..afeae49 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -18,8 +18,11 @@ use Modules\Organization\Models\Unit; use Modules\Organization\Models\UnitMapper; 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\ModuleInfo; +use phpOMS\Uri\HttpUri; /** * Installer class. @@ -47,6 +50,156 @@ final class Installer extends InstallerAbstract parent::install($app, $info, $cfgHandler); self::installDefaultUnit(); + + /* Attributes */ + $fileContent = \file_get_contents(__DIR__ . '/Install/attributes.json'); + if ($fileContent === false) { + return; + } + + $attributes = \json_decode($fileContent, true); + $attrTypes = self::createUnitAttributeTypes($app, $attributes); + $attrValues = self::createUnitAttributeValues($app, $attrTypes, $attributes); + } + + /** + * Install default attribute types + * + * @param ApplicationAbstract $app Application + * @param array, is_required?:bool, is_custom_allowed?:bool, validation_pattern?:string, value_type?:string, values?:array}> $attributes Attribute definition + * + * @return array + * + * @since 1.0.0 + */ + private static function createUnitAttributeTypes(ApplicationAbstract $app, array $attributes) : array + { + /** @var array $unitAttrType */ + $unitAttrType = []; + + /** @var \Modules\Organization\Controller\ApiController $module */ + $module = $app->moduleManager->getModuleInstance('Organization'); + + /** @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->apiUnitAttributeTypeCreate($request, $response); + + $responseData = $response->get(''); + + if (!\is_array($responseData)) { + continue; + } + + $unitAttrType[$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', $unitAttrType[$attribute['name']]['id']); + + $module->apiUnitAttributeTypeL11nCreate($request, $response); + } + } + + return $unitAttrType; + } + + /** + * Create default attribute values for types + * + * @param ApplicationAbstract $app Application + * @param array $unitAttrType Attribute types + * @param array, is_required?:bool, is_custom_allowed?:bool, validation_pattern?:string, value_type?:string, values?:array}> $attributes Attribute definition + * + * @return array + * + * @since 1.0.0 + */ + private static function createUnitAttributeValues(ApplicationAbstract $app, array $unitAttrType, array $attributes) : array + { + /** @var array $unitAttrValue */ + $unitAttrValue = []; + + /** @var \Modules\Organization\Controller\ApiController $module */ + $module = $app->moduleManager->getModuleInstance('Organization'); + + foreach ($attributes as $attribute) { + $unitAttrValue[$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', true); // always true since all defined values are possible default values + $request->setData('type', $unitAttrType[$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->apiUnitAttributeValueCreate($request, $response); + + $responseData = $response->get(''); + if (!\is_array($responseData)) { + continue; + } + + $attrValue = !\is_array($responseData['response']) + ? $responseData['response']->toArray() + : $responseData['response']; + + $unitAttrValue[$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->apiUnitAttributeValueL11nCreate($request, $response); + } + } + } + + return $unitAttrValue; } /** diff --git a/Admin/Routes/Web/Api.php b/Admin/Routes/Web/Api.php index c7d573a..9edbb18 100755 --- a/Admin/Routes/Web/Api.php +++ b/Admin/Routes/Web/Api.php @@ -133,6 +133,18 @@ return [ ], ], + '^.*/organization/unit/address/main(\?.*|$)' => [ + [ + 'dest' => '\Modules\Organization\Controller\ApiController:apiUnitMainAddressSet', + 'verb' => RouteVerb::SET, + 'permission' => [ + 'module' => ApiController::NAME, + 'type' => PermissionType::MODIFY, + 'state' => PermissionCategory::UNIT, + ], + ], + ], + '^.*/organization/unit/image(\?.*|$)' => [ [ 'dest' => '\Modules\Organization\Controller\ApiController:apiUnitImageSet', diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 7ecc6fc..f787c04 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -16,6 +16,9 @@ namespace Modules\Organization\Controller; use Model\Setting; use Model\SettingMapper; +use Modules\Admin\Models\Address; +use Modules\Admin\Models\AddressMapper; +use Modules\Admin\Models\NullAddress; use Modules\Admin\Models\SettingsEnum as ModelsSettingsEnum; use Modules\Media\Models\PathSettings; use Modules\Organization\Models\Department; @@ -23,13 +26,26 @@ use Modules\Organization\Models\DepartmentMapper; use Modules\Organization\Models\NullDepartment; use Modules\Organization\Models\NullPosition; use Modules\Organization\Models\NullUnit; +use Modules\Organization\Models\NullUnitAttributeType; +use Modules\Organization\Models\NullUnitAttributeValue; use Modules\Organization\Models\Position; use Modules\Organization\Models\PositionMapper; use Modules\Organization\Models\SettingsEnum; use Modules\Organization\Models\Status; use Modules\Organization\Models\Unit; +use Modules\Organization\Models\UnitAttribute; +use Modules\Organization\Models\UnitAttributeMapper; +use Modules\Organization\Models\UnitAttributeType; +use Modules\Organization\Models\UnitAttributeTypeL11nMapper; +use Modules\Organization\Models\UnitAttributeTypeMapper; +use Modules\Organization\Models\UnitAttributeValue; +use Modules\Organization\Models\UnitAttributeValueL11nMapper; +use Modules\Organization\Models\UnitAttributeValueMapper; use Modules\Organization\Models\UnitMapper; use phpOMS\Account\GroupStatus; +use phpOMS\Localization\BaseStringL11n; +use phpOMS\Localization\ISO3166TwoEnum; +use phpOMS\Localization\ISO639x1Enum; use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpResponse; use phpOMS\Message\Http\RequestStatusCode; @@ -215,12 +231,118 @@ final class ApiController extends Controller module: 'Admin' ); $this->createModel($request->header->account, $setting, SettingMapper::class, 'setting', $request->getOrigin()); - } $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Unit', 'Unit successfully created.', $unit); } + /** + * Api method to create a unit + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiUnitMainAddressSet(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void + { + if (!empty($val = $this->validateUnitMainAddressSet($request))) { + $response->set('unit_address_set', new FormValidation($val)); + $response->header->status = RequestStatusCode::R_400; + + return; + } + + /** @var Unit $unit */ + $unit = UnitMapper::get()->with('mainAddress')->where('id', $request->getData('unit'))->execute(); + $oldUnit = clone $unit; + + if ($unit->mainAddress->getId() !== 0) { + $oldAddr = clone $unit->mainAddress; + $addr = $this->updateUnitMainAddressFromRequest($request, $unit); + $this->updateModel($request->header->account, $oldAddr, $addr, AddressMapper::class, 'address', $request->getOrigin()); + + } else { + $addr = $this->createUnitMainAddressFromRequest($request); + $this->createModel($request->header->account, $addr, AddressMapper::class, 'address', $request->getOrigin()); + + $unit->mainAddress = new NullAddress($addr->getId()); + $this->updateModel($request->header->account, $oldUnit, $unit, UnitMapper::class, 'unit', $request->getOrigin()); + } + + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Address', 'Address successfully set.', $unit); + } + + /** + * Validate unit create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateUnitMainAddressSet(RequestAbstract $request) : array + { + $val = []; + if (($val['unit'] = empty($request->getData('unit'))) + || ($val['address'] = empty($request->getData('address'))) + ) { + return $val; + } + + return []; + } + + /** + * Method to create unit from request. + * + * @param RequestAbstract $request Request + * + * @return Address + * + * @since 1.0.0 + */ + private function createUnitMainAddressFromRequest(RequestAbstract $request) : Address + { + $addr = new Address(); + $addr->name = (string) ($request->getData('legal') ?? ''); + $addr->address = (string) ($request->getData('address') ?? ''); + $addr->postal = (string) ($request->getData('postal') ?? ''); + $addr->city = (string) ($request->getData('city') ?? ''); + $addr->setCountry($request->getData('country') ?? ISO3166TwoEnum::_XXX); + $addr->state = (string) ($request->getData('state') ?? ''); + + return $addr; + } + + /** + * Method to create unit from request. + * + * @param RequestAbstract $request Request + * + * @return Address + * + * @since 1.0.0 + */ + private function updateUnitMainAddressFromRequest(RequestAbstract $request, Unit $unit) : Address + { + $addr = $unit->mainAddress; + $addr->name = (string) ($request->getData('legal') ?? ''); + $addr->address = (string) ($request->getData('address') ?? ''); + $addr->postal = (string) ($request->getData('postal') ?? ''); + $addr->city = (string) ($request->getData('city') ?? ''); + $addr->setCountry($request->getData('country') ?? ISO3166TwoEnum::_XXX); + $addr->state = (string) ($request->getData('state') ?? ''); + + return $addr; + } + /** * Method to create unit from request. * @@ -240,6 +362,17 @@ final class ApiController extends Controller $unit->parent = new NullUnit((int) $request->getData('parent')); $unit->setStatus((int) $request->getData('status')); + if ($request->hasData('address')) { + $addr = new Address(); + $addr->name = (string) ($request->getData('legal') ?? ($request->getData('name') ?? '')); + $addr->address = (string) ($request->getData('address') ?? ''); + $addr->postal = (string) ($request->getData('postal') ?? ''); + $addr->city = (string) ($request->getData('city') ?? ''); + $addr->setCountry($request->getData('country') ?? ISO3166TwoEnum::_XXX); + $addr->state = (string) ($request->getData('state') ?? ''); + $unit->mainAddress = $addr; + } + return $unit; } @@ -712,4 +845,377 @@ final class ApiController extends Controller ) ); } + + /** + * Api method to create item attribute + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiUnitAttributeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void + { + if (!empty($val = $this->validateUnitAttributeCreate($request))) { + $response->set('attribute_create', new FormValidation($val)); + $response->header->status = RequestStatusCode::R_400; + + return; + } + + $attribute = $this->createUnitAttributeFromRequest($request); + $this->createModel($request->header->account, $attribute, UnitAttributeMapper::class, 'attribute', $request->getOrigin()); + + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute', 'Attribute successfully created', $attribute); + } + + /** + * Method to create item attribute from request. + * + * @param RequestAbstract $request Request + * + * @return UnitAttribute + * + * @since 1.0.0 + */ + private function createUnitAttributeFromRequest(RequestAbstract $request) : UnitAttribute + { + $attribute = new UnitAttribute(); + $attribute->unit = (int) $request->getData('unit'); + $attribute->type = new NullUnitAttributeType((int) $request->getData('type')); + + if ($request->getData('value') !== null) { + $attribute->value = new NullUnitAttributeValue((int) $request->getData('value')); + } else { + $newRequest = clone $request; + $newRequest->setData('value', $request->getData('custom'), true); + + $value = $this->createUnitAttributeValueFromRequest($newRequest); + + $attribute->value = $value; + } + + return $attribute; + } + + /** + * Validate unit attribute create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateUnitAttributeCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['type'] = empty($request->getData('type'))) + || ($val['value'] = (empty($request->getData('value')) && empty($request->getData('custom')))) + || ($val['unit'] = empty($request->getData('unit'))) + ) { + return $val; + } + + return []; + } + + /** + * Api method to create unit attribute l11n + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiUnitAttributeTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void + { + if (!empty($val = $this->validateUnitAttributeTypeL11nCreate($request))) { + $response->set('attr_type_l11n_create', new FormValidation($val)); + $response->header->status = RequestStatusCode::R_400; + + return; + } + + $attrL11n = $this->createUnitAttributeTypeL11nFromRequest($request); + $this->createModel($request->header->account, $attrL11n, UnitAttributeTypeL11nMapper::class, 'attr_type_l11n', $request->getOrigin()); + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Localization', 'Localization successfully created', $attrL11n); + } + + /** + * Method to create unit attribute l11n from request. + * + * @param RequestAbstract $request Request + * + * @return BaseStringL11n + * + * @since 1.0.0 + */ + private function createUnitAttributeTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n + { + $attrL11n = new BaseStringL11n(); + $attrL11n->ref = (int) ($request->getData('type') ?? 0); + $attrL11n->setLanguage((string) ( + $request->getData('language') ?? $request->getLanguage() + )); + $attrL11n->content = (string) ($request->getData('title') ?? ''); + + return $attrL11n; + } + + /** + * Validate unit attribute l11n create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateUnitAttributeTypeL11nCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['title'] = empty($request->getData('title'))) + || ($val['type'] = empty($request->getData('type'))) + ) { + return $val; + } + + return []; + } + + /** + * Api method to create unit attribute type + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiUnitAttributeTypeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void + { + if (!empty($val = $this->validateUnitAttributeTypeCreate($request))) { + $response->set('attr_type_create', new FormValidation($val)); + $response->header->status = RequestStatusCode::R_400; + + return; + } + + $attrType = $this->createUnitAttributeTypeFromRequest($request); + $this->createModel($request->header->account, $attrType, UnitAttributeTypeMapper::class, 'attr_type', $request->getOrigin()); + + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute type', 'Attribute type successfully created', $attrType); + } + + /** + * Method to create unit attribute from request. + * + * @param RequestAbstract $request Request + * + * @return UnitAttributeType + * + * @since 1.0.0 + */ + private function createUnitAttributeTypeFromRequest(RequestAbstract $request) : UnitAttributeType + { + $attrType = new UnitAttributeType($request->getData('name') ?? ''); + $attrType->datatype = (int) ($request->getData('datatype') ?? 0); + $attrType->custom = (bool) ($request->getData('custom') ?? false); + $attrType->isRequired = (bool) ($request->getData('is_required') ?? false); + $attrType->validationPattern = (string) ($request->getData('validation_pattern') ?? ''); + $attrType->setL11n((string) ($request->getData('title') ?? ''), $request->getData('language') ?? ISO639x1Enum::_EN); + $attrType->setFields((int) ($request->getData('fields') ?? 0)); + + return $attrType; + } + + /** + * Validate unit attribute create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateUnitAttributeTypeCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['title'] = empty($request->getData('title'))) + || ($val['name'] = empty($request->getData('name'))) + ) { + return $val; + } + + return []; + } + + /** + * Api method to create unit attribute value + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiUnitAttributeValueCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void + { + if (!empty($val = $this->validateUnitAttributeValueCreate($request))) { + $response->set('attr_value_create', new FormValidation($val)); + $response->header->status = RequestStatusCode::R_400; + + return; + } + + $attrValue = $this->createUnitAttributeValueFromRequest($request); + $this->createModel($request->header->account, $attrValue, UnitAttributeValueMapper::class, 'attr_value', $request->getOrigin()); + + if ($attrValue->isDefault) { + $this->createModelRelation( + $request->header->account, + (int) $request->getData('type'), + $attrValue->getId(), + UnitAttributeTypeMapper::class, 'defaults', '', $request->getOrigin() + ); + } + + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute value', 'Attribute value successfully created', $attrValue); + } + + /** + * Method to create unit attribute value from request. + * + * @param RequestAbstract $request Request + * + * @return UnitAttributeValue + * + * @since 1.0.0 + */ + private function createUnitAttributeValueFromRequest(RequestAbstract $request) : UnitAttributeValue + { + /** @var UnitAttributeType $type */ + $type = UnitAttributeTypeMapper::get() + ->where('id', (int) ($request->getData('type') ?? 0)) + ->execute(); + + $attrValue = new UnitAttributeValue(); + $attrValue->isDefault = (bool) ($request->getData('default') ?? false); + $attrValue->setValue($request->getData('value'), $type->datatype); + + if ($request->getData('title') !== null) { + $attrValue->setL11n($request->getData('title'), $request->getData('language') ?? ISO639x1Enum::_EN); + } + + return $attrValue; + } + + /** + * Validate unit attribute value create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateUnitAttributeValueCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['type'] = empty($request->getData('type'))) + || ($val['value'] = empty($request->getData('value'))) + ) { + return $val; + } + + return []; + } + + /** + * Api method to create unit attribute l11n + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiUnitAttributeValueL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void + { + if (!empty($val = $this->validateUnitAttributeValueL11nCreate($request))) { + $response->set('attr_value_l11n_create', new FormValidation($val)); + $response->header->status = RequestStatusCode::R_400; + + return; + } + + $attrL11n = $this->createUnitAttributeValueL11nFromRequest($request); + $this->createModel($request->header->account, $attrL11n, UnitAttributeValueL11nMapper::class, 'attr_value_l11n', $request->getOrigin()); + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Localization', 'Localization successfully created', $attrL11n); + } + + /** + * Method to create unit attribute l11n from request. + * + * @param RequestAbstract $request Request + * + * @return BaseStringL11n + * + * @since 1.0.0 + */ + private function createUnitAttributeValueL11nFromRequest(RequestAbstract $request) : BaseStringL11n + { + $attrL11n = new BaseStringL11n(); + $attrL11n->ref = (int) ($request->getData('value') ?? 0); + $attrL11n->setLanguage((string) ( + $request->getData('language') ?? $request->getLanguage() + )); + $attrL11n->content = (string) ($request->getData('title') ?? ''); + + return $attrL11n; + } + + /** + * Validate unit attribute l11n create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateUnitAttributeValueL11nCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['title'] = empty($request->getData('title'))) + || ($val['value'] = empty($request->getData('value'))) + ) { + return $val; + } + + return []; + } } diff --git a/Controller/BackendController.php b/Controller/BackendController.php index bd216a1..b6ba980 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -96,6 +96,7 @@ final class BackendController extends Controller $unit = UnitMapper::get() ->with('parent') + ->with('mainAddress') ->with('image') ->where('id', (int) $request->getData('id')) ->execute(); diff --git a/Models/AttributeValueType.php b/Models/AttributeValueType.php new file mode 100755 index 0000000..d300f2b --- /dev/null +++ b/Models/AttributeValueType.php @@ -0,0 +1,40 @@ +id = $id; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() : mixed + { + return ['id' => $this->id]; + } +} diff --git a/Models/NullUnitAttributeType.php b/Models/NullUnitAttributeType.php new file mode 100755 index 0000000..e7c5656 --- /dev/null +++ b/Models/NullUnitAttributeType.php @@ -0,0 +1,46 @@ +id = $id; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() : mixed + { + return ['id' => $this->id]; + } +} diff --git a/Models/NullUnitAttributeValue.php b/Models/NullUnitAttributeValue.php new file mode 100755 index 0000000..52239b6 --- /dev/null +++ b/Models/NullUnitAttributeValue.php @@ -0,0 +1,46 @@ +id = $id; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() : mixed + { + return ['id' => $this->id]; + } +} diff --git a/Models/PositionMapper.php b/Models/PositionMapper.php index c24710d..ae546c5 100755 --- a/Models/PositionMapper.php +++ b/Models/PositionMapper.php @@ -81,5 +81,5 @@ final class PositionMapper extends DataMapperFactory * @var string * @since 1.0.0 */ - public const PRIMARYFIELD ='organization_position_id'; + public const PRIMARYFIELD = 'organization_position_id'; } diff --git a/Models/Unit.php b/Models/Unit.php index 8a8dff7..057d889 100755 --- a/Models/Unit.php +++ b/Models/Unit.php @@ -14,9 +14,10 @@ declare(strict_types=1); namespace Modules\Organization\Models; +use Modules\Admin\Models\Address; +use Modules\Admin\Models\NullAddress; use Modules\Media\Models\Media; use Modules\Media\Models\NullMedia; - /** * Organization unit class. * @@ -83,6 +84,18 @@ class Unit implements \JsonSerializable */ protected int $status = Status::INACTIVE; + public Address $mainAddress; + + private array $address = []; + + /** + * Attributes. + * + * @var UnitAttribute[] + * @since 1.0.0 + */ + private array $attributes = []; + /** * Constructor. * @@ -92,6 +105,7 @@ class Unit implements \JsonSerializable { $this->image = new NullMedia(); $this->parent = new NullUnit(); + $this->mainAddress = new NullAddress(); } /** @@ -106,6 +120,52 @@ class Unit implements \JsonSerializable return $this->id; } + /** + * Add attribute to client + * + * @param UnitAttribute $attribute Attribute + * + * @return void + * + * @since 1.0.0 + */ + public function addAttribute(UnitAttribute $attribute) : void + { + $this->attributes[] = $attribute; + } + + /** + * Get attributes + * + * @return UnitAttribute[] + * + * @since 1.0.0 + */ + public function getAttributes() : array + { + return $this->attributes; + } + + /** + * Get attribute + * + * @param string $attrName Attribute name + * + * @return null|UnitAttribute + * + * @since 1.0.0 + */ + public function getAttribute(string $attrName) : ?UnitAttribute + { + foreach ($this->attributes as $attribute) { + if ($attribute->type->name === $attrName) { + return $attribute->value; + } + } + + return null; + } + /** * Get status * @@ -132,6 +192,18 @@ class Unit implements \JsonSerializable $this->status = $status; } + /** + * Get addresses. + * + * @return array + * + * @since 1.0.0 + */ + public function getAddresses() : array + { + return $this->address; + } + /** * {@inheritdoc} */ diff --git a/Models/UnitAttribute.php b/Models/UnitAttribute.php new file mode 100755 index 0000000..e5b91c3 --- /dev/null +++ b/Models/UnitAttribute.php @@ -0,0 +1,102 @@ +type = new NullUnitAttributeType(); + $this->value = new NullUnitAttributeValue(); + } + + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ + public function getId() : int + { + return $this->id; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return [ + 'id' => $this->id, + 'unit' => $this->unit, + 'type' => $this->type, + 'value' => $this->value, + ]; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() : mixed + { + return $this->toArray(); + } +} diff --git a/Models/UnitAttributeMapper.php b/Models/UnitAttributeMapper.php new file mode 100755 index 0000000..10bf132 --- /dev/null +++ b/Models/UnitAttributeMapper.php @@ -0,0 +1,74 @@ + + * @since 1.0.0 + */ + public const COLUMNS = [ + 'unit_attr_id' => ['name' => 'unit_attr_id', 'type' => 'int', 'internal' => 'id'], + 'unit_attr_unit' => ['name' => 'unit_attr_unit', 'type' => 'int', 'internal' => 'unit'], + 'unit_attr_type' => ['name' => 'unit_attr_type', 'type' => 'int', 'internal' => 'type'], + 'unit_attr_value' => ['name' => 'unit_attr_value', 'type' => 'int', 'internal' => 'value'], + ]; + + /** + * Has one relation. + * + * @var array + * @since 1.0.0 + */ + public const OWNS_ONE = [ + 'type' => [ + 'mapper' => UnitAttributeTypeMapper::class, + 'external' => 'unit_attr_type', + ], + 'value' => [ + 'mapper' => UnitAttributeValueMapper::class, + 'external' => 'unit_attr_value', + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'unit_attr'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'unit_attr_id'; +} diff --git a/Models/UnitAttributeType.php b/Models/UnitAttributeType.php new file mode 100755 index 0000000..b3eb6a1 --- /dev/null +++ b/Models/UnitAttributeType.php @@ -0,0 +1,216 @@ +name = $name; + } + + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ + public function getId() : int + { + return $this->id; + } + + public function getDefaultByValue(mixed $value) : UnitAttributeValue + { + foreach ($this->defaults as $default) { + if ($default->getValue() === $value) { + return $default; + } + } + + return new NullUnitAttributeValue(); + } + + /** + * Set l11n + * + * @param string|BaseStringL11n $l11n Tag article l11n + * @param string $lang Language + * + * @return void + * + * @since 1.0.0 + */ + public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void + { + if ($l11n instanceof BaseStringL11n) { + $this->l11n = $l11n; + } elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) { + $this->l11n->content = $l11n; + $this->l11n->setLanguage($lang); + } else { + $this->l11n = new BaseStringL11n(); + $this->l11n->content = $l11n; + $this->l11n->setLanguage($lang); + } + } + + /** + * @return string + * + * @since 1.0.0 + */ + public function getL11n() : string + { + if (!isset($this->l11n)) { + return ''; + } + + return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n; + } + + /** + * Set fields + * + * @param int $fields Fields + * + * @return void + * + * @since 1.0.0 + */ + public function setFields(int $fields) : void + { + $this->fields = $fields; + } + + /** + * Get default values + * + * @return array + * + * @sicne 1.0.0 + */ + public function getDefaults() : array + { + return $this->defaults; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return [ + 'id' => $this->id, + 'name' => $this->name, + 'validationPattern' => $this->validationPattern, + 'custom' => $this->custom, + 'isRequired' => $this->isRequired, + ]; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() : mixed + { + return $this->toArray(); + } +} diff --git a/Models/UnitAttributeTypeL11nMapper.php b/Models/UnitAttributeTypeL11nMapper.php new file mode 100755 index 0000000..8682438 --- /dev/null +++ b/Models/UnitAttributeTypeL11nMapper.php @@ -0,0 +1,66 @@ + + * @since 1.0.0 + */ + public const COLUMNS = [ + 'unit_attr_type_l11n_id' => ['name' => 'unit_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'unit_attr_type_l11n_title' => ['name' => 'unit_attr_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], + 'unit_attr_type_l11n_type' => ['name' => 'unit_attr_type_l11n_type', 'type' => 'int', 'internal' => 'ref'], + 'unit_attr_type_l11n_lang' => ['name' => 'unit_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'unit_attr_type_l11n'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'unit_attr_type_l11n_id'; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = BaseStringL11n::class; +} diff --git a/Models/UnitAttributeTypeMapper.php b/Models/UnitAttributeTypeMapper.php new file mode 100755 index 0000000..6b49cea --- /dev/null +++ b/Models/UnitAttributeTypeMapper.php @@ -0,0 +1,82 @@ + + * @since 1.0.0 + */ + public const COLUMNS = [ + 'unit_attr_type_id' => ['name' => 'unit_attr_type_id', 'type' => 'int', 'internal' => 'id'], + 'unit_attr_type_name' => ['name' => 'unit_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true], + 'unit_attr_type_datatype' => ['name' => 'unit_attr_type_datatype', 'type' => 'int', 'internal' => 'datatype'], + 'unit_attr_type_fields' => ['name' => 'unit_attr_type_fields', 'type' => 'int', 'internal' => 'fields'], + 'unit_attr_type_custom' => ['name' => 'unit_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'], + 'unit_attr_type_pattern' => ['name' => 'unit_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'], + 'unit_attr_type_required' => ['name' => 'unit_attr_type_required', 'type' => 'bool', 'internal' => 'isRequired'], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + public const HAS_MANY = [ + 'l11n' => [ + 'mapper' => UnitAttributeTypeL11nMapper::class, + 'table' => 'unit_attr_type_l11n', + 'self' => 'unit_attr_type_l11n_type', + 'column' => 'content', + 'external' => null, + ], + 'defaults' => [ + 'mapper' => UnitAttributeValueMapper::class, + 'table' => 'unit_attr_default', + 'self' => 'unit_attr_default_type', + 'external' => 'unit_attr_default_value', + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'unit_attr_type'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'unit_attr_type_id'; +} diff --git a/Models/UnitAttributeValue.php b/Models/UnitAttributeValue.php new file mode 100755 index 0000000..862b0b4 --- /dev/null +++ b/Models/UnitAttributeValue.php @@ -0,0 +1,230 @@ +id; + } + + /** + * Set l11n + * + * @param string|BaseStringL11n $l11n Tag article l11n + * @param string $lang Language + * + * @return void + * + * @since 1.0.0 + */ + public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void + { + if ($l11n instanceof BaseStringL11n) { + $this->l11n = $l11n; + } elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) { + $this->l11n->content = $l11n; + $this->l11n->setLanguage($lang); + } else { + $this->l11n = new BaseStringL11n(); + $this->l11n->content = $l11n; + $this->l11n->ref = $this->id; + $this->l11n->setLanguage($lang); + } + } + + /** + * Get localization + * + * @return null|string + * + * @since 1.0.0 + */ + public function getL11n() : ?string + { + return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n; + } + + /** + * Set value + * + * @param int|string|float $value Value + * @param int $datatype Datatype + * + * @return void + * + * @since 1.0.0 + */ + public function setValue(mixed $value, int $datatype) : void + { + if ($datatype === AttributeValueType::_STRING) { + $this->valueStr = (string) $value; + } elseif ($datatype === AttributeValueType::_INT + || $datatype === AttributeValueType::_FLOAT_INT + || $datatype === AttributeValueType::_BOOL + ) { + $this->valueInt = (int) $value; + } elseif ($datatype === AttributeValueType::_FLOAT) { + $this->valueDec = (float) $value; + } elseif ($datatype === AttributeValueType::_DATETIME) { + $this->valueDat = new \DateTime((string) $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; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return [ + 'id' => $this->id, + 'valueInt' => $this->valueInt, + 'valueStr' => $this->valueStr, + 'valueDec' => $this->valueDec, + 'valueDat' => $this->valueDat, + 'isDefault' => $this->isDefault, + ]; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() : mixed + { + return $this->toArray(); + } +} diff --git a/Models/UnitAttributeValueL11nMapper.php b/Models/UnitAttributeValueL11nMapper.php new file mode 100755 index 0000000..9840083 --- /dev/null +++ b/Models/UnitAttributeValueL11nMapper.php @@ -0,0 +1,66 @@ + + * @since 1.0.0 + */ + public const COLUMNS = [ + 'unit_attr_value_l11n_id' => ['name' => 'unit_attr_value_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'unit_attr_value_l11n_title' => ['name' => 'unit_attr_value_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], + 'unit_attr_value_l11n_value' => ['name' => 'unit_attr_value_l11n_value', 'type' => 'int', 'internal' => 'ref'], + 'unit_attr_value_l11n_lang' => ['name' => 'unit_attr_value_l11n_lang', 'type' => 'string', 'internal' => 'language'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'unit_attr_value_l11n'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'unit_attr_value_l11n_id'; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = BaseStringL11n::class; +} diff --git a/Models/UnitAttributeValueMapper.php b/Models/UnitAttributeValueMapper.php new file mode 100755 index 0000000..bd8c653 --- /dev/null +++ b/Models/UnitAttributeValueMapper.php @@ -0,0 +1,77 @@ + + * @since 1.0.0 + */ + public const COLUMNS = [ + 'unit_attr_value_id' => ['name' => 'unit_attr_value_id', 'type' => 'int', 'internal' => 'id'], + 'unit_attr_value_default' => ['name' => 'unit_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'], + 'unit_attr_value_valueStr' => ['name' => 'unit_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'], + 'unit_attr_value_valueInt' => ['name' => 'unit_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'], + 'unit_attr_value_valueDec' => ['name' => 'unit_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'], + 'unit_attr_value_valueDat' => ['name' => 'unit_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'], + 'unit_attr_value_unit' => ['name' => 'unit_attr_value_unit', 'type' => 'string', 'internal' => 'unit'], + 'unit_attr_value_deptype' => ['name' => 'unit_attr_value_deptype', 'type' => 'int', 'internal' => 'dependingAttributeType'], + 'unit_attr_value_depvalue' => ['name' => 'unit_attr_value_depvalue', 'type' => 'int', 'internal' => 'dependingAttributeValue'], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + public const HAS_MANY = [ + 'l11n' => [ + 'mapper' => UnitAttributeValueL11nMapper::class, + 'table' => 'unit_attr_value_l11n', + 'self' => 'unit_attr_value_l11n_value', + 'external' => null, + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'unit_attr_value'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'unit_attr_value_id'; +} diff --git a/Models/UnitMapper.php b/Models/UnitMapper.php index f545632..2449514 100755 --- a/Models/UnitMapper.php +++ b/Models/UnitMapper.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace Modules\Organization\Models; +use Modules\Admin\Models\AddressMapper; use Modules\Media\Models\MediaMapper; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; @@ -41,6 +42,29 @@ final class UnitMapper extends DataMapperFactory 'unit_descriptionraw' => ['name' => 'unit_descriptionraw', 'type' => 'string', 'internal' => 'descriptionRaw'], 'unit_parent' => ['name' => 'unit_parent', 'type' => 'int', 'internal' => 'parent'], 'unit_status' => ['name' => 'unit_status', 'type' => 'int', 'internal' => 'status'], + 'unit_address' => ['name' => 'unit_address', 'type' => 'int', 'internal' => 'mainAddress'], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + public const HAS_MANY = [ + 'address' => [ + 'mapper' => AddressMapper::class, + 'table' => 'unit_address_rel', + 'external' => 'unit_address_rel_address', + 'self' => 'unit_address_rel_unit', + ], + 'attributes' => [ + 'mapper' => UnitAttributeMapper::class, + 'table' => 'unit_attr', + 'self' => 'unit_attr_unit', + 'conditional' => true, + 'external' => null, + ], ]; /** @@ -50,6 +74,10 @@ final class UnitMapper extends DataMapperFactory * @since 1.0.0 */ public const OWNS_ONE = [ + 'mainAddress' => [ + 'mapper' => AddressMapper::class, + 'external' => 'unit_address', + ], 'image' => [ 'mapper' => MediaMapper::class, 'external' => 'unit_image', @@ -91,5 +119,5 @@ final class UnitMapper extends DataMapperFactory * @var string * @since 1.0.0 */ - public const PRIMARYFIELD ='unit_id'; + public const PRIMARYFIELD = 'unit_id'; } diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index aec41c1..5acbf2c 100755 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -28,5 +28,11 @@ return ['Organization' => [ 'Unit' => 'Unit', 'UnitLogo' => 'Unit Logo', 'Units' => 'Units', + 'LegalName' => 'Legal Name', + 'Address' => 'Address', + 'Postal' => 'Postal', + 'City' => 'City', + 'Country' => 'Country', + 'MainAddress' => 'Main Address', 'IMG_alt_profile' => 'Unit image', ]]; diff --git a/Theme/Backend/unit-create.tpl.php b/Theme/Backend/unit-create.tpl.php index 6f49083..e26976c 100755 --- a/Theme/Backend/unit-create.tpl.php +++ b/Theme/Backend/unit-create.tpl.php @@ -13,34 +13,42 @@ declare(strict_types=1); use Modules\Organization\Models\Status; +use phpOMS\Localization\ISO3166NameEnum; +use phpOMS\Localization\ISO3166TwoEnum; use phpOMS\Uri\UriFactory; +$countryCodes = ISO3166TwoEnum::getConstants(); +$countries = ISO3166NameEnum::getConstants(); + /** @var \phpOMS\Views\View $this */ echo $this->getData('nav')->render(); ?> +
-
getHtml('Unit'); ?>
- -
-
-
-
-
getData('media-preview-upload')->render('fUnitCreate', 'logo', '/Modules/Organization'); ?> -
-
getData('unit-selector')->render('iParent', 'parent', false); ?> -
-
-
getData('editor')->render('unit-editor'); ?> -
getData('editor')->getData('text')->render('unit-editor', 'description', 'fUnitCreate'); ?> -
+
+ + +
+ +
+ + getData('unit-selector')->render('iParent', 'parent', false); ?> +
+ +
+ + +
+ + getData('editor')->render('unit-editor'); ?> + getData('editor')->getData('text')->render('unit-editor', 'description', 'fUnitCreate'); ?>
@@ -48,6 +56,48 @@ echo $this->getData('nav')->render(); ?>
-
+ +
+
+
getHtml('MainAddress'); ?>
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+
+
+
+ getData('unit-selector')->getData('unit-selector-popup')->render(); ?> \ No newline at end of file diff --git a/Theme/Backend/unit-profile.tpl.php b/Theme/Backend/unit-profile.tpl.php index e896b81..02dd4b0 100755 --- a/Theme/Backend/unit-profile.tpl.php +++ b/Theme/Backend/unit-profile.tpl.php @@ -14,6 +14,8 @@ declare(strict_types=1); use Modules\Media\Models\NullMedia; use Modules\Organization\Models\Status; +use phpOMS\Localization\ISO3166NameEnum; +use phpOMS\Localization\ISO3166TwoEnum; use phpOMS\Uri\UriFactory; /** @@ -22,6 +24,9 @@ use phpOMS\Uri\UriFactory; */ $unit = $this->getData('unit'); +$countryCodes = ISO3166TwoEnum::getConstants(); +$countries = ISO3166NameEnum::getConstants(); + echo $this->getData('nav')->render(); ?>
@@ -46,25 +51,83 @@ echo $this->getData('nav')->render(); ?>
getHtml('Unit'); ?>
- -
-
-
-
getData('unit-selector')->render('iParent', 'parent', false); ?> -
-
-
getData('editor')->render('unit-editor'); ?> -
getData('editor')->getData('text')->render( - 'unit-editor', - 'description', - 'iUnit', - $unit->descriptionRaw, - $unit->description - ); ?> -
+
+ + +
+ +
+ + getData('unit-selector')->render('iParent', 'parent', false); ?> +
+ +
+ + +
+ + getData('editor')->render('unit-editor'); ?> + + getData('editor')->getData('text')->render( + 'unit-editor', + 'description', + 'iUnit', + $unit->descriptionRaw, + $unit->description + ); ?> +
+
+ + +
+ + + + +
+
+
getHtml('MainAddress'); ?>
+
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
diff --git a/composer.json b/composer.json index 15e8d01..6fc1e5d 100755 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "karaka/module", - "description": "Module for Karaka.", + "description": "Module for Jingga.", "authors": [ { "name": "Dennis Eichhorn", diff --git a/info.json b/info.json index 4818e55..2292398 100755 --- a/info.json +++ b/info.json @@ -11,7 +11,7 @@ "phpOMS-db": "1.0.0" }, "creator": { - "name": "Karaka", + "name": "Jingga", "website": "jingga.app" }, "description": "The business module.",