mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 12:26:15 +02:00
Prefill due date also on location change
This commit is contained in:
parent
2f071e945a
commit
cf39e598e1
|
|
@ -286,34 +286,7 @@ if (Grocy.Components.ProductPicker !== undefined)
|
||||||
$("#tare-weight-handling-info").addClass("d-none");
|
$("#tare-weight-handling-info").addClass("d-none");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
|
PrefillBestBeforeDate(productDetails.product, productDetails.location);
|
||||||
{
|
|
||||||
var dueDays;
|
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRODUCT_FREEZING && BoolVal(productDetails.location.is_freezer))
|
|
||||||
{
|
|
||||||
dueDays = productDetails.product.default_best_before_days_after_freezing;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dueDays = productDetails.product.default_best_before_days;
|
|
||||||
}
|
|
||||||
|
|
||||||
dueDays = parseFloat(dueDays);
|
|
||||||
if (dueDays != 0)
|
|
||||||
{
|
|
||||||
if (dueDays == -1)
|
|
||||||
{
|
|
||||||
if (!$("#datetimepicker-shortcut").is(":checked"))
|
|
||||||
{
|
|
||||||
$("#datetimepicker-shortcut").click();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Grocy.Components.DateTimePicker.SetValue(moment().add(dueDays, 'days').format('YYYY-MM-DD'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_LABEL_PRINTER)
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_LABEL_PRINTER)
|
||||||
{
|
{
|
||||||
|
|
@ -407,6 +380,53 @@ if (Grocy.Components.ProductPicker !== undefined)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function PrefillBestBeforeDate(product, location)
|
||||||
|
{
|
||||||
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
|
||||||
|
{
|
||||||
|
var dueDays;
|
||||||
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRODUCT_FREEZING && BoolVal(location.is_freezer))
|
||||||
|
{
|
||||||
|
dueDays = product.default_best_before_days_after_freezing;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dueDays = product.default_best_before_days;
|
||||||
|
}
|
||||||
|
|
||||||
|
dueDays = parseFloat(dueDays);
|
||||||
|
if (dueDays != 0)
|
||||||
|
{
|
||||||
|
if (dueDays == -1)
|
||||||
|
{
|
||||||
|
if (!$("#datetimepicker-shortcut").is(":checked"))
|
||||||
|
{
|
||||||
|
$("#datetimepicker-shortcut").click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Grocy.Components.DateTimePicker.SetValue(moment().add(dueDays, 'days').format('YYYY-MM-DD'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Grocy.Components.LocationPicker.GetPicker().on('change', function(e)
|
||||||
|
{
|
||||||
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRODUCT_FREEZING)
|
||||||
|
{
|
||||||
|
Grocy.Api.Get('objects/locations/' + Grocy.Components.LocationPicker.GetValue(),
|
||||||
|
function(location)
|
||||||
|
{
|
||||||
|
PrefillBestBeforeDate(CurrentProductDetails.product, location);
|
||||||
|
},
|
||||||
|
function(xhr)
|
||||||
|
{ }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_purchase_amount));
|
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_purchase_amount));
|
||||||
RefreshLocaleNumberInput();
|
RefreshLocaleNumberInput();
|
||||||
$(".input-group-productamountpicker").trigger("change");
|
$(".input-group-productamountpicker").trigger("change");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user