mirror of
https://github.com/grocy/grocy.git
synced 2025-08-19 03:40:10 +00:00
Removed type conversions where no longer needed
PHP 8.1 PDO SQLite now returns native data types
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
var firstDay = null;
|
||||
if (!Grocy.CalendarFirstDayOfWeek.isEmpty())
|
||||
if (Grocy.CalendarFirstDayOfWeek)
|
||||
{
|
||||
firstDay = parseInt(Grocy.CalendarFirstDayOfWeek);
|
||||
firstDay = Number.parseInt(Grocy.CalendarFirstDayOfWeek);
|
||||
}
|
||||
|
||||
var calendar = $("#calendar").fullCalendar({
|
||||
|
@@ -104,7 +104,7 @@ $('#chore-form input').keydown(function(event)
|
||||
var checkboxValues = $("#period_config").val().split(",");
|
||||
for (var i = 0; i < checkboxValues.length; i++)
|
||||
{
|
||||
if (!checkboxValues[i].isEmpty())
|
||||
if (checkboxValues[i])
|
||||
{
|
||||
$("#" + checkboxValues[i]).prop('checked', true);
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ $("#user-filter").on("change", function()
|
||||
|
||||
choresOverviewTable.column(choresOverviewTable.colReorder.transpose(6)).search(value).draw();
|
||||
|
||||
if (!value.isEmpty())
|
||||
if (value)
|
||||
{
|
||||
UpdateUriParam("user", $("#user-filter option:selected").data("user-id"));
|
||||
}
|
||||
@@ -152,7 +152,7 @@ $(document).on('click', '.track-chore-button', function(e)
|
||||
$('#chore-' + choreId + '-last-tracked-time').text(trackedTime);
|
||||
$('#chore-' + choreId + '-last-tracked-time-timeago').attr('datetime', trackedTime);
|
||||
|
||||
if (result.next_estimated_execution_time != null && !result.next_estimated_execution_time.isEmpty())
|
||||
if (result.next_estimated_execution_time)
|
||||
{
|
||||
$('#chore-' + choreId + '-next-execution-time').text(result.next_estimated_execution_time);
|
||||
$('#chore-' + choreId + '-next-execution-time-timeago').attr('datetime', result.next_estimated_execution_time);
|
||||
@@ -264,7 +264,7 @@ function RefreshStatistics()
|
||||
dueSoonCount++;
|
||||
}
|
||||
|
||||
if (parseInt(element.next_execution_assigned_to_user_id) == Grocy.UserId)
|
||||
if (element.next_execution_assigned_to_user_id == Grocy.UserId)
|
||||
{
|
||||
assignedToMeCount++;
|
||||
}
|
||||
@@ -291,7 +291,7 @@ $(document).on("click", ".reschedule-chore-button", function(e)
|
||||
Grocy.Api.Get("chores/" + choreId, function(choreDetails)
|
||||
{
|
||||
var prefillDate = choreDetails.next_estimated_execution_time || moment().format("YYYY-MM-DD HH:mm:ss");
|
||||
if (choreDetails.chore.rescheduled_date != null && !choreDetails.chore.rescheduled_date.isEmpty())
|
||||
if (choreDetails.chore.rescheduled_date)
|
||||
{
|
||||
prefillDate = choreDetails.chore.rescheduled_date;
|
||||
}
|
||||
@@ -311,7 +311,7 @@ $(document).on("click", ".reschedule-chore-button", function(e)
|
||||
{
|
||||
choreDetails.chore.next_execution_assigned_to_user_id = "";
|
||||
}
|
||||
if (choreDetails.chore.next_execution_assigned_to_user_id != null && !choreDetails.chore.next_execution_assigned_to_user_id.isEmpty())
|
||||
if (choreDetails.chore.next_execution_assigned_to_user_id)
|
||||
{
|
||||
Grocy.Components.UserPicker.SetId(choreDetails.chore.next_execution_assigned_to_user_id)
|
||||
}
|
||||
|
@@ -166,7 +166,7 @@ Quagga.onDetected(function(result)
|
||||
if (error.error != undefined)
|
||||
{
|
||||
Grocy.Components.BarcodeScanner.DecodedCodesCount++;
|
||||
Grocy.Components.BarcodeScanner.DecodedCodesErrorCount += parseFloat(error.error);
|
||||
Grocy.Components.BarcodeScanner.DecodedCodesErrorCount += Number.parseFloat(error.error);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -187,7 +187,7 @@ Quagga.onProcessed(function(result)
|
||||
{
|
||||
if (result.boxes)
|
||||
{
|
||||
drawingCtx.clearRect(0, 0, parseInt(drawingCanvas.getAttribute("width")), parseInt(drawingCanvas.getAttribute("height")));
|
||||
drawingCtx.clearRect(0, 0, Number.parseInt(drawingCanvas.getAttribute("width")), Number.parseInt(drawingCanvas.getAttribute("height")));
|
||||
result.boxes.filter(function(box)
|
||||
{
|
||||
return box !== result.box;
|
||||
|
@@ -37,7 +37,7 @@ Grocy.Components.ChoreCard.Refresh = function(choreId)
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#chorecard-average-execution-frequency').text(moment.duration(parseInt(choreDetails.average_execution_frequency_hours) / 24, "days").humanize());
|
||||
$('#chorecard-average-execution-frequency').text(moment.duration(choreDetails.average_execution_frequency_hours / 24, "days").humanize());
|
||||
}
|
||||
|
||||
RefreshContextualTimeago(".chorecard");
|
||||
|
@@ -173,7 +173,7 @@ Grocy.Components.DateTimePicker.GetInputElement().on('keyup', function(e)
|
||||
}
|
||||
else if ((value.startsWith("+") || value.startsWith("-")) && (lastCharacter == "d" || lastCharacter == "m" || lastCharacter == "y")) // Shorthand for [+/-]n[d/m/y]
|
||||
{
|
||||
var n = parseInt(value.substring(1, value.length - 1));
|
||||
var n = Number.parseInt(value.substring(1, value.length - 1));
|
||||
if (value.startsWith("-"))
|
||||
{
|
||||
n = n * -1;
|
||||
@@ -272,7 +272,7 @@ Grocy.Components.DateTimePicker.GetInputElement().on('keyup', function(e)
|
||||
}
|
||||
|
||||
var earlierThanLimit = Grocy.Components.DateTimePicker.GetInputElement().data("earlier-than-limit");
|
||||
if (!earlierThanLimit.isEmpty())
|
||||
if (earlierThanLimit)
|
||||
{
|
||||
if (moment(value).isBefore(moment(earlierThanLimit)))
|
||||
{
|
||||
|
@@ -173,7 +173,7 @@ Grocy.Components.DateTimePicker2.GetInputElement().on('keyup', function(e)
|
||||
}
|
||||
else if ((value.startsWith("+") || value.startsWith("-")) && (lastCharacter == "d" || lastCharacter == "m" || lastCharacter == "y")) // Shorthand for [+/-]n[d/m/y]
|
||||
{
|
||||
var n = parseInt(value.substring(1, value.length - 1));
|
||||
var n = Number.parseInt(value.substring(1, value.length - 1));
|
||||
if (value.startsWith("-"))
|
||||
{
|
||||
n = n * -1;
|
||||
@@ -272,7 +272,7 @@ Grocy.Components.DateTimePicker2.GetInputElement().on('keyup', function(e)
|
||||
}
|
||||
|
||||
var earlierThanLimit = Grocy.Components.DateTimePicker2.GetInputElement().data("earlier-than-limit");
|
||||
if (!earlierThanLimit.isEmpty())
|
||||
if (earlierThanLimit)
|
||||
{
|
||||
if (moment(value).isBefore(moment(earlierThanLimit)))
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
$(".numberpicker-down-button").unbind('click').on("click", function()
|
||||
{
|
||||
var inputElement = $(this).parent().parent().find('input[type="number"]');
|
||||
inputElement.val(parseFloat(inputElement.val() || 1) - 1);
|
||||
inputElement.val(Number.parseFloat(inputElement.val() || 1) - 1);
|
||||
inputElement.trigger('keyup');
|
||||
inputElement.trigger('change');
|
||||
});
|
||||
@@ -9,14 +9,14 @@ $(".numberpicker-down-button").unbind('click').on("click", function()
|
||||
$(".numberpicker-up-button").unbind('click').on("click", function()
|
||||
{
|
||||
var inputElement = $(this).parent().parent().find('input[type="number"]');
|
||||
inputElement.val(parseFloat(inputElement.val() || 0) + 1);
|
||||
inputElement.val(Number.parseFloat(inputElement.val() || 0) + 1);
|
||||
inputElement.trigger('keyup');
|
||||
inputElement.trigger('change');
|
||||
});
|
||||
|
||||
$(".numberpicker").on("keyup", function()
|
||||
{
|
||||
if ($(this).attr("data-not-equal") && !$(this).attr("data-not-equal").toString().isEmpty() && $(this).attr("data-not-equal") == $(this).val())
|
||||
if ($(this).attr("data-not-equal") && $(this).attr("data-not-equal") == $(this).val())
|
||||
{
|
||||
$(this)[0].setCustomValidity("error");
|
||||
}
|
||||
@@ -50,26 +50,26 @@ $(".numberpicker").each(function()
|
||||
|
||||
if (notEqual != "NaN")
|
||||
{
|
||||
if (max.isEmpty())
|
||||
if (!max)
|
||||
{
|
||||
element.parent().find(".invalid-feedback").text(__t("This cannot be lower than %1$s or equal %2$s and needs to be a valid number with max. %3$s decimal places", parseFloat(min).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: decimals }), parseFloat(notEqual).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: decimals }), decimals));
|
||||
element.parent().find(".invalid-feedback").text(__t("This cannot be lower than %1$s or equal %2$s and needs to be a valid number with max. %3$s decimal places", Number.parseFloat(min).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: decimals }), Number.parseFloat(notEqual).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: decimals }), decimals));
|
||||
}
|
||||
else
|
||||
{
|
||||
element.parent().find(".invalid-feedback").text(__t("This must be between %1$s and %2$s, cannot equal %3$s and needs to be a valid number with max. %4$s decimal places", parseFloat(min).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: decimals }), parseFloat(max).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: decimals }), parseFloat(notEqual).toLocaleString(undefined, { minimumFractionDigits: decimals, maximumFractionDigits: decimals }), decimals));
|
||||
element.parent().find(".invalid-feedback").text(__t("This must be between %1$s and %2$s, cannot equal %3$s and needs to be a valid number with max. %4$s decimal places", Number.parseFloat(min).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: decimals }), Number.parseFloat(max).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: decimals }), Number.parseFloat(notEqual).toLocaleString(undefined, { minimumFractionDigits: decimals, maximumFractionDigits: decimals }), decimals));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (max.isEmpty())
|
||||
if (!max)
|
||||
{
|
||||
element.parent().find(".invalid-feedback").text(__t("This cannot be lower than %1$s and needs to be a valid number with max. %2$s decimal places", parseFloat(min).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: decimals }), decimals));
|
||||
element.parent().find(".invalid-feedback").text(__t("This cannot be lower than %1$s and needs to be a valid number with max. %2$s decimal places", Number.parseFloat(min).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: decimals }), decimals));
|
||||
}
|
||||
else
|
||||
{
|
||||
element.parent().find(".invalid-feedback").text(__t("This must between %1$s and %2$s and needs to be a valid number with max. %3$s decimal places", parseFloat(min).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: decimals }), parseFloat(max).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: decimals }), decimals));
|
||||
element.parent().find(".invalid-feedback").text(__t("This must between %1$s and %2$s and needs to be a valid number with max. %3$s decimal places", Number.parseFloat(min).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: decimals }), Number.parseFloat(max).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: decimals }), decimals));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -98,19 +98,18 @@ $(".numberpicker.locale-number-input.locale-number-currency").on("blur", functio
|
||||
if (BoolVal(Grocy.UserSettings.stock_auto_decimal_separator_prices))
|
||||
{
|
||||
var value = this.value.toString();
|
||||
if (value == null || value.isEmpty() || value.includes(".") || value.includes(","))
|
||||
if (!value || value.includes(".") || value.includes(","))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var decimalPlaces = parseInt(Grocy.UserSettings.stock_decimal_places_prices_input);
|
||||
|
||||
var decimalPlaces = Grocy.UserSettings.stock_decimal_places_prices_input;
|
||||
if (value.length <= decimalPlaces)
|
||||
{
|
||||
value = value.padStart(decimalPlaces, "0");
|
||||
}
|
||||
|
||||
var valueNew = parseFloat(value.substring(0, value.length - decimalPlaces) + '.' + value.slice(decimalPlaces * -1));
|
||||
var valueNew = Number.parseFloat(value.substring(0, value.length - decimalPlaces) + '.' + value.slice(decimalPlaces * -1));
|
||||
$(this).val(valueNew);
|
||||
}
|
||||
});
|
||||
|
@@ -13,13 +13,11 @@ Grocy.Components.ProductAmountPicker.Reload = function(productId, destinationQuI
|
||||
|
||||
conversionsForProduct.forEach(conversion =>
|
||||
{
|
||||
var factor = parseFloat(conversion.factor);
|
||||
|
||||
// Only conversions related to the destination QU are needed
|
||||
// + only add one conversion per to_qu_id (multiple ones can be a result of contradictory definitions = user input bullshit)
|
||||
if ((conversion.from_qu_id == destinationQuId || conversion.to_qu_id == destinationQuId) && !$('#qu_id option[value="' + conversion.to_qu_id + '"]').length)
|
||||
{
|
||||
$("#qu_id").append('<option value="' + conversion.to_qu_id + '" data-qu-factor="' + factor + '" data-qu-name-plural="' + conversion.to_qu_name_plural + '">' + conversion.to_qu_name + '</option>');
|
||||
$("#qu_id").append('<option value="' + conversion.to_qu_id + '" data-qu-factor="' + conversion.factor + '" data-qu-name-plural="' + conversion.to_qu_name_plural + '">' + conversion.to_qu_name + '</option>');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -94,7 +92,7 @@ $(".input-group-productamountpicker").on("change", function()
|
||||
var destinationAmount = amount / quFactor;
|
||||
var destinationQuName = __n(destinationAmount, $("#qu_id").attr("data-destination-qu-name"), $("#qu_id").attr("data-destination-qu-name-plural"), true);
|
||||
|
||||
if ($("#qu_id").attr("data-destination-qu-name") == selectedQuName || Grocy.Components.ProductAmountPicker.AllowAnyQuEnabled || amount.toString().isEmpty() || selectedQuName.toString().isEmpty())
|
||||
if ($("#qu_id").attr("data-destination-qu-name") == selectedQuName || Grocy.Components.ProductAmountPicker.AllowAnyQuEnabled || !amount || !selectedQuName)
|
||||
{
|
||||
$("#qu-conversion-info").addClass("d-none");
|
||||
}
|
||||
@@ -104,7 +102,7 @@ $(".input-group-productamountpicker").on("change", function()
|
||||
$("#qu-conversion-info").text(__t("This equals %1$s %2$s", destinationAmount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }), destinationQuName));
|
||||
}
|
||||
|
||||
var n = Number.parseInt(Grocy.UserSettings.stock_decimal_places_amounts);
|
||||
var n = Grocy.UserSettings.stock_decimal_places_amounts;
|
||||
if (n <= 0)
|
||||
{
|
||||
n = 1;
|
||||
|
@@ -21,7 +21,7 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
||||
{
|
||||
$('#productcard-product-location').text(productDetails.location.name);
|
||||
}
|
||||
$('#productcard-product-spoil-rate').text((parseFloat(productDetails.spoil_rate_percent) / 100).toLocaleString(undefined, { style: "percent" }));
|
||||
$('#productcard-product-spoil-rate').text((productDetails.spoil_rate_percent / 100).toLocaleString(undefined, { style: "percent" }));
|
||||
|
||||
if (productDetails.is_aggregated_amount == 1)
|
||||
{
|
||||
@@ -44,7 +44,7 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
||||
$("#productcard-aggregated-amounts").addClass("d-none");
|
||||
}
|
||||
|
||||
if (productDetails.product.description != null && !productDetails.product.description.isEmpty())
|
||||
if (productDetails.product.description)
|
||||
{
|
||||
$("#productcard-product-description-wrapper").removeClass("d-none");
|
||||
}
|
||||
@@ -57,7 +57,7 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
||||
{
|
||||
$('#productcard-product-average-shelf-life').text(__t("Unknown"));
|
||||
}
|
||||
else if (parseInt(productDetails.average_shelf_life_days) > 73000) // > 200 years aka forever
|
||||
else if (productDetails.average_shelf_life_days > 73000) // > 200 years aka forever
|
||||
{
|
||||
$('#productcard-product-average-shelf-life').text(__t("Unlimited"));
|
||||
}
|
||||
@@ -84,8 +84,8 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
||||
|
||||
if (productDetails.last_price !== null)
|
||||
{
|
||||
$('#productcard-product-last-price').text(__t("%1$s per %2$s", (Number.parseFloat(productDetails.last_price) * Number.parseFloat(productDetails.qu_conversion_factor_purchase_to_stock)).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), productDetails.default_quantity_unit_purchase.name));
|
||||
$('#productcard-product-last-price').attr("data-original-title", __t("%1$s per %2$s", Number.parseFloat(productDetails.last_price).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), productDetails.quantity_unit_stock.name));
|
||||
$('#productcard-product-last-price').text(__t("%1$s per %2$s", (productDetails.last_price * productDetails.qu_conversion_factor_purchase_to_stock).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), productDetails.default_quantity_unit_purchase.name));
|
||||
$('#productcard-product-last-price').attr("data-original-title", __t("%1$s per %2$s", productDetails.last_price.toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), productDetails.quantity_unit_stock.name));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -95,8 +95,8 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
||||
|
||||
if (productDetails.avg_price !== null)
|
||||
{
|
||||
$('#productcard-product-average-price').text(__t("%1$s per %2$s", (Number.parseFloat(productDetails.avg_price) * Number.parseFloat(productDetails.qu_conversion_factor_purchase_to_stock)).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), productDetails.default_quantity_unit_purchase.name));
|
||||
$('#productcard-product-average-price').attr("data-original-title", __t("%1$s per %2$s", Number.parseFloat(productDetails.avg_price).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), productDetails.quantity_unit_stock.name));
|
||||
$('#productcard-product-average-price').text(__t("%1$s per %2$s", (productDetails.avg_price * productDetails.qu_conversion_factor_purchase_to_stock).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), productDetails.default_quantity_unit_purchase.name));
|
||||
$('#productcard-product-average-price').attr("data-original-title", __t("%1$s per %2$s", productDetails.avg_price.toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), productDetails.quantity_unit_stock.name));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -104,7 +104,7 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
||||
$().removeAttr("data-original-title");
|
||||
}
|
||||
|
||||
if (productDetails.product.picture_file_name !== null && !productDetails.product.picture_file_name.isEmpty())
|
||||
if (productDetails.product.picture_file_name)
|
||||
{
|
||||
$("#productcard-product-picture").removeClass("d-none");
|
||||
$("#productcard-product-picture").attr("src", U('/api/files/productpictures/' + btoa(productDetails.product.picture_file_name) + '?force_serve_as=picture&best_fit_width=400'));
|
||||
@@ -151,7 +151,7 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
||||
datasets[key] = []
|
||||
}
|
||||
chart.labels.push(moment(dataPoint.date).toDate());
|
||||
datasets[key].push({ x: moment(dataPoint.date).toDate(), y: Number.parseFloat(dataPoint.price) * Number.parseFloat(productDetails.qu_conversion_factor_purchase_to_stock) });
|
||||
datasets[key].push({ x: moment(dataPoint.date).toDate(), y: dataPoint.price * productDetails.qu_conversion_factor_purchase_to_stock });
|
||||
|
||||
});
|
||||
Object.keys(datasets).forEach((key) =>
|
||||
|
@@ -95,7 +95,7 @@ $('.product-combobox').combobox({
|
||||
|
||||
var prefillProduct = GetUriParam('product-name');
|
||||
var prefillProduct2 = Grocy.Components.ProductPicker.GetPicker().parent().data('prefill-by-name').toString();
|
||||
if (!prefillProduct2.isEmpty())
|
||||
if (prefillProduct2)
|
||||
{
|
||||
prefillProduct = prefillProduct2;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ if (typeof prefillProduct !== "undefined")
|
||||
|
||||
var prefillProductId = GetUriParam("product");
|
||||
var prefillProductId2 = Grocy.Components.ProductPicker.GetPicker().parent().data('prefill-by-id').toString();
|
||||
if (!prefillProductId2.isEmpty())
|
||||
if (prefillProductId2)
|
||||
{
|
||||
prefillProductId = prefillProductId2;
|
||||
}
|
||||
|
@@ -148,7 +148,7 @@ Grocy.Components.UserfieldsForm.Load = function()
|
||||
}
|
||||
else if (input.attr('type') == "file")
|
||||
{
|
||||
if (value != null && !value.isEmpty())
|
||||
if (value)
|
||||
{
|
||||
var fileName = atob(value.split('_')[1]);
|
||||
var fileSrc = value.split('_')[0];
|
||||
@@ -178,7 +178,7 @@ Grocy.Components.UserfieldsForm.Load = function()
|
||||
}
|
||||
else if (input.attr("data-userfield-type") == "link")
|
||||
{
|
||||
if (value != null && !value.isEmpty())
|
||||
if (value)
|
||||
{
|
||||
var data = JSON.parse(value);
|
||||
|
||||
|
@@ -82,7 +82,7 @@
|
||||
|
||||
if (productDetails.product.enable_tare_weight_handling == 1 && !jsonData.exact_amount)
|
||||
{
|
||||
var successMessage = __t('Removed %1$s of %2$s from stock', Math.abs(jsonForm.amount - (parseFloat(productDetails.product.tare_weight) + parseFloat(productDetails.stock_amount))) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
var successMessage = __t('Removed %1$s of %2$s from stock', Math.abs(jsonForm.amount - (productDetails.product.tare_weight + productDetails.stock_amount)) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -110,7 +110,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_consume_amount));
|
||||
$('#display_amount').val(Grocy.UserSettings.stock_default_consume_amount);
|
||||
}
|
||||
RefreshLocaleNumberInput();
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
@@ -187,7 +187,7 @@ $('#save-mark-as-open-button').on('click', function(e)
|
||||
}
|
||||
|
||||
Grocy.FrontendHelpers.EndUiBusy("consume-form");
|
||||
toastr.success(__t('Marked %1$s of %2$s as opened', parseFloat(jsonForm.amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + result[0].transaction_id + '\')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>');
|
||||
toastr.success(__t('Marked %1$s of %2$s as opened', Number.parseFloat(jsonForm.amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + result[0].transaction_id + '\')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>');
|
||||
|
||||
if (productDetails.product.move_on_open == 1 && productDetails.default_consume_location != null)
|
||||
{
|
||||
@@ -200,7 +200,7 @@ $('#save-mark-as-open-button').on('click', function(e)
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_consume_amount));
|
||||
$('#display_amount').val(Grocy.UserSettings.stock_default_consume_amount);
|
||||
}
|
||||
RefreshLocaleNumberInput();
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
@@ -292,7 +292,7 @@ function OnLocationChange(locationId, stockId)
|
||||
if ($("#specific_stock_entry option[value='" + stockEntry.stock_id + "']").length == 0)
|
||||
{
|
||||
var noteTxt = "";
|
||||
if (stockEntry.note != null && !stockEntry.note.isEmpty())
|
||||
if (stockEntry.note)
|
||||
{
|
||||
noteTxt = " " + stockEntry.note;
|
||||
}
|
||||
@@ -304,7 +304,7 @@ function OnLocationChange(locationId, stockId)
|
||||
}));
|
||||
}
|
||||
|
||||
sumValue = sumValue + parseFloat(stockEntry.amount || 0);
|
||||
sumValue = sumValue + (stockEntry.amount || 0);
|
||||
|
||||
if (stockEntry.stock_id == stockId)
|
||||
{
|
||||
@@ -372,13 +372,13 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_consume_amount));
|
||||
$('#display_amount').val(Grocy.UserSettings.stock_default_consume_amount);
|
||||
}
|
||||
RefreshLocaleNumberInput();
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
|
||||
var defaultLocationId = productDetails.location.id;
|
||||
if ((productDetails.product.default_consume_location_id || "").isEmpty())
|
||||
if (productDetails.product.default_consume_location_id)
|
||||
{
|
||||
defaultLocationId = productDetails.product.default_consume_location_id;
|
||||
}
|
||||
@@ -400,7 +400,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
$("#location_id").val(defaultLocationId);
|
||||
$("#location_id").trigger('change');
|
||||
setDefault = 1;
|
||||
stockAmountAtDefaultLocation += Number.parseFloat(stockLocation.amount);
|
||||
stockAmountAtDefaultLocation += stockLocation.amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -468,7 +468,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
if (productDetails.product.enable_tare_weight_handling == 1)
|
||||
{
|
||||
$("#display_amount").attr("min", productDetails.product.tare_weight);
|
||||
$('#display_amount').attr('max', parseFloat(productDetails.stock_amount) + parseFloat(productDetails.product.tare_weight));
|
||||
$('#display_amount').attr('max', productDetails.stock_amount + productDetails.product.tare_weight);
|
||||
$("#tare-weight-handling-info").removeClass("d-none");
|
||||
}
|
||||
else
|
||||
@@ -498,7 +498,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
}
|
||||
});
|
||||
|
||||
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_consume_amount));
|
||||
$('#display_amount').val(Grocy.UserSettings.stock_default_consume_amount);
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
Grocy.FrontendHelpers.ValidateForm('consume-form');
|
||||
|
||||
@@ -552,7 +552,7 @@ $("#specific_stock_entry").on("change", function(e)
|
||||
{
|
||||
if (stockEntry.location_id == $("#location_id").val() || stockEntry.location_id == "")
|
||||
{
|
||||
sumValue = sumValue + parseFloat(stockEntry.amount_aggregated);
|
||||
sumValue = sumValue + stockEntry.amount_aggregated;
|
||||
}
|
||||
});
|
||||
$("#display_amount").attr("max", sumValue);
|
||||
@@ -692,7 +692,7 @@ function RefreshForm()
|
||||
if (productDetails.product.enable_tare_weight_handling == 1 && !$('#consume-exact-amount').is(':checked'))
|
||||
{
|
||||
$("#display_amount").attr("min", productDetails.product.tare_weight);
|
||||
$('#display_amount').attr('max', sumValue + parseFloat(productDetails.product.tare_weight));
|
||||
$('#display_amount').attr('max', sumValue + productDetails.product.tare_weight);
|
||||
$("#tare-weight-handling-info").removeClass("d-none");
|
||||
}
|
||||
else
|
||||
|
@@ -35,7 +35,7 @@ function DisplayEquipment(id)
|
||||
$("#description-tab-content").html(equipmentItem.description);
|
||||
$(".equipment-edit-button").attr("href", U("/equipment/" + equipmentItem.id.toString()));
|
||||
|
||||
if (equipmentItem.instruction_manual_file_name !== null && !equipmentItem.instruction_manual_file_name.isEmpty())
|
||||
if (equipmentItem.instruction_manual_file_name)
|
||||
{
|
||||
var pdfUrl = U('/api/files/equipmentmanuals/' + btoa(equipmentItem.instruction_manual_file_name));
|
||||
$("#selected-equipment-instruction-manual").attr("src", pdfUrl);
|
||||
@@ -64,7 +64,7 @@ function DisplayEquipment(id)
|
||||
$.each(result, function(key, userfield)
|
||||
{
|
||||
var userfieldFile = equipmentItem.userfields[userfield.name];
|
||||
if (userfieldFile != null && !userfieldFile.isEmpty())
|
||||
if (userfieldFile)
|
||||
{
|
||||
var pdfUrl = U('/files/userfiles/' + userfieldFile);
|
||||
$("#file-userfield-" + userfield.name + "-embed").attr("src", pdfUrl);
|
||||
|
@@ -21,9 +21,9 @@ $('#save-inventory-button').on('click', function(e)
|
||||
function(productDetails)
|
||||
{
|
||||
var price = "";
|
||||
if (!jsonForm.price.toString().isEmpty())
|
||||
if (jsonForm.price)
|
||||
{
|
||||
price = parseFloat(jsonForm.price * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
|
||||
price = Number.parseFloat(jsonForm.price * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
|
||||
}
|
||||
|
||||
var jsonData = {};
|
||||
@@ -77,7 +77,7 @@ $('#save-inventory-button').on('click', function(e)
|
||||
);
|
||||
}
|
||||
|
||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_LABEL_PRINTER && parseFloat($("#display_amount").attr("data-estimated-booking-amount")) > 0)
|
||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_LABEL_PRINTER && Number.parseFloat($("#display_amount").attr("data-estimated-booking-amount")) > 0)
|
||||
{
|
||||
if (Grocy.Webhooks.labelprinter !== undefined)
|
||||
{
|
||||
@@ -225,9 +225,9 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
$("#tare-weight-handling-info").addClass("d-none");
|
||||
}
|
||||
|
||||
if (productDetails.last_price != null && !productDetails.last_price.isEmpty())
|
||||
if (productDetails.last_price)
|
||||
{
|
||||
$('#price').val(parseFloat(productDetails.last_price / $("#qu_id option:selected").attr("data-qu-factor")));
|
||||
$('#price').val(productDetails.last_price / $("#qu_id option:selected").attr("data-qu-factor"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -330,10 +330,10 @@ function refreshPriceHint()
|
||||
var amount = $('#display_amount').val();
|
||||
if (BoolVal(CurrentProductDetails.product.enable_tare_weight_handling))
|
||||
{
|
||||
amount -= parseFloat(CurrentProductDetails.product.tare_weight);
|
||||
amount -= CurrentProductDetails.product.tare_weight;
|
||||
}
|
||||
|
||||
var price = parseFloat($('#price').val() * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
|
||||
var price = Number.parseFloat($('#price').val() * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
|
||||
$('#price-hint').text(__t('means %1$s per %2$s', price.toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), $("#qu_id").attr("data-destination-qu-name")));
|
||||
}
|
||||
else
|
||||
@@ -397,7 +397,7 @@ $('#inventory-form input').keydown(function(event)
|
||||
|
||||
$('#qu_id').on('change', function(e)
|
||||
{
|
||||
$('#display_amount').attr('data-not-equal', parseFloat($('#display_amount').attr('data-stock-amount')) * parseFloat($("#qu_id option:selected").attr("data-qu-factor")));
|
||||
$('#display_amount').attr('data-not-equal', Number.parseFloat($('#display_amount').attr('data-stock-amount')) * Number.parseFloat($("#qu_id option:selected").attr("data-qu-factor")));
|
||||
Grocy.FrontendHelpers.ValidateForm('inventory-form');
|
||||
});
|
||||
|
||||
@@ -419,65 +419,65 @@ $('#price').on('focus', function(e)
|
||||
$('#display_amount').on('keyup', function(e)
|
||||
{
|
||||
var productId = Grocy.Components.ProductPicker.GetValue();
|
||||
var newAmount = parseFloat($('#amount').val());
|
||||
var newAmount = Number.parseFloat($('#amount').val());
|
||||
|
||||
if (productId)
|
||||
{
|
||||
Grocy.Api.Get('stock/products/' + productId,
|
||||
function(productDetails)
|
||||
{
|
||||
var productStockAmount = parseFloat(productDetails.stock_amount || parseFloat('0'));
|
||||
var productStockAmount = productDetails.stock_amount || 0);
|
||||
|
||||
var containerWeight = parseFloat("0");
|
||||
if (productDetails.product.enable_tare_weight_handling == 1)
|
||||
{
|
||||
containerWeight = parseFloat(productDetails.product.tare_weight);
|
||||
}
|
||||
var containerWeight = 0.0;
|
||||
if (productDetails.product.enable_tare_weight_handling == 1)
|
||||
{
|
||||
containerWeight = productDetails.product.tare_weight;
|
||||
}
|
||||
|
||||
var estimatedBookingAmount = (newAmount - productStockAmount - containerWeight).toFixed(Grocy.UserSettings.stock_decimal_places_amounts);
|
||||
$("#display_amount").attr("data-estimated-booking-amount", estimatedBookingAmount);
|
||||
estimatedBookingAmount = Math.abs(estimatedBookingAmount);
|
||||
$('#inventory-change-info').removeClass('d-none');
|
||||
var estimatedBookingAmount = (newAmount - productStockAmount - containerWeight).toFixed(Grocy.UserSettings.stock_decimal_places_amounts);
|
||||
$("#display_amount").attr("data-estimated-booking-amount", estimatedBookingAmount);
|
||||
estimatedBookingAmount = Math.abs(estimatedBookingAmount);
|
||||
$('#inventory-change-info').removeClass('d-none');
|
||||
|
||||
if (productDetails.product.enable_tare_weight_handling == 1 && newAmount < containerWeight)
|
||||
{
|
||||
$('#inventory-change-info').addClass('d-none');
|
||||
}
|
||||
else if (newAmount > productStockAmount + containerWeight)
|
||||
{
|
||||
$('#inventory-change-info').text(__t('This means %s will be added to stock', estimatedBookingAmount.toLocaleString() + ' ' + __n(estimatedBookingAmount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true)));
|
||||
Grocy.Components.DateTimePicker.GetInputElement().attr('required', '');
|
||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
|
||||
{
|
||||
Grocy.Components.LocationPicker.GetInputElement().attr('required', '');
|
||||
}
|
||||
}
|
||||
else if (newAmount < productStockAmount + containerWeight)
|
||||
{
|
||||
$('#inventory-change-info').text(__t('This means %s will be removed from stock', estimatedBookingAmount.toLocaleString() + ' ' + __n(estimatedBookingAmount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true)));
|
||||
Grocy.Components.DateTimePicker.GetInputElement().removeAttr('required');
|
||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
|
||||
{
|
||||
Grocy.Components.LocationPicker.GetInputElement().removeAttr('required');
|
||||
}
|
||||
}
|
||||
else if (newAmount == productStockAmount)
|
||||
{
|
||||
$('#inventory-change-info').addClass('d-none');
|
||||
}
|
||||
|
||||
if (!Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
|
||||
{
|
||||
Grocy.Components.DateTimePicker.GetInputElement().removeAttr('required');
|
||||
}
|
||||
|
||||
refreshPriceHint();
|
||||
Grocy.FrontendHelpers.ValidateForm('inventory-form');
|
||||
},
|
||||
function(xhr)
|
||||
if (productDetails.product.enable_tare_weight_handling == 1 && newAmount < containerWeight)
|
||||
{
|
||||
$('#inventory-change-info').addClass('d-none');
|
||||
}
|
||||
else if (newAmount > productStockAmount + containerWeight)
|
||||
{
|
||||
$('#inventory-change-info').text(__t('This means %s will be added to stock', estimatedBookingAmount.toLocaleString() + ' ' + __n(estimatedBookingAmount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true)));
|
||||
Grocy.Components.DateTimePicker.GetInputElement().attr('required', '');
|
||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
|
||||
{
|
||||
console.error(xhr);
|
||||
Grocy.Components.LocationPicker.GetInputElement().attr('required', '');
|
||||
}
|
||||
}
|
||||
else if (newAmount < productStockAmount + containerWeight)
|
||||
{
|
||||
$('#inventory-change-info').text(__t('This means %s will be removed from stock', estimatedBookingAmount.toLocaleString() + ' ' + __n(estimatedBookingAmount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true)));
|
||||
Grocy.Components.DateTimePicker.GetInputElement().removeAttr('required');
|
||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
|
||||
{
|
||||
Grocy.Components.LocationPicker.GetInputElement().removeAttr('required');
|
||||
}
|
||||
}
|
||||
else if (newAmount == productStockAmount)
|
||||
{
|
||||
$('#inventory-change-info').addClass('d-none');
|
||||
}
|
||||
|
||||
if (!Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
|
||||
{
|
||||
Grocy.Components.DateTimePicker.GetInputElement().removeAttr('required');
|
||||
}
|
||||
|
||||
refreshPriceHint();
|
||||
Grocy.FrontendHelpers.ValidateForm('inventory-form');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@@ -2,13 +2,13 @@
|
||||
Grocy.IsMealPlanEntryEditAction = false;
|
||||
|
||||
var firstDay = null;
|
||||
if (!Grocy.CalendarFirstDayOfWeek.isEmpty())
|
||||
if (Grocy.CalendarFirstDayOfWeek)
|
||||
{
|
||||
firstDay = parseInt(Grocy.CalendarFirstDayOfWeek);
|
||||
firstDay = Number.parseInt(Grocy.CalendarFirstDayOfWeek);
|
||||
}
|
||||
if (!Grocy.MealPlanFirstDayOfWeek.isEmpty())
|
||||
if (Grocy.MealPlanFirstDayOfWeek)
|
||||
{
|
||||
firstDay = parseInt(Grocy.MealPlanFirstDayOfWeek);
|
||||
firstDay = Number.parseInt(Grocy.MealPlanFirstDayOfWeek);
|
||||
}
|
||||
|
||||
$(".calendar").each(function()
|
||||
@@ -202,7 +202,7 @@ $(".calendar").each(function()
|
||||
</h5> \
|
||||
</div>');
|
||||
|
||||
if (recipe.picture_file_name && !recipe.picture_file_name.isEmpty())
|
||||
if (recipe.picture_file_name)
|
||||
{
|
||||
element.prepend('<div class="mx-auto mb-1"><img data-src="' + U("/api/files/recipepictures/") + btoa(recipe.picture_file_name) + '?force_serve_as=picture&best_fit_width=400" class="img-fluid rounded-circle lazy"></div>')
|
||||
}
|
||||
@@ -223,20 +223,20 @@ $(".calendar").each(function()
|
||||
element.attr("data-product-details", event.productDetails);
|
||||
|
||||
var productOrderMissingButtonDisabledClasses = "disabled";
|
||||
if (parseFloat(productDetails.stock_amount_aggregated) < parseFloat(mealPlanEntry.product_amount))
|
||||
if (productDetails.stock_amount_aggregated < mealPlanEntry.product_amount)
|
||||
{
|
||||
productOrderMissingButtonDisabledClasses = "";
|
||||
}
|
||||
|
||||
var productConsumeButtonDisabledClasses = "disabled";
|
||||
if (parseFloat(productDetails.stock_amount_aggregated) >= parseFloat(mealPlanEntry.product_amount))
|
||||
if (productDetails.stock_amount_aggregated >= mealPlanEntry.product_amount)
|
||||
{
|
||||
productConsumeButtonDisabledClasses = "";
|
||||
}
|
||||
|
||||
fulfillmentInfoHtml = __t('Not enough in stock');
|
||||
var fulfillmentIconHtml = '<i class="fa-solid fa-times text-danger"></i>';
|
||||
if (parseFloat(productDetails.stock_amount_aggregated) >= parseFloat(mealPlanEntry.product_amount))
|
||||
if (productDetails.stock_amount_aggregated >= mealPlanEntry.product_amount)
|
||||
{
|
||||
var fulfillmentInfoHtml = __t('Enough in stock');
|
||||
var fulfillmentIconHtml = '<i class="fa-solid fa-check text-success"></i>';
|
||||
@@ -267,13 +267,13 @@ $(".calendar").each(function()
|
||||
<h5 class="d-print-none"> \
|
||||
<a class="ml-1 btn btn-outline-danger btn-xs remove-product-button" href="#" data-toggle="tooltip" title="' + __t("Delete this item") + '"><i class="fa-solid fa-trash"></i></a> \
|
||||
<a class="btn btn-outline-info btn-xs edit-meal-plan-entry-button" href="#" data-toggle="tooltip" title="' + __t("Edit this item") + '"><i class="fa-solid fa-edit"></i></a> \
|
||||
<a class="ml-1 btn btn-outline-success btn-xs product-consume-button ' + productConsumeButtonDisabledClasses + '" href="#" data-toggle="tooltip" title="' + __t("Consume %1$s of %2$s", parseFloat(mealPlanEntry.product_amount).toLocaleString() + ' ' + __n(mealPlanEntry.product_amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true), productDetails.product.name) + '" data-product-id="' + productDetails.product.id.toString() + '" data-product-name="' + productDetails.product.name + '" data-product-amount="' + mealPlanEntry.product_amount + '" data-mealplan-entry-id="' + mealPlanEntry.id.toString() + '"><i class="fa-solid fa-utensils"></i></a> \
|
||||
<a class="ml-1 btn btn-outline-success btn-xs product-consume-button ' + productConsumeButtonDisabledClasses + '" href="#" data-toggle="tooltip" title="' + __t("Consume %1$s of %2$s", mealPlanEntry.product_amount.toLocaleString() + ' ' + __n(mealPlanEntry.product_amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true), productDetails.product.name) + '" data-product-id="' + productDetails.product.id.toString() + '" data-product-name="' + productDetails.product.name + '" data-product-amount="' + mealPlanEntry.product_amount + '" data-mealplan-entry-id="' + mealPlanEntry.id.toString() + '"><i class="fa-solid fa-utensils"></i></a> \
|
||||
' + shoppingListButtonHtml + ' \
|
||||
' + doneButtonHtml + ' \
|
||||
</h5> \
|
||||
</div>');
|
||||
|
||||
if (productDetails.product.picture_file_name && !productDetails.product.picture_file_name.isEmpty())
|
||||
if (productDetails.product.picture_file_name)
|
||||
{
|
||||
element.prepend('<div class="mx-auto mb-1"><img data-src="' + U("/api/files/productpictures/") + btoa(productDetails.product.picture_file_name) + '?force_serve_as=picture&best_fit_width=400" class="img-fluid rounded-circle lazy"></div>')
|
||||
}
|
||||
@@ -823,7 +823,7 @@ $(document).on('click', '.product-consume-button', function(e)
|
||||
Grocy.FrontendHelpers.BeginUiBusy();
|
||||
|
||||
var productId = $(e.currentTarget).attr('data-product-id');
|
||||
var consumeAmount = parseFloat($(e.currentTarget).attr('data-product-amount'));
|
||||
var consumeAmount = Number.parseFloat($(e.currentTarget).attr('data-product-amount'));
|
||||
var mealPlanEntryId = $(e.currentTarget).attr('data-mealplan-entry-id');
|
||||
|
||||
Grocy.Api.Post('stock/products/' + productId + '/consume', { 'amount': consumeAmount, 'spoiled': false },
|
||||
|
@@ -93,11 +93,6 @@ $('.save-product-button').on('click', function(e)
|
||||
jsonData.parent_product_id = parentProductId;
|
||||
Grocy.FrontendHelpers.BeginUiBusy("product-form");
|
||||
|
||||
if (jsonData.parent_product_id.toString().isEmpty())
|
||||
{
|
||||
jsonData.parent_product_id = null;
|
||||
}
|
||||
|
||||
if ($("#product-picture")[0].files.length > 0)
|
||||
{
|
||||
var someRandomStuff = Math.random().toString(36).substring(2, 100) + Math.random().toString(36).substring(2, 100);
|
||||
@@ -396,7 +391,7 @@ if (Grocy.EditMode == "create" && GetUriParam("copy-of") != undefined)
|
||||
{
|
||||
Grocy.Components.ProductPicker.SetId(sourceProduct.parent_product_id);
|
||||
}
|
||||
if (sourceProduct.description != null && !sourceProduct.description.isEmpty())
|
||||
if (sourceProduct.description)
|
||||
{
|
||||
$("#description").summernote("pasteHTML", sourceProduct.description);
|
||||
}
|
||||
|
@@ -37,16 +37,16 @@ $('#save-purchase-button').on('click', function(e)
|
||||
}
|
||||
else
|
||||
{
|
||||
var amount = jsonForm.display_amount;
|
||||
var amount = Number.parseFloat(jsonForm.display_amount);
|
||||
if (BoolVal(productDetails.product.enable_tare_weight_handling))
|
||||
{
|
||||
amount -= parseFloat(productDetails.product.tare_weight);
|
||||
amount -= productDetails.product.tare_weight;
|
||||
}
|
||||
|
||||
var price = parseFloat(jsonForm.price * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
|
||||
var price = Number.parseFloat(jsonForm.price * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
|
||||
if ($("input[name='price-type']:checked").val() == "total-price")
|
||||
{
|
||||
price = parseFloat(price / amount).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
|
||||
price = (price / amount).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
|
||||
}
|
||||
|
||||
jsonData.price = price;
|
||||
@@ -119,10 +119,10 @@ $('#save-purchase-button').on('click', function(e)
|
||||
);
|
||||
}
|
||||
|
||||
var amountMessage = parseFloat(jsonForm.amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts });
|
||||
var amountMessage = Number.parseFloat(jsonForm.amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts });
|
||||
if (BoolVal(productDetails.product.enable_tare_weight_handling))
|
||||
{
|
||||
amountMessage = parseFloat(jsonForm.amount) - parseFloat(productDetails.stock_amount) - parseFloat(productDetails.product.tare_weight);
|
||||
amountMessage = Number.parseFloat(jsonForm.amount) - productDetails.stock_amount - productDetails.product.tare_weight;
|
||||
}
|
||||
var successMessage = __t('Added %1$s of %2$s to stock', amountMessage + " " + __n(amountMessage, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + result[0].transaction_id + '\')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
|
||||
@@ -200,7 +200,7 @@ $('#save-purchase-button').on('click', function(e)
|
||||
Grocy.Components.ProductAmountPicker.Reset();
|
||||
$("#purchase-form").removeAttr("data-used-barcode");
|
||||
$("#display_amount").attr("min", Grocy.DefaultMinAmount);
|
||||
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_purchase_amount));
|
||||
$('#display_amount').val(Grocy.UserSettings.stock_default_purchase_amount);
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
$('#price').val('');
|
||||
$("#tare-weight-handling-info").addClass("d-none");
|
||||
@@ -280,13 +280,13 @@ if (Grocy.Components.ProductPicker !== undefined)
|
||||
{
|
||||
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.default_quantity_unit_purchase.id);
|
||||
}
|
||||
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_purchase_amount));
|
||||
$('#display_amount').val(Grocy.UserSettings.stock_default_purchase_amount);
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
|
||||
if (GetUriParam("flow") === "shoppinglistitemtostock")
|
||||
{
|
||||
Grocy.Components.ProductAmountPicker.SetQuantityUnit(GetUriParam("quId"));
|
||||
$('#display_amount').val(parseFloat(GetUriParam("amount") * $("#qu_id option:selected").attr("data-qu-factor")));
|
||||
$('#display_amount').val(Number.parseFloat(GetUriParam("amount") * $("#qu_id option:selected").attr("data-qu-factor")));
|
||||
}
|
||||
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
@@ -314,7 +314,7 @@ if (Grocy.Components.ProductPicker !== undefined)
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#price').val(parseFloat(productDetails.last_price / $("#qu_id option:selected").attr("data-qu-factor")));
|
||||
$('#price').val(productDetails.last_price / $("#qu_id option:selected").attr("data-qu-factor"));
|
||||
}
|
||||
|
||||
var priceTypeUnitPrice = $("#price-type-unit-price");
|
||||
@@ -325,7 +325,7 @@ if (Grocy.Components.ProductPicker !== undefined)
|
||||
|
||||
if (productDetails.product.enable_tare_weight_handling == 1)
|
||||
{
|
||||
var minAmount = parseFloat(productDetails.product.tare_weight) / $("#qu_id option:selected").attr("data-qu-factor") + parseFloat(productDetails.stock_amount);
|
||||
var minAmount = productDetails.product.tare_weight / $("#qu_id option:selected").attr("data-qu-factor") + productDetails.stock_amount;
|
||||
$("#display_amount").attr("min", minAmount);
|
||||
$("#tare-weight-handling-info").removeClass("d-none");
|
||||
}
|
||||
@@ -380,7 +380,7 @@ if (Grocy.Components.ProductPicker !== undefined)
|
||||
Grocy.Components.ShoppingLocationPicker.SetId(barcode.shopping_location_id);
|
||||
}
|
||||
|
||||
if (barcode.last_price != null && !barcode.last_price.isEmpty())
|
||||
if (barcode.last_price)
|
||||
{
|
||||
$("#price").val(barcode.last_price);
|
||||
$("#price-type-total-price").click();
|
||||
@@ -436,7 +436,6 @@ function PrefillBestBeforeDate(product, location)
|
||||
dueDays = product.default_best_before_days;
|
||||
}
|
||||
|
||||
dueDays = parseFloat(dueDays);
|
||||
if (dueDays != 0)
|
||||
{
|
||||
if (dueDays == -1)
|
||||
@@ -472,7 +471,7 @@ if (Grocy.Components.LocationPicker !== undefined)
|
||||
});
|
||||
}
|
||||
|
||||
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_purchase_amount));
|
||||
$('#display_amount').val(Grocy.UserSettings.stock_default_purchase_amount);
|
||||
RefreshLocaleNumberInput();
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
Grocy.FrontendHelpers.ValidateForm('purchase-form');
|
||||
@@ -592,16 +591,16 @@ function refreshPriceHint()
|
||||
|
||||
if ($("input[name='price-type']:checked").val() == "total-price" || $("#qu_id").attr("data-destination-qu-name") != $("#qu_id option:selected").text())
|
||||
{
|
||||
var amount = $('#display_amount').val();
|
||||
var amount = Number.parseFloat($('#display_amount').val());
|
||||
if (BoolVal(CurrentProductDetails.product.enable_tare_weight_handling))
|
||||
{
|
||||
amount -= parseFloat(CurrentProductDetails.product.tare_weight);
|
||||
amount -= CurrentProductDetails.product.tare_weight;
|
||||
}
|
||||
|
||||
var price = parseFloat($('#price').val() * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
|
||||
var price = Number.parseFloat($('#price').val() * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
|
||||
if ($("input[name='price-type']:checked").val() == "total-price")
|
||||
{
|
||||
price = parseFloat(price / amount).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
|
||||
price = (price / amount).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
|
||||
}
|
||||
|
||||
$('#price-hint').text(__t('means %1$s per %2$s', price.toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), $("#qu_id").attr("data-destination-qu-name")));
|
||||
|
@@ -101,7 +101,7 @@
|
||||
|
||||
$('#quantityunit-form input').keyup(function(event)
|
||||
{
|
||||
if (!$("#name").val().isEmpty())
|
||||
if ($("#name").val())
|
||||
{
|
||||
$("#qu-conversion-headline-info").text(__t('1 %s is the same as...', $("#name").val()));
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ function RefreshQuPluralTestingResult()
|
||||
var pluralForm = $("#qu_id option:selected").data("plural-form");
|
||||
var amount = $("#amount").val();
|
||||
|
||||
if (singularForm.toString().isEmpty() || amount.toString().isEmpty())
|
||||
if (!singularForm || !amount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -72,7 +72,7 @@ $("#search").on("keyup", Delay(function()
|
||||
|
||||
recipesTables.search(value).draw();
|
||||
|
||||
if (value.isEmpty())
|
||||
if (!value)
|
||||
{
|
||||
RemoveUriParam("search");
|
||||
}
|
||||
@@ -120,7 +120,7 @@ $("#status-filter").on("change", function()
|
||||
}
|
||||
}
|
||||
|
||||
if (value.isEmpty())
|
||||
if (!value)
|
||||
{
|
||||
RemoveUriParam("status");
|
||||
}
|
||||
|
@@ -508,7 +508,7 @@ $(document).on("click", "#print-shopping-list-button", function(e)
|
||||
$(".print-timestamp").text(moment().format("l LT"));
|
||||
|
||||
$("#description-for-print").html($("#description").val());
|
||||
if ($("#description").text().isEmpty())
|
||||
if (!$("#description").text())
|
||||
{
|
||||
$("#description-for-print").parent().addClass("d-print-none");
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ $('#save-shoppinglist-button').on('click', function(e)
|
||||
}
|
||||
|
||||
var jsonData = $('#shoppinglist-form').serializeJSON();
|
||||
var displayAmount = parseFloat(jsonData.display_amount);
|
||||
var displayAmount = Number.parseFloat(jsonData.display_amount);
|
||||
if (!jsonData.product_id)
|
||||
{
|
||||
jsonData.amount = jsonData.display_amount;
|
||||
@@ -200,7 +200,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.default_quantity_unit_purchase.id);
|
||||
}
|
||||
|
||||
if ($("#display_amount").val().toString().isEmpty())
|
||||
if (!$("#display_amount").val())
|
||||
{
|
||||
$("#display_amount").val(1);
|
||||
$("#display_amount").trigger("change");
|
||||
@@ -267,7 +267,7 @@ if (GetUriParam("list") !== undefined)
|
||||
|
||||
if (GetUriParam("amount") !== undefined)
|
||||
{
|
||||
$("#display_amount").val(parseFloat(GetUriParam("amount")));
|
||||
$("#display_amount").val(Number.parseFloat(GetUriParam("amount")));
|
||||
RefreshLocaleNumberInput();
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
|
||||
|
@@ -19,7 +19,7 @@ $.fn.dataTable.ext.search.push(function(settings, data, dataIndex)
|
||||
{
|
||||
var productId = Grocy.Components.ProductPicker.GetValue();
|
||||
|
||||
if ((isNaN(productId) || productId == "" || productId == data[1]))
|
||||
if (!productId || Number.isNaN(productId) || productId == data[1])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ $(document).on('click', '.stock-consume-button', function(e)
|
||||
var locationId = $(e.currentTarget).attr('data-location-id');
|
||||
var specificStockEntryId = $(e.currentTarget).attr('data-stock-id');
|
||||
var stockRowId = $(e.currentTarget).attr('data-stockrow-id');
|
||||
var consumeAmount = $(e.currentTarget).attr('data-consume-amount');
|
||||
var consumeAmount = Number.parseFloat($(e.currentTarget).attr('data-consume-amount'));
|
||||
|
||||
var wasSpoiled = $(e.currentTarget).hasClass("stock-consume-button-spoiled");
|
||||
|
||||
@@ -81,7 +81,7 @@ $(document).on('click', '.stock-consume-button', function(e)
|
||||
Grocy.Api.Get('stock/products/' + productId,
|
||||
function(result)
|
||||
{
|
||||
var toastMessage = __t('Removed %1$s of %2$s from stock', parseFloat(consumeAmount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural, true), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBookingEntry(' + bookingResponse[0].id + ',' + stockRowId + ')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
var toastMessage = __t('Removed %1$s of %2$s from stock', consumeAmount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural, true), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBookingEntry(' + bookingResponse[0].id + ',' + stockRowId + ')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
if (wasSpoiled)
|
||||
{
|
||||
toastMessage += " (" + __t("Spoiled") + ")";
|
||||
@@ -249,13 +249,13 @@ function RefreshStockEntryRow(stockRowId)
|
||||
Grocy.Api.Get("stock/products/" + result.product_id,
|
||||
function(productDetails)
|
||||
{
|
||||
if (result.price == null || result.price.isEmpty())
|
||||
if (!result.price)
|
||||
{
|
||||
result.price = 0;
|
||||
}
|
||||
|
||||
$('#stock-' + stockRowId + '-price').text(__t("%1$s per %2$s", (Number.parseFloat(result.price) * Number.parseFloat(productDetails.qu_conversion_factor_purchase_to_stock)).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), productDetails.default_quantity_unit_purchase.name));
|
||||
$('#stock-' + stockRowId + '-price').attr("data-original-title", __t("%1$s per %2$s", Number.parseFloat(result.price).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), productDetails.quantity_unit_stock.name));
|
||||
$('#stock-' + stockRowId + '-price').text(__t("%1$s per %2$s", (result.price * productDetails.qu_conversion_factor_purchase_to_stock).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), productDetails.default_quantity_unit_purchase.name));
|
||||
$('#stock-' + stockRowId + '-price').attr("data-original-title", __t("%1$s per %2$s", result.price.toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), productDetails.quantity_unit_stock.name));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -267,7 +267,7 @@ function RefreshStockEntryRow(stockRowId)
|
||||
$('#stock-' + stockRowId + '-purchased-date').text(result.purchased_date);
|
||||
$('#stock-' + stockRowId + '-purchased-date-timeago').attr('datetime', result.purchased_date + ' 23:59:59');
|
||||
|
||||
if (result.shopping_location_id != null && !result.shopping_location_id.isEmpty())
|
||||
if (result.shopping_location_id)
|
||||
{
|
||||
var shoppingLocationName = "";
|
||||
Grocy.Api.Get("objects/shopping_locations/" + result.shopping_location_id,
|
||||
|
@@ -15,9 +15,9 @@
|
||||
var jsonForm = $('#stockentry-form').serializeJSON();
|
||||
Grocy.FrontendHelpers.BeginUiBusy("stockentry-form");
|
||||
|
||||
if (!jsonForm.price.toString().isEmpty())
|
||||
if (jsonForm.price)
|
||||
{
|
||||
price = parseFloat(jsonForm.price).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
|
||||
price = Number.parseFloat(jsonForm.price).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
|
||||
}
|
||||
|
||||
var jsonData = {};
|
||||
|
@@ -108,7 +108,7 @@ $(document).on('click', '.undo-stock-booking-button', function(e)
|
||||
var correlationId = $("#stock-booking-" + bookingId + "-row").attr("data-correlation-id");
|
||||
|
||||
var correspondingBookingsRoot = $("#stock-booking-" + bookingId + "-row");
|
||||
if (!correlationId.isEmpty())
|
||||
if (correlationId)
|
||||
{
|
||||
correspondingBookingsRoot = $(".stock-booking-correlation-" + correlationId);
|
||||
}
|
||||
|
@@ -137,8 +137,8 @@ $(document).on('click', '.product-consume-button', function(e)
|
||||
Grocy.FrontendHelpers.BeginUiBusy();
|
||||
|
||||
var productId = $(e.currentTarget).attr('data-product-id');
|
||||
var consumeAmount = $(e.currentTarget).attr('data-consume-amount');
|
||||
var originalTotalStockAmount = $(e.currentTarget).attr('data-original-total-stock-amount');
|
||||
var consumeAmount = Number.parseFloat($(e.currentTarget).attr('data-consume-amount'));
|
||||
var originalTotalStockAmount = Number.parseFloat($(e.currentTarget).attr('data-original-total-stock-amount'));
|
||||
var wasSpoiled = $(e.currentTarget).hasClass("product-consume-button-spoiled");
|
||||
|
||||
Grocy.Api.Post('stock/products/' + productId + '/consume', { 'amount': consumeAmount, 'spoiled': wasSpoiled, 'allow_subproduct_substitution': true },
|
||||
@@ -149,11 +149,11 @@ $(document).on('click', '.product-consume-button', function(e)
|
||||
{
|
||||
if (result.product.enable_tare_weight_handling == 1)
|
||||
{
|
||||
var toastMessage = __t('Removed %1$s of %2$s from stock', parseFloat(originalTotalStockAmount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural, true), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
var toastMessage = __t('Removed %1$s of %2$s from stock', originalTotalStockAmount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural, true), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
var toastMessage = __t('Removed %1$s of %2$s from stock', parseFloat(consumeAmount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural, true), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
var toastMessage = __t('Removed %1$s of %2$s from stock', consumeAmount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural, true), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
}
|
||||
|
||||
if (wasSpoiled)
|
||||
@@ -194,7 +194,7 @@ $(document).on('click', '.product-open-button', function(e)
|
||||
var productId = $(e.currentTarget).attr('data-product-id');
|
||||
var productName = $(e.currentTarget).attr('data-product-name');
|
||||
var productQuName = $(e.currentTarget).attr('data-product-qu-name');
|
||||
var amount = $(e.currentTarget).attr('data-open-amount');
|
||||
var amount = Number.parseFloat($(e.currentTarget).attr('data-open-amount'));
|
||||
var button = $(e.currentTarget);
|
||||
|
||||
Grocy.Api.Post('stock/products/' + productId + '/open', { 'amount': amount, 'allow_subproduct_substitution': true },
|
||||
@@ -209,7 +209,7 @@ $(document).on('click', '.product-open-button', function(e)
|
||||
}
|
||||
|
||||
Grocy.FrontendHelpers.EndUiBusy();
|
||||
toastr.success(__t('Marked %1$s of %2$s as opened', parseFloat(amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + productQuName, productName) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>');
|
||||
toastr.success(__t('Marked %1$s of %2$s as opened', amount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + productQuName, productName) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>');
|
||||
|
||||
if (result.product.move_on_open == 1 && result.default_consume_location != null)
|
||||
{
|
||||
@@ -254,7 +254,7 @@ function RefreshStatistics()
|
||||
var valueSum = 0;
|
||||
result.forEach(element =>
|
||||
{
|
||||
valueSum += parseFloat(element.value);
|
||||
valueSum += element.value;
|
||||
});
|
||||
$("#info-current-stock").text(__n(result.length, '%s Product', '%s Products') + ", " + __t('%s total value', valueSum.toLocaleString(undefined, { style: "currency", currency: Grocy.Currency })));
|
||||
}
|
||||
@@ -295,7 +295,7 @@ function RefreshProductRow(productId)
|
||||
function(result)
|
||||
{
|
||||
// Also refresh the parent product, if any
|
||||
if (result.product.parent_product_id !== null && !result.product.parent_product_id.toString().isEmpty())
|
||||
if (result.product.parent_product_id)
|
||||
{
|
||||
RefreshProductRow(result.product.parent_product_id);
|
||||
}
|
||||
@@ -326,7 +326,7 @@ function RefreshProductRow(productId)
|
||||
{
|
||||
productRow.addClass("table-warning");
|
||||
}
|
||||
else if (parseFloat(result.product.min_stock_amount) > 0 && parseFloat(result.stock_amount_aggregated) < parseFloat(result.product.min_stock_amount))
|
||||
else if (result.product.min_stock_amount > 0 && result.stock_amount_aggregated < result.product.min_stock_amount)
|
||||
{
|
||||
productRow.addClass("table-info");
|
||||
}
|
||||
@@ -373,7 +373,7 @@ function RefreshProductRow(productId)
|
||||
$('#product-' + productId + '-opened-amount').text("");
|
||||
}
|
||||
|
||||
if (parseInt(result.is_aggregated_amount) === 1)
|
||||
if (result.is_aggregated_amount == 1)
|
||||
{
|
||||
$('#product-' + productId + '-amount-aggregated').text(result.stock_amount_aggregated);
|
||||
|
||||
|
@@ -61,7 +61,7 @@
|
||||
|
||||
if (productDetails.product.enable_tare_weight_handling == 1)
|
||||
{
|
||||
var successMessage = __t('Transfered %1$s of %2$s from %3$s to %4$s', Math.abs(jsonForm.amount - parseFloat(productDetails.product.tare_weight)) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true), productDetails.product.name, $('option:selected', "#location_id_from").text(), $('option:selected', "#location_id_to").text()) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
var successMessage = __t('Transfered %1$s of %2$s from %3$s to %4$s', Math.abs(jsonForm.amount - productDetails.product.tare_weight) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true), productDetails.product.name, $('option:selected', "#location_id_from").text(), $('option:selected', "#location_id_to").text()) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -80,7 +80,7 @@
|
||||
toastr.success(successMessage);
|
||||
Grocy.Components.ProductPicker.FinishFlow();
|
||||
|
||||
if (parseInt($("#location_id_from option:selected").attr("data-is-freezer")) === 0 && parseInt($("#location_id_to option:selected").attr("data-is-freezer")) === 1) // Frozen
|
||||
if ($("#location_id_from option:selected").attr("data-is-freezer") == 0 && $("#location_id_to option:selected").attr("data-is-freezer") == 1) // Frozen
|
||||
{
|
||||
toastr.info('<span>' + __t("Frozen") + "</span> <i class='fa-solid fa-snowflake'></i>");
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
toastr.warning(__t("This product shouldn't be frozen"));
|
||||
}
|
||||
}
|
||||
if (parseInt($("#location_id_from option:selected").attr("data-is-freezer")) === 1 && parseInt($("#location_id_to option:selected").attr("data-is-freezer")) === 0) // Thawed
|
||||
if ($("#location_id_from option:selected").attr("data-is-freezer") == 1 && $("#location_id_to option:selected").attr("data-is-freezer") == 0) // Thawed
|
||||
{
|
||||
toastr.info('<span>' + __t("Thawed") + "</span> <i class='fa-solid fa-fire-alt'></i>");
|
||||
}
|
||||
@@ -106,7 +106,7 @@
|
||||
$("#location_id_from").find("option").remove().end().append("<option></option>");
|
||||
$("#display_amount").attr("min", Grocy.DefaultMinAmount);
|
||||
$("#display_amount").removeAttr("max");
|
||||
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_transfer_amount));
|
||||
$('#display_amount').val(Grocy.UserSettings.stock_default_transfer_amount);
|
||||
RefreshLocaleNumberInput();
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
$("#tare-weight-handling-info").addClass("d-none");
|
||||
@@ -271,7 +271,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
}
|
||||
});
|
||||
|
||||
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_transfer_amount));
|
||||
$('#display_amount').val(Grocy.UserSettings.stock_default_transfer_amount);
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
Grocy.FrontendHelpers.ValidateForm('transfer-form');
|
||||
RefreshLocaleNumberInput();
|
||||
@@ -316,7 +316,7 @@ $("#location_id_from").on('change', function(e)
|
||||
if ($("#specific_stock_entry option[value='" + stockEntry.stock_id + "']").length == 0)
|
||||
{
|
||||
var noteTxt = "";
|
||||
if (stockEntry.note != null && !stockEntry.note.isEmpty())
|
||||
if (stockEntry.note)
|
||||
{
|
||||
noteTxt = " " + stockEntry.note;
|
||||
}
|
||||
@@ -333,7 +333,7 @@ $("#location_id_from").on('change', function(e)
|
||||
$("#specific_stock_entry").val(stockId);
|
||||
}
|
||||
|
||||
sumValue = sumValue + parseFloat(stockEntry.amount);
|
||||
sumValue = sumValue + stockEntry.amount;
|
||||
}
|
||||
});
|
||||
$("#display_amount").attr("max", sumValue * $("#qu_id option:selected").attr("data-qu-factor"));
|
||||
@@ -363,7 +363,7 @@ $("#location_id_to").on('change', function(e)
|
||||
|
||||
$("#qu_id").on('change', function(e)
|
||||
{
|
||||
$("#display_amount").attr("max", parseFloat($('#display_amount').attr("data-stock-amount")) * $("#qu_id option:selected").attr("data-qu-factor"));
|
||||
$("#display_amount").attr("max", Number.parseFloat($('#display_amount').attr("data-stock-amount")) * $("#qu_id option:selected").attr("data-qu-factor"));
|
||||
});
|
||||
|
||||
$('#display_amount').on('focus', function(e)
|
||||
@@ -410,7 +410,7 @@ $("#specific_stock_entry").on("change", function(e)
|
||||
{
|
||||
if (stockEntry.location_id == $("#location_id_from").val() || stockEntry.location_id == "")
|
||||
{
|
||||
sumValue = sumValue + parseFloat(stockEntry.amount);
|
||||
sumValue = sumValue + stockEntry.amount;
|
||||
}
|
||||
});
|
||||
$("#display_amount").attr("max", sumValue * $("#qu_id option:selected").attr("data-qu-factor"));
|
||||
|
@@ -16,7 +16,7 @@
|
||||
Grocy.FrontendHelpers.BeginUiBusy("userfield-form");
|
||||
|
||||
var redirectUrl = U("/userfields");
|
||||
if (typeof GetUriParam("entity") !== "undefined" && !GetUriParam("entity").isEmpty())
|
||||
if (GetUriParam("entity"))
|
||||
{
|
||||
redirectUrl = U("/userfields?entity=" + GetUriParam("entity"));
|
||||
}
|
||||
@@ -113,7 +113,7 @@ $("#type").on("change", function(e)
|
||||
|
||||
$('#entity').focus();
|
||||
|
||||
if (typeof GetUriParam("entity") !== "undefined" && !GetUriParam("entity").isEmpty())
|
||||
if (GetUriParam("entity"))
|
||||
{
|
||||
$("#entity").val(GetUriParam("entity"));
|
||||
$("#entity").trigger("change");
|
||||
|
@@ -76,7 +76,7 @@ $(document).on('click', '.userfield-delete-button', function(e)
|
||||
});
|
||||
});
|
||||
|
||||
if (GetUriParam("entity") != undefined && !GetUriParam("entity").isEmpty())
|
||||
if (GetUriParam("entity")
|
||||
{
|
||||
$("#entity-filter").val(GetUriParam("entity"));
|
||||
$("#entity-filter").trigger("change");
|
||||
|
Reference in New Issue
Block a user