diff --git a/.github/dev_bug_report.md b/.github/dev_bug_report.md deleted file mode 100755 index ef93e56..0000000 --- a/.github/dev_bug_report.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -name: Dev Bug Report -about: Create a report to help us improve -title: '' -labels: stat_backlog, type_bug -assignees: '' - ---- - -# Bug Description -A clear and concise description of what the bug is. - -# How to Reproduce - -Steps to reproduce the behavior: - -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -## Minimal Code Example - -``` -// your code ... -``` - -# Expected Behavior -A clear and concise description of what you expected to happen. - -# Screenshots -If applicable, add screenshots to help explain your problem. - -# Additional Information -Add any other context about the problem here. diff --git a/.github/dev_feature_request.md b/.github/dev_feature_request.md deleted file mode 100755 index 9573c35..0000000 --- a/.github/dev_feature_request.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -name: Dev Feature Request -about: Suggest an idea for this project -title: '' -labels: stat_backlog, type_feature -assignees: '' - ---- - -# What is the feature you request -* A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -* A clear and concise description of what you want to happen. - -# Alternatives -A clear and concise description of any alternative solutions or features you've considered. - -# Additional Information -Add any other context or screenshots about the feature request here. diff --git a/Admin/Install/Admin.install.json b/Admin/Install/Admin.install.json deleted file mode 100644 index f8d19f3..0000000 --- a/Admin/Install/Admin.install.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "description": "Default item segmentation (segment, section, sales group, product group)", - "type": "setting", - "name": "1004800001", - "content": "{\"segment\":1, \"section\":1, \"sales_group\":1, \"product_group\":1}", - "pattern": "", - "module": "ItemManagement" - } -] \ No newline at end of file diff --git a/Admin/Install/Admin.install.php b/Admin/Install/Admin.install.php new file mode 100644 index 0000000..097ed70 --- /dev/null +++ b/Admin/Install/Admin.install.php @@ -0,0 +1,27 @@ + "Default item segmentation (segment, section, sales group, product group)", + 'type' => 'setting', + 'name' => SettingsEnum::DEFAULT_SEGMENTATION, + 'content' => '{"segment":1, "section":1, "sales_group":1, "product_group":1}', + 'pattern' => '', + 'module' => ApiController::NAME, + ], +]; diff --git a/Admin/Install/Admin.php b/Admin/Install/Admin.php index 4951236..e37a653 100644 --- a/Admin/Install/Admin.php +++ b/Admin/Install/Admin.php @@ -42,6 +42,6 @@ class Admin // This requires that these settings are already available // However, this install script runs AFTER the primary installer runs. // This causes problems for the item installation and is therefore moved to the "Installer". - // \Modules\Admin\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Admin.install.json']); + // \Modules\Admin\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Admin.install.php']); } } diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json index 66e2d2f..406331a 100755 --- a/Admin/Install/Navigation.install.json +++ b/Admin/Install/Navigation.install.json @@ -65,7 +65,7 @@ "type": 2, "subtype": 1, "name": "Items", - "uri": "{/base}/item/list", + "uri": "{/base}/item/list?{?}", "target": "self", "icon": null, "order": 10, @@ -79,7 +79,7 @@ "type": 3, "subtype": 1, "name": "List", - "uri": "{/base}/item/list", + "uri": "{/base}/item/list?{?}", "target": "self", "icon": null, "order": 1, @@ -144,7 +144,7 @@ "type": 2, "subtype": 1, "name": "Items", - "uri": "{/base}/sales/item/list", + "uri": "{/base}/sales/item/list?{?}", "target": "self", "icon": null, "order": 10, @@ -158,7 +158,7 @@ "type": 3, "subtype": 1, "name": "List", - "uri": "{/base}/sales/item/list", + "uri": "{/base}/sales/item/list?{?}", "target": "self", "icon": null, "order": 1, @@ -206,7 +206,7 @@ "type": 2, "subtype": 1, "name": "Items", - "uri": "{/base}/purchase/item/list", + "uri": "{/base}/purchase/item/list?{?}", "target": "self", "icon": null, "order": 10, @@ -220,7 +220,7 @@ "type": 3, "subtype": 1, "name": "List", - "uri": "{/base}/purchase/item/list", + "uri": "{/base}/purchase/item/list?{?}", "target": "self", "icon": null, "order": 1, @@ -268,7 +268,7 @@ "type": 2, "subtype": 1, "name": "Items", - "uri": "{/base}/warehouse/item/list", + "uri": "{/base}/warehouse/item/list?{?}", "target": "self", "icon": null, "order": 10, @@ -282,7 +282,7 @@ "type": 3, "subtype": 1, "name": "List", - "uri": "{/base}/warehouse/item/list", + "uri": "{/base}/warehouse/item/list?{?}", "target": "self", "icon": null, "order": 1, @@ -330,7 +330,7 @@ "type": 2, "subtype": 1, "name": "Items", - "uri": "{/base}/production/item/list", + "uri": "{/base}/production/item/list?{?}", "target": "self", "icon": null, "order": 5, @@ -344,7 +344,7 @@ "type": 3, "subtype": 1, "name": "List", - "uri": "{/base}/production/item/list", + "uri": "{/base}/production/item/list?{?}", "target": "self", "icon": null, "order": 1, @@ -392,7 +392,7 @@ "type": 3, "subtype": 1, "name": "Item", - "uri": "{/base}/purchase/analysis/item", + "uri": "{/base}/purchase/analysis/item?{?}", "target": "self", "icon": null, "order": 10, diff --git a/Admin/Install/attributes.json b/Admin/Install/attributes.json index 6522ba6..7ada509 100755 --- a/Admin/Install/attributes.json +++ b/Admin/Install/attributes.json @@ -25,19 +25,6 @@ "default_value": "", "values": [] }, - { - "name": "primary_supplier", - "l11n": { - "en": "Primary Supplier", - "de": "Hauptlieferant" - }, - "value_type": 1, - "is_custom_allowed": true, - "validation_pattern": "", - "is_required": false, - "default_value": "", - "values": [] - }, { "name": "lead_time", "l11n": { @@ -52,10 +39,10 @@ "values": [] }, { - "name": "qc_time", + "name": "admin_time", "l11n": { - "en": "QC time", - "de": "QC Zeit" + "en": "Admin time", + "de": "Verabeitungszeit" }, "value_type": 1, "is_custom_allowed": true, @@ -569,9 +556,9 @@ "values": [] }, { - "name": "hc_code", + "name": "hs_code", "l11n": { - "en": "HC-code", + "en": "HS-code", "de": "Zolltarifnummer" }, "value_type": 2, @@ -731,7 +718,7 @@ "values": [] }, { - "name": "releasedate", + "name": "release_date", "value_type": 4, "is_custom_allowed": true, "validation_pattern": "", diff --git a/Admin/Install/items.json b/Admin/Install/items.json index 0ca5f7a..b371b71 100755 --- a/Admin/Install/items.json +++ b/Admin/Install/items.json @@ -4,9 +4,13 @@ "l11ns": { "name1": { "en": "Freight", - "de": "Freight" + "de": "Transportkosten" }, - "description_short": {} + "description_short": {}, + "internal_matchcodes": { + "en": "fuel, handling, freight, shipping", + "de": "versand, transport, fracht" + } }, "primary_image": "", "keywords": {}, @@ -24,7 +28,103 @@ "l11ns": { "name1": { "en": "Insurance", - "de": "Insurance" + "de": "Versicherung" + }, + "description_short": {}, + "internal_matchcodes": { + "en": "insurance", + "de": "versicherung" + } + }, + "primary_image": "", + "keywords": {}, + "attributes": [ + { + "type": "bill_fees", + "value": 1, + "custom": false + } + ], + "variants": [] + }, + { + "number": "3", + "l11ns": { + "name1": { + "en": "Customs", + "de": "Einfuhrsteuer" + }, + "description_short": {}, + "internal_matchcodes": { + "en": "customs", + "de": "zoll, einfuhrumsatz" + } + }, + "primary_image": "", + "keywords": {}, + "attributes": [ + { + "type": "bill_fees", + "value": 1, + "custom": false + } + ], + "variants": [] + }, + { + "number": "4", + "l11ns": { + "name1": { + "en": "Other invoice fees", + "de": "Sonstige Gebühren" + }, + "description_short": {}, + "internal_matchcodes": { + "en": "fee, surcharge", + "de": "gebühr" + } + }, + "primary_image": "", + "keywords": {}, + "attributes": [ + { + "type": "bill_fees", + "value": 1, + "custom": false + } + ], + "variants": [] + }, + { + "number": "5", + "l11ns": { + "name1": { + "en": "Packaging materials", + "de": "Verpackungsmaterial" + }, + "description_short": {}, + "internal_matchcodes": { + "en": "packaging", + "de": "verpackung" + } + }, + "primary_image": "", + "keywords": {}, + "attributes": [ + { + "type": "bill_fees", + "value": 1, + "custom": false + } + ], + "variants": [] + }, + { + "number": "99", + "l11ns": { + "name1": { + "en": "Discount", + "de": "Rabatt" }, "description_short": {} }, diff --git a/Admin/Install/localizations.json b/Admin/Install/localizations.json index f2cec38..b8e9ee3 100755 --- a/Admin/Install/localizations.json +++ b/Admin/Install/localizations.json @@ -11,6 +11,10 @@ "name": "info", "is_required": false }, + { + "name": "internal_matchcodes", + "is_required": false + }, { "name": "description_short", "is_required": false diff --git a/Admin/Installer.php b/Admin/Installer.php index 768ddbe..82e7a9c 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -60,7 +60,7 @@ final class Installer extends InstallerAbstract $attrTypes = self::createAttributeTypes($app, $attributes); $attrValues = self::createAttributeValues($app, $attrTypes, $attributes); - $data = \json_decode(\file_get_contents(__DIR__ . '/Install/Admin.install.json'), true); + $data = include __DIR__ . '/Install/Admin.install.php'; $content = \json_decode($data[0]['content'], true); foreach ($content as $type => $_) { @@ -126,10 +126,10 @@ final class Installer extends InstallerAbstract $itemArray = []; /** @var \Modules\ItemManagement\Controller\ApiController $module */ - $module = $app->moduleManager->getModuleInstance('ItemManagement'); + $module = $app->moduleManager->get('ItemManagement'); /** @var \Modules\ItemManagement\Controller\ApiAttributeController $module2 */ - $module2 = $app->moduleManager->getModuleInstance('ItemManagement', 'ApiAttribute'); + $module2 = $app->moduleManager->get('ItemManagement', 'ApiAttribute'); /** @var \Modules\Attribute\Models\AttributeType[] $attributeTypes */ $attributeTypes = ItemAttributeTypeMapper::getAll()->with('defaults')->execute(); @@ -246,7 +246,7 @@ final class Installer extends InstallerAbstract $l11nTypes = []; /** @var \Modules\ItemManagement\Controller\ApiController $module */ - $module = $app->moduleManager->getModuleInstance('ItemManagement'); + $module = $app->moduleManager->get('ItemManagement'); foreach ($l11ns as $l11n) { $response = new HttpResponse(); @@ -287,7 +287,7 @@ final class Installer extends InstallerAbstract $relations = []; /** @var \Modules\ItemManagement\Controller\ApiController $module */ - $module = $app->moduleManager->getModuleInstance('ItemManagement'); + $module = $app->moduleManager->get('ItemManagement'); foreach ($rels as $rel) { $response = new HttpResponse(); @@ -327,7 +327,7 @@ final class Installer extends InstallerAbstract $itemAttrType = []; /** @var \Modules\ItemManagement\Controller\ApiAttributeController $module */ - $module = $app->moduleManager->getModuleInstance('ItemManagement', 'ApiAttribute'); + $module = $app->moduleManager->get('ItemManagement', 'ApiAttribute'); /** @var array $attribute */ foreach ($attributes as $attribute) { @@ -395,7 +395,7 @@ final class Installer extends InstallerAbstract $itemAttrValue = []; /** @var \Modules\ItemManagement\Controller\ApiAttributeController $module */ - $module = $app->moduleManager->getModuleInstance('ItemManagement', 'ApiAttribute'); + $module = $app->moduleManager->get('ItemManagement', 'ApiAttribute'); foreach ($attributes as $attribute) { $itemAttrValue[$attribute['name']] = []; @@ -468,7 +468,7 @@ final class Installer extends InstallerAbstract $itemMaterialType = []; /** @var \Modules\ItemManagement\Controller\ApiController $module */ - $module = $app->moduleManager->getModuleInstance('ItemManagement', 'Api'); + $module = $app->moduleManager->get('ItemManagement', 'Api'); /** @var array $type */ foreach ($types as $type) { diff --git a/Admin/Routes/Web/Api.php b/Admin/Routes/Web/Api.php index 8a7b8be..0587b9d 100755 --- a/Admin/Routes/Web/Api.php +++ b/Admin/Routes/Web/Api.php @@ -18,6 +18,17 @@ use phpOMS\Account\PermissionType; use phpOMS\Router\RouteVerb; return [ + '^.*/item/list(\?.*$|$)' => [ + [ + 'dest' => '\Modules\ItemManagement\Controller\ApiController:apiItemListExport', + 'verb' => RouteVerb::GET, + 'permission' => [ + 'module' => ApiController::NAME, + 'type' => PermissionType::READ, + 'state' => PermissionCategory::SALES_ITEM, + ], + ], + ], '^.*/item/find(\?.*$|$)' => [ [ 'dest' => '\Modules\ItemManagement\Controller\ApiController:apiItemFind', diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 7452a6f..760acbe 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -57,6 +57,12 @@ use phpOMS\System\MimeType; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @todo Import item prices from csv/excel sheet + * https://github.com/Karaka-Management/oms-ItemManagement/issues/15 + * + * @todo Perform inflation increase on all items + * https://github.com/Karaka-Management/oms-ItemManagement/issues/16 */ final class ApiController extends Controller { @@ -75,33 +81,79 @@ final class ApiController extends Controller */ public function apiItemFind(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void { + // @question How to handle empty search? + // 1. Return empty + // 2. Return normal item list with default limit + /** @var BaseStringL11n[] $l11n */ $l11n = ItemL11nMapper::getAll() ->with('type') - ->where('type/title', ['name1', 'name2', 'name3'], 'IN') - ->where('language', $request->header->l11n->language) - ->where('description', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE') + ->where('type/title', ['internal_matchcodes'], 'IN') + ->where('language', $response->header->l11n->language) + ->where('content', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE') + ->limit($request->getDataInt('limit') ?? 50) ->execute(); - $items = []; - foreach ($l11n as $item) { - $items[] = $item->ref; + if (empty($l11n)) { + $l11n = ItemL11nMapper::getAll() + ->with('type') + ->where('type/title', ['name1', 'name2'], 'IN') + ->where('language', $response->header->l11n->language) + ->where('content', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE') + ->limit($request->getDataInt('limit') ?? 50) + ->execute(); } - /** @var \Modules\ItemManagement\Models\Item[] $itemList */ - $itemList = ItemMapper::getAll() - ->with('l11n') - ->with('l11n/type') - ->where('id', $items, 'IN') - ->where('l11n/type/title', ['name1', 'name2', 'name3'], 'IN') - ->where('l11n/language', $request->header->l11n->language) - ->execute(); + if (empty($l11n)) { + $searches = \explode(' ', $request->getDataString('search') ?? ''); + foreach ($searches as $search) { + $l11n = ItemL11nMapper::getAll() + ->with('type') + ->where('type/title', ['internal_matchcodes'], 'IN') + ->where('language', $response->header->l11n->language) + ->where('content', '%' . $search . '%', 'LIKE') + ->limit($request->getDataInt('limit') ?? 50) + ->execute(); + + if (!empty($l11n)) { + break; + } + } + + if (empty($l11n)) { + foreach ($searches as $search) { + $l11n = ItemL11nMapper::getAll() + ->with('type') + ->where('type/title', ['name1', 'name2'], 'IN') + ->where('language', $response->header->l11n->language) + ->where('content', '%' . $search . '%', 'LIKE') + ->limit($request->getDataInt('limit') ?? 50) + ->execute(); + + if (!empty($l11n)) { + break; + } + } + } + } + + $itemList = []; + if (!empty($l11n)) { + $itemIds = \array_map(function (BaseStringL11n $l) { + return $l->ref; + }, $l11n); + + $itemList = ItemMapper::getAll() + ->with('l11n') + ->with('l11n/type') + ->where('l11n/type/title', ['name1', 'name2'], 'IN') + ->where('l11n/language', $request->header->l11n->language) + ->where('id', $itemIds, 'IN') + ->execute(); + } $response->header->set('Content-Type', MimeType::M_JSON, true); - $response->set( - $request->uri->__toString(), - \array_values($itemList) - ); + $response->set($request->uri->__toString(), \array_values($itemList)); /* @todo BIG TODO. @@ -112,7 +164,7 @@ final class ApiController extends Controller left join itemmgmt_item_l11n on itemmgmt_item.itemmgmt_item_id = itemmgmt_item_l11n.itemmgmt_item_l11n_item left join itemmgmt_item_l11n_type on itemmgmt_item_l11n.itemmgmt_item_l11n_typeref = itemmgmt_item_l11n_type.itemmgmt_item_l11n_type_id where - itemmgmt_item_l11n_type.itemmgmt_item_l11n_type_title IN ("name1", "name2", "name3") + itemmgmt_item_l11n_type.itemmgmt_item_l11n_type_title IN ("name1", "name2") AND itemmgmt_item_l11n.itemmgmt_item_l11n_lang = "en" AND itemmgmt_item_l11n.itemmgmt_item_l11n_description LIKE "%Doc%" @@ -135,6 +187,26 @@ final class ApiController extends Controller . (empty($item->number) ? $item->id : $item->number); } + public function apiItemListExport(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void + { + $items = []; + + /** @var Item $item */ + foreach (ItemMapper::yield()->execute() as $item) { + $items[] = [ + 'id' => $item->id, + 'name1' => $item->getL11n('name1')->content, + 'name2' => $item->getL11n('name2')->content, + ]; + } + + $report = new \Modules\Exchange\Models\Report(); + $report->data = $items; + + $this->app->moduleManager->get('Exchange', 'Api') + ->apiExportReport($request, $response, $report, $request->getDataString('type') ?? 'csv'); + } + /** * Api method to create item * @@ -203,6 +275,7 @@ final class ApiController extends Controller $internalRequest->setData('name', 'default'); $internalRequest->setData('type', PriceType::PURCHASE); $internalRequest->setData('item', $item->id); + $internalRequest->setData('supplier', $request->getDataInt('supplier')); $internalRequest->setData('price_new', $request->getDataString('purchaseprice') ?? 0); $billing->apiPriceCreate($internalRequest, $internalResponse); @@ -325,12 +398,12 @@ final class ApiController extends Controller $item->purchasePrice = new FloatInt($request->getDataString('purchaseprice') ?? 0); $item->info = $request->getDataString('info') ?? ''; $item->parent = $request->getDataInt('parent'); - $item->unit = $request->getDataInt('unit'); + $item->unit = $request->getDataInt('unit') ?? $this->app->unitId; $item->status = ItemStatus::tryFromValue($request->getDataInt('status')) ?? ItemStatus::ACTIVE; $container = new Container(); $container->name = 'default'; - $container->quantity = \pow(10, FloatInt::MAX_DECIMALS); + $container->quantity = FloatInt::DIVISOR; $item->container[] = $container; diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 3a608c5..a3fff9e 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -27,10 +27,12 @@ use Modules\ItemManagement\Models\ItemL11nTypeMapper; use Modules\ItemManagement\Models\ItemMapper; use Modules\ItemManagement\Models\MaterialTypeL11nMapper; use Modules\ItemManagement\Models\MaterialTypeMapper; +use Modules\ItemManagement\Models\PermissionCategory; use Modules\Media\Models\MediaMapper; use Modules\Media\Models\MediaTypeMapper; use Modules\Organization\Models\Attribute\UnitAttributeMapper; use Modules\Organization\Models\UnitMapper; +use phpOMS\Account\PermissionType; use phpOMS\Asset\AssetType; use phpOMS\Contract\RenderableInterface; use phpOMS\DataStorage\Database\Query\Builder; @@ -51,6 +53,9 @@ use phpOMS\Views\View; * @link https://jingga.app * @since 1.0.0 * @codeCoverageIgnore + * + * @feature Show additional important item information for sales/purchase, currently too controlling/stats focused. + * https://github.com/Karaka-Management/oms-ItemManagement/issues/3 */ final class BackendController extends Controller { @@ -203,8 +208,9 @@ final class BackendController extends Controller ->with('files') ->with('files/types') ->where('l11n/language', $response->header->l11n->language) - ->where('l11n/type/title', ['name1', 'name2', 'name3'], 'IN') + ->where('l11n/type/title', ['name1', 'name2'], 'IN') ->where('files/types/name', 'item_profile_image') + ->where('unit', $this->app->unitId) ->limit(50) ->execute(); @@ -381,9 +387,9 @@ final class BackendController extends Controller $head = $response->data['Content']->head; $nonce = $this->app->appSettings->getOption('script-nonce'); - $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css'); - $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js', ['nonce' => $nonce]); - $head->addAsset(AssetType::JSLATE, 'Modules/ItemManagement/Controller.js', ['nonce' => $nonce, 'type' => 'module']); + $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css?v=' . $this->app->version); + $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js?v=' . $this->app->version, ['nonce' => $nonce]); + $head->addAsset(AssetType::JSLATE, 'Modules/ItemManagement/Controller.js?v=' . self::VERSION, ['nonce' => $nonce, 'type' => 'module']); $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/ItemManagement/Theme/Backend/item-view'); @@ -403,7 +409,7 @@ final class BackendController extends Controller //->with('attributes/value/l11n') ->where('id', (int) $request->getData('id')) ->where('l11n/language', $response->header->l11n->language) - ->where('l11n/type/title', ['name1', 'name2', 'name3'], 'IN') + ->where('l11n/type/title', ['name1', 'name2'], 'IN') ->where('attributes/type/l11n/language', $response->header->l11n->language) //->where('attributes/value/l11n/language', $response->header->l11n->language) ->execute(); @@ -471,6 +477,8 @@ final class BackendController extends Controller /** @var \Modules\Billing\Models\Price\Price[] */ $view->data['prices'] = $view->data['hasBilling'] ? \Modules\Billing\Models\Price\PriceMapper::getAll() + ->with('supplier') + ->with('supplier/account') ->where('item', $view->data['item']->id) ->where('client', null) ->execute() @@ -512,12 +520,24 @@ final class BackendController extends Controller $view->data['clientSegmentationTypes'] = $clientSegmentationTypes; - /** @var \Modules\Auditor\Models\Audit[] */ - $view->data['audits'] = AuditMapper::getAll() - ->where('type', StringUtils::intHash(ItemMapper::class)) - ->where('module', 'ItemManagement') - ->where('ref', (string) $view->data['item']->id) - ->execute(); + $logs = []; + if ($this->app->accountManager->get($request->header->account)->hasPermission( + PermissionType::READ, + $this->app->unitId, + null, + self::NAME, + PermissionCategory::ITEM_LOG, + ) + ) { + /** @var \Modules\Auditor\Models\Audit[] */ + $logs = AuditMapper::getAll() + ->where('type', StringUtils::intHash(ItemMapper::class)) + ->where('module', 'ItemManagement') + ->where('ref', (string) $view->data['item']->id) + ->execute(); + } + + $view->data['logs'] = $logs; // @todo join audit with files, attributes, localization, prices, notes, ... @@ -602,9 +622,9 @@ final class BackendController extends Controller $head = $response->data['Content']->head; $nonce = $this->app->appSettings->getOption('script-nonce'); - $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css'); - $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js', ['nonce' => $nonce]); - $head->addAsset(AssetType::JSLATE, 'Modules/Sales/Controller/Controller.js', ['nonce' => $nonce, 'type' => 'module']); + $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css?v=' . $this->app->version); + $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js?v=' . $this->app->version, ['nonce' => $nonce]); + $head->addAsset(AssetType::JSLATE, 'Modules/Sales/Controller/Controller.js?v=' . self::VERSION, ['nonce' => $nonce, 'type' => 'module']); $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/ItemManagement/Theme/Backend/item-analysis'); diff --git a/Docs/Help/de/SUMMARY.md b/Docs/Help/de/SUMMARY.md new file mode 100644 index 0000000..3e679fe --- /dev/null +++ b/Docs/Help/de/SUMMARY.md @@ -0,0 +1,4 @@ +# User Content + +* [Attributes]({%}&page=Help/attributes) +* [Localization]({%}&page=Help/localization) diff --git a/Docs/Help/de/accounting.md b/Docs/Help/de/accounting.md new file mode 100644 index 0000000..e69de29 diff --git a/Docs/Help/de/attributes.md b/Docs/Help/de/attributes.md new file mode 100644 index 0000000..6eb9b17 --- /dev/null +++ b/Docs/Help/de/attributes.md @@ -0,0 +1,116 @@ +# Attributes + +## Default + +The module automatically installs the following default attributes which can be set in the attribute tab in the respective item. + +### General + +| Attribute | Description | Internal default value | +| --------- | ----------- | ---------------------- | +| default_sales_container | Default sales container to be used | First container created for the item | +| default_purchase_container | Default purchase container to be used | First container created for the item | +| internal_item | Is the item only meant for internal purposes (e.g. cleaning utilities)? | | +| bill_fees | Is special item on invoices (e.g. shipping cost, insurance fees, ...) | | +| upc | Universal product code | | +| hs_code | Harmonized system code (HS code) | | +| hazmat | Hazardous material type | | +| color | Item color | | +| length | Item length | | +| weight | Item weight | | +| height | Item height | | +| volume | Item volume | | +| release_date | Date of first release | | +| license | License type | | +| it_platform | Is it platform | | +| brand | Brand name | | +| model | Model description | | +| os | Operating system | | +| os_version | Operating system version | | +| dual_use | Is dual use item | | +| contract | Contract id related to this item | | +| subscription | Is item with subscription model | | +| subscription_interval_types | Interval types of the subscription (e.g. monthly) | | +| subscription_interval_value | Interval of the subscription | | +| subscription_renewal_type | How does the subscription renew | | +| subscription_interval_end | When does the subscription end? | | +| one_click_pay_cc | One click payment link for credit card payment | | +| one_click_pay_cc_id | One click id for credit card payment | | +| one_click_pay_paypal | One click payment link for paypal payment | | +| iso_keep_dry | Does the item need to be kept dry? | | +| iso_temparature_lower_limit | Lowest temperature for storage/transportation | | +| iso_temparature_upper_limit | Highest temperature for storage/transportation | | +| iso_shelf_life | What is the shelf life in days? | | +| country_of_origin | Country of origin | | +| country_of_assembly | Country of assembly | | +| country_of_last_processing | Country of last processing | | +| consumablefor | Is consumable for other item? Id of item required | | +| successorof | Is successor of other item? Id of item required | | +| variantof | Is variant of other item? Id of item required | | +| accessoryfor | Is accessory for other item? Id of item required | | +| sparepartfor | Is sparepart for other item? Id of item required | | +| isfamilyfriendly | Is familyfriendly item? | | +| item_condition | Condition of the item (e.g. used) | | +| gtin | GTIN | | +| eu_medical_device_class | EU medical device class | | +| fda_medical_regulatory_class | FDA medical regulatory class | | + +### Categories + +Items can be put in categories for horizontal and vertical grouping. By default the system uses segment->section->sales_group->product_group as categories as well as product_type. These categories also get used by other modules. Additional groups can be defined but are not used by other modules by default. + +| Attribute | Description | Internal default value | +| --------- | ----------- | ---------------------- | +| segment | Level 1 | 1 | +| section | Level 2 | 1 | +| sales_group | Level 3 | 1 | +| product_group | Level 4 | 1 | +| product_type | **NOT** hierarchically but to the side (e.g. machine, consumable, spare part, ...) | 1 | + +The following table shows an example item segmentation for the hierarchically categories: + +| Level | > | > | > | > | > | > | Sample | +| :---: | :-------------------: | :-------------------: | :-------------------: | :-------------------: | :-------------------: | :-------------------: | :-------------------: | +| 1 | > | > | > | > | Segment 1 | > | Segment 2 | +| 2 | > | > | Section 1.1 | > | Section 1.2 | > | Section 2.1 | +| 3 | Sales Group 1.1.1 | > | Sales Group 1.1.2 | > | Sales Group 1.2.1 | Sales Group 2.1.1 | Sales Group 2.1.2 | +| 4 | Product Group 1.1.1.1 | Product Group 1.1.2.1 | Product Group 1.1.2.2 | Product Group 1.2.1.1 | Product Group 1.2.1.2 | Product Group 2.1.1.1 | Product Group 2.1.2.1 | + +> You could consider the item (number) itself `Level 5`. + +### Purchase & Stock + +| Attribute | Description | Internal default value | +| --------- | ----------- | ---------------------- | +| lead_time | Lead time in days for the procurement. Important for automatic order suggestions. | 3 days | +| admin_time | Internal administration time in seconds needed **per quantity** until a delivered item becomes ready for sales (e.g. quality control). Important for automatic order suggestions. | 10 seconds | +| maximum_stock_quantity | Maximum stock quantity to limit the automatic order suggestion. Only needed for certain algorithms. | | +| minimum_stock_quantity | Minimum stock quantity that should always be in stock. Important for automatic order suggestions. Alternatively, see **minimum_stock_range**. | | +| minimum_stock_range | Minimum stock range in days that should always be in stock. Important for automatic order suggestions. Alternatively, see **minimum_stock_quantity**. | 1 day | +| minimum_order_quantity | Minimum order quantity when ordering. Important for automatic order suggestions. | | +| order_quantity_steps | Minimum quantity increments above the minimum_order_quantity. This allows item purchases in increments of 10, 100 etc. Important for automatic order suggestions. | 1 | +| order_suggestion_type | Coming soon | | +| order_suggestion_optimization_type | Coming soon | | +| order_suggestion_history_duration | Coming soon | | +| order_suggestion_averaging_method | Coming soon | | +| order_suggestion_comparison_duration_type | Coming soon | | +| stock_evaluation_category | How should the item value for the stock evaluation be determined? | Average | + +### Shop + +| Attribute | Description | Internal default value | +| --------- | ----------- | ---------------------- | +| shop_item | Is the item used in a shop? | | +| shop_featured | Is the item a featured item? | | +| shop_front | Should the item be shown on the front page of the shop? | | +| shop_external_link | Link for the item to an external website (e.g. manufacturer website) | | + +### Accounting + +| Attribute | Description | Internal default value | +| --------- | ----------- | ---------------------- | +| sales_tax_code | Tax code for sales | | +| purchase_tax_code | Tax code for purchase | | +| costcenter | Cost center for accounting | | +| costobject | Cost object for accounting | | + diff --git a/Docs/Help/de/introduction.md b/Docs/Help/de/introduction.md new file mode 100644 index 0000000..14e6a9e --- /dev/null +++ b/Docs/Help/de/introduction.md @@ -0,0 +1,54 @@ +# Introduction + +The **Item Management** module is an essential module for any ERP application. This module handles basic item management and is deeply integrated into **Billing** and **Warehouse Management**. + +## Target Group + +The target group for this module is anyone who wants to manage their tangible and non-tangible products. + +# Setup + +This module doesn't have any additional setup requirements and can be simply installed through the module interface. + +# Features + +## Item master file + +The module provides basic item data management + +* Attach documents to items +* Write notes for items +* Overview of most recent notes, documents, invoices and sales statistics (requires **Billing**) + +## Localization + +Localizations allow you to define item names and descriptions in multiple languages. You can also define custom text elements for external use (e.g. descriptions to be exported to other systems such as your own shop system). + +## Attributes + +Attributes allow you to define various item characteristics such as color, medical device class, segmentation, hazardous good, brand, model and many more. + +## Pricing + +By installing the **Billing** module you are can define multiple purchase and sales prices. Prices and discounts can be defined for individual items, customers and suppliers and for customer groups. You may also define quantity based prices. + +## Procurement + +Together with the **Purchase** module you can define stock levels, order conditions and delivery times for automated order suggestion calculations making it a breeze to ensure sufficient stocks. + +## Accounting + +Together with the **Accounting** module you can define cost center, cost object and taxes for every item. + +## Stock + +Together with the **Warehouse Management** module you can also track your stocks and + +# Recommendation + +Other modules that work great with this one together are: + +* [Warehouse Management](WarehouseManagement) +* [Supplier Management](SupplierManagement) +* [Purchase](Purchase) +* [Accounting](Accounting) diff --git a/Docs/Help/de/localization.md b/Docs/Help/de/localization.md new file mode 100644 index 0000000..94aa062 --- /dev/null +++ b/Docs/Help/de/localization.md @@ -0,0 +1,14 @@ +# Localization + +## Default + +The module automatically installs the following default localizations which can be set in the localization tab in the respective item. + +* name1 - Primary item name +* name2 - Secondary item name +* info - Internal item info +* internal_matchcodes - Match code for finding item based on a specific name or short description +* description_short - Short item description +* description_long - Long item description +* shop_name1 - Primary item name for a shop system +* shop_name2 - Secondary item name for a shop system \ No newline at end of file diff --git a/Docs/Help/de/pricing.md b/Docs/Help/de/pricing.md new file mode 100644 index 0000000..e69de29 diff --git a/Docs/Help/de/procurement.md b/Docs/Help/de/procurement.md new file mode 100644 index 0000000..e69de29 diff --git a/Docs/Help/de/stock.md b/Docs/Help/de/stock.md new file mode 100644 index 0000000..e69de29 diff --git a/Docs/Help/en/SUMMARY.md b/Docs/Help/en/SUMMARY.md new file mode 100644 index 0000000..3e679fe --- /dev/null +++ b/Docs/Help/en/SUMMARY.md @@ -0,0 +1,4 @@ +# User Content + +* [Attributes]({%}&page=Help/attributes) +* [Localization]({%}&page=Help/localization) diff --git a/Docs/Help/en/accounting.md b/Docs/Help/en/accounting.md new file mode 100644 index 0000000..e69de29 diff --git a/Docs/Help/en/attributes.md b/Docs/Help/en/attributes.md new file mode 100644 index 0000000..6eb9b17 --- /dev/null +++ b/Docs/Help/en/attributes.md @@ -0,0 +1,116 @@ +# Attributes + +## Default + +The module automatically installs the following default attributes which can be set in the attribute tab in the respective item. + +### General + +| Attribute | Description | Internal default value | +| --------- | ----------- | ---------------------- | +| default_sales_container | Default sales container to be used | First container created for the item | +| default_purchase_container | Default purchase container to be used | First container created for the item | +| internal_item | Is the item only meant for internal purposes (e.g. cleaning utilities)? | | +| bill_fees | Is special item on invoices (e.g. shipping cost, insurance fees, ...) | | +| upc | Universal product code | | +| hs_code | Harmonized system code (HS code) | | +| hazmat | Hazardous material type | | +| color | Item color | | +| length | Item length | | +| weight | Item weight | | +| height | Item height | | +| volume | Item volume | | +| release_date | Date of first release | | +| license | License type | | +| it_platform | Is it platform | | +| brand | Brand name | | +| model | Model description | | +| os | Operating system | | +| os_version | Operating system version | | +| dual_use | Is dual use item | | +| contract | Contract id related to this item | | +| subscription | Is item with subscription model | | +| subscription_interval_types | Interval types of the subscription (e.g. monthly) | | +| subscription_interval_value | Interval of the subscription | | +| subscription_renewal_type | How does the subscription renew | | +| subscription_interval_end | When does the subscription end? | | +| one_click_pay_cc | One click payment link for credit card payment | | +| one_click_pay_cc_id | One click id for credit card payment | | +| one_click_pay_paypal | One click payment link for paypal payment | | +| iso_keep_dry | Does the item need to be kept dry? | | +| iso_temparature_lower_limit | Lowest temperature for storage/transportation | | +| iso_temparature_upper_limit | Highest temperature for storage/transportation | | +| iso_shelf_life | What is the shelf life in days? | | +| country_of_origin | Country of origin | | +| country_of_assembly | Country of assembly | | +| country_of_last_processing | Country of last processing | | +| consumablefor | Is consumable for other item? Id of item required | | +| successorof | Is successor of other item? Id of item required | | +| variantof | Is variant of other item? Id of item required | | +| accessoryfor | Is accessory for other item? Id of item required | | +| sparepartfor | Is sparepart for other item? Id of item required | | +| isfamilyfriendly | Is familyfriendly item? | | +| item_condition | Condition of the item (e.g. used) | | +| gtin | GTIN | | +| eu_medical_device_class | EU medical device class | | +| fda_medical_regulatory_class | FDA medical regulatory class | | + +### Categories + +Items can be put in categories for horizontal and vertical grouping. By default the system uses segment->section->sales_group->product_group as categories as well as product_type. These categories also get used by other modules. Additional groups can be defined but are not used by other modules by default. + +| Attribute | Description | Internal default value | +| --------- | ----------- | ---------------------- | +| segment | Level 1 | 1 | +| section | Level 2 | 1 | +| sales_group | Level 3 | 1 | +| product_group | Level 4 | 1 | +| product_type | **NOT** hierarchically but to the side (e.g. machine, consumable, spare part, ...) | 1 | + +The following table shows an example item segmentation for the hierarchically categories: + +| Level | > | > | > | > | > | > | Sample | +| :---: | :-------------------: | :-------------------: | :-------------------: | :-------------------: | :-------------------: | :-------------------: | :-------------------: | +| 1 | > | > | > | > | Segment 1 | > | Segment 2 | +| 2 | > | > | Section 1.1 | > | Section 1.2 | > | Section 2.1 | +| 3 | Sales Group 1.1.1 | > | Sales Group 1.1.2 | > | Sales Group 1.2.1 | Sales Group 2.1.1 | Sales Group 2.1.2 | +| 4 | Product Group 1.1.1.1 | Product Group 1.1.2.1 | Product Group 1.1.2.2 | Product Group 1.2.1.1 | Product Group 1.2.1.2 | Product Group 2.1.1.1 | Product Group 2.1.2.1 | + +> You could consider the item (number) itself `Level 5`. + +### Purchase & Stock + +| Attribute | Description | Internal default value | +| --------- | ----------- | ---------------------- | +| lead_time | Lead time in days for the procurement. Important for automatic order suggestions. | 3 days | +| admin_time | Internal administration time in seconds needed **per quantity** until a delivered item becomes ready for sales (e.g. quality control). Important for automatic order suggestions. | 10 seconds | +| maximum_stock_quantity | Maximum stock quantity to limit the automatic order suggestion. Only needed for certain algorithms. | | +| minimum_stock_quantity | Minimum stock quantity that should always be in stock. Important for automatic order suggestions. Alternatively, see **minimum_stock_range**. | | +| minimum_stock_range | Minimum stock range in days that should always be in stock. Important for automatic order suggestions. Alternatively, see **minimum_stock_quantity**. | 1 day | +| minimum_order_quantity | Minimum order quantity when ordering. Important for automatic order suggestions. | | +| order_quantity_steps | Minimum quantity increments above the minimum_order_quantity. This allows item purchases in increments of 10, 100 etc. Important for automatic order suggestions. | 1 | +| order_suggestion_type | Coming soon | | +| order_suggestion_optimization_type | Coming soon | | +| order_suggestion_history_duration | Coming soon | | +| order_suggestion_averaging_method | Coming soon | | +| order_suggestion_comparison_duration_type | Coming soon | | +| stock_evaluation_category | How should the item value for the stock evaluation be determined? | Average | + +### Shop + +| Attribute | Description | Internal default value | +| --------- | ----------- | ---------------------- | +| shop_item | Is the item used in a shop? | | +| shop_featured | Is the item a featured item? | | +| shop_front | Should the item be shown on the front page of the shop? | | +| shop_external_link | Link for the item to an external website (e.g. manufacturer website) | | + +### Accounting + +| Attribute | Description | Internal default value | +| --------- | ----------- | ---------------------- | +| sales_tax_code | Tax code for sales | | +| purchase_tax_code | Tax code for purchase | | +| costcenter | Cost center for accounting | | +| costobject | Cost object for accounting | | + diff --git a/Docs/Help/en/introduction.md b/Docs/Help/en/introduction.md new file mode 100644 index 0000000..14e6a9e --- /dev/null +++ b/Docs/Help/en/introduction.md @@ -0,0 +1,54 @@ +# Introduction + +The **Item Management** module is an essential module for any ERP application. This module handles basic item management and is deeply integrated into **Billing** and **Warehouse Management**. + +## Target Group + +The target group for this module is anyone who wants to manage their tangible and non-tangible products. + +# Setup + +This module doesn't have any additional setup requirements and can be simply installed through the module interface. + +# Features + +## Item master file + +The module provides basic item data management + +* Attach documents to items +* Write notes for items +* Overview of most recent notes, documents, invoices and sales statistics (requires **Billing**) + +## Localization + +Localizations allow you to define item names and descriptions in multiple languages. You can also define custom text elements for external use (e.g. descriptions to be exported to other systems such as your own shop system). + +## Attributes + +Attributes allow you to define various item characteristics such as color, medical device class, segmentation, hazardous good, brand, model and many more. + +## Pricing + +By installing the **Billing** module you are can define multiple purchase and sales prices. Prices and discounts can be defined for individual items, customers and suppliers and for customer groups. You may also define quantity based prices. + +## Procurement + +Together with the **Purchase** module you can define stock levels, order conditions and delivery times for automated order suggestion calculations making it a breeze to ensure sufficient stocks. + +## Accounting + +Together with the **Accounting** module you can define cost center, cost object and taxes for every item. + +## Stock + +Together with the **Warehouse Management** module you can also track your stocks and + +# Recommendation + +Other modules that work great with this one together are: + +* [Warehouse Management](WarehouseManagement) +* [Supplier Management](SupplierManagement) +* [Purchase](Purchase) +* [Accounting](Accounting) diff --git a/Docs/Help/en/localization.md b/Docs/Help/en/localization.md new file mode 100644 index 0000000..94aa062 --- /dev/null +++ b/Docs/Help/en/localization.md @@ -0,0 +1,14 @@ +# Localization + +## Default + +The module automatically installs the following default localizations which can be set in the localization tab in the respective item. + +* name1 - Primary item name +* name2 - Secondary item name +* info - Internal item info +* internal_matchcodes - Match code for finding item based on a specific name or short description +* description_short - Short item description +* description_long - Long item description +* shop_name1 - Primary item name for a shop system +* shop_name2 - Secondary item name for a shop system \ No newline at end of file diff --git a/Docs/Help/en/pricing.md b/Docs/Help/en/pricing.md new file mode 100644 index 0000000..e69de29 diff --git a/Docs/Help/en/procurement.md b/Docs/Help/en/procurement.md new file mode 100644 index 0000000..e69de29 diff --git a/Docs/Help/en/stock.md b/Docs/Help/en/stock.md new file mode 100644 index 0000000..e69de29 diff --git a/Models/ItemMapper.php b/Models/ItemMapper.php index 6706b63..c777690 100755 --- a/Models/ItemMapper.php +++ b/Models/ItemMapper.php @@ -185,7 +185,7 @@ final class ItemMapper extends DataMapperFactory left join itemmgmt_item_l11n_type on itemmgmt_item_l11n.itemmgmt_item_l11n_typeref = itemmgmt_item_l11n_type.itemmgmt_item_l11n_type_id where - itemmgmt_item_l11n_type.itemmgmt_item_l11n_type_title in ('name1', 'name2', 'name3') + itemmgmt_item_l11n_type.itemmgmt_item_l11n_type_title in ('name1', 'name2') and itemmgmt_item_l11n.itemmgmt_item_l11n_lang = :lang SQL; diff --git a/Models/ItemStatus.php b/Models/ItemStatus.php index f9eb9e8..f042a53 100755 --- a/Models/ItemStatus.php +++ b/Models/ItemStatus.php @@ -28,7 +28,9 @@ abstract class ItemStatus extends Enum { public const ACTIVE = 1; - public const INACTIVE = 2; + public const DRAFT = 2; - public const PREVIEW = 3; + public const INACTIVE = 3; + + public const DISCONTINUED = 4; } diff --git a/Models/PermissionCategory.php b/Models/PermissionCategory.php index 96882bf..19e63c9 100755 --- a/Models/PermissionCategory.php +++ b/Models/PermissionCategory.php @@ -37,4 +37,6 @@ abstract class PermissionCategory extends Enum public const NOTE = 5; public const MATERIAL = 6; + + public const ITEM_LOG = 101; } diff --git a/Theme/Backend/Lang/de.lang.php b/Theme/Backend/Lang/de.lang.php index 76a6089..ef8f499 100755 --- a/Theme/Backend/Lang/de.lang.php +++ b/Theme/Backend/Lang/de.lang.php @@ -30,7 +30,7 @@ return ['ItemManagement' => [ 'Commission' => 'Kommission', 'Container' => 'Container', 'CostCenter' => 'Kostenstelle', - 'CostIndicator' => 'Kostenindikator', + 'CostIndicator' => 'Einkaufssteuerkennzeichen', 'CostObject' => 'Kostenträger', 'Countries' => 'Länder', 'Country' => 'Land', @@ -44,7 +44,7 @@ return ['ItemManagement' => [ 'DiscountP' => 'Rabatt in%', 'Disposal' => 'Entsorgung', 'Documents' => 'Unterlagen', - 'EarningIndicator' => 'Indikator verdienen', + 'EarningIndicator' => 'Verkaufssteuerkennzeichen', 'End' => 'Ende', 'Files' => 'Dateien', 'General' => 'Allgemein', diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index ecee455..3aec540 100755 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -31,7 +31,7 @@ return ['ItemManagement' => [ 'Material' => 'Material', 'Container' => 'Container', 'CostCenter' => 'CostCenter', - 'CostIndicator' => 'Cost Indicator', + 'CostIndicator' => 'Purchase tax code', 'CostObject' => 'CostObject', 'Countries' => 'Countries', 'Country' => 'Country', @@ -45,7 +45,7 @@ return ['ItemManagement' => [ 'DiscountP' => 'Discount in %', 'Disposal' => 'Disposal', 'Documents' => 'Documents', - 'EarningIndicator' => 'Earning Indicator', + 'EarningIndicator' => 'Sales tax code', 'End' => 'End', 'Files' => 'Files', 'General' => 'General', diff --git a/Theme/Backend/item-create.tpl.php b/Theme/Backend/item-create.tpl.php index f6185e1..afa04d8 100755 --- a/Theme/Backend/item-create.tpl.php +++ b/Theme/Backend/item-create.tpl.php @@ -95,7 +95,7 @@ echo $this->data['nav']->render(); ?> request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>