From 21cab8a47c4724c649e1c9b1925dea3e4533c1b5 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 5 Aug 2024 13:43:19 +0000 Subject: [PATCH] Bug 34486: Show OPAC Column Due Date only if items on loan exist This patch updates the OPAC bibliographic detail page so that in the holdings table, the following columns are hidden if they contain no data: Call number, date due, materials, checkouts, barcode, and item-level holds. To test, apply the patch and restart services. - In the staff interface, go to Administration -> System preferences. - Search for OPACShowHoldQueueDetails and set it to "Show holds and their priority level." - Search for OPACShowHoldQueueDetails and set it to "Show holds and their priority level." - In the OPAC, locate a bibliographic record with multiple items. - View the detail page and confirm that the holdings table doesn't show these columns if there is no data in any of the rows: Call number, date due, materials, barcode, and item-level holds - For each of the affected fields, update the record the record so that there is data to be shown for at least one of the items: - Edit an item to add: call number, materials specified, barcode - Check out an item to someone in order to show the date due column - Place an item-level hold on one of the items to show the item holds column. - Go to Administration -> Table settings -> OPAC -> biblio-detail and configure some columns to be hidden by default. Confirm that your changes are correctly shown in the OPAC holdings table. Sponsored-by: Athens County Public Libraries Signed-off-by: Michaela Sieber Signed-off-by: Paul Derscheid Signed-off-by: Katrin Fischer --- .../bootstrap/en/modules/opac-detail.tt | 44 ++++++++++++------- opac/opac-detail.pl | 36 +++++++++------ 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 574c139c41..b448fffeb9 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -1189,8 +1189,10 @@ [% IF ( Koha.Preference('OpacLocationOnDetail') == 'column' && itemdata_location ) %] Shelving location [% END %] + [% IF ( itemdata_itemcallnumber ) %] Call number - [% UNLESS TablesSettings.is_hidden( 'opac', 'biblio-detail', 'holdingst', 'item_materials') %] + [% END %] + [% IF ( itemdata_materials ) %] Materials specified [% END %] [% IF ( itemdata_enumchron ) %] @@ -1206,9 +1208,13 @@ [% IF ( itemdata_itemnotes ) %] Notes [% END %] + [% IF ( item_checkouts ) %] Date due + [% END %] + [% IF ( itemdata_barcode ) %] Barcode - [% IF holds_count.defined %] + [% END %] + [% IF item_level_holds > 0 %] Item holds [% ELSIF show_priority %] Item hold queue priority @@ -1311,20 +1317,22 @@ [% ITEM_RESULT.location_description | html %] [% END %] - - [% IF ( ITEM_RESULT.itemcallnumber ) %] - [% ITEM_RESULT.itemcallnumber | html %] - [% IF ( OPACShelfBrowser ) %] - [% IF ( ITEM_RESULT.itemnumber == starting_itemnumber ) %] - (Browse shelf(Opens below)) - [% ELSE %] - (Browse shelf(Opens below)) + [% IF ( itemdata_itemcallnumber ) %] + + [% IF ( ITEM_RESULT.itemcallnumber ) %] + [% ITEM_RESULT.itemcallnumber | html %] + [% IF ( OPACShelfBrowser ) %] + [% IF ( ITEM_RESULT.itemnumber == starting_itemnumber ) %] + (Browse shelf(Opens below)) + [% ELSE %] + (Browse shelf(Opens below)) + [% END %] [% END %] [% END %] - [% END %] - + + [% END %] - [% UNLESS TablesSettings.is_hidden( 'opac', 'biblio-detail', 'holdingst', 'item_materials') %] + [% IF ( itemdata_materials ) %] [% ITEM_RESULT.materials | html %] [% END %] @@ -1378,14 +1386,15 @@ [% IF ( itemdata_copynumber ) %][% ITEM_RESULT.copynumber | html %][% END %] [% INCLUDE 'item-status.inc' item = ITEM_RESULT.object include_schema_org = 1 %] [% IF ( itemdata_itemnotes ) %][% ITEM_RESULT.itemnotes | $raw %][% END %] - [% IF ITEM_RESULT.checkout %] + [% IF item_checkouts %] [% ITEM_RESULT.checkout.date_due | $KohaDates as_due_date => 1 %] - [% ELSE %] - [% END %] + [% IF ( itemdata_barcode ) %] [% ITEM_RESULT.barcode | html %] - [% IF holds_count.defined || show_priority %] + [% END %] + + [% IF item_level_holds > 0 %] [% IF holds_count.defined %] [% ITEM_RESULT.holds_count | html %] [% END %] [% IF ITEM_RESULT.priority %] @@ -1397,6 +1406,7 @@ [% END %] [% END %] + [% IF ShowCourseReservesHeader %] [% IF ITEM_RESULT.course_reserves %] diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 96c73dd1fc..3d2da21763 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -670,6 +670,8 @@ my $holdable_items = $biblio->items->filter_by_for_hold->count; my $can_holds_be_placed = $patron ? 0 : $holdable_items; my ( $itemloop_has_images, $otheritemloop_has_images ); +my $item_level_holds; +my $item_checkouts; if ( not $viewallitems and $items->count > $max_items_to_display ) { $template->param( too_many_items => 1, @@ -681,6 +683,7 @@ else { while ( my $item = $items->next ) { my $item_info = $item->unblessed; $item_info->{holds_count} = $item_reserves{ $item->itemnumber }; + if( $item_info->{holds_count} && $item_info->{holds_count} > 0 ){ $item_level_holds = 1; } $item_info->{priority} = $priority{ $item->itemnumber }; # Get opac_info from Additional contents for home and holding library @@ -721,9 +724,11 @@ else { $item_info->{'description'} = $itemtypes->{ $itemtype->itemtype }->{translated_description}; + $item_info->{checkout} = $item->checkout; + if( $item_info->{checkout} && $item_info->{checkout} > 0 ){ $item_checkouts = 1; } + foreach my $field ( - qw(ccode materials enumchron copynumber itemnotes location_description uri) - ) + qw(ccode materials enumchron copynumber itemnotes location_description uri barcode itemcallnumber)) { $itemfields{$field} = 1 if $item_info->{$field}; } @@ -735,7 +740,6 @@ else { $item_info->{serial} = $serial if $serial; } - $item_info->{checkout} = $item->checkout; $item_info->{object} = $item; @@ -772,6 +776,8 @@ else { } $template->param( + item_checkouts => $item_checkouts, + item_level_holds => $item_level_holds, ReservableItems => $can_holds_be_placed, itemloop_has_images => $itemloop_has_images, otheritemloop_has_images => $otheritemloop_has_images, @@ -798,17 +804,19 @@ if( C4::Context->preference('ArticleRequests') ) { $template->param( artreqpossible => $artreqpossible ); } - $template->param( - MARCNOTES => $marcnotesarray, - itemdata_ccode => $itemfields{ccode}, - itemdata_materials => $itemfields{materials}, - itemdata_enumchron => $itemfields{enumchron}, - itemdata_uri => $itemfields{uri}, - itemdata_copynumber => $itemfields{copynumber}, - itemdata_itemnotes => $itemfields{itemnotes}, - itemdata_location => $itemfields{location_description}, - OpacStarRatings => C4::Context->preference("OpacStarRatings"), - ); +$template->param( + MARCNOTES => $marcnotesarray, + itemdata_ccode => $itemfields{ccode}, + itemdata_materials => $itemfields{materials}, + itemdata_enumchron => $itemfields{enumchron}, + itemdata_uri => $itemfields{uri}, + itemdata_copynumber => $itemfields{copynumber}, + itemdata_itemnotes => $itemfields{itemnotes}, + itemdata_location => $itemfields{location_description}, + itemdata_barcode => $itemfields{barcode}, + itemdata_itemcallnumber => $itemfields{itemcallnumber}, + OpacStarRatings => C4::Context->preference("OpacStarRatings"), +); if (C4::Context->preference("AlternateHoldingsField") && $items->count == 0) { my $fieldspec = C4::Context->preference("AlternateHoldingsField"); -- 2.39.5