From 30bd4f676b504617228a398f6a1de69fe7969ef4 Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Fri, 21 Sep 2018 11:09:13 +0100 Subject: [PATCH] Bug 7088: Allow renew on hold items with due date This patch adds the ability for items that are on hold to be renewed with a due date specfied by the user. It is enabled by the new "AllowRenewalOnHoldOverride" syspref. It is manifested in two locations: 1. In the "Checkouts" table on the Patron Details screen. It is now possible to select on loan items that would otherwise fulfil a hold request to be renewed. When such an item is selected, an additional date selection box is displayed to allow the user to specify the due date for all on hold items that are to be renewed. 2. In the Circulation > Renew alert screen. When a barcode of an on loan item that would ordinarily fulfil a hold request is entered, the usual alert is displayed indicating that the item is on hold, it is still possible to override this, and renew, however it is now also possible to specify a due date. Test plan: - Go to the Patron Details page for a patron who has an item on loan that would fulfil an outstanding loan request. - TEST: Observe that it is NOT possible to select this item - Enable the "AllowRenewalOnHoldOverride" syspref - Return to the Patron Details page for a patron who has an item on loan that would fulfil an outstanding loan request. - TEST: Observe that it IS possible to select this item - Select the item - TEST: Observe that an additional "On hold due date" input box is displayed - De-select the item - TEST: Observe that an additional "On hold due date" input box is hidden - Select the item - In the "On hold due date" input box, select a due date for the item - Click "Renew or check in selected items" - TEST: Observe that the item is renewed as usual - In the "Renewal due date" input box, select a due date - Remove the contents of the "On hold due date" input box - Click "Renew or check in selected items" - TEST: Observe that the item is renewed by falling back to the "Renewal due date" value if a value is not specified in the "On hold due date" input box - Remove the contents of the "Renewal due date" input box - Click "Renew or check in selected items" - TEST: Observe that the standard loan period is used for the renewal period if no due date is specified in either box - In the "On hold due date" input box, select a due date for the item - In the "Renewal due date" input box, select a different due date - Click "Renew all" - TEST: Observe that all non on hold items are renewed using the value in "Renewal due date" and on hold items are renewed using the value in "On hold due date" - From the main staff client from page, choose "Circulation", then choose "Renew" - Enter the barcode of an item that you know to be on hold and submit - TEST: In the alert box that appears, observe that a date picker is displayed - Choose a due date for this item, then click "Override and renew" - TEST: In the "Item renewed" box, observe that the item has been renewed to the date specified Sponsored-by: Cheshire Libraries Shared Services Sponsored-by: Halton Borough Council Sponsored-by: Sefton Council --- circ/renew.pl | 2 +- .../intranet-tmpl/prog/css/src/staff-global.scss | 19 ++++ .../prog/en/includes/checkouts-table-footer.inc | 10 +- .../prog/en/modules/circ/circulation.tt | 1 + .../intranet-tmpl/prog/en/modules/circ/renew.tt | 22 +++++ .../prog/en/modules/members/moremember.tt | 1 + koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 101 ++++++++++++++++----- .../intranet-tmpl/prog/js/pages/circulation.js | 2 +- svc/renew | 6 ++ 9 files changed, 136 insertions(+), 28 deletions(-) diff --git a/circ/renew.pl b/circ/renew.pl index 246c26629f..2ec674e810 100755 --- a/circ/renew.pl +++ b/circ/renew.pl @@ -92,7 +92,7 @@ if ($barcode) { } if ($can_renew) { my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; - my $date_due = AddRenewal( undef, $item->itemnumber(), $branchcode ); + my $date_due = AddRenewal( undef, $item->itemnumber(), $branchcode, dt_from_string( scalar $cgi->param('renewonholdduedate')) ); $template->param( date_due => $date_due ); } } diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index dc72a32732..0c08aac181 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -3761,12 +3761,31 @@ span { } } +input.renew { + margin-right: 1em; +} + .renewals { display: block; font-size: .8em; padding: .5em; } +.dialog input#renewonholdduedate { + padding: 2px; +} + +.date-select { + label { + display: inline-block; + width: 40%; + } +} + +#newonholdduedate { + display: none; +} + #transport-types { padding-top: .5px; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc index 40d2195e43..35f3c438fe 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc @@ -4,10 +4,12 @@ [% totaldue | html %] [% finetotal | html %] [% totalprice | html %] -
-

