From a8c94380b23fafb8827cf0b7707644b76aaa6fc2 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 21 Mar 2019 16:05:17 +0000 Subject: [PATCH] Bug 18306: "Renew selected" and "renew all" in OPAC can be confusing for users not allowed to do it This patch add additional checks to opac-user.pl defining the ability to renew some or all items. The template can now better check whether it should show the renewal controls. To test, apply the patch and log in to the OPAC as a user with multiple checkouts. Test the following conditions: - All checkouts can be renewed - "Renew selected" and "Renew all" should appear at the top and bottom of the table of checkouts. - No checkouts can be renewed - No renewal controls should appear. - Some checkouts can be renewed - "Renew selected" should appear but not "Renew all" Test with various settings of the OverduesBlockRenewing system preference. --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt | 7 +++++-- opac/opac-user.pl | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index 7c55d8d..4d3e666 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -360,7 +360,7 @@ [% END %] - [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( logged_in_user.is_expired && logged_in_user.category.effective_BlockExpiredPatronOpacActions ) ) %] + [% IF ( canrenew && can_renew_all && !userdebarred && OpacRenewalAllowed && !( logged_in_user.is_expired && logged_in_user.category.effective_BlockExpiredPatronOpacActions ) ) %]
@@ -1024,7 +1024,10 @@ $("#renewall").submit(); }); [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( logged_in_user.is_expired && logged_in_user.category.effective_BlockExpiredPatronOpacActions ) ) %] - $("#checkoutst caption").append(""); + $("#checkoutst caption").append(""); + [% IF ( can_renew_all ) %] + $("#renewcontrols").append(""+_("Renew all")+""); + [% END %] [% END %] [% END %] diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 1fde24b..48c032c 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -84,6 +84,7 @@ for ( C4::Context->preference("OPACShowHoldQueueDetails") ) { my $patronupdate = $query->param('patronupdate'); my $canrenew = 1; +my $can_renew_all = 1; $template->param( shibbolethAuthentication => C4::Context->config('useshibboleth') ); @@ -230,6 +231,7 @@ if ( $pending_checkouts->count ) { # Useless test $issue->{'renewed'} = $renewed{ $issue->{'itemnumber'} }; if ($renewerror) { + $can_renew_all = 0; $issue->{'too_many'} = 1 if $renewerror eq 'too_many'; $issue->{'on_reserve'} = 1 if $renewerror eq 'on_reserve'; $issue->{'norenew_overdue'} = 1 if $renewerror eq 'overdue'; @@ -284,11 +286,14 @@ if ( $pending_checkouts->count ) { # Useless test } } my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing'); -$canrenew = 0 if ($overduesblockrenewing ne 'allow' and $overdues_count == $count); +$canrenew = 0 if ( $overduesblockrenewing eq 'block' and $overdues_count > 0 ); +$can_renew_all = 0 if ( $overduesblockrenewing eq 'blockitem' and $overdues_count > 0 ); +$canrenew = 0 if ( $overduesblockrenewing eq 'blockitem' and $overdues_count == $count ); $template->param( ISSUES => \@issuedat ); $template->param( issues_count => $count ); $template->param( canrenew => $canrenew ); +$template->param( can_renew_all => $can_renew_all ); $template->param( OVERDUES => \@overdues ); $template->param( overdues_count => $overdues_count ); -- 2.1.4