Bug 17453: Allow pickup at a library where all items are checked out
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 31 Oct 2016 11:16:05 +0000 (11:16 +0000)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 17 Feb 2017 17:15:06 +0000 (17:15 +0000)
If all items are checked out then it should be possible to select the pickup
library for that record.

Signed-off-by: Janet McGowan <janet.mcgowan@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
https://bugs.koha-community.org/show_bug.cgi?id=14753

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
opac/opac-reserve.pl

index 5b28b27..f5e4130 100755 (executable)
@@ -287,7 +287,11 @@ if ( $query->param('place_reserve') ) {
         }
 
         unless ( $can_place_hold_if_available_at_pickup ) {
-            $canreserve = 0 if Koha::Items->search({ biblionumber => $biblioNum, holdingbranch => $branch })->count;
+            my $items_in_this_library = Koha::Items->search({ biblionumber => $biblioNum, holdingbranch => $branch });
+            my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count;
+            if ( $items_in_this_library->count > $nb_of_items_issued ) {
+                $canreserve = 0
+            }
         }
 
         my $itemtype = $query->param('itemtype') || undef;
@@ -535,7 +539,11 @@ foreach my $biblioNum (@biblionumbers) {
             $numCopiesAvailable++;
 
             unless ( $can_place_hold_if_available_at_pickup ) {
-                push @not_available_at, $itemInfo->{holdingbranch};
+                my $items_in_this_library = Koha::Items->search({ biblionumber => $itemInfo->{biblionumber}, holdingbranch => $itemInfo->{holdingbranch} });
+                my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count;
+                if ( $items_in_this_library->count > $nb_of_items_issued ) {
+                    push @not_available_at, $itemInfo->{holdingbranch};
+                }
             }
         }