From 7c95541a60a0454d504281a66482de9b3f0e219d 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 | 11 ++++++----- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl index 9335ea4ccd..219aafe6a2 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 @@ -167,7 +167,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', @@ -177,11 +178,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 0133784d39..728c1c76b7 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -59,7 +59,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 ); @@ -143,15 +143,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 b281c958f6..d25a4f896a 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -63,7 +63,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 ); @@ -698,7 +698,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 > $max_items_to_display ) { $template->param( @@ -711,8 +711,8 @@ if ( not $viewallitems and @items > $max_items_to_display ) { $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} }; $itm->{priority} = $priority{ $itm->{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 = $itm->{'ccode'}; @@ -776,7 +776,8 @@ if ( not $viewallitems and @items > $max_items_to_display ) { } } -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