From d134dbf4f11f8ed091c80eeae70d696f741c7376 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 28 Sep 2023 13:14:54 +0000 Subject: [PATCH] Bug 34886: Adjust other opac detail scripts Same chanegs as before, but for MARC and ISBD details pages Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer --- .../en/includes/opac-detail-sidebar.inc | 10 +++---- opac/opac-ISBDdetail.pl | 26 +++++++++---------- opac/opac-MARCdetail.pl | 19 +++++++++----- opac/opac-detail.pl | 20 +++++++------- 4 files changed, 38 insertions(+), 37 deletions(-) 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 05c09a938d..1407f5af5b 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( $can_item_be_reserved || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { - $template->param( ReservableItems => 1 ); +# 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 ); + } } -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,17 +136,22 @@ $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( $can_item_be_reserved || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { - $template->param( ReservableItems => 1 ); +if ($patron) { + $items->reset; + while ( my $item = $items->next ) { + $can_holds_be_placed = $can_holds_be_placed || IsAvailableForItemLevelRequest( $item, $patron, undef ); + } } +$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 e1d3f5cefc..36c2670b2a 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -662,12 +662,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 ) { @@ -692,11 +692,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; @@ -772,9 +771,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, ); -- 2.39.5