From 9408f57f3fbee29241d7ad582e44a0506a3d90eb 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 (cherry picked from commit a825c729386e7f528846445937e00eda92f01f68) Signed-off-by: Fridolin Somers (cherry picked from commit b150fdc79247b6fedda5054b374aafe8292ee3fa) Signed-off-by: Andrew Fuerste-Henry --- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 97 +++++++++++--------- 1 file changed, 56 insertions(+), 41 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index 8d16afc93d..8b50d58b66 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, + }); }); $(".renew:checked:visible").each(function() { @@ -155,34 +161,43 @@ $(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 == "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