From 7dd868bfcd019667255a95b461b997e416884c31 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 18 Oct 2016 14:02:58 +0100 Subject: [PATCH] Bug 17453: Inter-site holds improvement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At the moment users can reserve items and choose any library as a pick up location, but there is no mechanism to prevent users from reserving items that are available on the shelf at any given location from reserving the item at the same location, essentially creating a Fetch and Collect scenario. This has an impact on staff workloads as they are having to process reservations and check shelves for items that students can already come and collect from the open library shelves. The aim of this enhancement is to decrease the impact on staff workload there should be a restriction in place that prevents users from requesting items for collection at a library where the item is currently available. Implementation: We first tried to add a new circulation rule adding a 4th “NotIfAvailableAtPickupLibrary” option to "On shelf holds allowed". That would make the development more flexible. But in that case we quickly faced non-trivial problematics: Let's say you have 3 items I1, I2 and I3. The first one has onshelfholds set to Yes and 2 others has it set to “NotIfAvailableAtPickupLibrary”. What would be the expected behavior if a hold is placed at biblio level? And if a hold is placed at item level for I1? This second point could be answered by reworking the interface to move the libraries dropdown list elsewhere (1 list per item) or by adding a lot of JS code to handle the different situation. But it would be much more complicated to implement. So finally I moved back to the simple approach and added a new pref to handle the behavior globally. Test plan: 0/ Switch off OPACHoldsIfAvailableAtPickup 1/ Let's say you have 3 libraries L1, L2, L3, create 2 items owned by L1 and L2 2/ Place a biblio level hold. You should only be able to pick it up at L3 2/ Place a item level hold. You should only be able to pick it up at L3 3/ Create a third items owned by L3 4/ Now you should not be able to place a hold on this record anymore Sponsored-by: University of the Arts London Signed-off-by: Nick Clemens https://bugs.koha-community.org/show_bug.cgi?id=14753 --- .../opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 11 ++++++++++- opac/opac-reserve.pl | 23 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt index c0dd300..7bb7bd2 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -219,7 +219,16 @@ [% ELSE %] [% END # / UNLESS bibitemloo.holdable %] diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index f1fe2ff..1ba5ab3 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -278,6 +278,10 @@ if ( $query->param('place_reserve') ) { $canreserve = 0; } + unless ( C4::Context->preference('OPACHoldsIfAvailableAtPickup') ) { + $canreserve = 0 if Koha::Items->search({ biblionumber => $biblioNum, holdingbranch => $branch })->count; + } + my $itemtype = $query->param('itemtype') || undef; $itemtype = undef if $itemNum; @@ -378,6 +382,7 @@ $template->param('item_level_itypes' => $itemLevelTypes); foreach my $biblioNum (@biblionumbers) { + my @not_available_at = (); my $record = GetMarcBiblio($biblioNum); # Init the bib item with the choices for branch pickup my %biblioLoopIter; @@ -520,6 +525,10 @@ foreach my $biblioNum (@biblionumbers) { $biblioLoopIter{force_hold} = 1 if $hold_allowed eq 'F'; } $numCopiesAvailable++; + + if ( not C4::Context->preference('OPACHoldsIfAvailableAtPickup') ) { + push @not_available_at, $itemInfo->{holdingbranch}; + } } $itemLoopIter->{imageurl} = getitemtypeimagelocation( 'opac', $itemTypes->{ $itemInfo->{itype} }{imageurl} ); @@ -548,6 +557,20 @@ foreach my $biblioNum (@biblionumbers) { $biblioLoopIter{already_patron_possession} = 1; } + if ( $biblioLoopIter{holdable} ) { + @not_available_at = uniq @not_available_at; + $biblioLoopIter{not_available_at} = \@not_available_at ; + } + + unless ( C4::Context->preference('OPACHoldsIfAvailableAtPickup') ) { + @not_available_at = uniq @not_available_at; + $biblioLoopIter{not_available_at} = \@not_available_at ; + # The record is not holdable is not available at any of the libraries + if ( Koha::Libraries->search->count == @not_available_at ) { + $biblioLoopIter{holdable} = 0; + } + } + $biblioLoopIter{holdable} &&= CanBookBeReserved($borrowernumber,$biblioNum) eq 'OK'; # For multiple holds per record, if a patron has previously placed a hold, -- 2.1.4