mirror of
https://github.com/grocy/grocy.git
synced 2025-08-15 02:04:38 +00:00
Added on option to only show in-stock products on the /products page (closes #1388)
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
- Product barcodes are now enforced to be unique across products
|
- 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)
|
- 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 page now only shows products which are currently in stock
|
- The product picker on the consume page now only shows products which are currently in stock
|
||||||
|
- Added a filter option to only show in-stock products on the products list page (master data)
|
||||||
- Fixed that editing stock entries was not possible
|
- Fixed that editing stock entries was not possible
|
||||||
- Fixed that consuming with Scan Mode was not possible
|
- Fixed that consuming with Scan Mode was not possible
|
||||||
- Fixed that the current stock total value (header of the stock overview page) didn't include decimal amounts (thanks @Ape)
|
- Fixed that the current stock total value (header of the stock overview page) didn't include decimal amounts (thanks @Ape)
|
||||||
|
@@ -233,15 +233,19 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
public function ProductsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
public function ProductsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||||
{
|
{
|
||||||
if (isset($request->getQueryParams()['include_disabled']))
|
$products = $this->getDatabase()->products();
|
||||||
|
if (!isset($request->getQueryParams()['include_disabled']))
|
||||||
{
|
{
|
||||||
$products = $this->getDatabase()->products()->orderBy('name', 'COLLATE NOCASE');
|
$products = $products->where('active = 1');
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (isset($request->getQueryParams()['only_in_stock']))
|
||||||
{
|
{
|
||||||
$products = $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE');
|
$products = $products->where('id IN (SELECT product_id from stock_current WHERE amount_aggregated > 0)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$products = $products->orderBy('name', 'COLLATE NOCASE');
|
||||||
|
|
||||||
return $this->renderPage($response, 'products', [
|
return $this->renderPage($response, 'products', [
|
||||||
'products' => $products,
|
'products' => $products,
|
||||||
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
|
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
|
||||||
|
@@ -2144,3 +2144,6 @@ msgstr ""
|
|||||||
|
|
||||||
msgid "Only done items"
|
msgid "Only done items"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Show only in-stock products"
|
||||||
|
msgstr ""
|
||||||
|
@@ -38,7 +38,14 @@ $("#clear-filter-button").on("click", function()
|
|||||||
$("#product-group-filter").val("all");
|
$("#product-group-filter").val("all");
|
||||||
productsTable.column(6).search("").draw();
|
productsTable.column(6).search("").draw();
|
||||||
productsTable.search("").draw();
|
productsTable.search("").draw();
|
||||||
$("#show-disabled").prop('checked', false);
|
if ($("#show-disabled").is(":checked") || $("#show-only-in-stock").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 (typeof GetUriParam("product-group") !== "undefined")
|
if (typeof GetUriParam("product-group") !== "undefined")
|
||||||
@@ -90,12 +97,28 @@ $("#show-disabled").change(function()
|
|||||||
{
|
{
|
||||||
if (this.checked)
|
if (this.checked)
|
||||||
{
|
{
|
||||||
window.location.href = U('/products?include_disabled');
|
UpdateUriParam("include_disabled", "true");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
window.location.href = U('/products');
|
RemoveUriParam("include_disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#show-only-in-stock").change(function()
|
||||||
|
{
|
||||||
|
if (this.checked)
|
||||||
|
{
|
||||||
|
UpdateUriParam("only_in_stock", "true");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RemoveUriParam("only_in_stock");
|
||||||
|
}
|
||||||
|
|
||||||
|
window.location.reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (GetUriParam('include_disabled'))
|
if (GetUriParam('include_disabled'))
|
||||||
|
@@ -71,7 +71,7 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-md-6 col-xl-3">
|
<div class="col-12 col-md-6 col-xl-2">
|
||||||
<div class="form-check custom-control custom-checkbox">
|
<div class="form-check custom-control custom-checkbox">
|
||||||
<input class="form-check-input custom-control-input"
|
<input class="form-check-input custom-control-input"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
@@ -82,6 +82,17 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-12 col-md-6 col-xl-2">
|
||||||
|
<div class="form-check custom-control custom-checkbox">
|
||||||
|
<input class="form-check-input custom-control-input"
|
||||||
|
type="checkbox"
|
||||||
|
id="show-only-in-stock">
|
||||||
|
<label class="form-check-label custom-control-label"
|
||||||
|
for="show-only-in-stock">
|
||||||
|
{{ $__t('Show only in-stock products') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="float-right">
|
<div class="float-right">
|
||||||
<a id="clear-filter-button"
|
<a id="clear-filter-button"
|
||||||
|
Reference in New Issue
Block a user