diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 69f81df6e1..fd8f7e58bd 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1388,7 +1388,7 @@ sub IsAvailableForItemLevelRequest { return $any_available ? 0 : 1; } else { # on_shelf_holds == 0 "If any unavailable" (the description is rather cryptic and could still be improved) - return $item->onloan || IsItemOnHoldAndFound( $item->itemnumber ); + return $item->notforloan < 0 || $item->onloan || IsItemOnHoldAndFound( $item->itemnumber ); } } diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl index b3b29deea7..fb7fc05bf5 100755 --- a/opac/opac-ISBDdetail.pl +++ b/opac/opac-ISBDdetail.pl @@ -52,7 +52,7 @@ use C4::Biblio qw( GetMarcISSN TransformMarcToKoha ); -use C4::Reserves; +use C4::Reserves qw( IsAvailableForItemLevelRequest ); use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials ); use C4::Koha qw( GetNormalizedEAN @@ -168,7 +168,7 @@ $template->param( subscriptionsnumber => $subscriptionsnumber, ); -my $allow_onshelf_holds; +my $can_item_be_reserved = 0; my $res = GetISBDView({ 'record' => $record, 'template' => 'opac', @@ -178,11 +178,10 @@ my $res = GetISBDView({ my $items = $biblio->items; while ( my $item = $items->next ) { - $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) - unless $allow_onshelf_holds; + $can_item_be_reserved = $can_item_be_reserved || IsAvailableForItemLevelRequest($item, $patron, undef); } -if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { +if( $can_item_be_reserved || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { $template->param( ReservableItems => 1 ); } diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index f55d6bf5ef..c42d73abf0 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -58,7 +58,7 @@ use C4::Biblio qw( GetMarcStructure TransformMarcToKoha ); -use C4::Reserves; +use C4::Reserves qw( IsAvailableForItemLevelRequest ); use C4::Members; use C4::Koha qw( GetNormalizedISBN ); use List::MoreUtils qw( uniq ); @@ -136,15 +136,14 @@ $template->param( ) if $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} <= 0 && # <=0 OPAC visible. $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8; # except -8; -my $allow_onshelf_holds; +my $can_item_be_reserved = 0; $items->reset; while ( my $item = $items->next ) { - $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) - unless $allow_onshelf_holds; + $can_item_be_reserved = $can_item_be_reserved || IsAvailableForItemLevelRequest($item, $patron, undef); } -if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { +if( $can_item_be_reserved || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { $template->param( ReservableItems => 1 ); } diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 52e161205a..b62de56458 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -60,7 +60,7 @@ use C4::External::Syndetics qw( use C4::Members; use C4::XSLT qw( XSLTParse4Display ); use C4::ShelfBrowser qw( GetNearbyItems ); -use C4::Reserves qw( GetReserveStatus ); +use C4::Reserves qw( GetReserveStatus IsAvailableForItemLevelRequest ); use C4::Charset qw( SetUTF8Flag ); use MARC::Field; use List::MoreUtils qw( any ); @@ -658,7 +658,7 @@ if ( C4::Context->preference('OPACAcquisitionDetails' ) ) { }; } -my $allow_onshelf_holds; +my $can_item_be_reserved = 0; my ( $itemloop_has_images, $otheritemloop_has_images ); if ( not $viewallitems and $items->count > $max_items_to_display ) { $template->param( @@ -682,9 +682,7 @@ else { $item_info->{holding_library_info} = $opac_info_holding->content if $opac_info_holding; $item_info->{home_library_info} = $opac_info_home->content if $opac_info_home; - $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( - { item => $item, patron => $patron } ) - unless $allow_onshelf_holds; + $can_item_be_reserved = $can_item_be_reserved || IsAvailableForItemLevelRequest($item, $patron, undef); # get collection code description, too my $ccode = $item->ccode; @@ -760,7 +758,7 @@ else { } } -if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { +if( $can_item_be_reserved || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { $template->param( ReservableItems => 1 ); }