From 4068b889f8b745d72aea41688474b2d57f4d9c8f Mon Sep 17 00:00:00 2001 From: Shi Yao Wang Date: Wed, 27 Apr 2022 12:44:39 -0400 Subject: [PATCH] Bug 30556: Place hold button doesn't show when not allowed When On shelf holds allowed is on "If all unavailable", the Place hold button is not shown. To test: 1. Create a circulation rule with on shelf holds set to "If all unavailable" 2. Create or modify a record to match the items itype to the circulation rule 3. Use a patron matching the circ rule category to log into the opac 4. Look for the record 5. Notice that the Place hold button is there, even thought it's not allowed 6. Apply the patch. 7. The button is not there. 8. Logout of the opac. 9. The button is here again since it should always show when not logged in. Signed-off-by: David Nind Signed-off-by: David Nind --- opac/opac-ISBDdetail.pl | 12 +++++++----- opac/opac-MARCdetail.pl | 12 +++++++----- opac/opac-detail.pl | 12 ++++++------ 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl index b3b29deea7..3f9446583a 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 CanBookBeReserved ); use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials ); use C4::Koha qw( GetNormalizedEAN @@ -168,7 +168,8 @@ $template->param( subscriptionsnumber => $subscriptionsnumber, ); -my $allow_onshelf_holds; +my $currentbranch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef; +my $is_available; my $res = GetISBDView({ 'record' => $record, 'template' => 'opac', @@ -178,11 +179,12 @@ 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; + $is_available = IsAvailableForItemLevelRequest($item, $patron, $currentbranch) + unless $is_available; } -if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { +my $canReserve = CanBookBeReserved($loggedinuser, $biblionumber, $currentbranch); +if (!$loggedinuser || ($canReserve->{status} eq "OK" && $is_available)) { $template->param( ReservableItems => 1 ); } diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index f55d6bf5ef..089d978ca5 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 CanBookBeReserved ); use C4::Members; use C4::Koha qw( GetNormalizedISBN ); use List::MoreUtils qw( uniq ); @@ -136,15 +136,17 @@ $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 $currentbranch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef; +my $is_available; $items->reset; while ( my $item = $items->next ) { - $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) - unless $allow_onshelf_holds; + $is_available = IsAvailableForItemLevelRequest($item, $patron, $currentbranch) + unless $is_available; } -if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { +my $canReserve = CanBookBeReserved($loggedinuser, $biblionumber, $currentbranch); +if (!$loggedinuser || ($canReserve->{status} eq "OK" && $is_available)) { $template->param( ReservableItems => 1 ); } diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 98c4f94a8c..61c3f3c121 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 CanBookBeReserved ); 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 $is_available; my ( $itemloop_has_images, $otheritemloop_has_images ); if ( not $viewallitems and $items->count > $max_items_to_display ) { $template->param( @@ -682,9 +682,8 @@ 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; + $is_available = IsAvailableForItemLevelRequest($item, $patron, $currentbranch) + unless $is_available; # get collection code description, too my $ccode = $item->ccode; @@ -759,7 +758,8 @@ else { } } -if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { +my $canReserve = CanBookBeReserved($borrowernumber, $biblionumber, $currentbranch); +if (!$borrowernumber || ($canReserve->{status} eq "OK" && $is_available)) { $template->param( ReservableItems => 1 ); } -- 2.34.1