2018-10-27 17:26:00 +02:00
|
|
|
|
var stockJournalTable = $('#stock-journal-table').DataTable({
|
|
|
|
|
'paginate': true,
|
|
|
|
|
'order': [[3, 'desc']],
|
|
|
|
|
'columnDefs': [
|
2020-01-03 14:18:56 +01:00
|
|
|
|
{ 'orderable': false, 'targets': 0 },
|
|
|
|
|
{ 'searchable': false, "targets": 0 }
|
2019-10-15 19:38:51 +02:00
|
|
|
|
]
|
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();
|
|
|
|
|
var text = $("#product-filter option:selected").text();
|
|
|
|
|
if (value === "all")
|
|
|
|
|
{
|
|
|
|
|
text = "";
|
|
|
|
|
}
|
2019-01-19 00:37:21 -07:00
|
|
|
|
|
2018-10-27 17:26:00 +02:00
|
|
|
|
stockJournalTable.column(1).search(text).draw();
|
|
|
|
|
});
|
|
|
|
|
|
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();
|
2019-10-15 19:59:14 +02:00
|
|
|
|
}, 200));
|
2018-10-27 17:26:00 +02:00
|
|
|
|
|
|
|
|
|
if (typeof GetUriParam("product") !== "undefined")
|
|
|
|
|
{
|
|
|
|
|
$("#product-filter").val(GetUriParam("product"));
|
|
|
|
|
$("#product-filter").trigger("change");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).on('click', '.undo-stock-booking-button', function(e)
|
|
|
|
|
{
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
var element = $(e.currentTarget);
|
|
|
|
|
var bookingId = $(e.currentTarget).attr('data-booking-id');
|
|
|
|
|
|
2019-01-19 14:51:51 +01:00
|
|
|
|
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', { },
|
2018-10-27 17:26:00 +02:00
|
|
|
|
function(result)
|
|
|
|
|
{
|
|
|
|
|
element.closest("tr").addClass("text-muted");
|
2019-05-01 20:19:18 +02:00
|
|
|
|
element.parent().siblings().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>");
|
2018-10-27 17:26:00 +02:00
|
|
|
|
element.closest(".undo-stock-booking-button").addClass("disabled");
|
2018-11-18 12:58:15 +01:00
|
|
|
|
RefreshContextualTimeago();
|
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
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|