mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Use barcode amounts also for Consume/Transfer/Inventory (closes #1254)
This commit is contained in:
parent
d78e156609
commit
45abc99a77
@ -8,6 +8,7 @@
|
|||||||
- Added validation checks for most `data/config.php` settings to prevent using invalid ones (thanks @Forceu)
|
- Added validation checks for most `data/config.php` settings to prevent using invalid ones (thanks @Forceu)
|
||||||
- When using reverse proxy authentication (`ReverseProxyAuthMiddleware`), _additionally_ a valid API key can now also be used for authentication (if you don't want to protect the API endpoints via your reverse proxy, however)
|
- When using reverse proxy authentication (`ReverseProxyAuthMiddleware`), _additionally_ a valid API key can now also be used for authentication (if you don't want to protect the API endpoints via your reverse proxy, however)
|
||||||
- Added a new API endpoint `/system/time` to get the current server time (thanks @Forceu)
|
- Added a new API endpoint `/system/time` to get the current server time (thanks @Forceu)
|
||||||
|
- An amount attached to a barcode is now also prefiled when scanning the product on the Consume/Transfer/Inventory page
|
||||||
- Fixed that some number inputs were broken when the new decimal places setting were set to `0`
|
- Fixed that some number inputs were broken when the new decimal places setting were set to `0`
|
||||||
- Fixed that browser camera barcode scanning did not work on the product edit page for adding product barcodes
|
- Fixed that browser camera barcode scanning did not work on the product edit page for adding product barcodes
|
||||||
- Fixed that indirect unit conversions (those between units, not product overrides) could not be used/selected
|
- Fixed that indirect unit conversions (those between units, not product overrides) could not be used/selected
|
||||||
|
@ -344,22 +344,45 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (BoolVal(Grocy.UserSettings.scan_mode_consume_enabled))
|
if (document.getElementById("product_id").getAttribute("barcode") != "null")
|
||||||
{
|
{
|
||||||
$("#display_amount").val(1);
|
Grocy.Api.Get('objects/product_barcodes?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
|
||||||
RefreshLocaleNumberInput();
|
function(barcodeResult)
|
||||||
$(".input-group-productamountpicker").trigger("change");
|
{
|
||||||
|
if (barcodeResult != null)
|
||||||
|
{
|
||||||
|
var barcode = barcodeResult[0];
|
||||||
|
|
||||||
Grocy.FrontendHelpers.ValidateForm("consume-form");
|
if (barcode != null)
|
||||||
if (document.getElementById("consume-form").checkValidity() === true)
|
|
||||||
{
|
{
|
||||||
$('#save-consume-button').click();
|
if (barcode.amount != null && !barcode.amount.isEmpty())
|
||||||
|
{
|
||||||
|
$("#display_amount").val(barcode.amount);
|
||||||
|
$("#display_amount").select();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (barcode.qu_id != null)
|
||||||
|
{
|
||||||
|
Grocy.Components.ProductAmountPicker.SetQuantityUnit(barcode.qu_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$(".input-group-productamountpicker").trigger("change");
|
||||||
|
Grocy.FrontendHelpers.ValidateForm('consume-form');
|
||||||
|
RefreshLocaleNumberInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ScanModeSubmit(false);
|
||||||
|
},
|
||||||
|
function(xhr)
|
||||||
|
{
|
||||||
|
console.error(xhr);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
toastr.warning(__t("Scan mode is on but not all required fields could be populated automatically"));
|
ScanModeSubmit();
|
||||||
Grocy.UISound.Error();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
@ -619,3 +642,28 @@ function RefreshForm()
|
|||||||
|
|
||||||
Grocy.FrontendHelpers.ValidateForm("consume-form");
|
Grocy.FrontendHelpers.ValidateForm("consume-form");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ScanModeSubmit(singleUnit = true)
|
||||||
|
{
|
||||||
|
if (BoolVal(Grocy.UserSettings.scan_mode_consume_enabled))
|
||||||
|
{
|
||||||
|
if (singleUnit)
|
||||||
|
{
|
||||||
|
$("#display_amount").val(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
RefreshLocaleNumberInput();
|
||||||
|
$(".input-group-productamountpicker").trigger("change");
|
||||||
|
Grocy.FrontendHelpers.ValidateForm("consume-form");
|
||||||
|
|
||||||
|
if (document.getElementById("consume-form").checkValidity() === true)
|
||||||
|
{
|
||||||
|
$('#save-consume-button').click();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
toastr.warning(__t("Scan mode is on but not all required fields could be populated automatically"));
|
||||||
|
Grocy.UISound.Error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -182,6 +182,41 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (document.getElementById("product_id").getAttribute("barcode") != "null")
|
||||||
|
{
|
||||||
|
Grocy.Api.Get('objects/product_barcodes?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
|
||||||
|
function(barcodeResult)
|
||||||
|
{
|
||||||
|
if (barcodeResult != null)
|
||||||
|
{
|
||||||
|
var barcode = barcodeResult[0];
|
||||||
|
|
||||||
|
if (barcode != null)
|
||||||
|
{
|
||||||
|
if (barcode.amount != null && !barcode.amount.isEmpty())
|
||||||
|
{
|
||||||
|
$("#display_amount").val(barcode.amount);
|
||||||
|
$("#display_amount").select();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (barcode.qu_id != null)
|
||||||
|
{
|
||||||
|
Grocy.Components.ProductAmountPicker.SetQuantityUnit(barcode.qu_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$(".input-group-productamountpicker").trigger("change");
|
||||||
|
Grocy.FrontendHelpers.ValidateForm('inventory-form');
|
||||||
|
RefreshLocaleNumberInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function(xhr)
|
||||||
|
{
|
||||||
|
console.error(xhr);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$('#display_amount').val(productDetails.stock_amount);
|
$('#display_amount').val(productDetails.stock_amount);
|
||||||
RefreshLocaleNumberInput();
|
RefreshLocaleNumberInput();
|
||||||
$(".input-group-productamountpicker").trigger("change");
|
$(".input-group-productamountpicker").trigger("change");
|
||||||
|
@ -192,6 +192,41 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (document.getElementById("product_id").getAttribute("barcode") != "null")
|
||||||
|
{
|
||||||
|
Grocy.Api.Get('objects/product_barcodes?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
|
||||||
|
function(barcodeResult)
|
||||||
|
{
|
||||||
|
if (barcodeResult != null)
|
||||||
|
{
|
||||||
|
var barcode = barcodeResult[0];
|
||||||
|
|
||||||
|
if (barcode != null)
|
||||||
|
{
|
||||||
|
if (barcode.amount != null && !barcode.amount.isEmpty())
|
||||||
|
{
|
||||||
|
$("#display_amount").val(barcode.amount);
|
||||||
|
$("#display_amount").select();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (barcode.qu_id != null)
|
||||||
|
{
|
||||||
|
Grocy.Components.ProductAmountPicker.SetQuantityUnit(barcode.qu_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$(".input-group-productamountpicker").trigger("change");
|
||||||
|
Grocy.FrontendHelpers.ValidateForm('transfer-form');
|
||||||
|
RefreshLocaleNumberInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function(xhr)
|
||||||
|
{
|
||||||
|
console.error(xhr);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (productDetails.product.enable_tare_weight_handling == 1)
|
if (productDetails.product.enable_tare_weight_handling == 1)
|
||||||
{
|
{
|
||||||
$("#display_amount").attr("min", productDetails.product.tare_weight);
|
$("#display_amount").attr("min", productDetails.product.tare_weight);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user