From 642480e2478fa2af4a96bec577c92721f2596052 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 c902f849c4..353d250948 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 ); @@ -139,15 +139,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; 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-detail.pl b/opac/opac-detail.pl index 9e9c0eadb0..8da2474eca 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -61,7 +61,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 ); @@ -671,7 +671,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( @@ -685,9 +685,8 @@ else { $item->{holds_count} = $item_reserves{ $item->itemnumber }; $item->{priority} = $priority{ $item->itemnumber }; - $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; @@ -783,7 +782,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.25.1