diff --git a/changelog/67_UNRELEASED_xxxx-xx-xx.md b/changelog/67_UNRELEASED_xxxx-xx-xx.md index 26c7ceea..26a56372 100644 --- a/changelog/67_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/67_UNRELEASED_xxxx-xx-xx.md @@ -30,6 +30,7 @@ - When the product was once added to stock, there needs to exist a corresponding unit conversion for the new QU - New product option "Disable own stock" (defaults to disabled) - When enabled, the corresponding product can't have own stock, means it will not be selectable on purchase (useful for parent products which are just used as a summary/total view of the child products) +- The location content sheet can now optionally list also out of stock products (at the products default location, new checkbox "Show only in-stock products " at the top of the page, defaults to enabled) - Added the product grocycode as a (hidden by default) column to the products list (master data) - Fixed that consuming via the consume page was not possible when `FEATURE_FLAG_STOCK_LOCATION_TRACKING` was disabled diff --git a/controllers/StockController.php b/controllers/StockController.php index 75f0f8d3..1d39a037 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -72,7 +72,7 @@ class StockController extends BaseController 'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), 'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'), - 'currentStockLocationContent' => $this->getStockService()->GetCurrentStockLocationContent() + 'currentStockLocationContent' => $this->getStockService()->GetCurrentStockLocationContent(isset($request->getQueryParams()['include_out_of_stock'])) ]); } diff --git a/localization/strings.pot b/localization/strings.pot index 19a45b60..df2acada 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -2326,3 +2326,6 @@ msgstr "" msgid "When enabled, this product can't have own stock, means it will not be selectable on purchase (useful for parent products which are just used as a summary/total view of the child products)" msgstr "" + +msgid "Out of stock items will be shown at the products default location" +msgstr "" diff --git a/public/viewjs/locationcontentsheet.js b/public/viewjs/locationcontentsheet.js index 504a76ba..6f03c723 100644 --- a/public/viewjs/locationcontentsheet.js +++ b/public/viewjs/locationcontentsheet.js @@ -12,3 +12,18 @@ $(document).on("click", ".print-single-location-button", function(e) $(".print-timestamp").text(moment().format("l LT")); window.print(); }); + +$("#include-out-of-stock").change(function() +{ + if (this.checked) + { + RemoveUriParam("include_out_of_stock"); + } + else + { + UpdateUriParam("include_out_of_stock", true); + } + + window.location.reload(); +}); + diff --git a/services/StockService.php b/services/StockService.php index e5e47ab2..b16b540c 100644 --- a/services/StockService.php +++ b/services/StockService.php @@ -628,9 +628,15 @@ class StockService extends BaseService return array_column($currentStockMapped, 0); } - public function GetCurrentStockLocationContent() + public function GetCurrentStockLocationContent($includeOutOfStockProductsAtTheDefaultLocation = false) { - $sql = 'SELECT sclc.* FROM stock_current_location_content sclc JOIN products p ON sclc.product_id = p.id ORDER BY p.name'; + $leftJoin = ''; + if ($includeOutOfStockProductsAtTheDefaultLocation) + { + $leftJoin = 'LEFT'; + } + + $sql = 'SELECT IFNULL(sclc.location_id, p.location_id) AS location_id, p.id AS product_id, IFNULL(sclc.amount, 0) AS amount, IFNULL(sclc.amount_opened, 0) AS amount_opened FROM products p ' . $leftJoin . ' JOIN stock_current_location_content sclc ON sclc.product_id = p.id WHERE p.active = 1 ORDER BY p.name'; return $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ); } diff --git a/views/locationcontentsheet.blade.php b/views/locationcontentsheet.blade.php index 73e99125..9dc619d2 100644 --- a/views/locationcontentsheet.blade.php +++ b/views/locationcontentsheet.blade.php @@ -36,6 +36,20 @@ data-trigger="hover click" title="{{ $__t('Here you can print a page per location with the current stock, maybe to hang it there and note the consumed things on it') }}"> +
+ + +