diff --git a/Admin/Install/Media.install.json b/Admin/Install/Media.install.json index cb52c65..d031c96 100755 --- a/Admin/Install/Media.install.json +++ b/Admin/Install/Media.install.json @@ -5,5 +5,19 @@ "name": "SupplierManagement", "virtualPath": "/Modules", "user": 1 + }, + { + "type": "type", + "name": "supplier_profile_image", + "l11n": [ + { + "title": "Profile image", + "lang": "en" + }, + { + "title": "Profilbild", + "lang": "de" + } + ] } ] \ No newline at end of file diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 6288fb1..c4563a0 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -53,6 +53,14 @@ "default": null, "foreignTable": "address", "foreignKey": "address_id" + }, + "suppliermgmt_supplier_unit": { + "name": "suppliermgmt_supplier_unit", + "type": "INT", + "default": null, + "null": true, + "foreignTable": "organization_unit", + "foreignKey": "organization_unit_id" } } }, @@ -95,6 +103,12 @@ "suppliermgmt_attr_type_name": { "name": "suppliermgmt_attr_type_name", "type": "VARCHAR(255)", + "null": false, + "unique": true + }, + "suppliermgmt_attr_type_datatype": { + "name": "suppliermgmt_attr_type_datatype", + "type": "INT(11)", "null": false }, "suppliermgmt_attr_type_fields": { @@ -167,11 +181,6 @@ "type": "TINYINT(1)", "null": false }, - "suppliermgmt_attr_value_type": { - "name": "suppliermgmt_attr_value_type", - "type": "INT(11)", - "null": false - }, "suppliermgmt_attr_value_valueStr": { "name": "suppliermgmt_attr_value_valueStr", "type": "VARCHAR(255)", @@ -195,22 +204,37 @@ "type": "DATETIME", "null": true, "default": null + } + } + }, + "suppliermgmt_attr_value_l11n": { + "name": "suppliermgmt_attr_value_l11n", + "fields": { + "suppliermgmt_attr_value_l11n_id": { + "name": "suppliermgmt_attr_value_l11n_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true }, - "suppliermgmt_attr_value_lang": { - "name": "suppliermgmt_attr_value_lang", + "suppliermgmt_attr_value_l11n_title": { + "name": "suppliermgmt_attr_value_l11n_title", + "type": "VARCHAR(255)", + "null": false + }, + "suppliermgmt_attr_value_l11n_value": { + "name": "suppliermgmt_attr_value_l11n_value", + "type": "INT(11)", + "null": false, + "foreignTable": "suppliermgmt_attr_value", + "foreignKey": "suppliermgmt_attr_value_id" + }, + "suppliermgmt_attr_value_l11n_lang": { + "name": "suppliermgmt_attr_value_l11n_lang", "type": "VARCHAR(2)", - "null": true, - "default": null, + "null": false, "foreignTable": "language", "foreignKey": "language_639_1" - }, - "suppliermgmt_attr_value_country": { - "name": "suppliermgmt_attr_value_country", - "type": "VARCHAR(2)", - "null": true, - "default": null, - "foreignTable": "country", - "foreignKey": "country_code2" } } }, diff --git a/Controller/ApiController.php b/Controller/ApiController.php index dfc0e5a..dbc90f4 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -19,14 +19,13 @@ use Modules\Admin\Models\Address; use Modules\Media\Models\PathSettings; use Modules\Profile\Models\ContactElementMapper; use Modules\Profile\Models\Profile; -use Modules\SupplierManagement\Models\AttributeValueType; use Modules\SupplierManagement\Models\NullSupplierAttributeType; use Modules\SupplierManagement\Models\NullSupplierAttributeValue; use Modules\SupplierManagement\Models\Supplier; use Modules\SupplierManagement\Models\SupplierAttribute; use Modules\SupplierManagement\Models\SupplierAttributeMapper; use Modules\SupplierManagement\Models\SupplierAttributeType; -use Modules\SupplierManagement\Models\SupplierAttributeTypeL11n; +use phpOMS\Localization\BaseStringL11n; use Modules\SupplierManagement\Models\SupplierAttributeTypeL11nMapper; use Modules\SupplierManagement\Models\SupplierAttributeTypeMapper; use Modules\SupplierManagement\Models\SupplierAttributeValue; @@ -105,6 +104,8 @@ final class ApiController extends Controller $addr->setCountry((string) ($request->getData('country') ?? '')); $supplier->mainAddress = $addr; + $supplier->unit = $request->getData('unit', 'int'); + return $supplier; } @@ -265,18 +266,18 @@ final class ApiController extends Controller * * @param RequestAbstract $request Request * - * @return SupplierAttributeTypeL11n + * @return BaseStringL11n * * @since 1.0.0 */ - private function createSupplierAttributeTypeL11nFromRequest(RequestAbstract $request) : SupplierAttributeTypeL11n + private function createSupplierAttributeTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n { - $attrL11n = new SupplierAttributeTypeL11n(); - $attrL11n->type = (int) ($request->getData('type') ?? 0); + $attrL11n = new BaseStringL11n(); + $attrL11n->ref = (int) ($request->getData('type') ?? 0); $attrL11n->setLanguage((string) ( $request->getData('language') ?? $request->getLanguage() )); - $attrL11n->title = (string) ($request->getData('title') ?? ''); + $attrL11n->content = (string) ($request->getData('title') ?? ''); return $attrL11n; } @@ -341,10 +342,13 @@ final class ApiController extends Controller */ private function createSupplierAttributeTypeFromRequest(RequestAbstract $request) : SupplierAttributeType { - $attrType = new SupplierAttributeType(); + $attrType = new SupplierAttributeType($request->getData('name') ?? ''); $attrType->setL11n((string) ($request->getData('title') ?? ''), $request->getData('language') ?? ISO639x1Enum::_EN); - $attrType->fields = (int) ($request->getData('fields') ?? 0); - $attrType->custom = (bool) ($request->getData('custom') ?? false); + $attrType->datatype = (int) ($request->getData('datatype') ?? 0); + $attrType->setFields((int) ($request->getData('fields') ?? 0)); + $attrType->custom = (bool) ($request->getData('custom') ?? false); + $attrType->isRequired = (bool) ($request->getData('is_required') ?? false); + $attrType->validationPattern = (string) ($request->getData('validation_pattern') ?? ''); return $attrType; } @@ -362,6 +366,7 @@ final class ApiController extends Controller { $val = []; if (($val['title'] = empty($request->getData('title'))) + || ($val['name'] = empty($request->getData('name'))) ) { return $val; } @@ -397,7 +402,7 @@ final class ApiController extends Controller if ($attrValue->isDefault) { $this->createModelRelation( $request->header->account, - (int) $request->getData('attributetype'), + (int) $request->getData('type'), $attrValue->getId(), SupplierAttributeTypeMapper::class, 'defaults', '', $request->getOrigin() ); @@ -417,28 +422,16 @@ final class ApiController extends Controller */ private function createSupplierAttributeValueFromRequest(RequestAbstract $request) : SupplierAttributeValue { + $type = SupplierAttributeTypeMapper::get() + ->where('id', (int) ($request->getData('type') ?? 0)) + ->execute(); + $attrValue = new SupplierAttributeValue(); - - $type = (int) ($request->getData('type') ?? 0); - if ($type === AttributeValueType::_INT) { - $attrValue->valueInt = $request->hasData('value') ? (int) $request->getData('value') : null; - } elseif ($type === AttributeValueType::_STRING) { - $attrValue->valueStr = $request->hasData('value') ? (string) $request->getData('value') : null; - } elseif ($type === AttributeValueType::_FLOAT) { - $attrValue->valueDec = $request->hasData('value') ? (float) $request->getData('value') : null; - } elseif ($type === AttributeValueType::_DATETIME) { - $attrValue->valueDat = $request->hasData('value') ? new \DateTime((string) ($request->getData('value') ?? '')) : null; - } - - $attrValue->type = $type; $attrValue->isDefault = (bool) ($request->getData('default') ?? false); + $attrValue->setValue($request->getData('value'), $type->datatype); - if ($request->hasData('language')) { - $attrValue->setLanguage((string) ($request->getData('language') ?? $request->getLanguage())); - } - - if ($request->hasData('country')) { - $attrValue->setCountry((string) ($request->getData('country') ?? $request->header->l11n->getCountry())); + if ($request->getData('title') !== null) { + $attrValue->setL11n($request->getData('title'), $request->getData('language') ?? ISO639x1Enum::_EN); } return $attrValue; @@ -465,6 +458,75 @@ final class ApiController extends Controller return []; } + /** + * Api method to create item attribute l11n + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiSupplierAttributeValueL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void + { + if (!empty($val = $this->validateSupplierAttributeValueL11nCreate($request))) { + $response->set('attr_value_l11n_create', new FormValidation($val)); + $response->header->status = RequestStatusCode::R_400; + + return; + } + + $attrL11n = $this->createSupplierAttributeValueL11nFromRequest($request); + $this->createModel($request->header->account, $attrL11n, SupplierAttributeValueL11nMapper::class, 'attr_value_l11n', $request->getOrigin()); + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute type localization', 'Attribute type localization successfully created', $attrL11n); + } + + /** + * Method to create Supplier attribute l11n from request. + * + * @param RequestAbstract $request Request + * + * @return BaseStringL11n + * + * @since 1.0.0 + */ + private function createSupplierAttributeValueL11nFromRequest(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 Supplier attribute l11n create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateSupplierAttributeValueL11nCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['title'] = empty($request->getData('title'))) + || ($val['value'] = empty($request->getData('value'))) + ) { + return $val; + } + + return []; + } + /** * Api method to create supplier files * diff --git a/Models/NullSupplierAttributeTypeL11n.php b/Models/NullSupplierAttributeTypeL11n.php deleted file mode 100755 index e1f68fc..0000000 --- a/Models/NullSupplierAttributeTypeL11n.php +++ /dev/null @@ -1,46 +0,0 @@ -id = $id; - } - - /** - * {@inheritdoc} - */ - public function jsonSerialize() : mixed - { - return ['id' => $this->id]; - } -} diff --git a/Models/Supplier.php b/Models/Supplier.php index 794d88b..cfc2a62 100755 --- a/Models/Supplier.php +++ b/Models/Supplier.php @@ -82,6 +82,14 @@ class Supplier private array $partners = []; + /** + * Unit + * + * @var null|int + * @since 1.0.0 + */ + public ?int $unit = null; + /** * Constructor. * @@ -378,6 +386,26 @@ class Supplier return new NullMedia(); } + /** + * Get all media files by type name + * + * @param string $type Media type + * + * @return Media + * + * @since 1.0.0 + */ + public function getFileByTypeName(string $type) : Media + { + foreach ($this->files as $file) { + if ($file->type->name === $type) { + return $file; + } + } + + return new NullMedia(); + } + /** * {@inheritdoc} */ diff --git a/Models/SupplierAttributeType.php b/Models/SupplierAttributeType.php index b755869..a5ebc9c 100755 --- a/Models/SupplierAttributeType.php +++ b/Models/SupplierAttributeType.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace Modules\SupplierManagement\Models; use phpOMS\Localization\ISO639x1Enum; +use phpOMS\Localization\BaseStringL11n; /** * Supplier Attribute Type class. @@ -62,12 +63,20 @@ class SupplierAttributeType implements \JsonSerializable public bool $isRequired = false; + /** + * Datatype of the attribute + * + * @var int + * @since 1.0.0 + */ + public int $datatype = AttributeValueType::_STRING; + /** * Localization * - * @var string | SupplierAttributeTypeL11n + * @var string | BaseStringL11n */ - protected string | SupplierAttributeTypeL11n $l11n; + protected string | BaseStringL11n $l11n; /** * Possible default attribute values @@ -85,7 +94,7 @@ class SupplierAttributeType implements \JsonSerializable */ public function __construct(string $name = '') { - $this->setL11n($name); + $this->name = $name; } /** @@ -103,22 +112,22 @@ class SupplierAttributeType implements \JsonSerializable /** * Set l11n * - * @param string|SupplierAttributeTypeL11n $l11n Tag article l11n + * @param string|BaseStringL11n $l11n Tag article l11n * @param string $lang Language * * @return void * * @since 1.0.0 */ - public function setL11n(string | SupplierAttributeTypeL11n $l11n, string $lang = ISO639x1Enum::_EN) : void + public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void { - if ($l11n instanceof SupplierAttributeTypeL11n) { + if ($l11n instanceof BaseStringL11n) { $this->l11n = $l11n; - } elseif (isset($this->l11n) && $this->l11n instanceof SupplierAttributeTypeL11n) { - $this->l11n->title = $l11n; + } elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) { + $this->l11n->content = $l11n; } else { - $this->l11n = new SupplierAttributeTypeL11n(); - $this->l11n->title = $l11n; + $this->l11n = new BaseStringL11n(); + $this->l11n->content = $l11n; $this->l11n->setLanguage($lang); } } @@ -130,7 +139,33 @@ class SupplierAttributeType implements \JsonSerializable */ public function getL11n() : string { - return $this->l11n instanceof SupplierAttributeTypeL11n ? $this->l11n->title : $this->l11n; + 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; } /** diff --git a/Models/SupplierAttributeTypeL11n.php b/Models/SupplierAttributeTypeL11n.php deleted file mode 100755 index 95e8dd3..0000000 --- a/Models/SupplierAttributeTypeL11n.php +++ /dev/null @@ -1,135 +0,0 @@ -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(); - } -} diff --git a/Models/SupplierAttributeTypeL11nMapper.php b/Models/SupplierAttributeTypeL11nMapper.php index 2615be3..7988d5a 100755 --- a/Models/SupplierAttributeTypeL11nMapper.php +++ b/Models/SupplierAttributeTypeL11nMapper.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace Modules\SupplierManagement\Models; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; +use phpOMS\Localization\BaseStringL11n; /** * Supplier mapper class. @@ -34,8 +35,8 @@ final class SupplierAttributeTypeL11nMapper extends DataMapperFactory */ public const COLUMNS = [ 'suppliermgmt_attr_type_l11n_id' => ['name' => 'suppliermgmt_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'], - 'suppliermgmt_attr_type_l11n_title' => ['name' => 'suppliermgmt_attr_type_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true], - 'suppliermgmt_attr_type_l11n_type' => ['name' => 'suppliermgmt_attr_type_l11n_type', 'type' => 'int', 'internal' => 'type'], + 'suppliermgmt_attr_type_l11n_title' => ['name' => 'suppliermgmt_attr_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], + 'suppliermgmt_attr_type_l11n_type' => ['name' => 'suppliermgmt_attr_type_l11n_type', 'type' => 'int', 'internal' => 'ref'], 'suppliermgmt_attr_type_l11n_lang' => ['name' => 'suppliermgmt_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'], ]; @@ -54,4 +55,12 @@ final class SupplierAttributeTypeL11nMapper extends DataMapperFactory * @since 1.0.0 */ public const PRIMARYFIELD ='suppliermgmt_attr_type_l11n_id'; + + /** + * Model to use by the mapper. + * + * @var string + * @since 1.0.0 + */ + public const MODEL = BaseStringL11n::class; } diff --git a/Models/SupplierAttributeTypeMapper.php b/Models/SupplierAttributeTypeMapper.php index 8187b20..271b8e3 100755 --- a/Models/SupplierAttributeTypeMapper.php +++ b/Models/SupplierAttributeTypeMapper.php @@ -35,6 +35,7 @@ final class SupplierAttributeTypeMapper extends DataMapperFactory public const COLUMNS = [ 'suppliermgmt_attr_type_id' => ['name' => 'suppliermgmt_attr_type_id', 'type' => 'int', 'internal' => 'id'], 'suppliermgmt_attr_type_name' => ['name' => 'suppliermgmt_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true], + 'suppliermgmt_attr_type_datatype' => ['name' => 'suppliermgmt_attr_type_datatype', 'type' => 'int', 'internal' => 'datatype'], 'suppliermgmt_attr_type_fields' => ['name' => 'suppliermgmt_attr_type_fields', 'type' => 'int', 'internal' => 'fields'], 'suppliermgmt_attr_type_custom' => ['name' => 'suppliermgmt_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'], 'suppliermgmt_attr_type_pattern' => ['name' => 'suppliermgmt_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'], diff --git a/Models/SupplierAttributeValue.php b/Models/SupplierAttributeValue.php index b9e8184..8bd5f83 100755 --- a/Models/SupplierAttributeValue.php +++ b/Models/SupplierAttributeValue.php @@ -37,14 +37,6 @@ class SupplierAttributeValue implements \JsonSerializable */ protected int $id = 0; - /** - * Type of the attribute - * - * @var int - * @since 1.0.0 - */ - public int $type = 0; - /** * Int value * @@ -86,37 +78,11 @@ class SupplierAttributeValue implements \JsonSerializable public bool $isDefault = false; /** - * Language + * Localization * - * @var string - * @since 1.0.0 + * @var null|BaseStringL11n */ - protected string $language = ISO639x1Enum::_EN; - - /** - * Country - * - * @var string - * @since 1.0.0 - */ - protected string $country = ISO3166TwoEnum::_USA; - - /** - * Constructor. - * - * @param int $type Type - * @param mixed $value Value - * @param string $language Language - * - * @since 1.0.0 - */ - public function __construct(int $type = 0, $value = '', string $language = ISO639x1Enum::_EN) - { - $this->type = $type; - $this->language = $language; - - $this->setValue($value); - } + private ?BaseStringL11n $l11n = null; /** * Get id @@ -131,24 +97,61 @@ class SupplierAttributeValue implements \JsonSerializable } /** - * Set value + * Set l11n * - * @param int|string|float|\DateTimeInterface $value Value + * @param string|BaseStringL11n $l11n Tag article l11n + * @param string $lang Language * * @return void * * @since 1.0.0 */ - public function setValue($value) : void + public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void { - if (\is_string($value)) { - $this->valueStr = $value; - } elseif (\is_int($value)) { - $this->valueInt = $value; - } elseif (\is_float($value)) { - $this->valueDec = $value; - } elseif ($value instanceof \DateTimeInterface) { - $this->valueDat = $value; + 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 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|\DateTimeInterface $value Value + * @param int $type 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) { + $this->valueInt = (int) $value; + } elseif ($datatype === AttributeValueType::_FLOAT) { + $this->valueDec = (float) $value; + } elseif ($datatype === AttributeValueType::_DATETIME) { + $this->valueDat = new \DateTime($value); } } @@ -233,14 +236,11 @@ class SupplierAttributeValue implements \JsonSerializable { return [ 'id' => $this->id, - 'type' => $this->type, 'valueInt' => $this->valueInt, 'valueStr' => $this->valueStr, 'valueDec' => $this->valueDec, 'valueDat' => $this->valueDat, 'isDefault' => $this->isDefault, - 'language' => $this->language, - 'country' => $this->country, ]; } diff --git a/Models/SupplierAttributeValueL11nMapper.php b/Models/SupplierAttributeValueL11nMapper.php new file mode 100644 index 0000000..bae89a9 --- /dev/null +++ b/Models/SupplierAttributeValueL11nMapper.php @@ -0,0 +1,66 @@ + + * @since 1.0.0 + */ + public const COLUMNS = [ + 'suppliermgmt_attr_value_l11n_id' => ['name' => 'suppliermgmt_attr_value_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'suppliermgmt_attr_value_l11n_title' => ['name' => 'suppliermgmt_attr_value_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], + 'suppliermgmt_attr_value_l11n_value' => ['name' => 'suppliermgmt_attr_value_l11n_value', 'type' => 'int', 'internal' => 'ref'], + 'suppliermgmt_attr_value_l11n_lang' => ['name' => 'suppliermgmt_attr_value_l11n_lang', 'type' => 'string', 'internal' => 'language'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'suppliermgmt_attr_value_l11n'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD ='suppliermgmt_attr_value_l11n_id'; + + /** + * Model to use by the mapper. + * + * @var string + * @since 1.0.0 + */ + public const MODEL = BaseStringL11n::class; +} diff --git a/Models/SupplierAttributeValueMapper.php b/Models/SupplierAttributeValueMapper.php index 4acd7bc..7318213 100755 --- a/Models/SupplierAttributeValueMapper.php +++ b/Models/SupplierAttributeValueMapper.php @@ -35,13 +35,25 @@ final class SupplierAttributeValueMapper extends DataMapperFactory public const COLUMNS = [ 'suppliermgmt_attr_value_id' => ['name' => 'suppliermgmt_attr_value_id', 'type' => 'int', 'internal' => 'id'], 'suppliermgmt_attr_value_default' => ['name' => 'suppliermgmt_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'], - 'suppliermgmt_attr_value_type' => ['name' => 'suppliermgmt_attr_value_type', 'type' => 'int', 'internal' => 'type'], 'suppliermgmt_attr_value_valueStr' => ['name' => 'suppliermgmt_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'], 'suppliermgmt_attr_value_valueInt' => ['name' => 'suppliermgmt_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'], 'suppliermgmt_attr_value_valueDec' => ['name' => 'suppliermgmt_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'], 'suppliermgmt_attr_value_valueDat' => ['name' => 'suppliermgmt_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'], - 'suppliermgmt_attr_value_lang' => ['name' => 'suppliermgmt_attr_value_lang', 'type' => 'string', 'internal' => 'language'], - 'suppliermgmt_attr_value_country' => ['name' => 'suppliermgmt_attr_value_country', 'type' => 'string', 'internal' => 'country'], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + public const HAS_MANY = [ + 'l11n' => [ + 'mapper' => SupplierAttributeValueL11nMapper::class, + 'table' => 'suppliermgmt_attr_value_l11n', + 'self' => 'suppliermgmt_attr_value_l11n_value', + 'external' => null, + ], ]; /** diff --git a/Models/SupplierMapper.php b/Models/SupplierMapper.php index 4177f76..8bf06f8 100755 --- a/Models/SupplierMapper.php +++ b/Models/SupplierMapper.php @@ -47,6 +47,7 @@ final class SupplierMapper extends DataMapperFactory 'suppliermgmt_supplier_created_at' => ['name' => 'suppliermgmt_supplier_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true], 'suppliermgmt_supplier_profile' => ['name' => 'suppliermgmt_supplier_profile', 'type' => 'int', 'internal' => 'profile'], 'suppliermgmt_supplier_address' => ['name' => 'suppliermgmt_supplier_address', 'type' => 'int', 'internal' => 'mainAddress'], + 'suppliermgmt_supplier_unit' => ['name' => 'suppliermgmt_supplier_unit', 'type' => 'int', 'internal' => 'unit'], ]; /** diff --git a/Theme/Backend/supplier-list.tpl.php b/Theme/Backend/supplier-list.tpl.php index 1a6e11b..cdd1584 100755 --- a/Theme/Backend/supplier-list.tpl.php +++ b/Theme/Backend/supplier-list.tpl.php @@ -104,7 +104,7 @@ echo $this->getData('nav')->render(); ?> $value) : ++$count; $url = UriFactory::build('{/lang}/{/app}/purchase/supplier/profile?{?}&id=' . $value->getId()); - $image = $value->getFileByType(0); ?> + $image = $value->getFileByTypeName('supplier_profile_image'); ?>