diff --git a/Admin/Install/attributes.json b/Admin/Install/attributes.json index 7c0fb78..6522ba6 100755 --- a/Admin/Install/attributes.json +++ b/Admin/Install/attributes.json @@ -91,10 +91,10 @@ "values": [] }, { - "name": "maximum_order_interval", + "name": "minimum_order_quantity", "l11n": { - "en": "Maximum order interval", - "de": "Maximale Bestellhäufigkeit" + "en": "MOQ", + "de": "Mindestbestellmenge" }, "value_type": 1, "is_custom_allowed": true, @@ -104,10 +104,23 @@ "values": [] }, { - "name": "minimum_order_quantity", + "name": "order_quantity_steps", "l11n": { - "en": "MOQ", - "de": "Mindestbestellmenge" + "en": "Order quantity steps", + "de": "Bestellschritte" + }, + "value_type": 1, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "minimum_stock_range", + "l11n": { + "en": "Minimum stock range", + "de": "Mindestreichweite" }, "value_type": 1, "is_custom_allowed": true, diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 05046de..01ff746 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -43,6 +43,11 @@ "type": "TINYINT(1)", "null": false }, + "itemmgmt_item_createdat": { + "name": "itemmgmt_item_createdat", + "type": "DATETIME", + "null": false + }, "itemmgmt_item_parent": { "name": "itemmgmt_item_parent", "type": "INT(11)", diff --git a/Controller/ApiController.php b/Controller/ApiController.php index bb0fbf3..7452a6f 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -214,7 +214,7 @@ final class ApiController extends Controller $uploadedFiles = $request->files['item_profile_image'] ?? []; if (!empty($uploadedFiles)) { // upload image - $uploaded = $this->app->moduleManager->get('Media')->uploadFiles( + $uploaded = $this->app->moduleManager->get('Media', 'Api')->uploadFiles( names: [], fileNames: [], files: $uploadedFiles, @@ -676,7 +676,7 @@ final class ApiController extends Controller $path = $this->createItemDir($item); - $uploaded = $this->app->moduleManager->get('Media')->uploadFiles( + $uploaded = $this->app->moduleManager->get('Media', 'Api')->uploadFiles( names: $request->getDataList('names'), fileNames: $request->getDataList('filenames'), files: $uploadedFiles, diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 26df7d0..30e8971 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -216,62 +216,15 @@ final class BackendController extends Controller $reserved = []; $ordered = []; if ($this->app->moduleManager->isActive('WarehouseManagement')) { - $itemIds = \array_map(function (Item $item) { return $item->id; + $itemIds = \array_map(function (Item $item) { + return $item->id; }, $items); - $itemIdsString = \implode(',', $itemIds); - // @todo only select sales stock. Therefore we need a place to define the sales stock(s) - $temp = \Modules\WarehouseManagement\Models\StockDistributionMapper::getAll() - ->where('item', $itemIds, 'IN') - ->execute(); + $distributions = \Modules\WarehouseManagement\Models\StockMapper::getStockDistribution($itemIds); - foreach ($temp as $t) { - if (!isset($dists[$t->item])) { - $dists[$t->item] = []; - } - - // @todo These numbers might need adjustments for delivery notes/invoices depending on - // how we implement them in the warehouse management (maybe flag them in the transaction protocol as reserved?) - // also remember the SD issue where delivery notes can be technically still in stock -> stock value still belongs to company - // solution: "just" do a soft adjust of the available numbers?! but don't change the actual stock in the db - // the SD solution where actually delivered delivery notes can be adjusted after "archiving" will not be allowed - // to allow them to see what happened with such a delivery note maybe we can implement a view shows how many of the items are - // actually still outstanding. This shouldn't be anything special since we need importing of delivery notes anyways and marking - // old delivery note elements in a way to show which line items or even sub-line items got invoiced/returned etc. - $dists[$t->item][] = $t; - } - - $stockIdentifier = StockIdentifierType::NONE; - - $sql = <<app->dbPool->get()); - $results = $query->raw($sql)->execute()->fetchAll(\PDO::FETCH_ASSOC); - - foreach ($results as $result) { - if (!isset($reserved[(int) $result['billing_bill_element_item']])) { - $reserved[(int) $result['billing_bill_element_item']] = 0; - $ordered[(int) $result['billing_bill_element_item']] = 0; - } - - if ($result['billing_type_name'] === 'sales_order_confirmation') { - $reserved[(int) $result['billing_bill_element_item']] += (int) $result['quantity']; - } else { - $ordered[(int) $result['billing_bill_element_item']] += (int) $result['quantity']; - } - } + $dists = $distributions['dists']; + $reserved = $distributions['reserved']; + $ordered = $distributions['ordered']; } $view->data['dists'] = $dists; @@ -457,10 +410,8 @@ final class BackendController extends Controller ->execute(); // Get item profile image - // It might not be part of the 5 newest item files from above - // @todo It would be nice to have something like this as a default method in the model e.g. - // ItemManagement::getRelations()->with('types')->where(...); - // This should return the relations and NOT the model itself + // @feature Create a new read mapper function that returns relation models instead of its own model + // https://github.com/Karaka-Management/phpOMS/issues/320 $query = new Builder($this->app->dbPool->get()); $results = $query->selectAs(ItemMapper::HAS_MANY['files']['external'], 'file') ->from(ItemMapper::TABLE) diff --git a/Models/ItemMapper.php b/Models/ItemMapper.php index 1ed18a3..6706b63 100755 --- a/Models/ItemMapper.php +++ b/Models/ItemMapper.php @@ -52,6 +52,7 @@ final class ItemMapper extends DataMapperFactory 'itemmgmt_item_purchaseprice' => ['name' => 'itemmgmt_item_purchaseprice', 'type' => 'Serializable', 'internal' => 'purchasePrice'], 'itemmgmt_item_parent' => ['name' => 'itemmgmt_item_parent', 'type' => 'int', 'internal' => 'parent'], 'itemmgmt_item_unit' => ['name' => 'itemmgmt_item_unit', 'type' => 'int', 'internal' => 'unit'], + 'itemmgmt_item_createdat' => ['name' => 'itemmgmt_item_createdat', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt'], ]; /** diff --git a/Theme/Backend/item-create.tpl.php b/Theme/Backend/item-create.tpl.php index 7893bdd..f6185e1 100755 --- a/Theme/Backend/item-create.tpl.php +++ b/Theme/Backend/item-create.tpl.php @@ -616,10 +616,7 @@ echo $this->data['nav']->render(); ?>