Bug 22650: Prevent multiple holds on individual items
authorNick Clemens <nick@bywatersolutions.com>
Wed, 24 Apr 2019 15:12:17 +0000 (15:12 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 26 Apr 2019 15:17:30 +0000 (16:17 +0100)
This patch corrects a missing id on the holds_to_place field and adds code to disable the box when an item is checked

Additionally script login now places a single hold if an itemnumebr is passed and checks for holdability of the specific item

To test:
 1 - Allow multiple holds per record in circ rules
 2 - In staff client, go to place a hold on a record
 3 - Select a patron
 4 - Increase the number of holds
 5 - Then select a specific item to hold
 6 - Patron now has multiple holds on a single item
 7 - Apply patch
 8 - Repeat, notice that count is disabled when item checked
 9 - Confirm count is enabled when 'Hold next available item' is checked
10 - Set number to more than 1
11 - Check an item and submit
12 - Confirm only one item is reserved
13 - Hit the script directly (with valid info):
     http://localhost:8081/cgi-bin/koha/reserve/placerequest.pl?biblionumber=1&checkitem=1&holds_to_place_count=2&borrowernumber=5
14 - Confirm only one hold is placed
15 - Confirm multiple hits of the url do not generate further holds

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit ef5adaff5ac045000b90c4b2b121d8c2ce2d5c59)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

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

index ce0f2cd..6244e3b 100644 (file)
           [% IF remaining_holds_for_record > 1 %]
               <li>
                    <label for="holds_to_place_count">Holds to place (count)</label>
-                   <input type="number" name="holds_to_place_count" min="1" max="[% remaining_holds_for_record | html %]" step="1" value="1" />
+                   <input id="holds_to_place_count" type="number" name="holds_to_place_count" min="1" max="[% remaining_holds_for_record | html %]" step="1" value="1" />
               </li>
             [% ELSE %]
                 <input type="hidden" name="holds_to_place_count" value="1" />
                 });
                 if(onechecked == 1){
                     $("#requestany").prop("checked", false);
+                    $("#holds_to_place_count").prop('disabled', true);
                 } else {
                     $("#requestany").prop("checked",true);
+                    $("#holds_to_place_count").prop('disabled', false);
                 }
             });
             var prev_rank_request;
index 1f061fe..31b7e8c 100755 (executable)
@@ -91,9 +91,12 @@ if ( $type eq 'str8' && $borrower ) {
             if ( $item->{'biblionumber'} ne $biblionumber ) {
                 $biblionumber = $item->{'biblionumber'};
             }
-        }
-
-        if ($multi_hold) {
+            if ( CanItemBeReserved($borrower->{'borrowernumber'}, $item->itemnumber, $branch)->{status} eq 'OK' ) {
+                AddReserve( $branch, $borrower->{'borrowernumber'},
+                    $biblionumber, \@realbi, $rank[0], $startdate, $expirationdate, $notes, $title,
+                    $checkitem, $found, $itemtype );
+            }
+        } elsif ($multi_hold) {
             my $bibinfo = $bibinfos{$biblionumber};
             if ( CanBookBeReserved($borrower->{'borrowernumber'}, $biblionumber)->{status} eq 'OK' ) {
                 AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,[$biblionumber],