mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
Removed type conversions where no longer needed
PHP 8.1 PDO SQLite now returns native data types
This commit is contained in:
parent
d8d3c3ef0b
commit
d9667b4534
@ -165,7 +165,7 @@ class BaseController
|
||||
{
|
||||
$this->View->set('permissions', User::PermissionList());
|
||||
|
||||
$decimalPlacesAmounts = intval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'stock_decimal_places_amounts'));
|
||||
$decimalPlacesAmounts = $this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'stock_decimal_places_amounts');
|
||||
if ($decimalPlacesAmounts <= 0)
|
||||
{
|
||||
$defaultMinAmount = 1;
|
||||
|
@ -53,7 +53,7 @@ class GenericEntityApiController extends BaseApiController
|
||||
// TODO: This should be better done somehow in StockService
|
||||
if ($args['entity'] == 'products' && boolval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount')))
|
||||
{
|
||||
$this->getStockService()->AddMissingProductsToShoppingList(intval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount_list_id')));
|
||||
$this->getStockService()->AddMissingProductsToShoppingList($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount_list_id'));
|
||||
}
|
||||
|
||||
return $this->ApiResponse($response, [
|
||||
@ -167,7 +167,7 @@ class GenericEntityApiController extends BaseApiController
|
||||
// TODO: This should be better done somehow in StockService
|
||||
if ($args['entity'] == 'products' && boolval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount')))
|
||||
{
|
||||
$this->getStockService()->AddMissingProductsToShoppingList(intval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount_list_id')));
|
||||
$this->getStockService()->AddMissingProductsToShoppingList($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount_list_id'));
|
||||
}
|
||||
|
||||
return $this->EmptyApiResponse($response);
|
||||
|
@ -11,11 +11,6 @@ String.prototype.contains = function(search)
|
||||
return this.toLowerCase().indexOf(search.toLowerCase()) !== -1;
|
||||
};
|
||||
|
||||
String.prototype.isEmpty = function()
|
||||
{
|
||||
return (this.length === 0 || !this.trim());
|
||||
};
|
||||
|
||||
String.prototype.replaceAll = function(search, replacement)
|
||||
{
|
||||
return this.replace(new RegExp(search, "g"), replacement);
|
||||
|
@ -257,7 +257,7 @@ __n = function(number, singularForm, pluralForm, isQu = false)
|
||||
}
|
||||
}
|
||||
|
||||
if (pluralForm == null || pluralForm.isEmpty())
|
||||
if (!pluralForm)
|
||||
{
|
||||
pluralForm = singularForm;
|
||||
}
|
||||
@ -272,7 +272,7 @@ __n = function(number, singularForm, pluralForm, isQu = false)
|
||||
}
|
||||
}
|
||||
|
||||
if (!Grocy.ActiveNav.isEmpty())
|
||||
if (Grocy.ActiveNav)
|
||||
{
|
||||
var menuItem = $('#sidebarResponsive').find("[data-nav-for-page='" + Grocy.ActiveNav + "']");
|
||||
menuItem.addClass('active-page');
|
||||
@ -343,7 +343,7 @@ RefreshContextualTimeago = function(rootSelector = "#page-content")
|
||||
|
||||
var timestamp = element.attr("datetime");
|
||||
|
||||
if (timestamp.isEmpty() || timestamp.length < 10)
|
||||
if (!timestamp || timestamp.length < 10)
|
||||
{
|
||||
element.text("")
|
||||
return
|
||||
@ -490,7 +490,7 @@ Grocy.FrontendHelpers.DeleteUserSetting = function(settingsKey, reloadPageOnSucc
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
if (!xhr.statusText.isEmpty())
|
||||
if (xhr.statusText)
|
||||
{
|
||||
Grocy.FrontendHelpers.ShowGenericError('Error while deleting, please retry', xhr.response)
|
||||
}
|
||||
@ -635,36 +635,36 @@ function RefreshLocaleNumberDisplay(rootSelector = "#page-content")
|
||||
$(rootSelector + " .locale-number.locale-number-currency").each(function()
|
||||
{
|
||||
var text = $(this).text();
|
||||
if (isNaN(text) || text.isEmpty())
|
||||
if (!text || Number.isNaN(text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var value = parseFloat(text);
|
||||
var value = Number.parseFloat(text);
|
||||
$(this).text(value.toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }));
|
||||
});
|
||||
|
||||
$(rootSelector + " .locale-number.locale-number-quantity-amount").each(function()
|
||||
{
|
||||
var text = $(this).text();
|
||||
if (isNaN(text) || text.isEmpty())
|
||||
if (!text || Number.isNaN(text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var value = parseFloat(text);
|
||||
var value = Number.parseFloat(text);
|
||||
$(this).text(value.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }));
|
||||
});
|
||||
|
||||
$(rootSelector + " .locale-number.locale-number-generic").each(function()
|
||||
{
|
||||
var text = $(this).text();
|
||||
if (isNaN(text) || text.isEmpty())
|
||||
if (!text || Number.isNaN(text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var value = parseFloat(text);
|
||||
var value = Number.parseFloat(text);
|
||||
$(this).text(value.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 0 }));
|
||||
});
|
||||
}
|
||||
@ -675,29 +675,29 @@ function RefreshLocaleNumberInput(rootSelector = "#page-content")
|
||||
$(rootSelector + " .locale-number-input.locale-number-currency").each(function()
|
||||
{
|
||||
var value = $(this).val();
|
||||
if (isNaN(value) || value.toString().isEmpty())
|
||||
if (!value || Number.isNaN(value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$(this).val(parseFloat(value).toLocaleString("en", { minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_input, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_input, useGrouping: false }));
|
||||
$(this).val(Number.parseFloat(value).toLocaleString("en", { minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_input, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_input, useGrouping: false }));
|
||||
});
|
||||
|
||||
$(rootSelector + " .locale-number-input.locale-number-quantity-amount").each(function()
|
||||
{
|
||||
var value = $(this).val();
|
||||
if (isNaN(value) || value.toString().isEmpty())
|
||||
if (!value || Number.isNaN(value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$(this).val(parseFloat(value).toLocaleString("en", { minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts, useGrouping: false }));
|
||||
$(this).val(Number.parseFloat(value).toLocaleString("en", { minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts, useGrouping: false }));
|
||||
});
|
||||
|
||||
$(rootSelector + " .locale-number-input.locale-number-generic").each(function()
|
||||
{
|
||||
var value = $(this).val();
|
||||
if (isNaN(value) || value.toString().isEmpty())
|
||||
if (!value || Number.isNaN(value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -742,11 +742,11 @@ function LoadImagesLazy()
|
||||
}
|
||||
LoadImagesLazy();
|
||||
|
||||
if (!Grocy.CalendarFirstDayOfWeek.isEmpty())
|
||||
if (Grocy.CalendarFirstDayOfWeek)
|
||||
{
|
||||
moment.updateLocale(moment.locale(), {
|
||||
week: {
|
||||
dow: Grocy.CalendarFirstDayOfWeek
|
||||
dow: Number.parseInt(Grocy.CalendarFirstDayOfWeek)
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -905,7 +905,7 @@ $.fn.dataTable.ext.type.order["custom-sort-pre"] = function(data)
|
||||
// This here is for a custom column type "custom-sort",
|
||||
// the custom order value needs to be provided in the first child (<span>) of the <td>
|
||||
|
||||
return (parseFloat($(data).get(0).innerText));
|
||||
return (Number.parseFloat($(data).get(0).innerText));
|
||||
};
|
||||
|
||||
// serializeJSON defaults
|
||||
@ -973,6 +973,7 @@ $('.table').on('column-sizing.dt', function(e, settings)
|
||||
});
|
||||
$('td .dropdown').on('show.bs.dropdown', function(e)
|
||||
{
|
||||
console.log("xx");
|
||||
if ($('.dataTables_scrollBody').hasClass("no-force-overflow-visible"))
|
||||
{
|
||||
$('.dataTables_scrollBody').addClass("force-overflow-visible");
|
||||
@ -1034,7 +1035,7 @@ $(".change-table-columns-visibility-button").on("click", function(e)
|
||||
var title = headerCell.text();
|
||||
var visible = this.visible();
|
||||
|
||||
if (title.isEmpty() || title.startsWith("Hidden") || headerCell.hasClass("d-none"))
|
||||
if (!title || title.startsWith("Hidden") || headerCell.hasClass("d-none"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -45,8 +45,7 @@ class DatabaseMigrationService extends BaseService
|
||||
private function ExecutePhpMigrationWhenNeeded(int $migrationId, string $phpFile, int &$migrationCounter)
|
||||
{
|
||||
$rowCount = $this->getDatabaseService()->ExecuteDbQuery('SELECT COUNT(*) FROM migrations WHERE migration = ' . $migrationId)->fetchColumn();
|
||||
|
||||
if (intval($rowCount) === 0 || $migrationId == self::EMERGENCY_MIGRATION_ID || $migrationId == self::DOALWAYS_MIGRATION_ID)
|
||||
if ($rowCount == 0 || $migrationId == self::EMERGENCY_MIGRATION_ID || $migrationId == self::DOALWAYS_MIGRATION_ID)
|
||||
{
|
||||
include $phpFile;
|
||||
|
||||
@ -61,8 +60,7 @@ class DatabaseMigrationService extends BaseService
|
||||
private function ExecuteSqlMigrationWhenNeeded(int $migrationId, string $sql, int &$migrationCounter)
|
||||
{
|
||||
$rowCount = $this->getDatabaseService()->ExecuteDbQuery('SELECT COUNT(*) FROM migrations WHERE migration = ' . $migrationId)->fetchColumn();
|
||||
|
||||
if (intval($rowCount) === 0 || $migrationId == self::EMERGENCY_MIGRATION_ID || $migrationId == self::DOALWAYS_MIGRATION_ID)
|
||||
if ($rowCount == 0 || $migrationId == self::EMERGENCY_MIGRATION_ID || $migrationId == self::DOALWAYS_MIGRATION_ID)
|
||||
{
|
||||
$this->getDatabaseService()->GetDbConnectionRaw()->beginTransaction();
|
||||
|
||||
|
@ -69,6 +69,7 @@ class DatabaseService
|
||||
{
|
||||
$pdo = new \PDO('sqlite:' . $this->GetDbFilePath());
|
||||
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
||||
$pdo->setAttribute(\PDO::ATTR_ORACLE_NULLS, \PDO::NULL_EMPTY_STRING);
|
||||
|
||||
$pdo->sqliteCreateFunction('regexp', function ($pattern, $value) {
|
||||
mb_regex_encoding('UTF-8');
|
||||
|
@ -16,8 +16,7 @@ class DemoDataGeneratorService extends BaseService
|
||||
public function PopulateDemoData()
|
||||
{
|
||||
$rowCount = $this->getDatabaseService()->ExecuteDbQuery('SELECT COUNT(*) FROM migrations WHERE migration = -1')->fetchColumn();
|
||||
|
||||
if (intval($rowCount) === 0)
|
||||
if ($rowCount == 0)
|
||||
{
|
||||
$loremIpsum = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.';
|
||||
$loremIpsumWithHtmlFormattings = "<h1>Lorem ipsum</h1><p>Lorem ipsum <b>dolor sit</b> amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur <span style=\"background-color: rgb(255, 255, 0);\">sadipscing elitr</span>, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p><ul><li>At vero eos et accusam et justo duo dolores et ea rebum.</li><li>Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li></ul><h1>Lorem ipsum</h1><p>Lorem ipsum <b>dolor sit</b> amet, consetetur \r\nsadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et \r\ndolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et\r\n justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea \r\ntakimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit \r\namet, consetetur <span style=\"background-color: rgb(255, 255, 0);\">sadipscing elitr</span>,\r\n sed diam nonumy eirmod tempor invidunt ut labore et dolore magna \r\naliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo \r\ndolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus \r\nest Lorem ipsum dolor sit amet.</p>";
|
||||
@ -301,7 +300,7 @@ class DemoDataGeneratorService extends BaseService
|
||||
{
|
||||
foreach ($this->getDatabase()->chores() as $chore)
|
||||
{
|
||||
$hours = intval($chore->period_interval);
|
||||
$hours = $chore->period_interval;
|
||||
if ($chore->period_type == 'weekly')
|
||||
{
|
||||
$hours *= 7 * 24;
|
||||
|
@ -44,7 +44,7 @@ class LocalizationService
|
||||
{
|
||||
if ($this->Po->getHeader(Translations::HEADER_PLURAL) !== null)
|
||||
{
|
||||
return $this->Po->getPluralForms()[0];
|
||||
return intval($this->Po->getPluralForms()[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ class RecipesService extends BaseService
|
||||
$conversion = $this->getDatabase()->quantity_unit_conversions_resolved()->where('product_id = :1 AND from_qu_id = :2 AND to_qu_id = :3', $recipePosition->product_id, $recipePosition->qu_id, $product->qu_id_stock)->fetch();
|
||||
if ($conversion != null)
|
||||
{
|
||||
$toOrderAmount = $toOrderAmount * floatval($conversion->factor);
|
||||
$toOrderAmount = $toOrderAmount * $conversion->factor;
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ class RecipesService extends BaseService
|
||||
{
|
||||
$product = $this->getDatabase()->products()->where('id = :1', $recipeRow->product_id)->fetch();
|
||||
$recipeResolvedRow = $this->getDatabase()->recipes_resolved()->where('recipe_id = :1', $recipeId)->fetch();
|
||||
$this->getStockService()->AddProduct($recipeRow->product_id, floatval($recipeRow->desired_servings), null, StockService::TRANSACTION_TYPE_SELF_PRODUCTION, date('Y-m-d'), floatval($recipeResolvedRow->costs_per_serving), null, null, $dummyTransactionId, $product->default_stock_label_type, true);
|
||||
$this->getStockService()->AddProduct($recipeRow->product_id, $recipeRow->desired_servings, null, StockService::TRANSACTION_TYPE_SELF_PRODUCTION, date('Y-m-d'), $recipeResolvedRow->costs_per_serving, null, null, $dummyTransactionId, $product->default_stock_label_type, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ class SessionService extends BaseService
|
||||
public function CreateSession($userId, $stayLoggedInPermanently = false)
|
||||
{
|
||||
$newSessionKey = $this->GenerateSessionKey();
|
||||
$expires = date('Y-m-d H:i:s', intval(time() + 2592000));
|
||||
$expires = date('Y-m-d H:i:s', time() + 2592000);
|
||||
|
||||
// Default is that sessions expire in 30 days
|
||||
if ($stayLoggedInPermanently === true)
|
||||
|
@ -130,15 +130,15 @@ class StockService extends BaseService
|
||||
{
|
||||
if ($addExactAmount)
|
||||
{
|
||||
$amount = floatval($productDetails->stock_amount) + floatval($productDetails->product->tare_weight) + $amount;
|
||||
$amount = $productDetails->stock_amount + $productDetails->product->tare_weight + $amount;
|
||||
}
|
||||
|
||||
if ($amount <= floatval($productDetails->product->tare_weight) + floatval($productDetails->stock_amount))
|
||||
if ($amount <= $productDetails->product->tare_weight + $productDetails->stock_amount)
|
||||
{
|
||||
throw new \Exception('The amount cannot be lower or equal than the defined tare weight + current stock amount');
|
||||
}
|
||||
|
||||
$amount = $amount - floatval($productDetails->stock_amount) - floatval($productDetails->product->tare_weight);
|
||||
$amount = $amount - $productDetails->stock_amount - $productDetails->product->tare_weight;
|
||||
}
|
||||
|
||||
//Set the default due date, if none is supplied
|
||||
@ -153,9 +153,9 @@ class StockService extends BaseService
|
||||
$location = $this->getDatabase()->locations()->where('id', $locationId)->fetch();
|
||||
}
|
||||
|
||||
if (GROCY_FEATURE_FLAG_STOCK_PRODUCT_FREEZING && $locationId !== null && intval($location->is_freezer) === 1 && intval($productDetails->product->default_best_before_days_after_freezing) >= -1)
|
||||
if (GROCY_FEATURE_FLAG_STOCK_PRODUCT_FREEZING && $locationId !== null && $location->is_freezer == 1 && $productDetails->product->default_best_before_days_after_freezing >= -1)
|
||||
{
|
||||
if (intval($productDetails->product->default_best_before_days_after_freezing) == -1)
|
||||
if ($productDetails->product->default_best_before_days_after_freezing == -1)
|
||||
{
|
||||
$bestBeforeDate = date('2999-12-31');
|
||||
}
|
||||
@ -164,11 +164,11 @@ class StockService extends BaseService
|
||||
$bestBeforeDate = date('Y-m-d', strtotime('+' . $productDetails->product->default_best_before_days_after_freezing . ' days'));
|
||||
}
|
||||
}
|
||||
elseif (intval($productDetails->product->default_best_before_days) == -1)
|
||||
elseif ($productDetails->product->default_best_before_days == -1)
|
||||
{
|
||||
$bestBeforeDate = date('2999-12-31');
|
||||
}
|
||||
elseif (intval($productDetails->product->default_best_before_days) > 0)
|
||||
elseif ($productDetails->product->default_best_before_days > 0)
|
||||
{
|
||||
$bestBeforeDate = date('Y-m-d', strtotime(date('Y-m-d') . ' + ' . $productDetails->product->default_best_before_days . ' days'));
|
||||
}
|
||||
@ -378,14 +378,14 @@ class StockService extends BaseService
|
||||
{
|
||||
if ($consumeExactAmount)
|
||||
{
|
||||
$amount = floatval($productDetails->stock_amount) + floatval($productDetails->product->tare_weight) - $amount;
|
||||
$amount = $productDetails->stock_amount + $productDetails->product->tare_weight - $amount;
|
||||
}
|
||||
if ($amount < floatval($productDetails->product->tare_weight))
|
||||
if ($amount < $productDetails->product->tare_weight)
|
||||
{
|
||||
throw new \Exception('The amount cannot be lower than the defined tare weight');
|
||||
}
|
||||
|
||||
$amount = abs($amount - floatval($productDetails->stock_amount) - floatval($productDetails->product->tare_weight));
|
||||
$amount = abs($amount - $productDetails->stock_amount - $productDetails->product->tare_weight);
|
||||
}
|
||||
|
||||
if ($transactionType === self::TRANSACTION_TYPE_CONSUME || $transactionType === self::TRANSACTION_TYPE_INVENTORY_CORRECTION)
|
||||
@ -406,7 +406,7 @@ class StockService extends BaseService
|
||||
$potentialStockEntries = FindAllObjectsInArrayByPropertyValue($potentialStockEntries, 'stock_id', $specificStockEntryId);
|
||||
}
|
||||
|
||||
$productStockAmount = floatval($productDetails->stock_amount_aggregated);
|
||||
$productStockAmount = $productDetails->stock_amount_aggregated;
|
||||
if (round($amount, 2) > round($productStockAmount, 2))
|
||||
{
|
||||
throw new \Exception('Amount to be consumed cannot be > current stock amount (if supplied, at the desired location)');
|
||||
@ -431,7 +431,7 @@ class StockService extends BaseService
|
||||
$conversion = $this->getDatabase()->quantity_unit_conversions_resolved()->where('product_id = :1 AND from_qu_id = :2 AND to_qu_id = :3', $stockEntry->product_id, $productDetails->product->qu_id_stock, $subProduct->qu_id_stock)->fetch();
|
||||
if ($conversion != null)
|
||||
{
|
||||
$amount = $amount * floatval($conversion->factor);
|
||||
$amount = $amount * $conversion->factor;
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,7 +465,7 @@ class StockService extends BaseService
|
||||
{
|
||||
// A sub product with QU conversions was used
|
||||
// => Convert the rest amount back to be based on the original (parent) product for the next round
|
||||
$amount = $amount / floatval($conversion->factor);
|
||||
$amount = $amount / $conversion->factor;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -502,7 +502,7 @@ class StockService extends BaseService
|
||||
|
||||
if (boolval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount')))
|
||||
{
|
||||
$this->AddMissingProductsToShoppingList(intval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount_list_id')));
|
||||
$this->AddMissingProductsToShoppingList($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount_list_id'));
|
||||
}
|
||||
|
||||
return $transactionId;
|
||||
@ -749,7 +749,7 @@ class StockService extends BaseService
|
||||
$quStock = $this->getDatabase()->quantity_units($product->qu_id_stock);
|
||||
$quConsume = $this->getDatabase()->quantity_units($product->qu_id_consume);
|
||||
$location = $this->getDatabase()->locations($product->location_id);
|
||||
$averageShelfLifeDays = intval($this->getDatabase()->stock_average_product_shelf_life()->where('id', $productId)->fetch()->average_shelf_life_days);
|
||||
$averageShelfLifeDays = $this->getDatabase()->stock_average_product_shelf_life()->where('id', $productId)->fetch()->average_shelf_life_days;
|
||||
$currentPrice = $this->getDatabase()->products_current_price()->where('product_id', $productId)->fetch()->price;
|
||||
|
||||
$consumeCount = $this->getDatabase()->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->where('undone = 0')->sum('amount') * -1;
|
||||
@ -816,7 +816,7 @@ class StockService extends BaseService
|
||||
{
|
||||
throw new \Exception('Invalid grocycode');
|
||||
}
|
||||
return intval($gc->GetId());
|
||||
return $gc->GetId();
|
||||
}
|
||||
|
||||
$potentialProduct = $this->getDatabase()->product_barcodes()->where('barcode = :1 COLLATE NOCASE', $barcode)->fetch();
|
||||
@ -825,7 +825,7 @@ class StockService extends BaseService
|
||||
throw new \Exception("No product with barcode $barcode found");
|
||||
}
|
||||
|
||||
return intval($potentialProduct->product_id);
|
||||
return $potentialProduct->product_id;
|
||||
}
|
||||
|
||||
public function GetProductPriceHistory(int $productId)
|
||||
@ -931,16 +931,16 @@ class StockService extends BaseService
|
||||
|
||||
if ($productDetails->product->enable_tare_weight_handling == 1)
|
||||
{
|
||||
$containerWeight = floatval($productDetails->product->tare_weight);
|
||||
$containerWeight = $productDetails->product->tare_weight;
|
||||
}
|
||||
|
||||
if ($newAmount == floatval($productDetails->stock_amount) + $containerWeight)
|
||||
if ($newAmount == $productDetails->stock_amount + $containerWeight)
|
||||
{
|
||||
throw new \Exception('The new amount cannot equal the current stock amount');
|
||||
}
|
||||
elseif ($newAmount > floatval($productDetails->stock_amount) + $containerWeight)
|
||||
elseif ($newAmount > $productDetails->stock_amount + $containerWeight)
|
||||
{
|
||||
$bookingAmount = $newAmount - floatval($productDetails->stock_amount);
|
||||
$bookingAmount = $newAmount - $productDetails->stock_amount;
|
||||
|
||||
if ($productDetails->product->enable_tare_weight_handling == 1)
|
||||
{
|
||||
@ -972,7 +972,7 @@ class StockService extends BaseService
|
||||
}
|
||||
|
||||
$productDetails = (object) $this->GetProductDetails($productId);
|
||||
$productStockAmountUnopened = floatval($productDetails->stock_amount_aggregated) - floatval($productDetails->stock_amount_opened_aggregated);
|
||||
$productStockAmountUnopened = $productDetails->stock_amount_aggregated - $productDetails->stock_amount_opened_aggregated;
|
||||
$potentialStockEntries = $this->GetProductStockEntries($productId, true, $allowSubproductSubstitution);
|
||||
$product = $this->getDatabase()->products($productId);
|
||||
|
||||
@ -1038,7 +1038,7 @@ class StockService extends BaseService
|
||||
$conversion = $this->getDatabase()->quantity_unit_conversions_resolved()->where('product_id = :1 AND from_qu_id = :2 AND to_qu_id = :3', $stockEntry->product_id, $product->qu_id_stock, $subProduct->qu_id_stock)->fetch();
|
||||
if ($conversion != null)
|
||||
{
|
||||
$amount = $amount * floatval($conversion->factor);
|
||||
$amount = $amount * $conversion->factor;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1127,7 +1127,7 @@ class StockService extends BaseService
|
||||
|
||||
if (boolval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount')))
|
||||
{
|
||||
$this->AddMissingProductsToShoppingList(intval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount_list_id')));
|
||||
$this->AddMissingProductsToShoppingList($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount_list_id'));
|
||||
}
|
||||
|
||||
return $transactionId;
|
||||
@ -1142,10 +1142,10 @@ class StockService extends BaseService
|
||||
|
||||
$productRow = $this->getDatabase()->shopping_list()->where('product_id = :1', $productId)->fetch();
|
||||
|
||||
//If no entry was found with for this product, we return gracefully
|
||||
// If no entry was found with for this product, we return gracefully
|
||||
if ($productRow != null && !empty($productRow))
|
||||
{
|
||||
$decimals = intval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'stock_decimal_places_amounts'));
|
||||
$decimals = $this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'stock_decimal_places_amounts');
|
||||
$newAmount = $productRow->amount - $amount;
|
||||
|
||||
if ($newAmount < floatval('0.' . str_repeat('0', $decimals - ($decimals <= 0 ? 0 : 1)) . '1'))
|
||||
@ -1186,7 +1186,7 @@ class StockService extends BaseService
|
||||
$factor = 1.0;
|
||||
if ($conversion != null)
|
||||
{
|
||||
$factor = floatval($conversion->factor);
|
||||
$factor = $conversion->factor;
|
||||
}
|
||||
|
||||
$amount = round($row->amount * $factor);
|
||||
@ -1274,12 +1274,12 @@ class StockService extends BaseService
|
||||
{
|
||||
// Hard fail for now, as we not yet support transferring tare weight enabled products
|
||||
throw new \Exception('Transferring tare weight enabled products is not yet possible');
|
||||
if ($amount < floatval($productDetails->product->tare_weight))
|
||||
if ($amount < $productDetails->product->tare_weight)
|
||||
{
|
||||
throw new \Exception('The amount cannot be lower than the defined tare weight');
|
||||
}
|
||||
|
||||
$amount = abs($amount - floatval($productDetails->stock_amount) - floatval($productDetails->product->tare_weight));
|
||||
$amount = abs($amount - $productDetails->stock_amount - $productDetails->product->tare_weight);
|
||||
}
|
||||
|
||||
$productStockAmountAtFromLocation = $this->getDatabase()->stock()->where('product_id = :1 AND location_id = :2', $productId, $locationIdFrom)->sum('amount');
|
||||
@ -1314,7 +1314,7 @@ class StockService extends BaseService
|
||||
$locationTo = $this->getDatabase()->locations()->where('id', $locationIdTo)->fetch();
|
||||
|
||||
// Product was moved from a non-freezer to freezer location -> freeze
|
||||
if (intval($locationFrom->is_freezer) === 0 && intval($locationTo->is_freezer) === 1 && $productDetails->product->default_best_before_days_after_freezing >= -1)
|
||||
if ($locationFrom->is_freezer == 0 && $locationTo->is_freezer == 1 && $productDetails->product->default_best_before_days_after_freezing >= -1)
|
||||
{
|
||||
if ($productDetails->product->default_best_before_days_after_freezing == -1)
|
||||
{
|
||||
@ -1327,7 +1327,7 @@ class StockService extends BaseService
|
||||
}
|
||||
|
||||
// Product was moved from a freezer to non-freezer location -> thaw
|
||||
if (intval($locationFrom->is_freezer) === 1 && intval($locationTo->is_freezer) === 0 && $productDetails->product->default_best_before_days_after_thawing > 0)
|
||||
if ($locationFrom->is_freezer == 1 && $locationTo->is_freezer == 0 && $productDetails->product->default_best_before_days_after_thawing > 0)
|
||||
{
|
||||
$newBestBeforeDate = date('Y-m-d', strtotime('+' . $productDetails->product->default_best_before_days_after_thawing . ' days'));
|
||||
}
|
||||
@ -1689,7 +1689,7 @@ class StockService extends BaseService
|
||||
$factor = 1.0;
|
||||
if ($conversion != null)
|
||||
{
|
||||
$factor = floatval($conversion->factor);
|
||||
$factor = $conversion->factor;
|
||||
}
|
||||
|
||||
$this->getDatabaseService()->ExecuteDbStatement('UPDATE stock SET product_id = ' . $productIdToKeep . ', amount = amount * ' . $factor . ' WHERE product_id = ' . $productIdToRemove);
|
||||
|
@ -524,13 +524,13 @@
|
||||
name="default_stock_label_type">
|
||||
<option @if($mode=='edit'
|
||||
&&
|
||||
intval($product->default_stock_label_type) == 0 ) selected="selected" @endif value="0">{{ $__t('No label') }}</option>
|
||||
$product->default_stock_label_type == 0 ) selected="selected" @endif value="0">{{ $__t('No label') }}</option>
|
||||
<option @if($mode=='edit'
|
||||
&&
|
||||
intval($product->default_stock_label_type) == 1 ) selected="selected" @endif value="1">{{ $__t('Single label') }}</option>
|
||||
$product->default_stock_label_type == 1 ) selected="selected" @endif value="1">{{ $__t('Single label') }}</option>
|
||||
<option @if($mode=='edit'
|
||||
&&
|
||||
intval($product->default_stock_label_type) == 2 ) selected="selected" @endif value="2">{{ $__t('Label per unit') }}</option>
|
||||
$product->default_stock_label_type == 2 ) selected="selected" @endif value="2">{{ $__t('Label per unit') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
@ -89,7 +89,7 @@
|
||||
<button class="save-quantityunit-button btn btn-info mb-2"
|
||||
data-location="return">{{ $__t('Save & return to quantity units') }}</button>
|
||||
|
||||
@if(intval($pluralCount) > 2)
|
||||
@if($pluralCount > 2)
|
||||
<button id="test-quantityunit-plural-forms-button"
|
||||
class="btn btn-secondary">{{ $__t('Test plural forms') }}</button>
|
||||
@endif
|
||||
|
@ -386,7 +386,7 @@
|
||||
@endphp
|
||||
|
||||
<div class="row ml-1">
|
||||
@if(!empty($calories) && intval($calories) > 0)
|
||||
@if(!empty($calories) && $calories > 0)
|
||||
<div class="col-4">
|
||||
<label>{{ GROCY_ENERGY_UNIT }}</label>
|
||||
<i class="fa-solid fa-question-circle text-muted d-print-none"
|
||||
|
@ -287,7 +287,7 @@
|
||||
data-trigger="hover click"
|
||||
data-html="true"
|
||||
title="{!! $__t('%1$s per %2$s', '<span class=\'locale-number locale-number-currency\'>' . $stockEntry->price . '</span>', FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $stockEntry->product_id)->qu_id_stock)->name) !!}">
|
||||
{!! $__t('%1$s per %2$s', '<span class="locale-number locale-number-currency">' . floatval($stockEntry->price) * floatval($stockEntry->product_qu_factor_purchase_to_stock) . '</span>', FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $stockEntry->product_id)->qu_id_purchase)->name) !!}
|
||||
{!! $__t('%1$s per %2$s', '<span class="locale-number locale-number-currency">' . $stockEntry->price * $stockEntry->product_qu_factor_purchase_to_stock . '</span>', FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $stockEntry->product_id)->qu_id_purchase)->name) !!}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
|
@ -192,7 +192,7 @@
|
||||
href="#"
|
||||
data-toggle="tooltip"
|
||||
data-placement="left"
|
||||
title="{{ $__t('Consume %1$s of %2$s', floatval($currentStockEntry->quick_consume_amount_qu_consume) . ' ' . $currentStockEntry->qu_consume_name, $currentStockEntry->product_name) }}"
|
||||
title="{{ $__t('Consume %1$s of %2$s', $currentStockEntry->quick_consume_amount_qu_consume . ' ' . $currentStockEntry->qu_consume_name, $currentStockEntry->product_name) }}"
|
||||
data-product-id="{{ $currentStockEntry->product_id }}"
|
||||
data-product-name="{{ $currentStockEntry->product_name }}"
|
||||
data-product-qu-name="{{ $currentStockEntry->qu_stock_name }}"
|
||||
@ -217,7 +217,7 @@
|
||||
href="#"
|
||||
data-toggle="tooltip"
|
||||
data-placement="left"
|
||||
title="{{ $__t('Mark %1$s of %2$s as open', floatval($currentStockEntry->quick_open_amount_qu_consume) . ' ' . $currentStockEntry->qu_consume_name, $currentStockEntry->product_name) }}"
|
||||
title="{{ $__t('Mark %1$s of %2$s as open', $currentStockEntry->quick_open_amount_qu_consume . ' ' . $currentStockEntry->qu_consume_name, $currentStockEntry->product_name) }}"
|
||||
data-product-id="{{ $currentStockEntry->product_id }}"
|
||||
data-product-name="{{ $currentStockEntry->product_name }}"
|
||||
data-product-qu-name="{{ $currentStockEntry->qu_stock_name }}"
|
||||
@ -409,7 +409,7 @@
|
||||
data-trigger="hover click"
|
||||
data-html="true"
|
||||
title="{!! $__t('%1$s per %2$s', '<span class=\'locale-number locale-number-currency\'>' . $currentStockEntry->last_price . '</span>', $currentStockEntry->qu_stock_name) !!}">
|
||||
{!! $__t('%1$s per %2$s', '<span class="locale-number locale-number-currency">' . floatval($currentStockEntry->last_price) * floatval($currentStockEntry->product_qu_factor_purchase_to_stock) . '</span>', $currentStockEntry->qu_purchase_name) !!}
|
||||
{!! $__t('%1$s per %2$s', '<span class="locale-number locale-number-currency">' . $currentStockEntry->last_price * $currentStockEntry->product_qu_factor_purchase_to_stock . '</span>', $currentStockEntry->qu_purchase_name) !!}
|
||||
</span>
|
||||
@endif
|
||||
</td>
|
||||
@ -439,7 +439,7 @@
|
||||
data-trigger="hover click"
|
||||
data-html="true"
|
||||
title="{!! $__t('%1$s per %2$s', '<span class=\'locale-number locale-number-currency\'>' . $currentStockEntry->average_price . '</span>', $currentStockEntry->qu_stock_name) !!}">
|
||||
{!! $__t('%1$s per %2$s', '<span class="locale-number locale-number-currency">' . floatval($currentStockEntry->average_price) * floatval($currentStockEntry->product_qu_factor_purchase_to_stock) . '</span>', $currentStockEntry->qu_purchase_name) !!}
|
||||
{!! $__t('%1$s per %2$s', '<span class="locale-number locale-number-currency">' . $currentStockEntry->average_price * $currentStockEntry->product_qu_factor_purchase_to_stock . '</span>', $currentStockEntry->qu_purchase_name) !!}
|
||||
</span>
|
||||
@endif
|
||||
</td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user