diff --git a/Admin/Install/db.json b/Admin/Install/db.json index f307586..5b57d05 100644 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -32,6 +32,11 @@ "null": false, "primary": true, "autoincrement": true + }, + "itemmgmt_item_l11n_type_title": { + "name": "itemmgmt_item_l11n_type_title", + "type": "VARCHAR(255)", + "null": false } } }, @@ -57,8 +62,8 @@ "foreignTable": "itemmgmt_item", "foreignKey": "itemmgmt_item_id" }, - "itemmgmt_item_l11n_type_ref": { - "name": "itemmgmt_item_l11n_type_ref", + "itemmgmt_item_l11n_typeref": { + "name": "itemmgmt_item_l11n_typeref", "type": "INT(11)", "null": false, "foreignTable": "itemmgmt_item_l11n_type", @@ -66,51 +71,183 @@ }, "itemmgmt_item_l11n_lang": { "name": "itemmgmt_item_l11n_lang", - "type": "INT(11)", + "type": "VARCHAR(2)", "null": false, "foreignTable": "language", - "foreignKey": "language_id" + "foreignKey": "language_639_1" } } }, - "itemmgmt_item_attr_l11n": { - "name": "itemmgmt_item_attr_l11n", + "itemmgmt_attr_type": { + "name": "itemmgmt_attr_type", "fields": { - "itemmgmt_item_attr_l11n_id": { - "name": "itemmgmt_item_attr_l11n_id", + "itemmgmt_attr_type_id": { + "name": "itemmgmt_attr_type_id", "type": "INT", "null": false, "primary": true, "autoincrement": true }, - "itemmgmt_item_attr_l11n_item": { - "name": "itemmgmt_item_attr_l11n_item", + "itemmgmt_attr_type_name": { + "name": "itemmgmt_attr_type_name", + "type": "VARCHAR(255)", + "null": false + }, + "itemmgmt_attr_type_fields": { + "name": "itemmgmt_attr_type_fields", + "type": "INT(11)", + "null": false + }, + "itemmgmt_attr_type_custom": { + "name": "itemmgmt_attr_type_custom", + "type": "TINYINT(1)", + "null": false + } + } + }, + "itemmgmt_attr_type_l11n": { + "name": "itemmgmt_attr_type_l11n", + "fields": { + "itemmgmt_attr_type_l11n_id": { + "name": "itemmgmt_attr_type_l11n_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "itemmgmt_attr_type_l11n_title": { + "name": "itemmgmt_attr_type_l11n_title", + "type": "VARCHAR(255)", + "null": false + }, + "itemmgmt_attr_type_l11n_type": { + "name": "itemmgmt_attr_type_l11n_type", + "type": "INT(11)", + "null": false, + "foreignTable": "itemmgmt_attr_type", + "foreignKey": "itemmgmt_attr_type_id" + }, + "itemmgmt_attr_type_l11n_lang": { + "name": "itemmgmt_attr_type_l11n_lang", + "type": "VARCHAR(2)", + "null": false, + "foreignTable": "language", + "foreignKey": "language_639_1" + } + } + }, + "itemmgmt_attr_value": { + "name": "itemmgmt_attr_value", + "fields": { + "itemmgmt_attr_value_id": { + "name": "itemmgmt_attr_value_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "itemmgmt_attr_value_default": { + "name": "itemmgmt_attr_value_default", + "type": "TINYINT(1)", + "null": false + }, + "itemmgmt_attr_value_type": { + "name": "itemmgmt_attr_value_type", + "type": "INT(11)", + "null": false, + "foreignTable": "itemmgmt_attr_type", + "foreignKey": "itemmgmt_attr_type_id" + }, + "itemmgmt_attr_value_valueStr": { + "name": "itemmgmt_attr_value_valueStr", + "type": "VARCHAR(255)", + "null": true, + "default": null + }, + "itemmgmt_attr_value_valueInt": { + "name": "itemmgmt_attr_value_valueInt", + "type": "INT(11)", + "null": true, + "default": null + }, + "itemmgmt_attr_value_valueDec": { + "name": "itemmgmt_attr_value_valueDec", + "type": "DECIMAL(19,5)", + "null": true, + "default": null + }, + "itemmgmt_attr_value_valueDat": { + "name": "itemmgmt_attr_value_valueDat", + "type": "DATETIME", + "null": true, + "default": null + }, + "itemmgmt_attr_value_lang": { + "name": "itemmgmt_attr_value_lang", + "type": "VARCHAR(2)", + "null": true, + "default": null, + "foreignTable": "language", + "foreignKey": "language_639_1" + }, + "itemmgmt_attr_value_country": { + "name": "itemmgmt_attr_value_country", + "type": "VARCHAR(2)", + "null": true, + "default": null, + "foreignTable": "country", + "foreignKey": "country_code2" + } + } + }, + "itemmgmt_item_attr": { + "name": "itemmgmt_item_attr", + "fields": { + "itemmgmt_item_attr_id": { + "name": "itemmgmt_item_attr_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "itemmgmt_item_attr_item": { + "name": "itemmgmt_item_attr_item", "type": "INT(11)", "null": false, "foreignTable": "itemmgmt_item", "foreignKey": "itemmgmt_item_id" }, - "itemmgmt_item_attr_l11n_attr": { - "name": "itemmgmt_item_attr_l11n_attr", - "type": "INT(3)", - "null": false - }, - "itemmgmt_item_attr_l11n_name": { - "name": "itemmgmt_item_attr_l11n_name", - "type": "VARCHAR(255)", - "null": false - }, - "itemmgmt_item_attr_l11n_value": { - "name": "itemmgmt_item_attr_l11n_value", - "type": "VARCHAR(255)", - "null": false - }, - "itemmgmt_item_attr_l11n_lang": { - "name": "itemmgmt_item_attr_l11n_lang", + "itemmgmt_item_attr_type": { + "name": "itemmgmt_item_attr_type", "type": "INT(11)", "null": false, - "foreignTable": "language", - "foreignKey": "language_id" + "foreignTable": "itemmgmt_attr_type", + "foreignKey": "itemmgmt_attr_type_id" + }, + "itemmgmt_item_attr_value": { + "name": "itemmgmt_item_attr_value", + "type": "INT(11)", + "null": true, + "default": null, + "foreignTable": "itemmgmt_attr_value", + "foreignKey": "itemmgmt_attr_value_id" + } + } + }, + "itemmgmt_item_media_type": { + "name": "itemmgmt_item_media_type", + "fields": { + "itemmgmt_item_media_type_id": { + "name": "itemmgmt_item_media_type_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "itemmgmt_item_media_type_title": { + "name": "itemmgmt_item_media_type_title", + "type": "VARCHAR(255)", + "null": false } } }, @@ -127,17 +264,19 @@ "itemmgmt_item_media_type": { "name": "itemmgmt_item_media_type", "type": "INT", - "null": false + "null": false, + "foreignTable": "itemmgmt_item_media_type", + "foreignKey": "itemmgmt_item_media_type_id" }, - "itemmgmt_item_media_src": { - "name": "itemmgmt_item_media_src", + "itemmgmt_item_media_item": { + "name": "itemmgmt_item_media_item", "type": "INT", "null": false, "foreignTable": "itemmgmt_item", "foreignKey": "itemmgmt_item_id" }, - "itemmgmt_item_media_dst": { - "name": "itemmgmt_item_media_dst", + "itemmgmt_item_media_media": { + "name": "itemmgmt_item_media_media", "type": "INT", "null": false, "foreignTable": "media", diff --git a/Admin/Installer.php b/Admin/Installer.php index a26ccc0..c079f0e 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -15,6 +15,16 @@ declare(strict_types=1); namespace Modules\ItemManagement\Admin; use phpOMS\Module\InstallerAbstract; +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Module\ModuleInfo; +use phpOMS\Config\SettingsInterface; +use phpOMS\Localization\ISO639x1Enum; +use Modules\ItemManagement\Models\ItemAttributeType; +use Modules\ItemManagement\Models\ItemAttributeValue; +use Modules\ItemManagement\Models\ItemAttributeTypeL11n; +use Modules\ItemManagement\Models\ItemAttributeTypeMapper; +use Modules\ItemManagement\Models\ItemAttributeTypeL11nMapper; +use Modules\ItemManagement\Models\ItemAttributeValueMapper; /** * Installer class. @@ -26,4 +36,80 @@ use phpOMS\Module\InstallerAbstract; */ final class Installer extends InstallerAbstract { + /** + * {@inheritdoc} + */ + public static function install(DatabasePool $dbPool, ModuleInfo $info, SettingsInterface $cfgHandler) : void + { + parent::install($dbPool, $info, $cfgHandler); + + $attrTypes = self::createItemAttributeTypes(); + self::createItemAttributeValues($attrTypes); + } + + private static function createItemAttributeTypes() : array + { + $itemAttrType = []; + + $itemAttrType['color'] = new ItemAttributeType('color'); + ItemAttributeTypeMapper::create($itemAttrType['color']); + ItemAttributeTypeL11nMapper::create(new ItemAttributeTypeL11n($itemAttrType['color']->getId(), 'Color', ISO639x1Enum::_EN)); + ItemAttributeTypeL11nMapper::create(new ItemAttributeTypeL11n($itemAttrType['color']->getId(), 'Farbe', ISO639x1Enum::_DE)); + + return $itemAttrType; + } + + private static function createItemAttributeValues(array $itemAttrType) : array + { + $itemAttrValue = []; + + $id = $itemAttrType['color']->getId(); + $itemAttrValue['color'] = []; + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Red', ISO639x1Enum::_EN); + ItemAttributeValueMapper::create($itemAttrValue['color'][0]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Rot', ISO639x1Enum::_DE); + ItemAttributeValueMapper::create($itemAttrValue['color'][1]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Blue', ISO639x1Enum::_EN); + ItemAttributeValueMapper::create($itemAttrValue['color'][2]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Blau', ISO639x1Enum::_DE); + ItemAttributeValueMapper::create($itemAttrValue['color'][3]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Green', ISO639x1Enum::_EN); + ItemAttributeValueMapper::create($itemAttrValue['color'][4]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'GrĂ¼n', ISO639x1Enum::_DE); + ItemAttributeValueMapper::create($itemAttrValue['color'][5]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Yellow', ISO639x1Enum::_EN); + ItemAttributeValueMapper::create($itemAttrValue['color'][6]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Gelb', ISO639x1Enum::_DE); + ItemAttributeValueMapper::create($itemAttrValue['color'][7]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'White', ISO639x1Enum::_EN); + ItemAttributeValueMapper::create($itemAttrValue['color'][8]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Weiss', ISO639x1Enum::_DE); + ItemAttributeValueMapper::create($itemAttrValue['color'][9]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Black', ISO639x1Enum::_EN); + ItemAttributeValueMapper::create($itemAttrValue['color'][10]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Schwarz', ISO639x1Enum::_DE); + ItemAttributeValueMapper::create($itemAttrValue['color'][11]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Braun', ISO639x1Enum::_EN); + ItemAttributeValueMapper::create($itemAttrValue['color'][12]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Braun', ISO639x1Enum::_DE); + ItemAttributeValueMapper::create($itemAttrValue['color'][13]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Purple', ISO639x1Enum::_EN); + ItemAttributeValueMapper::create($itemAttrValue['color'][14]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Lila', ISO639x1Enum::_DE); + ItemAttributeValueMapper::create($itemAttrValue['color'][15]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Pink', ISO639x1Enum::_EN); + ItemAttributeValueMapper::create($itemAttrValue['color'][16]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Rosa', ISO639x1Enum::_DE); + ItemAttributeValueMapper::create($itemAttrValue['color'][17]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Orange', ISO639x1Enum::_EN); + ItemAttributeValueMapper::create($itemAttrValue['color'][18]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Orange', ISO639x1Enum::_DE); + ItemAttributeValueMapper::create($itemAttrValue['color'][19]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Grey', ISO639x1Enum::_EN); + ItemAttributeValueMapper::create($itemAttrValue['color'][20]); + $itemAttrValue['color'][] = new ItemAttributeValue($id, 'Grau', ISO639x1Enum::_DE); + ItemAttributeValueMapper::create($itemAttrValue['color'][21]); + + return $itemAttrType; + } } diff --git a/Controller/BackendController.php b/Controller/BackendController.php index ac91f96..77c7be7 100644 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -19,6 +19,8 @@ use phpOMS\Contract\RenderableInterface; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; use phpOMS\Views\View; +use Model\SettingsEnum; +use Modules\Admin\Models\LocalizationMapper; /** * ItemManagement controller class. @@ -48,7 +50,7 @@ final class BackendController extends Controller $view->setTemplate('/Modules/ItemManagement/Theme/Backend/sales-item-list'); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004805001, $request, $response)); - $items = ItemMapper::getAll(); + $items = ItemMapper::withConditional('language', $response->getHeader()->getL11n()->getLanguage())::getAll(); $view->addData('items', $items); return $view; @@ -180,6 +182,12 @@ final class BackendController extends Controller $item = ItemMapper::get((int) $request->getData('id')); $view->addData('item', $item); + $settings = $this->app->appSettings->get(null, [ + SettingsEnum::DEFAULT_LOCALIZATION, + ]); + + $view->setData('defaultlocalization', LocalizationMapper::get((int) $settings['id'])); + return $view; } } diff --git a/Docs/Dev/en/database.md b/Docs/Dev/en/database.md new file mode 100644 index 0000000..0b94af6 --- /dev/null +++ b/Docs/Dev/en/database.md @@ -0,0 +1,33 @@ +# Database + +## itemmgmt_item + +Items + +## itemmgmt_item_l11n + +Item localizations + +## itemmgmt_item_l11n_type + +Item localization types (e.g. nam1, name2, description, ...) + +## itemmgmt_attr_type + +Available attribute types (e.g. size, color, weight, etc.) + +## itemmgmt_attr_type_l11n + +Attribute localizations + +## itemmgmt_attr_value + +Attribute values belonging to the attribute types (already localized). The localization can be omitted for globally valid values. Detailled numeric specifications should not be stored in here (e.g. size, length, weight etc.) since there are too many variations. + +## itemmgmt_item_attr + +Attribute types which a item has / should have. This references the selected default value from `itemmgmt_attr_value` or a custom value from `itemmgmt_item_attr_value` + +## itemmgmt_item_attr_value + +Custom attribute values of an item, in case globally defined attributes make no sense (e.g. color code, weight, length, size, ... usually numeric). These values are already localized. The localization can be omitted for globally valid values. \ No newline at end of file diff --git a/Models/Item.php b/Models/Item.php index 91ba18b..dd703d2 100644 --- a/Models/Item.php +++ b/Models/Item.php @@ -48,7 +48,7 @@ class Item private $media = []; - private $l11n = null; + private $l11n = []; private $attributes = []; @@ -145,4 +145,38 @@ class Item { $this->number = $number; } + + /** + * Add item l11n + * + * @param ItemL11n $l11n Item localization + * + * @return void + * + * @since 1.0.0 + */ + public function addL11n(ItemL11n $l11n) : void + { + $this->l11n[] = $l11n; + } + + /** + * Get l11n + * + * @param string $type Localization type + * + * @return ItemL11n + * + * @since 1.0.0 + */ + public function getL11n(string $type) : ItemL11n + { + foreach ($this->l11n as $l11n) { + if ($l11n->getType()->getTitle() === $type) { + return $l11n; + } + } + + return new NullItemL11n(); + } } diff --git a/Models/ItemAttribute.php b/Models/ItemAttribute.php new file mode 100644 index 0000000..be899e4 --- /dev/null +++ b/Models/ItemAttribute.php @@ -0,0 +1,64 @@ +id; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return []; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/Models/ItemAttributeMapper.php b/Models/ItemAttributeMapper.php new file mode 100644 index 0000000..cf25f5d --- /dev/null +++ b/Models/ItemAttributeMapper.php @@ -0,0 +1,77 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'itemmgmt_item_attr_id' => ['name' => 'itemmgmt_item_attr_id', 'type' => 'int', 'internal' => 'id'], + 'itemmgmt_item_attr_item' => ['name' => 'itemmgmt_item_attr_item', 'type' => 'int', 'internal' => 'item'], + 'itemmgmt_item_attr_type' => ['name' => 'itemmgmt_item_attr_type', 'type' => 'int', 'internal' => 'type'], + 'itemmgmt_item_attr_value' => ['name' => 'itemmgmt_item_attr_value', 'type' => 'int', 'internal' => 'value'], + ]; + + /** + * Has one relation. + * + * @var array + * @since 1.0.0 + */ + protected static array $ownsOne = [ + 'type' => [ + 'mapper' => ItemAttributeTypeMapper::class, + 'self' => 'itemmgmt_item_l11n_typeref', + ], + 'value' => [ + 'mapper' => ItemAttributeValueMapper::class, + 'self' => 'itemmgmt_item_l11n_typeref', + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'itemmgmt_item_attr'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'itemmgmt_item_attr_id'; +} diff --git a/Models/ItemAttributeType.php b/Models/ItemAttributeType.php new file mode 100644 index 0000000..4a7a6de --- /dev/null +++ b/Models/ItemAttributeType.php @@ -0,0 +1,71 @@ +name = $name; + } + + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ + public function getId() : int + { + return $this->id; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return []; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/Models/ItemAttributeTypeL11n.php b/Models/ItemAttributeTypeL11n.php new file mode 100644 index 0000000..b432308 --- /dev/null +++ b/Models/ItemAttributeTypeL11n.php @@ -0,0 +1,103 @@ +type = $type; + $this->title = $title; + $this->language = $language; + } + + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ + public function getId() : int + { + return $this->id; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return []; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/Models/ItemAttributeTypeL11nMapper.php b/Models/ItemAttributeTypeL11nMapper.php new file mode 100644 index 0000000..72d56b9 --- /dev/null +++ b/Models/ItemAttributeTypeL11nMapper.php @@ -0,0 +1,76 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'itemmgmt_attr_type_l11n_id' => ['name' => 'itemmgmt_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'itemmgmt_attr_type_l11n_title' => ['name' => 'itemmgmt_attr_type_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true], + 'itemmgmt_attr_type_l11n_type' => ['name' => 'itemmgmt_attr_type_l11n_type', 'type' => 'int', 'internal' => 'type'], + 'itemmgmt_attr_type_l11n_lang' => ['name' => 'itemmgmt_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'], + ]; + + /** + * Has one relation. + * + * @var array + * @since 1.0.0 + */ + protected static array $ownsOne = [ + 'language' => [ + 'mapper' => LanguageMapper::class, + 'self' => 'itemmgmt_attr_type_l11n_lang', + 'by' => 'code2', + 'column' => 'code2', + 'conditional' => true, + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'itemmgmt_attr_type_l11n'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'itemmgmt_attr_type_l11n_id'; +} diff --git a/Models/ItemAttributeTypeMapper.php b/Models/ItemAttributeTypeMapper.php new file mode 100644 index 0000000..f236106 --- /dev/null +++ b/Models/ItemAttributeTypeMapper.php @@ -0,0 +1,77 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'itemmgmt_attr_type_id' => ['name' => 'itemmgmt_attr_type_id', 'type' => 'int', 'internal' => 'id'], + 'itemmgmt_attr_type_name' => ['name' => 'itemmgmt_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true], + 'itemmgmt_attr_type_fields' => ['name' => 'itemmgmt_attr_type_fields', 'type' => 'int', 'internal' => 'fields'], + 'itemmgmt_attr_type_custom' => ['name' => 'itemmgmt_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + protected static array $hasMany = [ + 'l11n' => [ + 'mapper' => ItemAttributeTypeL11nMapper::class, + 'table' => 'itemmgmt_attr_type_l11n', + 'external' => 'itemmgmt_attr_type_l11n_type', + 'column' => 'title', + 'conditional' => true, + 'self' => null, + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'itemmgmt_attr_type'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'itemmgmt_attr_type_id'; +} diff --git a/Models/ItemAttributeValue.php b/Models/ItemAttributeValue.php new file mode 100644 index 0000000..f8cb819 --- /dev/null +++ b/Models/ItemAttributeValue.php @@ -0,0 +1,100 @@ +type = $type; + + 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; + } + + $this->language = $language; + } + + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ + public function getId() : int + { + return $this->id; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return []; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/Models/ItemAttributeValueMapper.php b/Models/ItemAttributeValueMapper.php new file mode 100644 index 0000000..e8912ea --- /dev/null +++ b/Models/ItemAttributeValueMapper.php @@ -0,0 +1,89 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'itemmgmt_attr_value_id' => ['name' => 'itemmgmt_attr_value_id', 'type' => 'int', 'internal' => 'id'], + 'itemmgmt_attr_value_default' => ['name' => 'itemmgmt_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'], + 'itemmgmt_attr_value_type' => ['name' => 'itemmgmt_attr_value_type', 'type' => 'int', 'internal' => 'type'], + 'itemmgmt_attr_value_valueStr' => ['name' => 'itemmgmt_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'], + 'itemmgmt_attr_value_valueInt' => ['name' => 'itemmgmt_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'], + 'itemmgmt_attr_value_valueDec' => ['name' => 'itemmgmt_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'], + 'itemmgmt_attr_value_valueDat' => ['name' => 'itemmgmt_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'], + 'itemmgmt_attr_value_lang' => ['name' => 'itemmgmt_attr_value_lang', 'type' => 'string', 'internal' => 'language'], + 'itemmgmt_attr_value_country' => ['name' => 'itemmgmt_attr_value_country', 'type' => 'string', 'internal' => 'country'], + ]; + + /** + * Has one relation. + * + * @var array + * @since 1.0.0 + */ + protected static array $ownsOne = [ + 'language' => [ + 'mapper' => LanguageMapper::class, + 'self' => 'itemmgmt_attr_value_lang', + 'by' => 'code2', + 'column' => 'code2', + 'conditional' => true, + ], + 'country' => [ + 'mapper' => CountryMapper::class, + 'self' => 'itemmgmt_attr_value_country', + 'by' => 'code2', + 'column' => 'code2', + 'conditional' => true, + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'itemmgmt_attr_value'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'itemmgmt_attr_value_id'; +} diff --git a/Models/ItemL11n.php b/Models/ItemL11n.php new file mode 100644 index 0000000..441850c --- /dev/null +++ b/Models/ItemL11n.php @@ -0,0 +1,220 @@ +type = $type; + $this->description = $description; + $this->language = $language; + } + + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ + public function getId() : int + { + return $this->id; + } + + /** + * Set item. + * + * @param int $item Item id + * + * @return void + * + * @since 1.0.0 + */ + public function setItem(int $item) : void + { + $this->item = $item; + } + + /** + * Get item + * + * @return int + * + * @since 1.0.0 + */ + public function getItem() : int + { + return $this->item; + } + + /** + * Set type. + * + * @param int|ItemL11nType $type Item type + * + * @return void + * + * @since 1.0.0 + */ + public function setType($type) : void + { + $this->type = $type; + } + + /** + * Get type + * + * @return int + * + * @since 1.0.0 + */ + public function getType() + { + return $this->type; + } + + /** + * 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; + } + + /** + * Get item description. + * + * @return string + * + * @since 1.0.0 + */ + public function getDescription() : string + { + return $this->description; + } + + /** + * Set description + * + * @param string $description Description + * + * @return void + * + * @since 1.0.0 + */ + public function setDescription(string $description) : void + { + $this->description = $description; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return [ + 'id' => $this->id, + 'description' => $this->description, + 'item' => $this->item, + 'language' => $this->language, + ]; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/Models/ItemL11nMapper.php b/Models/ItemL11nMapper.php new file mode 100644 index 0000000..20e59ac --- /dev/null +++ b/Models/ItemL11nMapper.php @@ -0,0 +1,81 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'itemmgmt_item_l11n_id' => ['name' => 'itemmgmt_item_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'itemmgmt_item_l11n_description' => ['name' => 'itemmgmt_item_l11n_description', 'type' => 'string', 'internal' => 'description', 'autocomplete' => true], + 'itemmgmt_item_l11n_item' => ['name' => 'itemmgmt_item_l11n_item', 'type' => 'int', 'internal' => 'item'], + 'itemmgmt_item_l11n_lang' => ['name' => 'itemmgmt_item_l11n_lang', 'type' => 'string', 'internal' => 'language'], + 'itemmgmt_item_l11n_typeref' => ['name' => 'itemmgmt_item_l11n_typeref', 'type' => 'int', 'internal' => 'type'], + ]; + + /** + * Has one relation. + * + * @var array + * @since 1.0.0 + */ + protected static array $ownsOne = [ + 'language' => [ + 'mapper' => LanguageMapper::class, + 'self' => 'itemmgmt_item_l11n_lang', + 'by' => 'code2', + 'column' => 'code2', + 'conditional' => true, + ], + 'type' => [ + 'mapper' => ItemL11nTypeMapper::class, + 'self' => 'itemmgmt_item_l11n_typeref', + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'itemmgmt_item_l11n'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'itemmgmt_item_l11n_id'; +} diff --git a/Models/ItemL11nType.php b/Models/ItemL11nType.php new file mode 100644 index 0000000..0697079 --- /dev/null +++ b/Models/ItemL11nType.php @@ -0,0 +1,110 @@ +title = $title; + } + + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ + public function getId() : int + { + return $this->id; + } + + /** + * Get title + * + * @return string + * + * @since 1.0.0 + */ + public function getTitle() : string + { + return $this->title; + } + + /** + * Set title + * + * @param string $title title + * + * @return void + * + * @since 1.0.0 + */ + public function setTitle(string $title) : void + { + $this->title = $title; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return []; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/Models/ItemL11nTypeMapper.php b/Models/ItemL11nTypeMapper.php new file mode 100644 index 0000000..5867694 --- /dev/null +++ b/Models/ItemL11nTypeMapper.php @@ -0,0 +1,58 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'itemmgmt_item_l11n_type_id' => ['name' => 'itemmgmt_item_l11n_type_id', 'type' => 'int', 'internal' => 'id'], + 'itemmgmt_item_l11n_type_title' => ['name' => 'itemmgmt_item_l11n_type_title', 'type' => 'string', 'internal' => 'title'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'itemmgmt_item_l11n_type'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'itemmgmt_item_l11n_type_id'; +} diff --git a/Models/ItemMapper.php b/Models/ItemMapper.php index 921dc86..6926d5e 100644 --- a/Models/ItemMapper.php +++ b/Models/ItemMapper.php @@ -35,7 +35,7 @@ final class ItemMapper extends DataMapperAbstract */ protected static array $columns = [ 'itemmgmt_item_id' => ['name' => 'itemmgmt_item_id', 'type' => 'int', 'internal' => 'id'], - 'itemmgmt_item_no' => ['name' => 'itemmgmt_item_no', 'type' => 'string', 'internal' => 'number'], + 'itemmgmt_item_no' => ['name' => 'itemmgmt_item_no', 'type' => 'string', 'internal' => 'number', 'autocomplete' => true], 'itemmgmt_item_info' => ['name' => 'itemmgmt_item_info', 'type' => 'string', 'internal' => 'info'], ]; @@ -66,11 +66,25 @@ final class ItemMapper extends DataMapperAbstract * @since 1.0.0 */ protected static array $hasMany = [ - 'media' => [ - 'mapper' => MediaMapper::class, /* mapper of the related object */ - 'table' => 'itemmgmt_item_media', /* table of the related object, null if no relation table is used (many->1) */ - 'external' => 'itemmgmt_item_media_dst', - 'self' => 'itemmgmt_item_media_src', +// 'media' => [ +// 'mapper' => MediaMapper::class, /* mapper of the related object */ +// 'table' => 'itemmgmt_item_media', /* table of the related object, null if no relation table is used (many->1) */ +// 'external' => 'itemmgmt_item_media_dst', +// 'self' => 'itemmgmt_item_media_src', +// ], + 'l11n' => [ + 'mapper' => ItemL11nMapper::class, + 'table' => 'itemmgmt_item_l11n', + 'external' => 'itemmgmt_item_l11n_item', + 'conditional' => true, + 'self' => null, + ], + 'attributes' => [ + 'mapper' => ItemAttributeMapper::class, + 'table' => 'itemmgmt_item_attr', + 'external' => 'itemmgmt_item_attr_item', + 'conditional' => true, + 'self' => null, ], ]; } diff --git a/Models/ItemMedia.php b/Models/ItemMedia.php new file mode 100644 index 0000000..e69de29 diff --git a/Models/NullItemAttribute.php b/Models/NullItemAttribute.php new file mode 100644 index 0000000..5243dec --- /dev/null +++ b/Models/NullItemAttribute.php @@ -0,0 +1,38 @@ +id = $id; + } +} diff --git a/Models/NullItemAttributeType.php b/Models/NullItemAttributeType.php new file mode 100644 index 0000000..088b038 --- /dev/null +++ b/Models/NullItemAttributeType.php @@ -0,0 +1,38 @@ +id = $id; + } +} diff --git a/Models/NullItemAttributeTypeL11n.php b/Models/NullItemAttributeTypeL11n.php new file mode 100644 index 0000000..39c462b --- /dev/null +++ b/Models/NullItemAttributeTypeL11n.php @@ -0,0 +1,38 @@ +id = $id; + } +} diff --git a/Models/NullItemAttributeValue.php b/Models/NullItemAttributeValue.php new file mode 100644 index 0000000..35459f1 --- /dev/null +++ b/Models/NullItemAttributeValue.php @@ -0,0 +1,38 @@ +id = $id; + } +} diff --git a/Models/NullItemL11n.php b/Models/NullItemL11n.php new file mode 100644 index 0000000..9cca59c --- /dev/null +++ b/Models/NullItemL11n.php @@ -0,0 +1,38 @@ +id = $id; + } +} diff --git a/Models/NullItemL11nType.php b/Models/NullItemL11nType.php new file mode 100644 index 0000000..accd1c5 --- /dev/null +++ b/Models/NullItemL11nType.php @@ -0,0 +1,38 @@ +id = $id; + } +} diff --git a/Models/StockManagementType.php b/Models/StockManagementType.php new file mode 100644 index 0000000..7d43ade --- /dev/null +++ b/Models/StockManagementType.php @@ -0,0 +1,34 @@ +getData('nav')->render(); ?>
getHtml('Items'); ?>
- +
$value) : ++$count; $url = UriFactory::build('{/prefix}sales/item/profile?{?}&id=' . $value->getId()); ?>
getHtml('ID', '0', '0'); ?> + + + getHtml('Name'); ?> + + + getHtml('Name'); ?> + + getHtml('Name'); ?> + + getHtml('Price'); ?> + + getHtml('Available'); ?> + + getHtml('Reserved'); ?> + + getHtml('Ordered'); ?> + +
printHtml($value->getNumber()); ?> - + printHtml($value->getL11n('name1')->getDescription()); ?> + printHtml($value->getL11n('name2')->getDescription()); ?> + printHtml($value->getL11n('name3')->getDescription()); ?> diff --git a/Theme/Backend/sales-item-profile.tpl.php b/Theme/Backend/sales-item-profile.tpl.php index 3d6f628..d28777f 100644 --- a/Theme/Backend/sales-item-profile.tpl.php +++ b/Theme/Backend/sales-item-profile.tpl.php @@ -12,11 +12,17 @@ */ declare(strict_types=1); +use phpOMS\Localization\NullLocalization; + /** * @var \Modules\ItemManagement\Models\Item $item */ $item = $this->getData('item'); +$languages = \phpOMS\Localization\ISO639Enum::getConstants(); + +$l11n = $this->getData('defaultlocalization') ?? new NullLocalization(); + echo $this->getData('nav')->render(); ?> @@ -50,11 +56,11 @@ echo $this->getData('nav')->render();
-
+
-
+
-
+
@@ -200,7 +206,7 @@ echo $this->getData('nav')->render(); @@ -209,7 +215,7 @@ echo $this->getData('nav')->render(); @@ -268,7 +274,7 @@ echo $this->getData('nav')->render(); @@ -277,7 +283,7 @@ echo $this->getData('nav')->render(); @@ -286,13 +292,13 @@ echo $this->getData('nav')->render(); - + @@ -619,7 +625,7 @@ echo $this->getData('nav')->render(); @@ -628,7 +634,7 @@ echo $this->getData('nav')->render(); @@ -637,7 +643,7 @@ echo $this->getData('nav')->render(); @@ -646,7 +652,7 @@ echo $this->getData('nav')->render();