diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc
index a0b0cd1ac2..6e5f23abfd 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc
@@ -1,12 +1,10 @@
[% USE raw %]
[% USE Biblio %]
- [% UNLESS ( norequests ) %]
- [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
- [% IF Koha.Preference( 'OPACHoldRequests' ) == 1 %]
- [% IF ( ReservableItems ) %]
- - Place hold
- [% END %]
+ [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
+ [% IF Koha.Preference( 'OPACHoldRequests' ) == 1 %]
+ [% IF ( ReservableItems ) %]
+ - Place hold
[% END %]
[% END %]
[% END %]
diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl
index 86685f9239..b0dd51de30 100755
--- a/opac/opac-ISBDdetail.pl
+++ b/opac/opac-ISBDdetail.pl
@@ -168,29 +168,29 @@ $template->param(
subscriptionsnumber => $subscriptionsnumber,
);
-my $can_item_be_reserved = 0;
my $res = GetISBDView({
'record' => $record,
'template' => 'opac',
'framework' => $biblio->frameworkcode
});
-my $items = $biblio->items;
-while ( my $item = $items->next ) {
+# Count the number of items that allow holds at the 'All libraries' rule level
+my $holdable_items = $biblio->items->filter_by_for_hold->count;
- $can_item_be_reserved = $can_item_be_reserved || $patron && IsAvailableForItemLevelRequest( $item, $patron, undef );
+# If we have a patron we need to check their policies for holds in the loop below
+# If we don't have a patron, then holdable items determines holdability
+my $can_holds_be_placed = $patron ? 0 : $holdable_items;
+if ($patron) {
+ my $items = $biblio->items;
+ while ( my $item = $items->next ) {
+ $can_holds_be_placed = $can_holds_be_placed || IsAvailableForItemLevelRequest( $item, $patron, undef );
+ }
}
-if( $can_item_be_reserved || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
- $template->param( ReservableItems => 1 );
-}
-
-my $norequests = ! $items->filter_by_for_hold->count;
-
$template->param(
- norequests => $norequests,
- ISBD => $res,
- biblio => $biblio,
+ ReservableItems => $can_holds_be_placed,
+ ISBD => $res,
+ biblio => $biblio,
);
#Search for title in links
diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl
index 0829341d73..bac3cc2efb 100755
--- a/opac/opac-MARCdetail.pl
+++ b/opac/opac-MARCdetail.pl
@@ -136,16 +136,21 @@ $template->param(
) if $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} <= 0 && # <=0 OPAC visible.
$tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8; # except -8;
-my $can_item_be_reserved = 0;
-$items->reset;
+# Count the number of items that allow holds at the 'All libraries' rule level
+my $holdable_items = $biblio->items->filter_by_for_hold->count;
-while ( my $item = $items->next ) {
- $can_item_be_reserved = $can_item_be_reserved || $patron && IsAvailableForItemLevelRequest( $item, $patron, undef );
+# If we have a patron we need to check their policies for holds in the loop below
+# If we don't have a patron, then holdable items determines holdability
+my $can_holds_be_placed = $patron ? 0 : $holdable_items;
+
+if ($patron) {
+ $items->reset;
+ while ( my $item = $items->next ) {
+ $can_holds_be_placed = $can_holds_be_placed || IsAvailableForItemLevelRequest( $item, $patron, undef );
+ }
}
-if( $can_item_be_reserved || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
- $template->param( ReservableItems => 1 );
-}
+$template->param( ReservableItems => $can_holds_be_placed );
# fill arrays
my @loop_data = ();
diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl
index 7cf087dde5..5b8d6524c1 100755
--- a/opac/opac-detail.pl
+++ b/opac/opac-detail.pl
@@ -658,12 +658,12 @@ if ( C4::Context->preference('OPACAcquisitionDetails' ) ) {
};
}
-# Count the number of items that allow holds
+# Count the number of items that allow holds at the 'All libraries' rule level
my $holdable_items = $biblio->items->filter_by_for_hold->count;
-# If we have a patron and there are no holdable items - we set to no
-# If we have a patron and there are holdable items we set to no - and we need to check each item specifically
+
+# If we have a patron we need to check their policies for holds in the loop below
# If we don't have a patron, then holdable items determines holdability
-my $can_holds_be_placed = $patron && $holdable_items ? 0 : $holdable_items;
+my $can_holds_be_placed = $patron ? 0 : $holdable_items;
my ( $itemloop_has_images, $otheritemloop_has_images );
if ( not $viewallitems and $items->count > $max_items_to_display ) {
@@ -688,11 +688,10 @@ 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;
- # We only need to check if we haven't determined holds can be place, and there are items that can
- # be held, and we have a patron to determine holdability
- if( !$can_holds_be_placed && $holdable_items && $patron ){
- $can_holds_be_placed = IsAvailableForItemLevelRequest($item, $patron, undef);
- }
+ # We only need to check if we haven't determined holds can be placed
+ # and if we don't have patron, we have already decided
+ $can_holds_be_placed =
+ $can_holds_be_placed || $patron && IsAvailableForItemLevelRequest( $item, $patron, undef );
# get collection code description, too
my $ccode = $item->ccode;
@@ -768,9 +767,8 @@ else {
}
}
-$template->param( ReservableItems => $can_holds_be_placed );
-
$template->param(
+ ReservableItems => $can_holds_be_placed,
itemloop_has_images => $itemloop_has_images,
otheritemloop_has_images => $otheritemloop_has_images,
);