From 953c5df62708c4cd0f90b7f3a63eb620a183eb58 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 21 Jun 2016 09:52:47 -0400 Subject: [PATCH] Bug 16787 - 'Too many holds' message appears inappropriately and is missing data This patch alters C4/Reserves.pm to pass back 'noReservesAllowed' when allowedreserves=0. This allows passing to the user an appropriate message about the availability of items for holds To test: 1 - Set an item type to allow no holds 2 - Attempt to place a hold for a patron 3 - Message should be "No holds allowed: [Firstname Surname] cannot place holds on any of these items" 4 - Try placing a multihold with the record above and a holdable record, message should end "...cannot place holds on some of these titles' items" --- C4/Reserves.pm | 3 +++ koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt | 7 ++++++- reserve/request.pl | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index b83f8e1..70a35a9 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -542,6 +542,9 @@ sub CanItemBeReserved{ $reservecount = $rowcount->{count}; } # we check if it's ok or not + if( $allowedreserves == 0 ){ + return 'noReservesAllowed'; + } if( $reservecount >= $allowedreserves ){ return 'tooManyReserves'; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index 1f01a69..608dd2c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -268,7 +268,9 @@ function checkMultiHold() { [% UNLESS ( multi_hold ) %]

Cannot place hold

[% ELSE %]

Cannot place hold on some items

+ [% IF ( no_reserves_allowed) %] +
  • No holds allowed: [% borrowerfirstname %] [% borrowersurname %] cannot place holds on some of these title's items.
  • + [% END %] [% IF ( exceeded_maxreserves ) %]
  • Too many holds: [% borrowerfirstname %] [% borrowersurname %] can place [% new_reserves_allowed %] of the requested [% new_reserves_count %] holds for a maximum of [% maxreserves %] total holds.
  • [% END %] diff --git a/reserve/request.pl b/reserve/request.pl index 1826e00..4c653fc 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -151,6 +151,8 @@ if ($borrowernumber_hold && !$action) { my $new_reserves_count = scalar( @biblionumbers ); my $maxreserves = C4::Context->preference('maxreserves'); + $template->param( maxreserves => $maxreserves ); + if ( $maxreserves && ( $reserves_count + $new_reserves_count > $maxreserves ) ) { @@ -211,6 +213,7 @@ my $borrowerinfo = GetMember( borrowernumber => $borrowernumber_hold ); my $itemdata_enumchron = 0; my @biblioloop = (); +my $no_reserves_allowed = 0; foreach my $biblionumber (@biblionumbers) { my %biblioloopiter = (); @@ -223,6 +226,9 @@ foreach my $biblionumber (@biblionumbers) { #All is OK and we can continue } + elsif ( $canReserve eq 'noReservesAllowed') { + $no_reserves_allowed = 1; + } elsif ( $canReserve eq 'tooManyReserves' ) { $exceeded_maxreserves = 1; } @@ -622,6 +628,7 @@ foreach my $biblionumber (@biblionumbers) { $template->param( biblioloop => \@biblioloop ); $template->param( biblionumbers => $biblionumbers ); +$template->param( no_reserves_allowed => $no_reserves_allowed ); $template->param( exceeded_maxreserves => $exceeded_maxreserves ); if ($multihold) { -- 2.1.4