From e6c573180680d28d0457efe9b9ce27fd595223de Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 10 May 2018 11:40:11 -0300 Subject: [PATCH] Bug 20724: Move the ReservesNeedReturns logic to AddReserve Signed-off-by: Victor Grousset Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart (cherry picked from commit 1798d22e764bebf46e2915e1c0b7c3360ea8dd51) Signed-off-by: Fridolin Somers (cherry picked from commit 04ca9e923f4b5d0f0c8f78b9e08742b899dd7d3f) Signed-off-by: Fridolin Somers --- C4/Reserves.pm | 10 ++++++++++ opac/opac-reserve.pl | 6 ------ reserve/placerequest.pl | 12 ------------ 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 2f480cac8e..ec555c849d 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -178,6 +178,16 @@ sub AddReserve { $expdate = output_pref({ str => $expdate, dateonly => 1, dateformat => 'iso' }); + # if we have an item selectionned, and the pickup branch is the same as the holdingbranch + # of the document, we force the value $priority and $found . + if ( $checkitem and not C4::Context->preference('ReservesNeedReturns') ) { + $priority = 0; + my $item = Koha::Items->find( $checkitem ); # FIXME Prevent bad calls + if ( $item->holdingbranch eq $branch ) { + $found = 'W'; + } + } + if ( C4::Context->preference('AllowHoldDateInFuture') ) { # Make room in reserves for this before those of a later reserve date diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 7de7b978b9..f1baf46664 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -268,12 +268,6 @@ if ( $query->param('place_reserve') ) { my $rank = $biblioData->{rank}; if ( $itemNum ne '' ) { $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum ) eq 'OK'; - $rank = '0' unless C4::Context->preference('ReservesNeedReturns'); - my $item = GetItem($itemNum); - if ( $item->{'holdingbranch'} eq $branch ) { - $found = 'W' - unless C4::Context->preference('ReservesNeedReturns'); - } } else { $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum ) eq 'OK'; diff --git a/reserve/placerequest.pl b/reserve/placerequest.pl index 92f3c48b01..b5d4ed9162 100755 --- a/reserve/placerequest.pl +++ b/reserve/placerequest.pl @@ -69,18 +69,6 @@ foreach my $bibnum (@biblionumbers) { my $found; -# if we have an item selectionned, and the pickup branch is the same as the holdingbranch -# of the document, we force the value $rank and $found . -if (defined $checkitem && $checkitem ne ''){ - $holds_to_place_count = 1; - $rank[0] = '0' unless C4::Context->preference('ReservesNeedReturns'); - my $item = $checkitem; - $item = GetItem($item); - if ( $item->{'holdingbranch'} eq $branch ){ - $found = 'W' unless C4::Context->preference('ReservesNeedReturns'); - } -} - if ( $type eq 'str8' && $borrower ) { foreach my $biblionumber ( keys %bibinfos ) { -- 2.39.5