Bug 10247: show warning if hold blocked due to maxreserves syspre
authorFridolyn SOMERS <fridolyn.somers@biblibre.com>
Wed, 15 May 2013 09:52:57 +0000 (11:52 +0200)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 12 Aug 2013 15:02:57 +0000 (15:02 +0000)
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 <srdjan@catalyst.net.nz>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
reserve/request.pl

index a9385b2..20853b3 100644 (file)
@@ -230,7 +230,7 @@ function checkMultiHold() {
     </form>
   [% ELSE %]
 
-[% IF ( warnings ) %]
+[% IF ( maxreserves || alreadyreserved || none_available || alreadypossession ) %]
     <div class="dialog alert">
 
     [% UNLESS ( multi_hold ) %]
@@ -256,13 +256,13 @@ function checkMultiHold() {
     </div>
 [% END %]
 
-[% IF ( messages ) %]
-    <div class="dialog message"><ul>
+[% IF ( expiry || diffbranch ) %]
+<div class="dialog message"><ul>
     [% IF ( expiry ) %]
     <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a>'s <strong>account has expired</strong></li>
     [% END %]
 
-[% IF ( diffbranch ) %]
+    [% IF ( diffbranch ) %]
     <li> <strong>Pickup library is different</strong> than <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a>'s home library ([% borrower_branchname %] / [% borrower_branchcode %] )</li>
     [% END %]
 
index 11741e2..c411ce9 100755 (executable)
@@ -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 );