From 53eeaedc7fc9c5f1325ab27fb7d9cb52d1e88f69 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 28 Sep 2023 12:27:21 +0000 Subject: [PATCH] Bug 34886: [alternate] Adjust holdability checks on opac details page This patch tries to simplify some of the logic here to match that on the search results. When we don't have a patron, we fallback to determining if an item can be held buy determining whether there are any items that don't have holds disallowed at the all libraries level. We also remove items with non-holdable statuses like withdrawn etc (and check some system preferences) If we don't have a patron, then we are done, however, if we do, then we need to check each item against the policies related to that patron. This patch also removes two checks at the end: CountItemsIssued($biblionumber) $biblio->has_items_waiting_or_intransit These seem to be from bug 4319 - however, those rules are checked by IsAvailableForItemLevelRequest and are only relevant when we have a patron. These checks essentially assumed 'onshelfholds' policy of 'If any unavailable' For consistency sake I think we should follow the same logic as the results page. To test: 1 - Find a record with two items, of different types, set a 'Default checkout, hold and return policy' of 'No holds allowed' 2 - Search opac, not logged in, and verify neither the results page or details page shows the place hold button 3 - Delete that rule, make both items withdrawn 4 - Search opac, not logged in, and verify neither the results page or details page shows the place hold button 5 - Mark one item as not withdrawn 6 - Search opac, not logged in, and verify both the results page or details page shows the place hold button 7 - Log in to opac 8 - Search opac, logged in, and verify both the results page or details page shows the place hold button 9 - Place an 'On shelf holds policy' rule for that patron category of 'If any unavailable' 10 - Search opac, logged in, and verify the results and details page shows the place hold button 11 - Set the other item to not withdrawn 12 - Search opac, logged in, and verify the results page shows the place hold button, but details does not 13 - Try various other scenarios - details page should be more correct, results page is always an approximation --- opac/opac-detail.pl | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 5f5ce3013a..7cf087dde5 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -658,7 +658,13 @@ if ( C4::Context->preference('OPACAcquisitionDetails' ) ) { }; } -my $can_item_be_reserved = 0; +# Count the number of items that allow holds +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 don't have a patron, then holdable items determines holdability +my $can_holds_be_placed = $patron && $holdable_items ? 0 : $holdable_items; + my ( $itemloop_has_images, $otheritemloop_has_images ); if ( not $viewallitems and $items->count > $max_items_to_display ) { $template->param( @@ -682,7 +688,11 @@ 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; - $can_item_be_reserved = $can_item_be_reserved || $patron && IsAvailableForItemLevelRequest($item, $patron, undef); + # 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); + } # get collection code description, too my $ccode = $item->ccode; @@ -758,9 +768,7 @@ else { } } -if( $can_item_be_reserved || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { - $template->param( ReservableItems => 1 ); -} +$template->param( ReservableItems => $can_holds_be_placed ); $template->param( itemloop_has_images => $itemloop_has_images, @@ -788,10 +796,8 @@ if( C4::Context->preference('ArticleRequests') ) { $template->param( artreqpossible => $artreqpossible ); } -my $norequests = ! $biblio->items->filter_by_for_hold->count; $template->param( MARCNOTES => $marcnotesarray, - norequests => $norequests, itemdata_ccode => $itemfields{ccode}, itemdata_materials => $itemfields{materials}, itemdata_enumchron => $itemfields{enumchron}, -- 2.30.2