From 25a8641519e2335d41bd99eb40a8528dc84d1f9e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 4 Jul 2025 12:07:35 +0200 Subject: [PATCH] Bug 38122: Add the ability to group holdings by status This is a quite ugly solution, but that may answer end-user needs. It add the option the group items by status on the bibliographic record detail page. However it will have VERY bad impact on performances for record with a lot of items, as we are going to determine the status of each items of the record. --- .../tables/items/catalogue_detail.inc | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc index 65743a2f0e..8d602d288c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc @@ -316,6 +316,25 @@ } }); + let group_by_status_values = { + holdings: false, + otherholdings: false, + }; + $(".GroupByStatus").on("click",function(e){ + e.preventDefault(); + let tab_id = $(this).data("tab"); + let was_grouped = group_by_status_values[tab_id]; + group_by_status_values[tab_id] = !was_grouped; + + build_items_table(tab_id, true, { destroy: true }, build_items_table_drawncallback ); + + if ( was_grouped ) { + $(this).html(' Group by status'); + } else { + $(this).html(' Ungroup by status'); + } + }); + function build_items_table (tab_id, add_filters, dt_options, drawcallback) { let table_dt; @@ -367,6 +386,15 @@ return $("#" + tab_id + "_status select").val(); }; + let offset = 2; + [% UNLESS Koha.Preference('LocalCoverImages') %]offset--;[% END %] + let filters_options = { + [offset] : () => all_item_types, + [offset+1] : () => all_libraries, + [offset+2] : () => all_libraries, + [offset+7] : () => all_statuses, + }; + let group_by_status = function(){ if ( group_by_status_values[tab_id] ) { return 'group_by_status=1'; -- 2.52.0