@@ -, +, @@ opac-reserve.pl --- opac/opac-reserve.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/opac/opac-reserve.pl +++ a/opac/opac-reserve.pl @@ -476,6 +476,8 @@ foreach my $biblioNum (@biblionumbers) { # (before this loop was inside that sub loop so it was O(n^2) ) my $items_any_available; $items_any_available = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblioNum, patron => $patron }) if $patron; + my $can_book_be_reserved = CanBookBeReserved( $borrowernumber, $biblioNum, undef, { return_all_items => 1 }); + warn Data::Dumper::Dumper($can_book_be_reserved); foreach my $itemInfo (@{$biblioData->{itemInfos}}) { my $itemNum = $itemInfo->{itemnumber}; my $item = $visible_items->{$itemNum}; @@ -566,7 +568,7 @@ foreach my $biblioNum (@biblionumbers) { # items_any_available defined outside of the current loop, # so we avoiding loop inside IsAvailableForItemLevelRequest: $policy_holdallowed &&= - CanItemBeReserved( $patron, $item )->{status} eq 'OK' && + $can_book_be_reserved->{$item->itemnumber}->{status} eq 'OK' && IsAvailableForItemLevelRequest($item, $patron, undef, $items_any_available); if ($policy_holdallowed) { @@ -629,7 +631,7 @@ foreach my $biblioNum (@biblionumbers) { } } - my $status = CanBookBeReserved( $borrowernumber, $biblioNum )->{status}; + my $status = $can_book_be_reserved->{status}; $biblioLoopIter{holdable} &&= $status eq 'OK'; $biblioLoopIter{already_patron_possession} = $status eq 'alreadypossession'; --