Bug 35573: Correctly display warning when placing a hold

Test plan:

1) Add a basic circulation rule like : 0 hold allowed on patron category
   'A' and set AllowHoldPolicyOverride to 'Allow'
2) Make a hold on a patron belongs to this category
3) Normally you should see a warning on item (override needed) but it's
   not the case
4) Apply this patch
5) Refresh and repeat step 2

This patch comes from an alternative patch on the original bug (I'm including
the original test plan for your information) :

(Bug 30687 - alternative patch): Always allow to force hold pickup location

If AllowHoldPolicyOverride is enabled and only some pickup locations are
available, you still have the possibility to force one of the others
pickup locations.
But when there are zero pickup locations available, that is not
possible.

This patch change that by always displaying the list of pickup locations
when AllowHoldPolicyOverride is enabled.

Test plan:
1. Apply patch
2. Disable AllowHoldPolicyOverride
3. Create a biblio B with an item I at library A.
4. Configure this library A to not be a pickup location
5. Add a "Default holds policy by item type" for item I type where "Hold
   pickup library match" is "item's home library"
6. Try to place a hold on biblio B
   You should not be able to place a hold because there is no valid
   pickup locations
7. Enable AllowHoldPolicyOverride
8. Try to place a hold on biblio B
   You should now see all valid pickup locations in a dropdown list
   (with an exclamation mark in front of each option) with none selected
   by default
9. Verify you can place a title-level hold and an item-level hold

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 805ea1a00e)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 204b5c76ce)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Julian Maurice 2022-09-07 11:24:49 +02:00 committed by Lucas Gass
parent 1697c8adcf
commit a66c9e2944
2 changed files with 4 additions and 4 deletions

View file

@ -789,7 +789,7 @@
[% END # /IF force_hold_level %]
</td>
<td>
[% IF (itemloo.pickup_locations_count > 0) %]
[% IF (itemloo.pickup_locations_count > 0) || Koha.Preference('AllowHoldPolicyOverride') %]
<select name="item_pickup_[% itemloo.itemnumber | html %]" class="pickup_locations" style="width:100%;"
data-item-id="[% itemloo.itemnumber | html %]"
data-patron-id="[% patron.borrowernumber | html %]"
@ -1507,7 +1507,7 @@
msg = (_("- Please select an item to place a hold") + "\n");
}
} else {
if( $("#pickup").length < 1 || $("#pickup").val() == "" ){
if( $("#pickup").length < 1 || $("#pickup").val() == "" || $('#pickup').val() === null ){
msg = _("- Please select a pickup location for this hold" + "\n");
}
}

View file

@ -512,7 +512,7 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold )
# Send the pickup locations count to the UI, the pickup locations will be pulled using the API
my $pickup_locations = $item_object->pickup_locations({ patron => $patron });
$item->{pickup_locations_count} = $pickup_locations->count;
if ( $item->{pickup_locations_count} > 0 ) {
if ( $item->{pickup_locations_count} > 0 || C4::Context->preference('AllowHoldPolicyOverride') ) {
$num_items_available++;
$item->{available} = 1;
# pass the holding branch for use as default
@ -534,7 +534,7 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold )
my @pickup_locations = $item_object->pickup_locations({ patron => $patron })->as_list;
$item->{pickup_locations_count} = scalar @pickup_locations;
if ( @pickup_locations ) {
if ( @pickup_locations || C4::Context->preference('AllowHoldPolicyOverride') ) {
$num_items_available++;
$item->{override} = 1;