-

-

+ +
+

+

+

+
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 6700b0e581..e04d6165a2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -995,6 +995,7 @@ No patron matched [% message | html %] var branchcode = "[% branch | html %]"; var exports_enabled = "[% Koha.Preference('ExportCircHistory') | html %]"; var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 | html %]; + var AllowRenewalOnHoldOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalOnHoldOverride') )? 1: 0 | html %]; var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 | html %]; var script = "circulation"; var relatives_borrowernumbers = new Array(); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt index 5498c169ef..8ded40bc9a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt @@ -1,3 +1,5 @@ +[% USE raw %] +[% USE Asset %] [% USE Koha %] [% USE KohaDates %] [% SET footerjs = 1 %] @@ -110,6 +112,9 @@ +
+ +
@@ -179,6 +184,9 @@
[% MACRO jsinclude BLOCK %] + [% INCLUDE 'calendar.inc' %] + [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") | $raw %] + [% INCLUDE 'timepicker.inc' %] [% IF error %] [% END %] + [% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index 6e15e3c4d1..124cf84ed1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -815,6 +815,7 @@ var exports_enabled = "[% Koha.Preference('ExportCircHistory') | html %]"; var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 | html %] var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 | html %]; + var AllowRenewalOnHoldOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalOnHoldOverride') )? 1: 0 | html %]; var script = "moremember"; var relatives_borrowernumbers = new Array(); [% FOREACH b IN relatives_borrowernumbers %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index 9902f5be01..7a832965e9 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -3,14 +3,37 @@ $(document).ready(function() { var barcodefield = $("#barcode"); + var onHoldDueDateSet = false; + + var onHoldChecked = function() { + var isChecked = false; + $('input[data-on-reserve]').each(function() { + if ($(this).is(':checked')) { + isChecked=true; + } + }); + return isChecked; + }; + + var showHideOnHoldRenewal = function() { + // Display the date input + if (onHoldChecked()) { + $('#newonholdduedate').show() + } else { + $('#newonholdduedate').hide(); + } + }; + // Handle the select all/none links for checkouts table columns $("#CheckAllRenewals").on("click",function(){ $("#UncheckAllCheckins").click(); $(".renew:visible").prop("checked", true); + showHideOnHoldRenewal(); return false; }); $("#UncheckAllRenewals").on("click",function(){ $(".renew:visible").prop("checked", false); + showHideOnHoldRenewal(); return false; }); @@ -24,6 +47,16 @@ $(document).ready(function() { return false; }); + $("#newduedate").on("change", function() { + if (!onHoldDueDateSet) { + $('#newonholdduedate input').val($('#newduedate').val()); + } + }); + + $("#newonholdduedate").on("change", function() { + onHoldDueDateSet = true; + }); + // Don't allow both return and renew checkboxes to be checked $(document).on("change", '.renew', function(){ if ( $(this).is(":checked") ) { @@ -36,6 +69,12 @@ $(document).ready(function() { } }); + // Display on hold due dates input when an on hold item is + // selected + $(document).on('change', '.renew', function(){ + showHideOnHoldRenewal(); + }); + $("#output_format > option:first-child").attr("selected", "selected"); $("select[name='csv_profile_id']").hide(); $(document).on("change", '#issues-table-output-format', function(){ @@ -92,18 +131,28 @@ $(document).ready(function() { $(".renew:checked:visible").each(function() { var override_limit = $("#override_limit").is(':checked') ? 1 : 0; + var isOnReserve = $(this).data().hasOwnProperty('onReserve'); + var itemnumber = $(this).val(); $(this).parent().parent().replaceWith(""); var params = { - itemnumber: itemnumber, - borrowernumber: borrowernumber, - branchcode: branchcode, - override_limit: override_limit, - date_due: $("#newduedate").val() + itemnumber: itemnumber, + borrowernumber: borrowernumber, + branchcode: branchcode, + override_limit: override_limit, }; + // Determine which due date we need to use + var dueDate = isOnReserve ? + $("#newonholdduedate input").val() : + $("#newduedate").val(); + + if (dueDate && dueDate.length > 0) { + params.date_due = dueDate + } + $.post( "/cgi-bin/koha/svc/renew", params, function( data ) { var id = "#renew_" + data.itemnumber; @@ -146,6 +195,7 @@ $(document).ready(function() { $("#RenewAll").on("click",function(){ $("#CheckAllRenewals").click(); $("#UncheckAllCheckins").click(); + showHideOnHoldRenewal(); $("#RenewCheckinChecked").click(); // Prevent form submit @@ -351,79 +401,77 @@ $(document).ready(function() { "bVisible": AllowCirculate ? true : false, "mDataProp": function ( oObj ) { var content = ""; + var msg = ""; var span_style = ""; var span_class = ""; - content += ""; - content += "" + oObj.renewals_count + ""; - if ( oObj.can_renew ) { // Do nothing } else if ( oObj.can_renew_error == "on_reserve" ) { - content += "" + msg += "" + "" + ON_HOLD + "" + ""; - span_style = "display: none"; + span_style = AllowRenewalLimitOverride ? "" : "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "too_many" ) { - content += "" + msg += "" + NOT_RENEWABLE + ""; span_style = "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "restriction" ) { - content += "" + msg += "" + NOT_RENEWABLE_RESTRICTION + ""; span_style = "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "overdue" ) { - content += "" + msg += "" + NOT_RENEWABLE_OVERDUE + ""; span_style = "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "too_soon" ) { - content += "" + msg += "" + NOT_RENEWABLE_TOO_SOON.format( oObj.can_renew_date ) + ""; span_style = "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "auto_too_soon" ) { - content += "" + msg += "" + NOT_RENEWABLE_AUTO_TOO_SOON + ""; span_style = "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "auto_too_late" ) { - content += "" + msg += "" + NOT_RENEWABLE_AUTO_TOO_LATE + ""; span_style = "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "auto_too_much_oweing" ) { - content += "" + msg += "" + NOT_RENEWABLE_AUTO_TOO_MUCH_OWEING + ""; span_style = "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "auto_account_expired" ) { - content += "" + msg += "" + NOT_RENEWABLE_AUTO_ACCOUNT_EXPIRED + ""; span_style = "display: none"; span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "auto_renew" ) { - content += "" + msg += "" + NOT_RENEWABLE_AUTO_RENEW + ""; @@ -439,7 +487,7 @@ $(document).ready(function() { span_style = "display: none"; span_class = "renewals-allowed"; } else { - content += "" + msg += "" + oObj.can_renew_error + ""; @@ -447,17 +495,26 @@ $(document).ready(function() { span_class = "renewals-allowed"; } - var can_force_renew = ( oObj.onsite_checkout == 0 ) && ( oObj.can_renew_error != "on_reserve" ); + var can_force_renew = ( oObj.onsite_checkout == 0 ) && + ( oObj.can_renew_error != "on_reserve" || (oObj.can_renew_error == "on_reserve" && AllowRenewalOnHoldOverride)) + ? true : false; var can_renew = ( oObj.renewals_remaining > 0 && !oObj.can_renew_error ); + content += ""; if ( can_renew || can_force_renew ) { + content += "" + oObj.renewals_count + ""; content += "" + "" + ""; - + } + content += msg; + if ( can_renew || can_force_renew ) { content += "(" + RENEWALS_REMAINING.format( oObj.renewals_remaining, oObj.renewals_allowed ) + ")"; diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js b/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js index cd2ca9bc4f..9602550500 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js +++ b/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js @@ -28,7 +28,7 @@ $(document).ready(function() { radioCheckBox($(this)); }); - $("#newduedate").datetimepicker({ + $("#newduedate, #newonholdduedate input").datetimepicker({ onClose: function(dateText, inst) { validate_date(dateText, inst); }, diff --git a/svc/renew b/svc/renew index 1aa9a28944..29e51d8cf7 100755 --- a/svc/renew +++ b/svc/renew @@ -59,6 +59,12 @@ $data->{branchcode} = $branchcode; ( $data->{renew_okay}, $data->{error} ) = CanBookBeRenewed( $borrowernumber, $itemnumber, $override_limit ); +# If we're allowing reserved items to be renewed... +if ( $data->{error} && $data->{error} eq 'on_reserve' && C4::Context->preference('AllowRenewalOnHoldOverride')) { + $data->{renew_okay} = 1; + $data->{error} = undef; +} + if ( $data->{renew_okay} ) { $date_due = AddRenewal( $borrowernumber, $itemnumber, $branchcode, $date_due ); $data->{date_due} = output_pref( { dt => $date_due, as_due_date => 1 } ); -- 2.11.0