From 21c9f670fd48cd3a9dfb297021715cfa8fc8bb82 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 31 Oct 2016 11:16:05 +0000 Subject: [PATCH] Bug 17453: Allow pickup at a library where all items are checked out If all items are checked out then it should be possible to select the pickup library for that record. --- opac/opac-reserve.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 63f0c80..3b4c431 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -285,7 +285,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; @@ -532,7 +536,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}; + } } } -- 2.1.4