mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Optionally show out of stock products on the location content sheet (closes #1641)
This commit is contained in:
parent
ebfc55064e
commit
f7c33a4579
@ -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
|
||||
|
||||
|
@ -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']))
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -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 ""
|
||||
|
@ -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();
|
||||
});
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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') }}"></i>
|
||||
</h2>
|
||||
<div class="form-check custom-control custom-checkbox">
|
||||
<input class="form-check-input custom-control-input"
|
||||
type="checkbox"
|
||||
id="include-out-of-stock"
|
||||
checked>
|
||||
<label class="form-check-label custom-control-label"
|
||||
for="include-out-of-stock">
|
||||
{{ $__t('Show only in-stock products') }}
|
||||
<i class="fas fa-question-circle text-muted"
|
||||
data-toggle="tooltip"
|
||||
data-trigger="hover click"
|
||||
title="{{ $__t('Out of stock items will be shown at the products default location') }}"></i>
|
||||
</label>
|
||||
</div>
|
||||
<div class="float-right">
|
||||
<button class="btn btn-outline-dark d-md-none mt-2 order-1 order-md-3"
|
||||
type="button"
|
||||
|
Loading…
x
Reference in New Issue
Block a user