From 4f263b3a909b420e31b5c43a17331d0231260003 Mon Sep 17 00:00:00 2001 From: Fridolyn SOMERS Date: Wed, 15 May 2013 11:52:57 +0200 Subject: [PATCH] Bug 10247: show warning if hold blocked due to maxreserves syspre On intranet, when placing a hold requst: If borrower has reached the request limit, a warning should appear : Cannot place hold * Too Many Holds: TEST has too many holds. This works when quota defined in circulation rules is reached but not when limit specified in syspref maxreserves is reached, in case this limit is lower than the one defined is circulation rules. This is because template param maxreserves is set twice, this patch corrects this bug. Also moves warnings and messages conditional variable from Perl to template because it cause the same bug as for maxreserves. Signed-off-by: Srdjan Signed-off-by: Kyle M Hall Signed-off-by: Galen Charlton --- .../prog/en/modules/reserve/request.tt | 8 +++---- reserve/request.pl | 23 ++++--------------- 2 files changed, 9 insertions(+), 22 deletions(-) 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 a9385b2127..20853b3680 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -230,7 +230,7 @@ function checkMultiHold() { [% ELSE %] -[% IF ( warnings ) %] +[% IF ( maxreserves || alreadyreserved || none_available || alreadypossession ) %]
[% UNLESS ( multi_hold ) %] @@ -256,13 +256,13 @@ function checkMultiHold() {
[% END %] -[% IF ( messages ) %] -
    +[% IF ( expiry || diffbranch ) %] +
      [% IF ( expiry ) %]
    • [% borrowerfirstname %] [% borrowersurname %]'s account has expired
    • [% END %] -[% IF ( diffbranch ) %] + [% IF ( diffbranch ) %]
    • Pickup library is different than [% borrowerfirstname %] [% borrowersurname %]'s home library ([% borrower_branchname %] / [% borrower_branchcode %] )
    • [% END %] diff --git a/reserve/request.pl b/reserve/request.pl index 11741e2c24..c411ce9bdf 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -77,8 +77,7 @@ $findborrower = '' unless defined $findborrower; $findborrower =~ s|,| |g; my $borrowernumber_hold = $input->param('borrowernumber') || ''; my $messageborrower; -my $warnings; -my $messages; +my $maxreserves; my $date = C4::Dates->today('iso'); my $action = $input->param('action'); @@ -122,7 +121,6 @@ if ($borrowernumber_hold && !$action) { my $diffbranch; my @getreservloop; my $count_reserv = 0; - my $maxreserves; # we check the reserves of the borrower, and if he can reserv a document # FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ... @@ -131,7 +129,6 @@ if ($borrowernumber_hold && !$action) { GetReserveCount( $borrowerinfo->{'borrowernumber'} ); if ( C4::Context->preference('maxreserves') && ($number_reserves >= C4::Context->preference('maxreserves')) ) { - $warnings = 1; $maxreserves = 1; } @@ -140,12 +137,11 @@ if ($borrowernumber_hold && !$action) { my $expiry = 0; # flag set if patron account has expired if ($expiry_date and $expiry_date ne '0000-00-00' and Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) { - $messages = $expiry = 1; + $expiry = 1; } # check if the borrower make the reserv in a different branch if ( $borrowerinfo->{'branchcode'} ne C4::Context->userenv->{'branch'} ) { - $messages = 1; $diffbranch = 1; } @@ -164,11 +160,8 @@ if ($borrowernumber_hold && !$action) { borrowercategory => $borrowerinfo->{'category'}, borrowerreservs => $count_reserv, cardnumber => $borrowerinfo->{'cardnumber'}, - maxreserves => $maxreserves, expiry => $expiry, diffbranch => $diffbranch, - messages => $messages, - warnings => $warnings ); } @@ -190,18 +183,15 @@ my @biblioloop = (); foreach my $biblionumber (@biblionumbers) { my %biblioloopiter = (); - my $maxreserves; my $dat = GetBiblioData($biblionumber); unless ( CanBookBeReserved($borrowerinfo->{borrowernumber}, $biblionumber) ) { - $warnings = 1; $maxreserves = 1; } my $alreadypossession; if (not C4::Context->preference('AllowHoldsOnPatronsPossessions') and CheckIfIssuedToPatron($borrowerinfo->{borrowernumber},$biblionumber)) { - $warnings = 1; $alreadypossession = 1; } @@ -223,15 +213,12 @@ foreach my $biblionumber (@biblionumbers) { if ( $holds_count ) { $alreadyreserved = 1; - $warnings = 1; $biblioloopiter{warn} = 1; $biblioloopiter{alreadyres} = 1; } - $template->param( alreadyreserved => $alreadyreserved, - messages => $messages, - warnings => $warnings, - maxreserves => $maxreserves, + $template->param( + alreadyreserved => $alreadyreserved, alreadypossession => $alreadypossession, ); @@ -456,7 +443,6 @@ foreach my $biblionumber (@biblionumbers) { $template->param( override_required => 1 ); } elsif ( $num_available == 0 ) { $template->param( none_available => 1 ); - $template->param( warnings => 1 ); $biblioloopiter{warn} = 1; $biblioloopiter{none_avail} = 1; } @@ -591,6 +577,7 @@ foreach my $biblionumber (@biblionumbers) { $template->param( biblioloop => \@biblioloop ); $template->param( biblionumbers => $biblionumbers ); +$template->param( maxreserves => $maxreserves ); if ($multihold) { $template->param( multi_hold => 1 ); -- 2.39.5