Bug 41568: circ - auto tidy
Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
a1d951b591
commit
efb7754c8f
|
|
@ -531,57 +531,57 @@
|
|||
const interface = "[% interface | html %]";
|
||||
const theme = "[% theme | html %]";
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var active_tab = "#article-requests-requested_panel";
|
||||
var last_cancel_reason, requested_datatable, pending_datatable, processing_datatable, active_datatable, requested_dt, pending_dt, processing_dt;
|
||||
$(document).ready(function() {
|
||||
|
||||
$(document).ready(function () {
|
||||
$("#article-request-tabs a[data-bs-toggle='tab']").on("shown.bs.tab", function (e) {
|
||||
active_tab = e.target.hash;
|
||||
if( active_tab == "#article-requests-requested_panel" ){
|
||||
if (active_tab == "#article-requests-requested_panel") {
|
||||
active_datatable = requested_datatable;
|
||||
} else if( active_tab == "#article-requests-pending_panel" ){
|
||||
} else if (active_tab == "#article-requests-pending_panel") {
|
||||
active_datatable = pending_datatable;
|
||||
} else {
|
||||
active_datatable = processing_datatable;
|
||||
}
|
||||
activateBatchActions( active_tab );
|
||||
activateBatchActions(active_tab);
|
||||
});
|
||||
|
||||
$( "input:checkbox, #article-request-tabs" ).on("change", function(){
|
||||
activateBatchActions( active_tab );
|
||||
$("input:checkbox, #article-request-tabs").on("change", function () {
|
||||
activateBatchActions(active_tab);
|
||||
});
|
||||
|
||||
$(".SelectAll").on("click", function(e) {
|
||||
$(".SelectAll").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
$( active_tab + " input[type='checkbox']").prop('checked', true);
|
||||
activateBatchActions( active_tab );
|
||||
$(active_tab + " input[type='checkbox']").prop("checked", true);
|
||||
activateBatchActions(active_tab);
|
||||
});
|
||||
$(".ClearAll").on("click", function(e) {
|
||||
$(".ClearAll").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
$( active_tab + " input[type='checkbox']").prop('checked', false);
|
||||
activateBatchActions( active_tab );
|
||||
$(active_tab + " input[type='checkbox']").prop("checked", false);
|
||||
activateBatchActions(active_tab);
|
||||
});
|
||||
$("a.ar-actions").on('click', function(e) {
|
||||
$("a.ar-actions").on("click", function (e) {
|
||||
// Hide menu option ?
|
||||
if( $('#article-requests-requested-table:visible,#article-requests-pending-table:visible').length )
|
||||
$('a.ar-process-request').show();
|
||||
else $('a.ar-process-request').hide();
|
||||
if ($("#article-requests-requested-table:visible,#article-requests-pending-table:visible").length) $("a.ar-process-request").show();
|
||||
else $("a.ar-process-request").hide();
|
||||
|
||||
if( $('#article-requests-requested-table').is(":visible") )
|
||||
$('a.ar-set-pending-request').show();
|
||||
else $('a.ar-set-pending-request').hide();
|
||||
if ($("#article-requests-requested-table").is(":visible")) $("a.ar-set-pending-request").show();
|
||||
else $("a.ar-set-pending-request").hide();
|
||||
});
|
||||
|
||||
$('#myModal').on("shown.bs.modal", function () {
|
||||
$('#myModal textarea').focus();
|
||||
$("#myModal").on("shown.bs.modal", function () {
|
||||
$("#myModal textarea").focus();
|
||||
});
|
||||
$('#myModal').on("hidden.bs.modal", function () {
|
||||
$("#myModal").on("hidden.bs.modal", function () {
|
||||
// Set focus back to dropdown
|
||||
var id = $('#myModal textarea').attr('ar_id');
|
||||
var link = $('span#url_'+ id).parent().parent().find('td.ar-actions').find('div.dropdown a');
|
||||
if( link.length > 0 ) link[0].focus();
|
||||
var id = $("#myModal textarea").attr("ar_id");
|
||||
var link = $("span#url_" + id)
|
||||
.parent()
|
||||
.parent()
|
||||
.find("td.ar-actions")
|
||||
.find("div.dropdown a");
|
||||
if (link.length > 0) link[0].focus();
|
||||
});
|
||||
|
||||
requested_datatable = $("#article-requests-requested-table").kohaTable({}, requested_table_settings);
|
||||
|
|
@ -594,212 +594,227 @@
|
|||
processing_dt = processing_datatable.DataTable();
|
||||
|
||||
active_datatable = requested_datatable;
|
||||
activateBatchActions( active_tab );
|
||||
activateBatchActions(active_tab);
|
||||
});
|
||||
|
||||
function activateBatchActions( active_tab ){
|
||||
function activateBatchActions(active_tab) {
|
||||
// Check to see whether batch menu should be shown based on state of checkboxes
|
||||
if ( $( "input:checkbox", active_tab ).length > 0 ) {
|
||||
if ($("input:checkbox", active_tab).length > 0) {
|
||||
// There are rows with checkboxes
|
||||
$( "[class$='_table_controls']", active_tab ).show();
|
||||
if ( $( "input:checkbox:checked", active_tab ).length > 0 ) {
|
||||
$( "[id^='article-menu-']", active_tab ).css("display","inline-block");
|
||||
$("[class$='_table_controls']", active_tab).show();
|
||||
if ($("input:checkbox:checked", active_tab).length > 0) {
|
||||
$("[id^='article-menu-']", active_tab).css("display", "inline-block");
|
||||
} else {
|
||||
$( "[id^='article-menu-']", active_tab ).hide();
|
||||
$("[id^='article-menu-']", active_tab).hide();
|
||||
}
|
||||
} else {
|
||||
// All rows have been removed
|
||||
$("[class$='_table_controls']", active_tab ).hide();
|
||||
$("[class$='_table_controls']", active_tab).hide();
|
||||
}
|
||||
}
|
||||
|
||||
function HandleMulti( fnHandler, id, a ) {
|
||||
function HandleMulti(fnHandler, id, a) {
|
||||
last_cancel_reason = undefined;
|
||||
if( id !== 0 ) { fnHandler( id, a ); return; }
|
||||
$( active_tab + " input[type='checkbox']:checked").each(function() {
|
||||
fnHandler( $(this).attr('reqid'), $(this).closest('tr').find('td.ar-actions div a') );
|
||||
if (id !== 0) {
|
||||
fnHandler(id, a);
|
||||
return;
|
||||
}
|
||||
$(active_tab + " input[type='checkbox']:checked").each(function () {
|
||||
fnHandler($(this).attr("reqid"), $(this).closest("tr").find("td.ar-actions div a"));
|
||||
});
|
||||
}
|
||||
|
||||
function PrintSlip(id, a) {
|
||||
var link = 'article-request-slip.pl?id='+id;
|
||||
window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
|
||||
var link = "article-request-slip.pl?id=" + id;
|
||||
window.open(link, "popup", "width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top");
|
||||
}
|
||||
$(".ar-print-request").on("click", function (e){
|
||||
$(".ar-print-request").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
HandleMulti(PrintSlip, $(this).data('ar-id'));
|
||||
HandleMulti(PrintSlip, $(this).data("ar-id"));
|
||||
});
|
||||
|
||||
$('#modal-cancellation-reason').on('change', function(e) {
|
||||
$("#modal-cancellation-reason").on("change", function (e) {
|
||||
let reason = $(this).val();
|
||||
$('#modal-notes').attr('disabled', !!reason);
|
||||
})
|
||||
$("#modal-notes").attr("disabled", !!reason);
|
||||
});
|
||||
|
||||
// Confirm cancellation of article requests
|
||||
let cancel_id;
|
||||
let cancel_a;
|
||||
$("#cancelModalConfirmBtn").on("click",function(e) {
|
||||
$("#cancelModalConfirmBtn").on("click", function (e) {
|
||||
let reason = $("#modal-cancellation-reason").val();
|
||||
let notes = $("#modal-notes").val();
|
||||
let query = '?'+(reason?'cancellation_reason='+reason:'notes='+notes)
|
||||
let query = "?" + (reason ? "cancellation_reason=" + reason : "notes=" + notes);
|
||||
|
||||
HandleMulti(function(id, a) {
|
||||
var table_row = a.closest('tr');
|
||||
table_row.find('.ar-process-request').remove();
|
||||
table_row.find('input[type="checkbox"]').prop('checked', false);
|
||||
HandleMulti(
|
||||
function (id, a) {
|
||||
var table_row = a.closest("tr");
|
||||
table_row.find(".ar-process-request").remove();
|
||||
table_row.find('input[type="checkbox"]').prop("checked", false);
|
||||
|
||||
|
||||
a.closest('td').prepend('<img src="' + interface + '/' + theme + '/img/spinner-small.gif"/>').find('div.dropdown').hide();
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: '/api/v1/article_requests/'+id+query,
|
||||
success: function( data ) {
|
||||
active_datatable.DataTable().row( table_row ).remove().draw();
|
||||
UpdateTabCounts();
|
||||
activateBatchActions( active_tab );
|
||||
}
|
||||
});
|
||||
}, cancel_id, cancel_a)
|
||||
a.closest("td")
|
||||
.prepend('<img src="' + interface + "/" + theme + '/img/spinner-small.gif"/>')
|
||||
.find("div.dropdown")
|
||||
.hide();
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: "/api/v1/article_requests/" + id + query,
|
||||
success: function (data) {
|
||||
active_datatable.DataTable().row(table_row).remove().draw();
|
||||
UpdateTabCounts();
|
||||
activateBatchActions(active_tab);
|
||||
},
|
||||
});
|
||||
},
|
||||
cancel_id,
|
||||
cancel_a
|
||||
);
|
||||
});
|
||||
|
||||
function PrintMultipleSlip() {
|
||||
var ids = [];
|
||||
$( active_tab + " input[type='checkbox']:checked").each(function() {
|
||||
ids.push($(this).attr('reqid'));
|
||||
$(active_tab + " input[type='checkbox']:checked").each(function () {
|
||||
ids.push($(this).attr("reqid"));
|
||||
});
|
||||
var link = 'article-request-slip.pl?multi=1&id='+ids.join(',');
|
||||
window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
|
||||
var link = "article-request-slip.pl?multi=1&id=" + ids.join(",");
|
||||
window.open(link, "popup", "width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top");
|
||||
}
|
||||
$(".ar-print-multiple-requests").on("click", function (e){
|
||||
$(".ar-print-multiple-requests").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
PrintMultipleSlip();
|
||||
});
|
||||
|
||||
function Cancel( id, a ) {
|
||||
function Cancel(id, a) {
|
||||
cancel_id = id;
|
||||
cancel_a = a;
|
||||
|
||||
$('#cancelModal').modal('show');
|
||||
$("#cancelModal").modal("show");
|
||||
}
|
||||
$(".ar-cancel-request").on("click", function (e){
|
||||
$(".ar-cancel-request").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
HandleMulti(Cancel, $(this).data('ar-id'), $(this));
|
||||
HandleMulti(Cancel, $(this).data("ar-id"), $(this));
|
||||
});
|
||||
|
||||
async function Process( id, a ) {
|
||||
var table_row = a.closest('tr');
|
||||
var table = a.closest('table');
|
||||
var orig_dt = table.attr('id')==='article-requests-pending-table'?pending_dt:requested_dt;
|
||||
async function Process(id, a) {
|
||||
var table_row = a.closest("tr");
|
||||
var table = a.closest("table");
|
||||
var orig_dt = table.attr("id") === "article-requests-pending-table" ? pending_dt : requested_dt;
|
||||
|
||||
a.closest('td').prepend('<img src="' + interface + '/' + theme + '/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide();
|
||||
a.closest("td")
|
||||
.prepend('<img src="' + interface + "/" + theme + '/img/spinner-small.gif" class="spinner"/>')
|
||||
.find("div.dropdown")
|
||||
.hide();
|
||||
|
||||
const client = APIClient.article_request;
|
||||
await client.articleRequests.process(id).then(
|
||||
success => {
|
||||
$("img.spinner").remove();
|
||||
table_row.find('.ar-process-request').remove();
|
||||
table_row.find('input[type="checkbox"]').prop('checked', false);
|
||||
orig_dt.row( table_row ).remove().draw();
|
||||
processing_dt.row.add( table_row ).draw();
|
||||
table_row.find(".ar-process-request").remove();
|
||||
table_row.find('input[type="checkbox"]').prop("checked", false);
|
||||
orig_dt.row(table_row).remove().draw();
|
||||
processing_dt.row.add(table_row).draw();
|
||||
UpdateTabCounts();
|
||||
activateBatchActions( active_tab );
|
||||
activateBatchActions(active_tab);
|
||||
},
|
||||
error => {
|
||||
console.warn("Something wrong happened: %s".format(error));
|
||||
}
|
||||
);
|
||||
}
|
||||
$(".ar-process-request").on("click", function (e){
|
||||
$(".ar-process-request").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
HandleMulti(Process, $(this).data('ar-id'), $(this));
|
||||
HandleMulti(Process, $(this).data("ar-id"), $(this));
|
||||
});
|
||||
|
||||
async function Complete( id, a ) {
|
||||
async function Complete(id, a) {
|
||||
// if it is a scan, check if urls field is filled
|
||||
var urlspan = $('span#url_'+id);
|
||||
if( urlspan.length>0 && urlspan.text() === '' ) {
|
||||
alert( _("Please fill URL before completing request.") );
|
||||
var urlspan = $("span#url_" + id);
|
||||
if (urlspan.length > 0 && urlspan.text() === "") {
|
||||
alert(_("Please fill URL before completing request."));
|
||||
return;
|
||||
}
|
||||
a.closest('td').prepend('<img src="' + interface + '/' + theme + '/img/spinner-small.gif"/>').find('div.dropdown').hide();
|
||||
a.closest("td")
|
||||
.prepend('<img src="' + interface + "/" + theme + '/img/spinner-small.gif"/>')
|
||||
.find("div.dropdown")
|
||||
.hide();
|
||||
const client = APIClient.article_request;
|
||||
await client.articleRequests.complete(id).then(
|
||||
success => {
|
||||
$("img.spinner").remove();
|
||||
active_datatable.DataTable().row( a.closest('tr') ).remove().draw();
|
||||
active_datatable.DataTable().row(a.closest("tr")).remove().draw();
|
||||
UpdateTabCounts();
|
||||
activateBatchActions( active_tab );
|
||||
activateBatchActions(active_tab);
|
||||
},
|
||||
error => {
|
||||
console.warn("Something wrong happened: %s".format(error));
|
||||
}
|
||||
);
|
||||
}
|
||||
$(".ar-complete-request").on("click", function (e){
|
||||
$(".ar-complete-request").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
HandleMulti(Complete, $(this).data('ar-id'), $(this));
|
||||
HandleMulti(Complete, $(this).data("ar-id"), $(this));
|
||||
});
|
||||
|
||||
async function SetPending( id, a ) {
|
||||
var table_row = a.closest('tr');
|
||||
table_row.find('.ar-set-pending-request').remove();
|
||||
table_row.find('input[type="checkbox"]').prop('checked', false);
|
||||
a.closest('td').prepend('<img src="' + interface + '/' + theme + '/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide();
|
||||
async function SetPending(id, a) {
|
||||
var table_row = a.closest("tr");
|
||||
table_row.find(".ar-set-pending-request").remove();
|
||||
table_row.find('input[type="checkbox"]').prop("checked", false);
|
||||
a.closest("td")
|
||||
.prepend('<img src="' + interface + "/" + theme + '/img/spinner-small.gif" class="spinner"/>')
|
||||
.find("div.dropdown")
|
||||
.hide();
|
||||
const client = APIClient.article_request;
|
||||
await client.articleRequests.pending(id).then(
|
||||
success => {
|
||||
$("img.spinner").remove();
|
||||
requested_dt.row( table_row ).remove().draw();
|
||||
pending_dt.row.add( table_row ).draw();
|
||||
requested_dt.row(table_row).remove().draw();
|
||||
pending_dt.row.add(table_row).draw();
|
||||
UpdateTabCounts();
|
||||
activateBatchActions( active_tab );
|
||||
activateBatchActions(active_tab);
|
||||
},
|
||||
error => {
|
||||
console.warn("Something wrong happened: %s".format(error));
|
||||
}
|
||||
);
|
||||
}
|
||||
$(".ar-set-pending-request").on("click", function (e){
|
||||
$(".ar-set-pending-request").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
HandleMulti(SetPending, $(this).data('ar-id'), $(this));
|
||||
HandleMulti(SetPending, $(this).data("ar-id"), $(this));
|
||||
});
|
||||
|
||||
function UpdateTabCounts() {
|
||||
$("#ar_requested_count").html( requested_dt.rows().count() );
|
||||
$("#ar_pending_count").html( pending_dt.rows().count() );
|
||||
$("#ar_processing_count").html( processing_dt.rows().count() );
|
||||
$("#ar_requested_count").html(requested_dt.rows().count());
|
||||
$("#ar_pending_count").html(pending_dt.rows().count());
|
||||
$("#ar_processing_count").html(processing_dt.rows().count());
|
||||
}
|
||||
|
||||
function EditURLs(id) {
|
||||
var urls = $('span#url_'+ id).text();
|
||||
$('#myModal textarea').val(urls);
|
||||
$('#myModal textarea').attr('ar_id', id);
|
||||
$('#myModal').modal('show');
|
||||
var urls = $("span#url_" + id).text();
|
||||
$("#myModal textarea").val(urls);
|
||||
$("#myModal textarea").attr("ar_id", id);
|
||||
$("#myModal").modal("show");
|
||||
}
|
||||
$(".ar-edit-urls").on("click", function (e){
|
||||
$(".ar-edit-urls").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
HandleMulti(EditURLs, $(this).data('ar-id'));
|
||||
HandleMulti(EditURLs, $(this).data("ar-id"));
|
||||
});
|
||||
|
||||
async function SaveURLs(newurl) {
|
||||
var id = $('#myModal textarea').attr('ar_id');
|
||||
$('span#url_'+ id).text(newurl);
|
||||
if(newurl)
|
||||
$('span#url_yesno_'+id).text(_("Yes"));
|
||||
else
|
||||
$('span#url_yesno_'+id).text(_("No"));
|
||||
var id = $("#myModal textarea").attr("ar_id");
|
||||
$("span#url_" + id).text(newurl);
|
||||
if (newurl) $("span#url_yesno_" + id).text(_("Yes"));
|
||||
else $("span#url_yesno_" + id).text(_("No"));
|
||||
|
||||
const client = APIClient.article_request;
|
||||
await client.articleRequests.update_urls(id, newurl).then(
|
||||
success => {
|
||||
},
|
||||
success => {},
|
||||
error => {
|
||||
console.warn("Something wrong happened: %s".format(error));
|
||||
}
|
||||
);
|
||||
}
|
||||
$( '#myModal button' ).on("click", function () {
|
||||
SaveURLs( $('#myModal textarea').val() );
|
||||
$("#myModal button").on("click", function () {
|
||||
SaveURLs($("#myModal textarea").val());
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
|
|
|||
|
|
@ -481,12 +481,10 @@
|
|||
dt_settings.push( [% TablesSettings.GetTableSettings('circ', 'curbside_pickups', 'delivered_todayt', 'json') | $raw %] );
|
||||
|
||||
const tab = "[% tab | html %]";
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
let existingPickupMoments = [];
|
||||
pickups.forEach(function(pickup){
|
||||
pickups.forEach(function (pickup) {
|
||||
let scheduled_pickup_datetime = pickup.scheduled_pickup_datetime;
|
||||
let pickupMoment = dayjs(scheduled_pickup_datetime);
|
||||
|
||||
|
|
@ -494,34 +492,34 @@
|
|||
});
|
||||
|
||||
let slots_per_day = {};
|
||||
opening_slots.forEach(function(slot){
|
||||
opening_slots.forEach(function (slot) {
|
||||
let day = slot.day;
|
||||
if(!slots_per_day[day]) slots_per_day[day] = [];
|
||||
if (!slots_per_day[day]) slots_per_day[day] = [];
|
||||
slots_per_day[day].push(slot);
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#schedule-pickup-tab').on('click', function() {
|
||||
$('#find-patron').focus();
|
||||
$(document).ready(function () {
|
||||
$("#schedule-pickup-tab").on("click", function () {
|
||||
$("#find-patron").focus();
|
||||
});
|
||||
|
||||
if (tab == 'schedule-pickup_panel'){
|
||||
$('#find-patron').focus();
|
||||
if (tab == "schedule-pickup_panel") {
|
||||
$("#find-patron").focus();
|
||||
}
|
||||
|
||||
const pickup_date = document.querySelector("#pickup_date");
|
||||
if ( pickup_date ) {
|
||||
if (pickup_date) {
|
||||
const fp = pickup_date._flatpickr;
|
||||
fp.set('disable', [function(date) {
|
||||
return !slots_per_day.hasOwnProperty(date.getDay());
|
||||
}]);
|
||||
fp.set("disable", [
|
||||
function (date) {
|
||||
return !slots_per_day.hasOwnProperty(date.getDay());
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
$("#pickup_date").on('change', function() {
|
||||
|
||||
$('#pickup-times').empty();
|
||||
$('#schedule-pickup-button').prop( 'disabled', 1 );
|
||||
$("#pickup_date").on("change", function () {
|
||||
$("#pickup-times").empty();
|
||||
$("#schedule-pickup-button").prop("disabled", 1);
|
||||
|
||||
var currentDate = $(this).val();
|
||||
|
||||
|
|
@ -530,77 +528,77 @@
|
|||
let pickupSlots = [];
|
||||
let available_count = 0;
|
||||
let dow = selectedDate.day(); // Sunday is 0 (at least for now)
|
||||
if (!slots_per_day[dow]){
|
||||
$('#pickup-times').html("<div>"+_("No pickup time defined for this day.")+"</div>");
|
||||
if (!slots_per_day[dow]) {
|
||||
$("#pickup-times").html("<div>" + _("No pickup time defined for this day.") + "</div>");
|
||||
return;
|
||||
}
|
||||
|
||||
slots_per_day[dow].sort((a, b) => a.start_hour - b.start_hour).forEach(function(slot){
|
||||
let pickup_interval = policy.pickup_interval;
|
||||
if (!pickup_interval) {
|
||||
$('#pickup-times').html("<div>"+_("No pickup time defined for this day.")+"</div>");
|
||||
return;
|
||||
}
|
||||
|
||||
let listStartMoment = selectedDate.hour(slot.start_hour).minute(slot.start_minute);
|
||||
let listEndMoment = selectedDate.hour(slot.end_hour).minute(slot.end_minute);
|
||||
|
||||
let keep_going = true;
|
||||
let now = dayjs();
|
||||
|
||||
// Initialize pickup slots starting at opening time
|
||||
let pickupIntervalStartMoment = listStartMoment;
|
||||
let pickupIntervalEndMoment = listStartMoment.add(pickup_interval, 'minutes');
|
||||
while (keep_going) {
|
||||
let available = true;
|
||||
let display_slot = true
|
||||
|
||||
if (pickupIntervalStartMoment.isBefore(now)) {
|
||||
// Slots in the past are unavailable
|
||||
available = false;
|
||||
display_slot = false;
|
||||
slots_per_day[dow]
|
||||
.sort((a, b) => a.start_hour - b.start_hour)
|
||||
.forEach(function (slot) {
|
||||
let pickup_interval = policy.pickup_interval;
|
||||
if (!pickup_interval) {
|
||||
$("#pickup-times").html("<div>" + _("No pickup time defined for this day.") + "</div>");
|
||||
return;
|
||||
}
|
||||
|
||||
if (pickupIntervalEndMoment.isAfter(listEndMoment)) {
|
||||
// Slots after the end of pickup times for the day are unavailable
|
||||
available = false;
|
||||
}
|
||||
let listStartMoment = selectedDate.hour(slot.start_hour).minute(slot.start_minute);
|
||||
let listEndMoment = selectedDate.hour(slot.end_hour).minute(slot.end_minute);
|
||||
|
||||
let pickups_scheduled = 0;
|
||||
existingPickupMoments.forEach(function(pickupMoment){
|
||||
// An existing pickup time
|
||||
if (pickupMoment.isSameOrAfter(pickupIntervalStartMoment) && pickupMoment.isBefore(pickupIntervalEndMoment)) {
|
||||
// This calculated pickup is in use by another scheduled pickup
|
||||
pickups_scheduled++;
|
||||
let keep_going = true;
|
||||
let now = dayjs();
|
||||
|
||||
// Initialize pickup slots starting at opening time
|
||||
let pickupIntervalStartMoment = listStartMoment;
|
||||
let pickupIntervalEndMoment = listStartMoment.add(pickup_interval, "minutes");
|
||||
while (keep_going) {
|
||||
let available = true;
|
||||
let display_slot = true;
|
||||
|
||||
if (pickupIntervalStartMoment.isBefore(now)) {
|
||||
// Slots in the past are unavailable
|
||||
available = false;
|
||||
display_slot = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (pickups_scheduled >= policy.patrons_per_interval) {
|
||||
available = false;
|
||||
}
|
||||
if (pickupIntervalEndMoment.isAfter(listEndMoment)) {
|
||||
// Slots after the end of pickup times for the day are unavailable
|
||||
available = false;
|
||||
}
|
||||
|
||||
if ( display_slot ) {
|
||||
pickupSlots.push(
|
||||
{
|
||||
"available": available,
|
||||
"moment": pickupIntervalStartMoment,
|
||||
"pickups_scheduled": pickups_scheduled
|
||||
let pickups_scheduled = 0;
|
||||
existingPickupMoments.forEach(function (pickupMoment) {
|
||||
// An existing pickup time
|
||||
if (pickupMoment.isSameOrAfter(pickupIntervalStartMoment) && pickupMoment.isBefore(pickupIntervalEndMoment)) {
|
||||
// This calculated pickup is in use by another scheduled pickup
|
||||
pickups_scheduled++;
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
if ( available ) {
|
||||
available_count++;
|
||||
}
|
||||
if (pickups_scheduled >= policy.patrons_per_interval) {
|
||||
available = false;
|
||||
}
|
||||
|
||||
pickupIntervalStartMoment = pickupIntervalEndMoment;
|
||||
pickupIntervalEndMoment = pickupIntervalStartMoment.add(pickup_interval, 'minutes');
|
||||
if (pickupIntervalEndMoment.isAfter(listEndMoment)) {
|
||||
// This latest slot is after the end of pickup times for the day, so we can stop
|
||||
keep_going = false;
|
||||
if (display_slot) {
|
||||
pickupSlots.push({
|
||||
available: available,
|
||||
moment: pickupIntervalStartMoment,
|
||||
pickups_scheduled: pickups_scheduled,
|
||||
});
|
||||
}
|
||||
|
||||
if (available) {
|
||||
available_count++;
|
||||
}
|
||||
|
||||
pickupIntervalStartMoment = pickupIntervalEndMoment;
|
||||
pickupIntervalEndMoment = pickupIntervalStartMoment.add(pickup_interval, "minutes");
|
||||
if (pickupIntervalEndMoment.isAfter(listEndMoment)) {
|
||||
// This latest slot is after the end of pickup times for the day, so we can stop
|
||||
keep_going = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
for (let i = 0; i < pickupSlots.length; i++) {
|
||||
let pickupSlot = pickupSlots[i];
|
||||
|
|
@ -611,67 +609,69 @@
|
|||
$("#pickup-times").append(`<span class="pickup_time"><input type="radio" id="slot_${i}" name="pickup_time" value="${optValue}" ${disabled} /> <label for="slot_${i}">${optText} (${pickups_scheduled})</label></span>`);
|
||||
}
|
||||
|
||||
$('#pickup-times').show();
|
||||
$('#schedule-pickup-button').prop( 'disabled', available_count <= 0 );
|
||||
$("#pickup-times").show();
|
||||
$("#schedule-pickup-button").prop("disabled", available_count <= 0);
|
||||
});
|
||||
|
||||
$("#create-pickup").on('submit', function(){
|
||||
if ( ! $("input[type='radio']:checked").length ) {
|
||||
alert(_("Please select a date and a pickup time"))
|
||||
$("#create-pickup").on("submit", function () {
|
||||
if (!$("input[type='radio']:checked").length) {
|
||||
alert(_("Please select a date and a pickup time"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
if ( $("#find-patron").length ) {
|
||||
patron_autocomplete($("#find-patron"), { 'on-select-callback': function( event, ui ) {
|
||||
if ($("#find-patron").length) {
|
||||
patron_autocomplete($("#find-patron"), {
|
||||
"on-select-callback": function (event, ui) {
|
||||
window.location.href = "/cgi-bin/koha/circ/curbside_pickups.pl?op=find-patron&borrowernumber=" + ui.item.patron_id;
|
||||
return false;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
$("#pickup-tabs a[data-bs-toggle='tab']").on("shown.bs.tab", function (e) {
|
||||
$("#current-tab").val($(this).attr('href').substring(1)); // Remove #
|
||||
$("#current-tab").val($(this).attr("href").substring(1)); // Remove #
|
||||
});
|
||||
$("#auto_refresh,#refresh_delay").on("change", function(){
|
||||
$("#auto_refresh,#refresh_delay").on("change", function () {
|
||||
set_interval_if_needed();
|
||||
});
|
||||
|
||||
set_interval_if_needed();
|
||||
|
||||
let dt_tables = new Array("to_be_stagedt", "staged_and_readyt", "patron_is_outsidet", "delivered_todayt");
|
||||
dt_tables.forEach(function( id, index ){
|
||||
$("#" + id).kohaTable({
|
||||
autoWidth: false
|
||||
}, dt_settings[ index ] );
|
||||
dt_tables.forEach(function (id, index) {
|
||||
$("#" + id).kohaTable(
|
||||
{
|
||||
autoWidth: false,
|
||||
},
|
||||
dt_settings[index]
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
let refresh_interval_id = 0;
|
||||
let countdown_interval_id = 0;
|
||||
function set_interval(refresh_delay_ms){
|
||||
function set_interval(refresh_delay_ms) {
|
||||
clear_intervals();
|
||||
let next_refresh = new Date();
|
||||
next_refresh.setSeconds(next_refresh.getSeconds() + refresh_delay_ms / 1000);
|
||||
|
||||
countdown_interval_id = setInterval(function() {
|
||||
countdown_interval_id = setInterval(function () {
|
||||
const now = new Date().getTime();
|
||||
const seconds = Math.floor(( next_refresh - now + 1 ) / 1000);
|
||||
if ( seconds > 0 ) {
|
||||
const seconds = Math.floor((next_refresh - now + 1) / 1000);
|
||||
if (seconds > 0) {
|
||||
$("#refresh_info").text(_("Refresh in %s seconds").format(seconds));
|
||||
} else {
|
||||
$("#refresh_info").text(""); // In case something is going wrong
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
setInterval(function() {
|
||||
setInterval(function () {
|
||||
$(".refresh-form:visible").submit();
|
||||
}, refresh_delay_ms);
|
||||
}
|
||||
function clear_intervals(){
|
||||
function clear_intervals() {
|
||||
if (refresh_interval_id) {
|
||||
clearInterval(refresh_interval_id);
|
||||
refresh_interval_id = 0;
|
||||
|
|
@ -682,11 +682,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
function set_interval_if_needed(){
|
||||
function set_interval_if_needed() {
|
||||
const refresh_delay = $("#refresh_delay").val();
|
||||
const auto_refresh = $("#auto_refresh").is(":checked");
|
||||
|
||||
if (auto_refresh && refresh_delay){
|
||||
if (auto_refresh && refresh_delay) {
|
||||
set_interval(refresh_delay * 1000);
|
||||
} else {
|
||||
clear_intervals();
|
||||
|
|
|
|||
|
|
@ -352,31 +352,30 @@
|
|||
table_settings['columns'].splice(13, 1);
|
||||
[% END %]
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function clone_input( node, original_id ) {
|
||||
function clone_input(node, original_id) {
|
||||
var original = node;
|
||||
var clone = original.clone();
|
||||
var appendid = original_id + "-" + Math.floor(Math.random()*1000+1);
|
||||
var appendid = original_id + "-" + Math.floor(Math.random() * 1000 + 1);
|
||||
clone.find(".delete_clone").show();
|
||||
if( clone.find("select").length ){
|
||||
if (clone.find("select").length) {
|
||||
/* <select> element is present */
|
||||
clone.find("select").removeClass("select2-hidden-accessible").removeAttr("data-select2-id").attr("id", appendid );
|
||||
clone.find("select").removeClass("select2-hidden-accessible").removeAttr("data-select2-id").attr("id", appendid);
|
||||
clone.find(".select2").remove();
|
||||
original.after( clone );
|
||||
$("#" + appendid ).select2();
|
||||
} else if( clone.find(".flatpickr").length ){
|
||||
clone.attr("id", appendid );
|
||||
original.after( clone );
|
||||
original.after(clone);
|
||||
$("#" + appendid).select2();
|
||||
} else if (clone.find(".flatpickr").length) {
|
||||
clone.attr("id", appendid);
|
||||
original.after(clone);
|
||||
apply_flatpickr(clone.find(".flatpickr"));
|
||||
} else {
|
||||
clone.attr("id", appendid );
|
||||
original.after( clone );
|
||||
clone.attr("id", appendid);
|
||||
original.after(clone);
|
||||
}
|
||||
}
|
||||
|
||||
function update_date_due_filters_visibility(){
|
||||
if( $("#showall").is(":checked")) {
|
||||
function update_date_due_filters_visibility() {
|
||||
if ($("#showall").is(":checked")) {
|
||||
$(".date_due_filter").hide();
|
||||
$("#from").prop("disabled", true);
|
||||
$("#to").prop("disabled", true);
|
||||
|
|
@ -387,8 +386,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#overduest").kohaTable(
|
||||
$(document).ready(function () {
|
||||
$("#overduest").kohaTable(
|
||||
{
|
||||
pagingType: "full",
|
||||
autoWidth: false,
|
||||
|
|
@ -396,24 +395,24 @@
|
|||
table_settings
|
||||
);
|
||||
|
||||
$("#showall").on("change", function(){
|
||||
$("#showall").on("change", function () {
|
||||
update_date_due_filters_visibility();
|
||||
});
|
||||
update_date_due_filters_visibility();
|
||||
|
||||
$(".pattrodue-input").each(function(){
|
||||
$(".pattrodue-input").each(function () {
|
||||
$(this).select2();
|
||||
});
|
||||
|
||||
$("body").on("click", ".delete_clone", function(e){
|
||||
$("body").on("click", ".delete_clone", function (e) {
|
||||
e.preventDefault();
|
||||
$(this).parent().remove();
|
||||
});
|
||||
|
||||
$("body").on("click", ".clone-attribute", function(e){
|
||||
$("body").on("click", ".clone-attribute", function (e) {
|
||||
e.preventDefault();
|
||||
clone_input( $(this).parent(), $(this).data("original-id") );
|
||||
})
|
||||
clone_input($(this).parent(), $(this).data("original-id"));
|
||||
});
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
|
|
|||
|
|
@ -118,168 +118,168 @@
|
|||
<script>
|
||||
let table_settings = [% TablesSettings.GetTableSettings( 'circ', 'bookings', 'bookings-to-collect', 'json' ) | $raw %];
|
||||
|
||||
let all_libraries = [% To.json(Branches.all) | $raw %].map(e => {
|
||||
e['_id'] = e.branchcode;
|
||||
e['_str'] = e.branchname;
|
||||
return e;
|
||||
});
|
||||
let all_libraries = [% To.json(Branches.all) | $raw %].map(e => {
|
||||
e['_id'] = e.branchcode;
|
||||
e['_str'] = e.branchname;
|
||||
return e;
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var coded_values = {
|
||||
library: new Map(all_libraries.map( l => [l.branchname, l.branchcode] )),
|
||||
};
|
||||
|
||||
let filters_options = {
|
||||
libraries: all_libraries,
|
||||
};
|
||||
$(document).ready(function() {
|
||||
var coded_values = {
|
||||
library: new Map(all_libraries.map(l => [l.branchname, l.branchcode])),
|
||||
};
|
||||
|
||||
let filters_options = {
|
||||
libraries: all_libraries,
|
||||
};
|
||||
$(document).ready(function () {
|
||||
let additional_filters = {
|
||||
start_date: function() {
|
||||
let fromdate = $("#from");
|
||||
let isoFrom;
|
||||
if ( fromdate.val() !== '' ) {
|
||||
let selectedDate = fromdate.get(0)._flatpickr.selectedDates[0];
|
||||
selectedDate.setHours(0, 0, 0, 0);
|
||||
isoFrom = selectedDate.toISOString();
|
||||
}
|
||||
start_date: function () {
|
||||
let fromdate = $("#from");
|
||||
let isoFrom;
|
||||
if (fromdate.val() !== "") {
|
||||
let selectedDate = fromdate.get(0)._flatpickr.selectedDates[0];
|
||||
selectedDate.setHours(0, 0, 0, 0);
|
||||
isoFrom = selectedDate.toISOString();
|
||||
}
|
||||
|
||||
let todate = $("#to");
|
||||
let isoTo;
|
||||
if ( todate.val() !== '' ) {
|
||||
let selectedDate = todate.get(0)._flatpickr.selectedDates[0];
|
||||
selectedDate.setHours(23, 59, 59, 999);
|
||||
isoTo = selectedDate.toISOString();
|
||||
}
|
||||
let todate = $("#to");
|
||||
let isoTo;
|
||||
if (todate.val() !== "") {
|
||||
let selectedDate = todate.get(0)._flatpickr.selectedDates[0];
|
||||
selectedDate.setHours(23, 59, 59, 999);
|
||||
isoTo = selectedDate.toISOString();
|
||||
}
|
||||
|
||||
if ( isoFrom || isoTo ) {
|
||||
return { '>=': isoFrom, '<=': isoTo };
|
||||
} else {
|
||||
return
|
||||
}
|
||||
if (isoFrom || isoTo) {
|
||||
return { ">=": isoFrom, "<=": isoTo };
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
},
|
||||
'item.holding_library_id': function() {
|
||||
let library = $("#holding_library").find(":selected").val();
|
||||
return library;
|
||||
"item.holding_library_id": function () {
|
||||
let library = $("#holding_library").find(":selected").val();
|
||||
return library;
|
||||
},
|
||||
'pickup_library_id': function() {
|
||||
pickup_library_id: function () {
|
||||
let library = $("#pickup_library").find(":selected").val();
|
||||
return library;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
var bookings_table_url = '/api/v1/bookings?';
|
||||
var bookings_table = $("#bookingst").kohaTable({
|
||||
ajax: {
|
||||
url: bookings_table_url
|
||||
},
|
||||
embed: [
|
||||
"biblio",
|
||||
"item+strings",
|
||||
"item.checkout",
|
||||
"patron",
|
||||
"pickup_library"
|
||||
],
|
||||
order: [[ 7, "asc" ]],
|
||||
columns: [{
|
||||
data: "booking_id",
|
||||
title: _("Booking ID"),
|
||||
visible: false
|
||||
},
|
||||
var bookings_table_url = "/api/v1/bookings?";
|
||||
var bookings_table = $("#bookingst").kohaTable(
|
||||
{
|
||||
data: "me.pickup_library_id",
|
||||
title: _("Pickup library"),
|
||||
datatype: "coded_value:library",
|
||||
dataFilter: "libraries",
|
||||
searchable: true,
|
||||
orderable: true,
|
||||
render: function( data, type, row, meta ) {
|
||||
return escape_str(row.pickup_library_id ? row.pickup_library.name : row.pickup_library_id);
|
||||
}
|
||||
ajax: {
|
||||
url: bookings_table_url,
|
||||
},
|
||||
embed: ["biblio", "item+strings", "item.checkout", "patron", "pickup_library"],
|
||||
order: [[7, "asc"]],
|
||||
columns: [
|
||||
{
|
||||
data: "booking_id",
|
||||
title: _("Booking ID"),
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
data: "me.pickup_library_id",
|
||||
title: _("Pickup library"),
|
||||
datatype: "coded_value:library",
|
||||
dataFilter: "libraries",
|
||||
searchable: true,
|
||||
orderable: true,
|
||||
render: function (data, type, row, meta) {
|
||||
return escape_str(row.pickup_library_id ? row.pickup_library.name : row.pickup_library_id);
|
||||
},
|
||||
},
|
||||
{
|
||||
data: "biblio.title",
|
||||
title: _("Title"),
|
||||
searchable: true,
|
||||
orderable: true,
|
||||
render: function (data, type, row, meta) {
|
||||
return $biblio_to_html(row.biblio, {
|
||||
link: "bookings",
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
data: "item.external_id",
|
||||
title: _("Item"),
|
||||
searchable: true,
|
||||
orderable: true,
|
||||
defaultContent: _("Any item"),
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.item) {
|
||||
return row.item.external_id + " (" + row.booking_id + ")";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
data: "item.callnumber",
|
||||
title: _("Callnumber"),
|
||||
searchable: true,
|
||||
orderable: true,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.item) {
|
||||
return row.item.callnumber;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
data: "item.location",
|
||||
title: _("Location"),
|
||||
searchable: false,
|
||||
orderable: false,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.item) {
|
||||
if (row.item.checked_out_date) {
|
||||
return _("On loan, due: ") + $date(row.item.checked_out_date);
|
||||
} else {
|
||||
return row.item._strings.location.str;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
data: "patron.firstname:patron.surname",
|
||||
title: _("Patron"),
|
||||
searchable: true,
|
||||
orderable: true,
|
||||
render: function (data, type, row, meta) {
|
||||
return $patron_to_html(row.patron, {
|
||||
display_cardnumber: true,
|
||||
url: true,
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
data: "start_date",
|
||||
name: "start_date",
|
||||
title: _("Booking dates"),
|
||||
type: "date",
|
||||
searchable: false,
|
||||
orderable: true,
|
||||
render: function (data, type, row, meta) {
|
||||
return $date(row.start_date) + " - " + $date(row.end_date);
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
data: "biblio.title",
|
||||
title: _("Title"),
|
||||
searchable: true,
|
||||
orderable: true,
|
||||
render: function(data,type,row,meta) {
|
||||
return $biblio_to_html(row.biblio, {
|
||||
link: 'bookings'
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
data: "item.external_id",
|
||||
title: _("Item"),
|
||||
searchable: true,
|
||||
orderable: true,
|
||||
defaultContent: _("Any item"),
|
||||
render: function(data,type,row,meta) {
|
||||
if ( row.item ) {
|
||||
return row.item.external_id + " (" + row.booking_id + ")";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
data: "item.callnumber",
|
||||
title: _("Callnumber"),
|
||||
searchable: true,
|
||||
orderable: true,
|
||||
render: function(data,type,row,meta) {
|
||||
if ( row.item ) {
|
||||
return row.item.callnumber;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
data: "item.location",
|
||||
title: _("Location"),
|
||||
searchable: false,
|
||||
orderable: false,
|
||||
render: function(data,type,row,meta) {
|
||||
if ( row.item ) {
|
||||
if ( row.item.checked_out_date ) {
|
||||
return _("On loan, due: ") + $date(row.item.checked_out_date);
|
||||
} else {
|
||||
return row.item._strings.location.str;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
data: "patron.firstname:patron.surname",
|
||||
title: _("Patron"),
|
||||
searchable: true,
|
||||
orderable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
return $patron_to_html(row.patron, {
|
||||
display_cardnumber: true,
|
||||
url: true
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
data: "start_date",
|
||||
name: "start_date",
|
||||
title: _("Booking dates"),
|
||||
type: "date",
|
||||
searchable: false,
|
||||
orderable: true,
|
||||
render: function(data, type, row, meta) {
|
||||
return $date(row.start_date) + ' - ' + $date(row.end_date);
|
||||
}
|
||||
}]
|
||||
}, table_settings, 1, additional_filters, filters_options);
|
||||
table_settings,
|
||||
1,
|
||||
additional_filters,
|
||||
filters_options
|
||||
);
|
||||
|
||||
/** Date filtering */
|
||||
$("#bookingsf").on("submit", function(e){
|
||||
$("#bookingsf").on("submit", function (e) {
|
||||
/* stop form from submitting normally */
|
||||
e.preventDefault();
|
||||
bookings_table.DataTable().draw();
|
||||
|
|
|
|||
|
|
@ -301,52 +301,61 @@
|
|||
<script>
|
||||
var table_settings = [% TablesSettings.GetTableSettings('circ', 'holds', 'holds-to-pull', 'json') | $raw %];
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function get_options(column){
|
||||
let regex = /(<([^>]+)>)/ig; // Remove html tags
|
||||
let options = [... new Set(column
|
||||
.data()
|
||||
.toArray()
|
||||
.map(d => d.replace(regex, '').trim().split(/\n/gi).map(s => s.trim()).flat())
|
||||
.flat()
|
||||
.sort())];
|
||||
function get_options(column) {
|
||||
let regex = /(<([^>]+)>)/gi; // Remove html tags
|
||||
let options = [
|
||||
...new Set(
|
||||
column
|
||||
.data()
|
||||
.toArray()
|
||||
.map(d =>
|
||||
d
|
||||
.replace(regex, "")
|
||||
.trim()
|
||||
.split(/\n/gi)
|
||||
.map(s => s.trim())
|
||||
.flat()
|
||||
)
|
||||
.flat()
|
||||
.sort()
|
||||
),
|
||||
];
|
||||
|
||||
return options
|
||||
.map(e => {
|
||||
return {_id: e, _str: e}
|
||||
});
|
||||
return options.map(e => {
|
||||
return { _id: e, _str: e };
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
let filters_options = {
|
||||
libraries: (table_dt) => get_options(table_dt.column(5)),
|
||||
item_types: (table_dt) => get_options(table_dt.column(10)),
|
||||
locations: (table_dt) => get_options(table_dt.column(11)),
|
||||
pickup_locations : (table_dt) => get_options(table_dt.column(15)),
|
||||
libraries: table_dt => get_options(table_dt.column(5)),
|
||||
item_types: table_dt => get_options(table_dt.column(10)),
|
||||
locations: table_dt => get_options(table_dt.column(11)),
|
||||
pickup_locations: table_dt => get_options(table_dt.column(15)),
|
||||
};
|
||||
|
||||
var holdst = $("#holdst").kohaTable(
|
||||
{
|
||||
pagingType: "full_numbers",
|
||||
columns: [
|
||||
{name: "pull_items" },
|
||||
{name: "available_items" },
|
||||
{name: "patrons" },
|
||||
{name: "patron" },
|
||||
{name: "title" },
|
||||
{name: "libraries", dataFilter: "libraries" },
|
||||
{name: "barcodes" },
|
||||
{name: "call_numbers" },
|
||||
{name: "copy_numbers" },
|
||||
{name: "enumeration" },
|
||||
{name: "itemtypes", dataFilter: "item_types" },
|
||||
{name: "locations", dataFilter: "locations" },
|
||||
{name: "collection" },
|
||||
{name: "hold_date" },
|
||||
{name: "reserve_nodes" },
|
||||
{name: "pickup_location", dataFilter: "pickup_locations" },
|
||||
{name: "action" },
|
||||
{ name: "pull_items" },
|
||||
{ name: "available_items" },
|
||||
{ name: "patrons" },
|
||||
{ name: "patron" },
|
||||
{ name: "title" },
|
||||
{ name: "libraries", dataFilter: "libraries" },
|
||||
{ name: "barcodes" },
|
||||
{ name: "call_numbers" },
|
||||
{ name: "copy_numbers" },
|
||||
{ name: "enumeration" },
|
||||
{ name: "itemtypes", dataFilter: "item_types" },
|
||||
{ name: "locations", dataFilter: "locations" },
|
||||
{ name: "collection" },
|
||||
{ name: "hold_date" },
|
||||
{ name: "reserve_nodes" },
|
||||
{ name: "pickup_location", dataFilter: "pickup_locations" },
|
||||
{ name: "action" },
|
||||
],
|
||||
},
|
||||
table_settings,
|
||||
|
|
|
|||
|
|
@ -217,23 +217,20 @@
|
|||
<script>
|
||||
var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holdsratios', 'holds-ratios', 'json' ) | $raw %];
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#holds-ratios").kohaTable(
|
||||
{
|
||||
order: [
|
||||
[2, "desc"],
|
||||
[3, "asc"],
|
||||
],
|
||||
columnDefs: [
|
||||
{ type: "natural", targets: ["natural"] },
|
||||
],
|
||||
pagingType: "full",
|
||||
autoWidth: false,
|
||||
},
|
||||
table_settings
|
||||
);
|
||||
$(document).ready(function () {
|
||||
$("#holds-ratios").kohaTable(
|
||||
{
|
||||
order: [
|
||||
[2, "desc"],
|
||||
[3, "asc"],
|
||||
],
|
||||
columnDefs: [{ type: "natural", targets: ["natural"] }],
|
||||
pagingType: "full",
|
||||
autoWidth: false,
|
||||
},
|
||||
table_settings
|
||||
);
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
|
|
|||
|
|
@ -1536,54 +1536,55 @@
|
|||
AutomaticConfirmTransfer: [% Koha.Preference('AutomaticConfirmTransfer') ? 1 : 0 | html %],
|
||||
});
|
||||
</script>
|
||||
|
||||
[% IF ( ReturnClaims ) %]
|
||||
[% Asset.js("js/resolve_claim_modal.js") | $raw %]
|
||||
[% END %]
|
||||
[% IF ( Koha.Preference('CatalogConcerns') ) %]
|
||||
[% Asset.js("js/modals/add_catalog_concern.js") | $raw %]
|
||||
[% END %]
|
||||
|
||||
<script>
|
||||
function Dopop(link) {
|
||||
var newin = window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
|
||||
var newin = window.open(link, "popup", "width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top");
|
||||
$("#barcode").focus();
|
||||
}
|
||||
$(document).ready(function () {
|
||||
$("#checkin-form").preventDoubleFormSubmit();
|
||||
|
||||
$(".modal.block")
|
||||
.on('shown.bs.modal', function() {
|
||||
$("#barcode").prop("disabled", true);
|
||||
$(".show_checkin_dialog").show();
|
||||
}).on('hidden.bs.modal', function() {
|
||||
$("#barcode").prop("disabled", false).focus();
|
||||
})
|
||||
.modal("show");
|
||||
.on("shown.bs.modal", function () {
|
||||
$("#barcode").prop("disabled", true);
|
||||
$(".show_checkin_dialog").show();
|
||||
})
|
||||
.on("hidden.bs.modal", function () {
|
||||
$("#barcode").prop("disabled", false).focus();
|
||||
})
|
||||
.modal("show");
|
||||
|
||||
$(".modal.noblock").modal('show')
|
||||
.on('shown.bs.modal', function() {
|
||||
$("#barcode").prop("disabled", false).focus();
|
||||
}).on('hidden.bs.modal', function() {
|
||||
$("#barcode").prop("disabled", false).focus();
|
||||
});
|
||||
$(".modal.noblock")
|
||||
.modal("show")
|
||||
.on("shown.bs.modal", function () {
|
||||
$("#barcode").prop("disabled", false).focus();
|
||||
})
|
||||
.on("hidden.bs.modal", function () {
|
||||
$("#barcode").prop("disabled", false).focus();
|
||||
});
|
||||
|
||||
$("body").on("click", ".show_checkin_dialog button", function(e){
|
||||
$("body").on("click", ".show_checkin_dialog button", function (e) {
|
||||
e.preventDefault();
|
||||
$(".modal.audio-alert-action").modal("show");
|
||||
});
|
||||
if (reserve_id){
|
||||
$(".print-slip").on('click', function(e) {
|
||||
if (reserve_id) {
|
||||
$(".print-slip").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
Dopop("hold-transfer-slip.pl?reserve_id=" + reserve_id );
|
||||
Dopop("hold-transfer-slip.pl?reserve_id=" + reserve_id);
|
||||
});
|
||||
if (print_slip){
|
||||
Dopop("hold-transfer-slip.pl?reserve_id=" + reserve_id );
|
||||
if (print_slip) {
|
||||
Dopop("hold-transfer-slip.pl?reserve_id=" + reserve_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (recall_slip){
|
||||
Dopop('/cgi-bin/koha/recalls/recall_pickup_slip.pl?recall_id=' + recall_id);
|
||||
if (recall_slip) {
|
||||
Dopop("/cgi-bin/koha/recalls/recall_pickup_slip.pl?recall_id=" + recall_id);
|
||||
}
|
||||
|
||||
var returns_table = $("#checkedintable").kohaTable(
|
||||
|
|
@ -1613,12 +1614,12 @@
|
|||
$("#barcode").addClass("input-warning");
|
||||
$("#dropboxmode").show();
|
||||
|
||||
$("#return_date_override_fields :input").prop('disabled', true);
|
||||
$("#return_date_override_fields :input").prop("disabled", true);
|
||||
} else {
|
||||
$("#barcode").removeClass("input-warning");
|
||||
$("#dropboxmode").hide();
|
||||
|
||||
$("#return_date_override_fields :input").prop('disabled', false);
|
||||
$("#return_date_override_fields :input").prop("disabled", false);
|
||||
}
|
||||
$("#barcode").focus();
|
||||
});
|
||||
|
|
@ -1634,9 +1635,9 @@
|
|||
$("#barcode").focus();
|
||||
});
|
||||
|
||||
if (overduecharges){
|
||||
if (overduecharges) {
|
||||
$("#barcode").focus(function () {
|
||||
if (($("#exemptcheck").prop("checked") == true) || ($("#dropboxcheck").prop("checked") == true)) {
|
||||
if ($("#exemptcheck").prop("checked") == true || $("#dropboxcheck").prop("checked") == true) {
|
||||
$("#barcode").addClass("input-warning");
|
||||
} else {
|
||||
$("#barcode").removeClass("input-warning");
|
||||
|
|
@ -1647,44 +1648,44 @@
|
|||
});
|
||||
}
|
||||
|
||||
$('.openWin').on("click",function(e){
|
||||
Dopop( $(this).data("url") );
|
||||
$(".openWin").on("click", function (e) {
|
||||
Dopop($(this).data("url"));
|
||||
});
|
||||
|
||||
$('.submit').on("click",function(e){
|
||||
$(".submit").on("click", function (e) {
|
||||
this.form.submit();
|
||||
});
|
||||
|
||||
$('.cancel').on("click",function(e){
|
||||
$(".cancel").on("click", function (e) {
|
||||
var docancel = $("<input>").attr("type", "hidden").attr("name", "canceltransfer").val(1);
|
||||
$('#wrongtransferform').append(docancel);
|
||||
$("#wrongtransferform").append(docancel);
|
||||
this.form.submit();
|
||||
});
|
||||
|
||||
$(".print").on("click",function(e){
|
||||
$(".print").on("click", function (e) {
|
||||
this.form.print_slip.value = 1;
|
||||
let barcode = document.getElementById('confirm-hold-barcode');
|
||||
if ( barcode ) barcode.remove();
|
||||
let barcode = document.getElementById("confirm-hold-barcode");
|
||||
if (barcode) barcode.remove();
|
||||
this.form.submit();
|
||||
});
|
||||
|
||||
$('.print-recall').on("click",function(e){
|
||||
$(".print-recall").on("click", function (e) {
|
||||
this.form.recall_slip.value = 1;
|
||||
this.form.submit();
|
||||
});
|
||||
|
||||
$(".approve").on("click",function(e){
|
||||
let barcode = document.getElementById('confirm-hold-barcode');
|
||||
if ( barcode ) barcode.remove();
|
||||
$(".approve").on("click", function (e) {
|
||||
let barcode = document.getElementById("confirm-hold-barcode");
|
||||
if (barcode) barcode.remove();
|
||||
this.form.submit();
|
||||
});
|
||||
$(".ignore").on("click",function(e){
|
||||
$(".ignore").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
$('.cancel-hold').on("click",function(e){
|
||||
let cancel_form = document.getElementById('cancellation-reason');
|
||||
let cancel_reason = '';
|
||||
if ( cancel_form ) {
|
||||
$(".cancel-hold").on("click", function (e) {
|
||||
let cancel_form = document.getElementById("cancellation-reason");
|
||||
let cancel_reason = "";
|
||||
if (cancel_form) {
|
||||
cancel_reason = cancel_form.value;
|
||||
}
|
||||
this.form.cancel_reserve.value = 1;
|
||||
|
|
@ -1692,21 +1693,21 @@
|
|||
this.form.submit();
|
||||
});
|
||||
|
||||
$('.action').on("click",function(e){
|
||||
$(".action").on("click", function (e) {
|
||||
this.checked = false;
|
||||
this.form.return_date_override.value = '';
|
||||
this.form.return_date_override.value = "";
|
||||
this.form.return_date_override_remember.checked = false;
|
||||
this.form.barcode.focus();
|
||||
$("#return_date_remember").hide();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#return_date_override_remember").on("change", function(){
|
||||
if( $(this).prop("checked" ) ){
|
||||
if( $("#return_date_override").val() == "" ){
|
||||
$("#saved_return_date").text( _("No date selected") );
|
||||
$("#return_date_override_remember").on("change", function () {
|
||||
if ($(this).prop("checked")) {
|
||||
if ($("#return_date_override").val() == "") {
|
||||
$("#saved_return_date").text(_("No date selected"));
|
||||
} else {
|
||||
$("#saved_return_date").text( $("#return_date_override").val() );
|
||||
$("#saved_return_date").text($("#return_date_override").val());
|
||||
}
|
||||
$("#return_date_remember").show();
|
||||
} else {
|
||||
|
|
@ -1714,60 +1715,62 @@
|
|||
}
|
||||
});
|
||||
|
||||
$(".printcheckinslip").on("click", function(e){
|
||||
$(".printcheckinslip").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
var borrowernumber = $(this).data('borrowernumber');
|
||||
var borrowernumber = $(this).data("borrowernumber");
|
||||
window.open("/cgi-bin/koha/members/printslip.pl?borrowernumber=" + borrowernumber + "&print=checkinslip", "printwindow");
|
||||
});
|
||||
|
||||
// item bundles
|
||||
$('#verify-items-bundle-contents-barcodes').on('input', function (ev) {
|
||||
$("#verify-items-bundle-contents-barcodes").on("input", function (ev) {
|
||||
let char = ev.target.value.slice(-1);
|
||||
if ( char.match(/\n/) ) {
|
||||
const barcodes = ev.target.value.split('\n').map(function(s) { return s.trim().toUpperCase() });
|
||||
if (char.match(/\n/)) {
|
||||
const barcodes = ev.target.value.split("\n").map(function (s) {
|
||||
return s.trim().toUpperCase();
|
||||
});
|
||||
const expected = [];
|
||||
let found = 0;
|
||||
$('#items-bundle-contents-table tbody > tr').each(function () {
|
||||
const barcode = this.getAttribute('data-barcode').toUpperCase();
|
||||
$("#items-bundle-contents-table tbody > tr").each(function () {
|
||||
const barcode = this.getAttribute("data-barcode").toUpperCase();
|
||||
expected.push(barcode);
|
||||
if (barcodes.includes(barcode)) {
|
||||
this.classList.add('ok');
|
||||
this.classList.add("ok");
|
||||
found++;
|
||||
} else {
|
||||
this.classList.remove('ok');
|
||||
this.classList.remove("ok");
|
||||
}
|
||||
});
|
||||
const last = barcodes[barcodes.length -2];
|
||||
const feedback = $('#bundle-feedback');
|
||||
const last = barcodes[barcodes.length - 2];
|
||||
const feedback = $("#bundle-feedback");
|
||||
let string;
|
||||
if ( !expected.includes(last) ) {
|
||||
feedback.fadeOut(100, function(){
|
||||
string = _("Unexpected: ") +last;
|
||||
feedback.addClass('alert-danger').removeClass('alert-success').html(string).fadeIn(100);
|
||||
if (!expected.includes(last)) {
|
||||
feedback.fadeOut(100, function () {
|
||||
string = _("Unexpected: ") + last;
|
||||
feedback.addClass("alert-danger").removeClass("alert-success").html(string).fadeIn(100);
|
||||
});
|
||||
} else {
|
||||
feedback.fadeOut(100, function(){
|
||||
string = _("Verified: ")+last;
|
||||
feedback.addClass('alert-success').removeClass('alert-danger').html(string).fadeIn(100);
|
||||
feedback.fadeOut(100, function () {
|
||||
string = _("Verified: ") + last;
|
||||
feedback.addClass("alert-success").removeClass("alert-danger").html(string).fadeIn(100);
|
||||
});
|
||||
}
|
||||
$('#verify-progress').show();
|
||||
$('#verified').text(found);
|
||||
$('#expected').text(expected.length);
|
||||
$("#verify-progress").show();
|
||||
$("#verified").text(found);
|
||||
$("#expected").text(expected.length);
|
||||
}
|
||||
});
|
||||
|
||||
$('.bundle_remove').on('click', function() {
|
||||
var component_itemnumber = $(this).data('itemnumber');
|
||||
var host_itemnumber = $(this).data('hostnumber');
|
||||
var alert = $(this).closest('div');
|
||||
$(".bundle_remove").on("click", function () {
|
||||
var component_itemnumber = $(this).data("itemnumber");
|
||||
var host_itemnumber = $(this).data("hostnumber");
|
||||
var alert = $(this).closest("div");
|
||||
var unlink_item_url = "/api/v1/items/" + host_itemnumber + "/bundled_items/" + component_itemnumber;
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: unlink_item_url,
|
||||
success: function(){
|
||||
success: function () {
|
||||
alert.remove();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -1781,12 +1784,12 @@
|
|||
],
|
||||
});
|
||||
|
||||
if( !prefs.TransfersBlockCirc && prefs.AutomaticConfirmTransfer ){
|
||||
$("#wrong-transfer-modal").on('hidden.bs.modal',function(){
|
||||
if (!prefs.TransfersBlockCirc && prefs.AutomaticConfirmTransfer) {
|
||||
$("#wrong-transfer-modal").on("hidden.bs.modal", function () {
|
||||
$("#wrongtransferform").submit();
|
||||
});
|
||||
if (was_transferred){
|
||||
$("#item-transfer-modal").on('hidden.bs.modal',function(){
|
||||
if (was_transferred) {
|
||||
$("#item-transfer-modal").on("hidden.bs.modal", function () {
|
||||
$("#mainform").submit();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,9 +102,8 @@
|
|||
library_ids.push("[% library.branchcode | html %]");
|
||||
[% END %]
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
library_ids.forEach(library_id => {
|
||||
$(`#transferst${library_id}`).kohaTable({
|
||||
dom: "t",
|
||||
|
|
|
|||
|
|
@ -123,7 +123,6 @@
|
|||
library_ids.push("[% library.branchcode | html %]");
|
||||
[% END %]
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
library_ids.forEach(library_id => {
|
||||
|
|
|
|||
|
|
@ -383,12 +383,11 @@
|
|||
<script>
|
||||
var table_settings = [% TablesSettings.GetTableSettings('circ', 'view_holdsqueue', 'holds-table', 'json') | $raw %];
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
// Apply select2 to all select fields having a "multiple" attribute
|
||||
let selectFields = document.querySelectorAll('select[multiple]');
|
||||
selectFields.forEach((selectField) => {
|
||||
let selectFields = document.querySelectorAll("select[multiple]");
|
||||
selectFields.forEach(selectField => {
|
||||
$(selectField).select2({
|
||||
width: "100%",
|
||||
allowClear: true,
|
||||
|
|
@ -399,15 +398,19 @@
|
|||
// Setup filters before DataTables initialisation, in case some columns are
|
||||
// hidden by default
|
||||
var filterColumnTimeoutId;
|
||||
var filterColumn = function(e) {
|
||||
var filterColumn = function (e) {
|
||||
clearTimeout(filterColumnTimeoutId);
|
||||
filterColumnTimeoutId = setTimeout(function() {
|
||||
filterColumnTimeoutId = setTimeout(function () {
|
||||
var input = $(e.target);
|
||||
var idx = input.parents('td').index();
|
||||
holdst.api().column(idx + ':visible').search(input.val()).draw();
|
||||
var idx = input.parents("td").index();
|
||||
holdst
|
||||
.api()
|
||||
.column(idx + ":visible")
|
||||
.search(input.val())
|
||||
.draw();
|
||||
}, 200);
|
||||
};
|
||||
$('#holdst thead input').on('change keyup keydown', filterColumn);
|
||||
$("#holdst thead input").on("change keyup keydown", filterColumn);
|
||||
|
||||
var holdst = $("#holdst").kohaTable(
|
||||
{
|
||||
|
|
@ -417,7 +420,6 @@
|
|||
},
|
||||
table_settings
|
||||
);
|
||||
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
|
|
|||
|
|
@ -209,10 +209,9 @@
|
|||
var holdso_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdso', 'json' ) | $raw %];
|
||||
var holdscr_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdscr', 'json' ) | $raw %];
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var MSG_CANCEL_SELECTED = _("Cancel selected (%s)");
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
$("#holdst").kohaTable(
|
||||
{
|
||||
pagingType: "full",
|
||||
|
|
@ -239,102 +238,101 @@
|
|||
|
||||
let cancel_link;
|
||||
|
||||
$("#cancelModalConfirmBtn").on("click",function(e) {
|
||||
var ids = cancel_link.data('ids');
|
||||
$("#cancelModalConfirmBtn").on("click", function (e) {
|
||||
var ids = cancel_link.data("ids");
|
||||
localStorage.selectedWaitingHolds = JSON.stringify(JSON.parse(localStorage.selectedWaitingHolds).filter(id => !ids.includes(id)));
|
||||
let link = `waitingreserves.pl?cancelBulk=1&ids=${ids.join(',')}`;
|
||||
let link = `waitingreserves.pl?cancelBulk=1&ids=${ids.join(",")}`;
|
||||
let reason = $("#modal-cancellation-reason").val();
|
||||
if ( reason ) {
|
||||
link += "&cancellation-reason=" + reason
|
||||
if (reason) {
|
||||
link += "&cancellation-reason=" + reason;
|
||||
}
|
||||
window.location.href = link;
|
||||
return false;
|
||||
});
|
||||
|
||||
if(!localStorage.selectedWaitingHolds || document.referrer.replace(/\?.*/, '') !== document.location.origin+document.location.pathname) {
|
||||
localStorage.selectedWaitingHolds = '[]';
|
||||
if (!localStorage.selectedWaitingHolds || document.referrer.replace(/\?.*/, "") !== document.location.origin + document.location.pathname) {
|
||||
localStorage.selectedWaitingHolds = "[]";
|
||||
}
|
||||
|
||||
try {
|
||||
JSON.parse(localStorage.selectedWaitingHolds);
|
||||
} catch(e) {
|
||||
localStorage.selectedWaitingHolds = '[]';
|
||||
} catch (e) {
|
||||
localStorage.selectedWaitingHolds = "[]";
|
||||
}
|
||||
|
||||
$('.holds_table .select_hold').each(function() {
|
||||
if(JSON.parse(localStorage.selectedWaitingHolds).includes($(this).data('id'))) {
|
||||
$(this).prop('checked', true);
|
||||
$(".holds_table .select_hold").each(function () {
|
||||
if (JSON.parse(localStorage.selectedWaitingHolds).includes($(this).data("id"))) {
|
||||
$(this).prop("checked", true);
|
||||
}
|
||||
});
|
||||
|
||||
function get_selected_ids(dt){
|
||||
function get_selected_ids(dt) {
|
||||
let selected_ids = [];
|
||||
dt.cells(null, 0).every(function(){
|
||||
dt.cells(null, 0).every(function () {
|
||||
let checkbox = $(this.node()).find('input[type="checkbox"]');
|
||||
if ( checkbox.is(':checked') ) {
|
||||
selected_ids.push(checkbox.data('id'));
|
||||
if (checkbox.is(":checked")) {
|
||||
selected_ids.push(checkbox.data("id"));
|
||||
}
|
||||
})
|
||||
});
|
||||
return selected_ids;
|
||||
}
|
||||
|
||||
$('.holds_table').each(function() {
|
||||
var parent = $(this).parents('.tab-pane');
|
||||
$(".holds_table").each(function () {
|
||||
var parent = $(this).parents(".tab-pane");
|
||||
var this_dt = $(this).DataTable();
|
||||
let selected_ids = get_selected_ids(this_dt);
|
||||
parent.find('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format(selected_ids.length));
|
||||
parent.find('.cancel_selected_holds').click(function(e) {
|
||||
e.preventDefault();
|
||||
if(get_selected_ids(this_dt).length) {
|
||||
cancel_link = $(this);
|
||||
$('#cancelModal').modal('show');
|
||||
}
|
||||
return false;
|
||||
parent.find(".cancel_selected_holds").html(MSG_CANCEL_SELECTED.format(selected_ids.length));
|
||||
parent.find(".cancel_selected_holds").click(function (e) {
|
||||
e.preventDefault();
|
||||
if (get_selected_ids(this_dt).length) {
|
||||
cancel_link = $(this);
|
||||
$("#cancelModal").modal("show");
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
$('.holds_table').on('click', '.select_hold_all', function() {
|
||||
var parent = $(this).parents('.tab-pane');
|
||||
var this_dt = $(this).closest('.holds_table').DataTable();
|
||||
$(".holds_table").on("click", ".select_hold_all", function () {
|
||||
var parent = $(this).parents(".tab-pane");
|
||||
var this_dt = $(this).closest(".holds_table").DataTable();
|
||||
|
||||
var all_checked = $(this).closest('.select_hold_all').prop('checked');
|
||||
var all_checked = $(this).closest(".select_hold_all").prop("checked");
|
||||
|
||||
this_dt.cells(null, 0).every(function(){
|
||||
$(this.node()).find('input[type="checkbox"]').prop('checked', all_checked)
|
||||
this_dt.cells(null, 0).every(function () {
|
||||
$(this.node()).find('input[type="checkbox"]').prop("checked", all_checked);
|
||||
});
|
||||
|
||||
let selected_ids = get_selected_ids(this_dt);
|
||||
var count = selected_ids.length;
|
||||
parent.find('.cancel_selected_holds').data('ids', selected_ids).html(MSG_CANCEL_SELECTED.format(count));
|
||||
parent.find(".cancel_selected_holds").data("ids", selected_ids).html(MSG_CANCEL_SELECTED.format(count));
|
||||
localStorage.selectedWaitingHolds = JSON.stringify(selected_ids);
|
||||
});
|
||||
|
||||
$('.holds_table').on('click', '.select_hold', function() {
|
||||
var parent = $(this).parents('.tab-pane');
|
||||
var this_dt = $(this).closest('.holds_table').DataTable();
|
||||
$(".holds_table").on("click", ".select_hold", function () {
|
||||
var parent = $(this).parents(".tab-pane");
|
||||
var this_dt = $(this).closest(".holds_table").DataTable();
|
||||
let selected_ids = get_selected_ids(this_dt);
|
||||
var count = selected_ids.length;
|
||||
parent.find('.cancel_selected_holds').data('ids', selected_ids).html(MSG_CANCEL_SELECTED.format(count));
|
||||
parent.find(".cancel_selected_holds").data("ids", selected_ids).html(MSG_CANCEL_SELECTED.format(count));
|
||||
localStorage.selectedWaitingHolds = JSON.stringify(selected_ids);
|
||||
});
|
||||
|
||||
var hash = document.location.hash;
|
||||
if( hash !== "" ){
|
||||
if (hash !== "") {
|
||||
/* The existence of location.hash means someone clicked a link which targets a specific tab */
|
||||
$( hash ).tab("show");
|
||||
$(hash).tab("show");
|
||||
} else {
|
||||
/* If no specific tab was linked to, use the last active tab */
|
||||
var activeTab = localStorage.getItem("waitingreserves_activetab");
|
||||
if( activeTab ){
|
||||
if (activeTab) {
|
||||
$("div#resultlist li:eq(" + activeTab + ") a").tab("show");
|
||||
}
|
||||
}
|
||||
$("div#resultlist a[data-bs-toggle='tab']").on("shown.bs.tab", function (e) {
|
||||
var thisTab = $(e.target).parent();
|
||||
var activeTab = thisTab.index();
|
||||
localStorage.setItem("waitingreserves_activetab", activeTab );
|
||||
localStorage.setItem("waitingreserves_activetab", activeTab);
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
|
|
|||
Loading…
Reference in New Issue