Bug 22284: New message, new column and filter pickup locations in reserve/request.tt
authorAgustin Moyano <agustinmoyano@theke.io>
Thu, 4 Apr 2019 04:10:16 +0000 (01:10 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 3 Jan 2020 12:58:05 +0000 (12:58 +0000)
This patch adds a new message to 'Hold' column in 'Place a hold on a specific item' table.

The message is "Cannot place hold from patrons's library". It appears when patron's homebranch is not in item's hold group, and hold_fulfillment_policy is set to 'holdgroup'.

This patch also adds a new column "Allowed pickup locations" that lists allowed pickup locations per item.

Finally, the select that displays pickup locations is filtered by allowed pickup locations, when multi_hold is not enabled

To test:
1) Apply this patch
2) In library groups add a root group and check it as hold group.
3) Add two libraries to the group
4) In circulation and fines rules, in 'Default checkout, hold and return policy', in Hold policy change the value to 'From local hold group'
5) Search a patron from a different library than step 3, select one and click 'search to hold'
6) Search by location for items in any library of step 3
7) On any item, clic on 'Place hold for ...'
SUCCESS => when the page is loaded, in the 'Place a hold on a specific item', you should see the message "Cannot place hold from patrons's library" in 'Hold' column
=> You should see a new column called "Allowed pickup locations" and the message is "Any library"
8) In circulation and fines rules, in 'Default checkout, hold and return policy', in 'Hold policy' change the value again to 'From any library' and change 'Hold pickup library match' to "Item's hold group"
8) Repeat steps 5 to 7
SUCCESS => when the page is loaded, you should see the "Pickup at" select filtered by libraries in hold group
=> You should see in "Allowed pickup locations" a coma separated list of the libraries in item's hold group
=> If biblio has an item whose control branch is not in a hold group, you should see the control branch name in "Allowed pickup locations"
9) Sign off

Sponsored-by: VOKAL
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

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

index 43c0f2a..4b3d20c 100644 (file)
                             <li>
                                 <label for="pickup">Pickup at:</label>
                                 <select name="pickup" size="1" id="pickup">
-                                    [% PROCESS options_for_libraries libraries => Branches.all({ selected => pickup, search_params => { pickup_location => 1 } }) %]
+                                    [% UNLESS ( multi_hold ) %]
+                                       [% PROCESS options_for_libraries libraries => Branches.pickup_locations({ search_params => { biblio => biblionumber, patron => patron }, selected => pickup }) %]
+                                   [% ELSE %]
+                                       [% PROCESS options_for_libraries libraries => Branches.all({ selected => pickup, search_params => { pickup_location => 1 } }) %]
+                                   [% END %]
                                 </select>
                             </li>
 
                                                 <th>Vol no.</th>
                                             [% END %]
                                             <th class="title-string">Information</th>
+                                           <th class="title-string">Allowed pickup locations</th>
                                         </tr>
                                     </thead>
                                     <tbody>
                                                                         Not holdable
                                                                     [% ELSIF itemloo.not_holdable == 'cannotReserveFromOtherBranches' %]
                                                                         Patron is from different library
+                                                                   [% ELSIF itemloo.not_holdable == 'branchNotInHoldGroup' %]
+                                                                       Cannot place hold from patrons's library
                                                                     [% ELSIF itemloo.not_holdable == 'itemAlreadyOnHold' %]
                                                                         Patron already has hold for this item
                                                                     [% ELSIF itemloo.not_holdable == 'cannotBeTransferred' %]
                                                            <span class="nfl">Not for loan ([% AuthorisedValues.GetByCode( 'NOT_LOAN', itemloo.notforloan ) | html %])</span>
                                                         [% END %]
                                                     </td>
+                                                   <td>
+                                                       [% itemloo.pickup_locations | html %]
+                                                   </td>
                                                 </tr>
                                             [% END # / UNLESS itemloo.hide %]
                                         [% END # /FOREACH itemloo %]
index 4f80b8d..6b6b99e 100755 (executable)
@@ -298,7 +298,7 @@ foreach my $biblionumber (@biblionumbers) {
     my $force_hold_level;
     if ( $patron ) {
         { # CanBookBeReserved
-            my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber, $pickup );
+            my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber );
             if ( $canReserve->{status} eq 'OK' ) {
 
                 #All is OK and we can continue
@@ -548,8 +548,8 @@ foreach my $biblionumber (@biblionumbers) {
 
                 $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
 
-                my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber, $pickup )->{status};
-                $item->{not_holdable} = $can_item_be_reserved unless $can_item_be_reserved eq 'OK';
+                my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber )->{status};
+                $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved->{status} eq 'OK' );
 
                 $item->{item_level_holds} = Koha::IssuingRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
 
@@ -562,6 +562,11 @@ foreach my $biblionumber (@biblionumbers) {
                 {
                     $item->{available} = 1;
                     $num_available++;
+                    if($branchitemrule->{'hold_fulfillment_policy'} eq 'any' ) {
+                        $item->{pickup_locations} = 'Any library';
+                    } else {
+                        $item->{pickup_locations} = join (', ', map { $_->{branchname} } Koha::Items->find($itemnumber)->pickup_locations());
+                    }
 
                     push( @available_itemtypes, $item->{itype} );
                 }