diff --git a/changelog/62_3.1.0_2021-07-16.md b/changelog/62_3.1.0_2021-07-16.md index 83f6c1fb..0aab3cf2 100644 --- a/changelog/62_3.1.0_2021-07-16.md +++ b/changelog/62_3.1.0_2021-07-16.md @@ -37,7 +37,7 @@ - Product barcodes are now enforced to be unique across products - On the stock overview page it's now also possible to search/filter by product barcodes (via the general search field) - The product picker on the consume and transfer page now only shows products which are currently in stock -- Added a filter option to only show in-stock products on the stock overview and products list (master data) page +- Added a filter option to only show currently in-stock products on the stock overview and products list (master data) page - Added new columns on the stock overview page (hidden by default): Product description, product default location, parent product, product picture - Added a new product option "Should not be frozen" (defaults to disabled and only visible when `FEATURE_FLAG_STOCK_PRODUCT_FREEZING` is enabled) - When enabled, on moving the product to a freezer location (so when freezing it), a corresponding warning will be shown diff --git a/changelog/70_UNRELEASED_xxxx.xx.xx.md b/changelog/70_UNRELEASED_xxxx.xx.xx.md index 257a7731..1c5bf57c 100644 --- a/changelog/70_UNRELEASED_xxxx.xx.xx.md +++ b/changelog/70_UNRELEASED_xxxx.xx.xx.md @@ -30,6 +30,7 @@ - This option will be automatically set on changing the entry's due date - The product option "Quick consume amount" (the amount used for the "quick consume/open buttons" on the stock overview page) has been split into another option "Quick open amount", to be able to set different amounts for consume and open (defaults to the "Quick consume amount" per product, so no changed behavior when not configured) - Changed that for the product's average and last price (and for the price history chart) stock transactions with an empty or `0` price are ignored +- Added a filter option to only show currently out-of-stock products on the products list (master data) page - Fixed that hiding the "Purchased date" column (table options) on the stock entries page didn't work - Fixed that sorting by the "Value" and "Min. stock amount" columns on the stock overview page didn't work - Fixed that the consumed amount was wrong, when consuming multiple substituted subproducts at once and when multiple/different conversion factors were involved diff --git a/controllers/StockController.php b/controllers/StockController.php index 26ec8527..1af1123c 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -243,6 +243,10 @@ class StockController extends BaseController { $products = $products->where('id IN (SELECT product_id from stock_current WHERE amount_aggregated > 0)'); } + if (isset($request->getQueryParams()['only_out_of_stock'])) + { + $products = $products->where('id NOT IN (SELECT product_id from stock_current WHERE amount_aggregated > 0)'); + } $products = $products->orderBy('name', 'COLLATE NOCASE'); diff --git a/localization/strings.pot b/localization/strings.pot index dc3cf0f4..f6482add 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -2412,3 +2412,6 @@ msgstr "" msgid "Stock report" msgstr "" + +msgid "Out-of-stock products" +msgstr "" diff --git a/public/viewjs/products.js b/public/viewjs/products.js index 3810d122..6dfcd758 100644 --- a/public/viewjs/products.js +++ b/public/viewjs/products.js @@ -40,14 +40,20 @@ $("#clear-filter-button").on("click", function() $("#product-group-filter").val("all"); productsTable.column(productsTable.colReorder.transpose(6)).search("").draw(); productsTable.search("").draw(); - if ($("#show-disabled").is(":checked") || $("#show-only-in-stock").is(":checked")) + + if ($("#show-disabled").is(":checked")) { $("#show-disabled").prop("checked", false); - $("#show-only-in-stock").prop("checked", false); RemoveUriParam("include_disabled"); RemoveUriParam("only_in_stock"); window.location.reload(); } + + if ($("#status-filter").val() != "all") + { + $("#status-filter").val("all"); + $("#status-filter").trigger("change"); + } }); if (typeof GetUriParam("product-group") !== "undefined") @@ -109,15 +115,25 @@ $("#show-disabled").change(function() window.location.reload(); }); -$("#show-only-in-stock").change(function() +$("#status-filter").change(function() { - if (this.checked) + var value = $(this).val(); + + if (value == "all") { UpdateUriParam("only_in_stock", "true"); + RemoveUriParam("only_in_stock"); + RemoveUriParam("only_out_of_stock"); } - else + else if (value == "out-of-stock") { RemoveUriParam("only_in_stock"); + UpdateUriParam("only_out_of_stock", "true"); + } + else if (value == "in-stock") + { + RemoveUriParam("only_out_of_stock"); + UpdateUriParam("only_in_stock", "true"); } window.location.reload(); diff --git a/views/products.blade.php b/views/products.blade.php index 4eedb0a6..904ecd04 100644 --- a/views/products.blade.php +++ b/views/products.blade.php @@ -71,6 +71,19 @@ +
+
+
+  {{ $__t('Status') }} +
+ +
+
-
-
- - -
-