Bugzilla – Attachment 144825 Details for
Bug 30687
Unable to override hold policy if no pickup locations are available
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30687: [alternate-alternate] Allow pickup locatoin to be forced when override is allowed
Bug-30687-alternate-alternate-Allow-pickup-locatoi.patch (text/plain), 7.71 KB, created by
Nick Clemens
on 2022-12-23 15:08:57 UTC
(
hide
)
Description:
Bug 30687: [alternate-alternate] Allow pickup locatoin to be forced when override is allowed
Filename:
MIME Type:
Creator:
Nick Clemens
Created:
2022-12-23 15:08:57 UTC
Size:
7.71 KB
patch
obsolete
>From 7ca36827006fdb6731e7ce8c03392dec20c66863 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 23 Dec 2022 15:04:26 +0000 >Subject: [PATCH] Bug 30687: [alternate-alternate] Allow pickup locatoin to be > forced when override is allowed > >This is Julian's patch with some extra cleanup to reduce repeated code > >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 >--- > .../prog/en/modules/reserve/request.tt | 4 +- > reserve/request.pl | 54 ++++++++----------- > 2 files changed, 23 insertions(+), 35 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >index e2d33c5415..a9b88388a7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -799,7 +799,7 @@ > [% END # /IF force_hold_level %] > </td> > <td> >- [% IF (itemloo.pickup_locations_count > 0) %] >+ [% IF (itemloo.pickup_locations_count > 0) || itemloo.override %] > <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 %]" >@@ -1518,7 +1518,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"); > } > } >diff --git a/reserve/request.pl b/reserve/request.pl >index e5faf1426a..7720f34425 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -503,13 +503,21 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) > $default_pickup_branch = C4::Context->userenv->{branch}; > } > >- if ( >- !$item->{cantreserve} >- && !$exceeded_maxreserves >- && $can_item_be_reserved eq 'OK' >- # items_any_available defined outside of the current loop, >- # so we avoiding loop inside IsAvailableForItemLevelRequest: >- && IsAvailableForItemLevelRequest($item_object, $patron, undef, $items_any_available) >+ if ( $can_item_be_reserved eq 'itemAlreadyOnHold' ) { >+ # itemAlreadyOnHold cannot be overridden >+ $num_alreadyheld++ >+ } >+ elsif ( >+ ( >+ !$item->{cantreserve} >+ && !$exceeded_maxreserves >+ && $can_item_be_reserved eq 'OK' >+ # items_any_available defined outside of the current loop, >+ # so we avoiding loop inside IsAvailableForItemLevelRequest: >+ && IsAvailableForItemLevelRequest($item_object, $patron, undef, $items_any_available) >+ ) || C4::Context->preference('AllowHoldPolicyOverride') >+ # If AllowHoldPolicyOverride is set, it overrides EVERY restriction >+ # not just branch item rules > ) > { > # Send the pickup locations count to the UI, the pickup locations will be pulled using the API >@@ -522,37 +530,17 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) > my $default_pickup_location = $pickup_locations->search({ branchcode => $default_pickup_branch })->next; > $item->{default_pickup_location} = $default_pickup_location; > } >+ elsif ( C4::Context->preference('AllowHoldPolicyOverride') ){ >+ $num_items_available++; >+ $item->{override} = 1; >+ my $default_pickup_location = $pickup_locations->search({ branchcode => $default_pickup_branch })->next; >+ $item->{default_pickup_location} = $default_pickup_location; >+ } > else { > $item->{available} = 0; > $item->{not_holdable} = "no_valid_pickup_location"; > } > >- push( @available_itemtypes, $item->{itype} ); >- } >- elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) { >- # If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules >- # with the exception of itemAlreadyOnHold because, you know, the item is already on hold >- if ( $can_item_be_reserved ne 'itemAlreadyOnHold' ) { >- # 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 })->as_list; >- $item->{pickup_locations_count} = scalar @pickup_locations; >- >- if ( @pickup_locations ) { >- $num_items_available++; >- $item->{override} = 1; >- >- my $default_pickup_location; >- >- ($default_pickup_location) = grep { $_->branchcode eq $default_pickup_branch } @pickup_locations; >- >- $item->{default_pickup_location} = $default_pickup_location; >- } >- else { >- $item->{available} = 0; >- $item->{not_holdable} = "no_valid_pickup_location"; >- } >- } else { $num_alreadyheld++ } >- > push( @available_itemtypes, $item->{itype} ); > } else { > # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30687
:
134625
|
137643
|
140683
|
140712
|
140713
|
143457
|
144427
|
144825
|
144896
|
148502
|
150260