Bug 20724: Move the ReservesNeedReturns logic to AddReserve
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 10 May 2018 14:40:11 +0000 (11:40 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 16 May 2018 13:53:13 +0000 (10:53 -0300)
Signed-off-by: Victor Grousset <victor.grousset@biblibre.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

C4/Reserves.pm
opac/opac-reserve.pl
reserve/placerequest.pl

index a919f75..c0a977f 100644 (file)
@@ -171,6 +171,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
index 4a0dbb9..c290ea4 100755 (executable)
@@ -272,12 +272,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';
index 3c55656..351041b 100755 (executable)
@@ -70,18 +70,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 ) {