@@ -, +, @@ --- .../opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 11 +++++++++- opac/opac-reserve.pl | 23 ++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -219,7 +219,16 @@ [% ELSE %] [% END # / UNLESS bibitemloo.holdable %] --- a/opac/opac-reserve.pl +++ a/opac/opac-reserve.pl @@ -276,6 +276,10 @@ if ( $query->param('place_reserve') ) { $canreserve = 0; } + unless ( C4::Context->preference('OPACHoldsIfAvailableAtPickup') ) { + $canreserve = 0 if Koha::Items->search({ biblionumber => $biblioNum, holdingbranch => $branch })->count; + } + my $itemtype = $query->param('itemtype') || undef; $itemtype = undef if $itemNum; @@ -375,6 +379,7 @@ $template->param('item_level_itypes' => $itemLevelTypes); foreach my $biblioNum (@biblionumbers) { + my @not_available_at = (); my $record = GetMarcBiblio($biblioNum); # Init the bib item with the choices for branch pickup my %biblioLoopIter; @@ -517,6 +522,10 @@ foreach my $biblioNum (@biblionumbers) { $biblioLoopIter{force_hold} = 1 if $hold_allowed eq 'F'; } $numCopiesAvailable++; + + if ( not C4::Context->preference('OPACHoldsIfAvailableAtPickup') ) { + push @not_available_at, $itemInfo->{holdingbranch}; + } } $itemLoopIter->{imageurl} = getitemtypeimagelocation( 'opac', $itemTypes->{ $itemInfo->{itype} }{imageurl} ); @@ -545,6 +554,20 @@ foreach my $biblioNum (@biblionumbers) { $biblioLoopIter{already_patron_possession} = 1; } + if ( $biblioLoopIter{holdable} ) { + @not_available_at = uniq @not_available_at; + $biblioLoopIter{not_available_at} = \@not_available_at ; + } + + unless ( C4::Context->preference('OPACHoldsIfAvailableAtPickup') ) { + @not_available_at = uniq @not_available_at; + $biblioLoopIter{not_available_at} = \@not_available_at ; + # The record is not holdable is not available at any of the libraries + if ( Koha::Libraries->search->count == @not_available_at ) { + $biblioLoopIter{holdable} = 0; + } + } + $biblioLoopIter{holdable} &&= CanBookBeReserved($borrowernumber,$biblioNum) eq 'OK'; # For multiple holds per record, if a patron has previously placed a hold, --