From a825c729386e7f528846445937e00eda92f01f68 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 3 Dec 2020 19:13:15 +0000 Subject: [PATCH] Bug 26208: Perform batch checkin/renewals serially rather than asynchronously The issue here seems to be that when multiple requests hit at once they may not register that the renewal performed by the request should lift restrictions on the account. To mitigate this we can simply perform the renewals one after the other. To test: 1 - have multiple overdue items on one patron 2 - run overdues.pl with triggers set to generate a restriction 3 - renew all overdues with the Renew All button 4 - restriction is not removed even though patron no longer has overdue items 5 - Apply patch 6 - Make all items overdue again 7 - Click Renew All 8 - Items are renewed and restriction removed 9 - Checkout items to patron again (overdue or not) 10 - Click 'Select all' in checkin column 11 - Click 'Renew/Checkin selected items' 12 - Confirm checkin succeeds as before patches Signed-off-by: Kelly McElligott Signed-off-by: Martin Renvoize Bug 26208: (follow-up) Remove debugging statements Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 98 +++++++++++--------- 1 file changed, 55 insertions(+), 43 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index b5347c0bae..fc67a26488 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -110,24 +110,30 @@ $(document).ready(function() { exempt_fine: $("#exemptfine").is(':checked') }; - $.post( "/cgi-bin/koha/svc/checkin", params, function( data ) { - id = "#checkin_" + data.itemnumber; - - content = ""; - if ( data.returned ) { - content = __("Checked in"); - $(id).parent().parent().addClass('ok'); - $('#date_due_' + data.itemnumber).html( __("Checked in") ); - if ( data.patronnote != null ) { - $('.patron_note_' + data.itemnumber).html( __("Patron note") + ": " + data.patronnote); + $.post({ + url: "/cgi-bin/koha/svc/checkin", + data: params, + success: function( data ) { + id = "#checkin_" + data.itemnumber; + + content = ""; + if ( data.returned ) { + content = __("Checked in"); + $(id).parent().parent().addClass('ok'); + $('#date_due_' + data.itemnumber).html( __("Checked in") ); + if ( data.patronnote != null ) { + $('.patron_note_' + data.itemnumber).html( __("Patron note") + ": " + data.patronnote); + } + } else { + content = __("Unable to check in"); + $(id).parent().parent().addClass('warn'); } - } else { - content = __("Unable to check in"); - $(id).parent().parent().addClass('warn'); - } - $(id).replaceWith( content ); - }, "json") + $(id).replaceWith( content ); + }, + dataType: "json", + async: false, + }); }); $(".confirm:checked:visible").each(function() { @@ -170,36 +176,42 @@ $(document).ready(function() { params.date_due = dueDate } - $.post( "/cgi-bin/koha/svc/renew", params, function( data ) { - var id = "#renew_" + data.itemnumber; - - var content = ""; - if ( data.renew_okay ) { - content = __("Renewed, due:") + " " + data.date_due; - $('#date_due_' + data.itemnumber).replaceWith( data.date_due ); - } else { - content = __("Renew failed:") + " "; - if ( data.error == "no_checkout" ) { - content += __("not checked out"); - } else if ( data.error == "too_many" ) { - content += __("too many renewals"); - } else if ( data.error == "too_unseen" ) { - content += __("too many consecutive renewals without being seen by the library"); - } else if ( data.error == "on_reserve" ) { - content += __("on hold"); - } else if ( data.error == "restriction" ) { - content += __("Not allowed: patron restricted"); - } else if ( data.error == "overdue" ) { - content += __("Not allowed: overdue"); - } else if ( data.error ) { - content += data.error; + $.post({ + url: "/cgi-bin/koha/svc/renew", + data: params, + success: function( data ) { + var id = "#renew_" + data.itemnumber; + + var content = ""; + if ( data.renew_okay ) { + content = __("Renewed, due:") + " " + data.date_due; + $('#date_due_' + data.itemnumber).replaceWith( data.date_due ); } else { - content += __("reason unknown"); + content = __("Renew failed:") + " "; + if ( data.error == "no_checkout" ) { + content += __("not checked out"); + } else if ( data.error == "too_many" ) { + content += __("too many renewals"); + } else if ( data.error == "too_unseen" ) { + content += __("too many consecutive renewals without being seen by the library"); + } else if ( data.error == "on_reserve" ) { + content += __("on hold"); + } else if ( data.error == "restriction" ) { + content += __("Not allowed: patron restricted"); + } else if ( data.error == "overdue" ) { + content += __("Not allowed: overdue"); + } else if ( data.error ) { + content += data.error; + } else { + content += __("reason unknown"); + } } - } - $(id).replaceWith( content ); - }, "json") + $(id).replaceWith( content ); + }, + dataType: "json", + async: false, + }); }); // Refocus on barcode field if it exists -- 2.39.5