2018-10-27 17:26:00 +02:00
|
|
|
|
var stockJournalTable = $('#stock-journal-table').DataTable({
|
|
|
|
|
'order': [[3, 'desc']],
|
|
|
|
|
'columnDefs': [
|
2020-01-03 14:18:56 +01:00
|
|
|
|
{ 'orderable': false, 'targets': 0 },
|
|
|
|
|
{ 'searchable': false, "targets": 0 }
|
2020-12-07 19:48:33 +01:00
|
|
|
|
].concat($.fn.dataTable.defaults.columnDefs)
|
2018-10-27 17:26:00 +02:00
|
|
|
|
});
|
2019-01-05 20:06:35 +01:00
|
|
|
|
$('#stock-journal-table tbody').removeClass("d-none");
|
2019-03-04 17:43:12 +01:00
|
|
|
|
stockJournalTable.columns.adjust().draw();
|
2018-10-27 17:26:00 +02:00
|
|
|
|
|
|
|
|
|
$("#product-filter").on("change", function()
|
|
|
|
|
{
|
|
|
|
|
var value = $(this).val();
|
|
|
|
|
if (value === "all")
|
|
|
|
|
{
|
2021-07-13 19:29:23 +02:00
|
|
|
|
RemoveUriParam("product");
|
2021-07-02 18:24:08 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-07-13 19:29:23 +02:00
|
|
|
|
UpdateUriParam("product", value);
|
2018-10-27 17:26:00 +02:00
|
|
|
|
}
|
2021-07-13 19:29:23 +02:00
|
|
|
|
|
|
|
|
|
window.location.reload();
|
2018-10-27 17:26:00 +02:00
|
|
|
|
});
|
|
|
|
|
|
2020-11-17 19:11:02 +01:00
|
|
|
|
$("#transaction-type-filter").on("change", function()
|
|
|
|
|
{
|
|
|
|
|
var value = $(this).val();
|
|
|
|
|
var text = $("#transaction-type-filter option:selected").text();
|
|
|
|
|
if (value === "all")
|
|
|
|
|
{
|
|
|
|
|
text = "";
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-12 18:26:19 +01:00
|
|
|
|
stockJournalTable.column(stockJournalTable.colReorder.transpose(4)).search(text).draw();
|
2020-11-17 19:11:02 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#location-filter").on("change", function()
|
|
|
|
|
{
|
|
|
|
|
var value = $(this).val();
|
|
|
|
|
var text = $("#location-filter option:selected").text();
|
|
|
|
|
if (value === "all")
|
|
|
|
|
{
|
|
|
|
|
text = "";
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-12 18:26:19 +01:00
|
|
|
|
stockJournalTable.column(stockJournalTable.colReorder.transpose(5)).search(text).draw();
|
2020-11-17 19:11:02 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#user-filter").on("change", function()
|
|
|
|
|
{
|
|
|
|
|
var value = $(this).val();
|
|
|
|
|
var text = $("#user-filter option:selected").text();
|
|
|
|
|
if (value === "all")
|
|
|
|
|
{
|
|
|
|
|
text = "";
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-12 18:26:19 +01:00
|
|
|
|
stockJournalTable.column(stockJournalTable.colReorder.transpose(6)).search(text).draw();
|
2020-11-17 19:11:02 +01:00
|
|
|
|
});
|
|
|
|
|
|
2021-07-13 19:29:23 +02:00
|
|
|
|
$("#daterange-filter").on("change", function()
|
|
|
|
|
{
|
|
|
|
|
UpdateUriParam("months", $(this).val());
|
|
|
|
|
window.location.reload();
|
|
|
|
|
});
|
|
|
|
|
|
2019-10-15 19:59:14 +02:00
|
|
|
|
$("#search").on("keyup", Delay(function()
|
2018-10-27 17:26:00 +02:00
|
|
|
|
{
|
|
|
|
|
var value = $(this).val();
|
|
|
|
|
if (value === "all")
|
|
|
|
|
{
|
|
|
|
|
value = "";
|
|
|
|
|
}
|
2019-01-19 00:37:21 -07:00
|
|
|
|
|
2018-10-27 17:26:00 +02:00
|
|
|
|
stockJournalTable.search(value).draw();
|
2025-01-11 15:41:04 +01:00
|
|
|
|
}, 500));
|
2018-10-27 17:26:00 +02:00
|
|
|
|
|
2020-11-07 14:53:45 +01:00
|
|
|
|
$("#clear-filter-button").on("click", function()
|
|
|
|
|
{
|
|
|
|
|
$("#search").val("");
|
2020-11-17 19:11:02 +01:00
|
|
|
|
$("#transaction-type-filter").val("all");
|
|
|
|
|
$("#location-filter").val("all");
|
|
|
|
|
$("#user-filter").val("all");
|
2021-07-13 19:29:23 +02:00
|
|
|
|
$("#daterange-filter").val("6");
|
|
|
|
|
RemoveUriParam("months");
|
2025-01-11 12:06:15 +01:00
|
|
|
|
|
|
|
|
|
if (GetUriParam("embedded") === undefined)
|
|
|
|
|
{
|
|
|
|
|
RemoveUriParam("product");
|
|
|
|
|
$("#product-filter").val("all");
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-13 19:29:23 +02:00
|
|
|
|
window.location.reload();
|
2020-11-07 14:53:45 +01:00
|
|
|
|
});
|
|
|
|
|
|
2018-10-27 17:26:00 +02:00
|
|
|
|
if (typeof GetUriParam("product") !== "undefined")
|
|
|
|
|
{
|
|
|
|
|
$("#product-filter").val(GetUriParam("product"));
|
2021-07-13 19:29:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (typeof GetUriParam("months") !== "undefined")
|
|
|
|
|
{
|
|
|
|
|
$("#daterange-filter").val(GetUriParam("months"));
|
2018-10-27 17:26:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).on('click', '.undo-stock-booking-button', function(e)
|
|
|
|
|
{
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
var bookingId = $(e.currentTarget).attr('data-booking-id');
|
2020-01-27 19:00:49 +01:00
|
|
|
|
var correlationId = $("#stock-booking-" + bookingId + "-row").attr("data-correlation-id");
|
|
|
|
|
|
|
|
|
|
var correspondingBookingsRoot = $("#stock-booking-" + bookingId + "-row");
|
2023-02-06 20:22:10 +01:00
|
|
|
|
if (correlationId)
|
2020-01-27 19:00:49 +01:00
|
|
|
|
{
|
|
|
|
|
correspondingBookingsRoot = $(".stock-booking-correlation-" + correlationId);
|
|
|
|
|
}
|
2018-10-27 17:26:00 +02:00
|
|
|
|
|
2020-08-30 12:18:16 +02:00
|
|
|
|
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', {},
|
2018-10-27 17:26:00 +02:00
|
|
|
|
function(result)
|
|
|
|
|
{
|
2020-01-27 19:00:49 +01:00
|
|
|
|
correspondingBookingsRoot.addClass("text-muted");
|
|
|
|
|
correspondingBookingsRoot.find("span.name-anchor").addClass("text-strike-through").after("<br>" + __t("Undone on") + " " + moment().format("YYYY-MM-DD HH:mm:ss") + " <time class='timeago timeago-contextual' datetime='" + moment().format("YYYY-MM-DD HH:mm:ss") + "'></time>");
|
|
|
|
|
correspondingBookingsRoot.find(".undo-stock-booking-button").addClass("disabled");
|
|
|
|
|
RefreshContextualTimeago("#stock-booking-" + bookingId + "-row");
|
2019-05-01 20:19:18 +02:00
|
|
|
|
toastr.success(__t("Booking successfully undone"));
|
2018-10-27 17:26:00 +02:00
|
|
|
|
},
|
|
|
|
|
function(xhr)
|
|
|
|
|
{
|
|
|
|
|
console.error(xhr);
|
2019-06-08 16:53:31 +02:00
|
|
|
|
toastr.error(__t(JSON.parse(xhr.response).error_message));
|
2018-10-27 17:26:00 +02:00
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|
2023-05-21 18:40:59 +02:00
|
|
|
|
|
|
|
|
|
$(document).on('click', '.product-grocycode-label-print', function(e)
|
|
|
|
|
{
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
document.activeElement.blur();
|
|
|
|
|
|
|
|
|
|
var productId = $(e.currentTarget).attr('data-product-id');
|
|
|
|
|
Grocy.Api.Get('stock/products/' + productId + '/printlabel', function(labelData)
|
|
|
|
|
{
|
|
|
|
|
if (Grocy.Webhooks.labelprinter !== undefined)
|
|
|
|
|
{
|
|
|
|
|
Grocy.FrontendHelpers.RunWebhook(Grocy.Webhooks.labelprinter, labelData);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|