Bug 14695 - Warn librarian if max_holds_per_record is reached
authorAlex Arnaud <alex.arnaud@biblibre.com>
Wed, 27 Jan 2016 15:48:02 +0000 (16:48 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Sat, 3 Sep 2016 00:21:22 +0000 (00:21 +0000)
Signed-off-by: Jason M. Burds <JBurds@dubuque.lib.ia.us>
Signed-off-by: Benjamin Rokseth <benjamin.rokseth@kul.oslo.kommune.no>

koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
reserve/request.pl

index e4e5467..b5fca88 100644 (file)
@@ -253,7 +253,7 @@ function checkMultiHold() {
     </form>
   [% ELSIF NOT noitems %]
 
-[% IF ( exceeded_maxreserves || alreadyreserved || none_available || alreadypossession || ageRestricted ) %]
+[% IF ( exceeded_maxreserves || exceeded_holds_per_record || alreadyreserved || none_available || alreadypossession || ageRestricted ) %]
     <div class="dialog alert">
 
     [% UNLESS ( multi_hold ) %]
@@ -261,6 +261,8 @@ function checkMultiHold() {
       <ul>
         [% IF ( exceeded_maxreserves ) %]
           <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %] </a> can only place a maximum of [% maxreserves %] total holds.</li>
+        [% ELSIF ( exceeded_holds_per_record ) %]
+          <li><strong>Too many holds for this record: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %] </a> can only place a maximum of [% max_holds_for_record %] hold(s) on this record.</li>
         [% ELSIF ( alreadypossession ) %]
           <li> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> <strong>is already in possession</strong> of one item</lie
         [% ELSIF ( alreadyreserved ) %]
@@ -277,6 +279,12 @@ function checkMultiHold() {
         <h3>Cannot place hold on some items</h3>
         [% IF ( exceeded_maxreserves ) %]
           <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %] </a> can place [% new_reserves_allowed %] of the requested [% new_reserves_count %] holds for a maximum of [% maxreserves %] total holds.</li>
+        [% ELSIF ( exceeded_holds_per_record ) %]
+            [% FOREACH biblioloo IN biblioloop %]
+                [% IF (biblioloo.tooManyHoldsForThisRecord) %]
+                    <li><strong>Too many holds for <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber %]"> [% biblioloo.title %]</a>: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %] </a> can only place a maximum of [% max_holds_for_record %] hold(s) on this record.</li>
+                [% END %]
+            [% END %]
         [% END %]
     [% END %]
 
@@ -406,12 +414,12 @@ function checkMultiHold() {
                <input type="hidden" name="alreadyreserved" value="[% alreadyreserved %]" />
           </li>
 
-          [% IF max_holds_for_record > 1 %]
+          [% IF remaining_holds_for_record > 1 %]
               [% SET count = 1 %]
               <li>
                    <label for="holds_to_place_count">Holds to place (count)</label>
                    <select name="holds_to_place_count" id="holds_to_place_count">
-                   [% WHILE count <= max_holds_for_record %]
+                   [% WHILE count <= remaining_holds_for_record %]
                         <option value="[% count %]">[% count %]</option>
                         [% SET count = count + 1 %]
                    [% END %]
index b44493f..1b6554c 100755 (executable)
@@ -82,6 +82,7 @@ my $messageborrower;
 my $warnings;
 my $messages;
 my $exceeded_maxreserves;
+my $exceeded_holds_per_record;
 
 my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
 my $action = $input->param('action');
@@ -227,6 +228,10 @@ foreach my $biblionumber (@biblionumbers) {
     elsif ( $canReserve eq 'tooManyReserves' ) {
         $exceeded_maxreserves = 1;
     }
+    elsif ( $canReserve eq 'tooManyHoldsForThisRecord' ) {
+        $exceeded_holds_per_record = 1;
+        $biblioloopiter{$canReserve} = 1;
+    }
     elsif ( $canReserve eq 'ageRestricted' ) {
         $template->param( $canReserve => 1 );
         $biblioloopiter{$canReserve} = 1;
@@ -256,9 +261,10 @@ foreach my $biblionumber (@biblionumbers) {
         # For a librarian to be able to place multiple record holds for a patron for a record,
         # we must find out what the maximum number of holds they can place for the patron is
         my $max_holds_for_record = GetMaxPatronHoldsForRecord( $borrowerinfo->{borrowernumber}, $biblionumber );
-        $max_holds_for_record = $max_holds_for_record - $holds->count();
-        $biblioloopiter{max_holds_for_record} = $max_holds_for_record;
+        my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
+        $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record;
         $template->param( max_holds_for_record => $max_holds_for_record );
+        $template->param( remaining_holds_for_record => $remaining_holds_for_record );
     }
 
     # Check to see if patron is allowed to place holds on records where the
@@ -635,6 +641,7 @@ foreach my $biblionumber (@biblionumbers) {
 $template->param( biblioloop => \@biblioloop );
 $template->param( biblionumbers => $biblionumbers );
 $template->param( exceeded_maxreserves => $exceeded_maxreserves );
+$template->param( exceeded_holds_per_record => $exceeded_holds_per_record );
 
 if ($multihold) {
     $template->param( multi_hold => 1 );