From 74e3f40f08653330e6fcdabc7f2118ab65b1fa75 Mon Sep 17 00:00:00 2001 From: Eric Garcia Date: Fri, 27 Jun 2025 15:25:31 +0000 Subject: [PATCH] Bug 35211: Separate group holdings --- catalogue/detail.pl | 18 +++++++----------- .../tables/items/catalogue_detail.inc | 7 +++++-- .../prog/en/modules/catalogue/detail.tt | 11 ++++++++--- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index b5a858416f..5a85161031 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -342,25 +342,21 @@ if ( C4::Context->preference('SeparateHoldings') ) { my @all_search_groups = Koha::Library::Groups->get_search_groups( { interface => 'staff' } ); if ( C4::Context->preference('SeparateHoldingsByGroup') ) { - my @libs_in_group; + my @lib_groups; foreach my $search_group (@all_search_groups) { while ( my $group = $search_group->next ) { my @all_libs = $group->all_libraries; if ( grep { $_->branchcode eq $branchcode } @all_libs ) { - foreach my $lib (@all_libs) { - if ( $lib->branchcode ne $branchcode ) { - push @libs_in_group, $lib->branchcode; - } - } + push @lib_groups, $group; } } } - - my $group_holdings_count = - $items_to_display->search( { $SeparateHoldingsBranch => { -in => \@libs_in_group } } )->count; + foreach my $group (@lib_groups) { +# warn 'LIBRARY_GROUP' . Data::Dumper::Dumper($group->title); + } +# warn Data::Dumper::Dumper(\@lib_groups); $template->param( - libs_in_group => \@libs_in_group, - group_holdings_count => $group_holdings_count, + library_groups => \@lib_groups ); } 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 5dcb5aa322..5951e318a3 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 @@ -308,12 +308,15 @@ } let default_filters = {}; [% IF Koha.Preference('SeparateHoldings') %] + console.log(tab_id.includes('group_holdings')); + console.log(tab_id); [% SET SeparateHoldingsBranch = Koha.Preference('SeparateHoldingsBranch') || 'homebranch' %]; let branch = '[% IF SeparateHoldingsBranch == 'homebranch' %]me.home_library_id[% ELSE %]me.holding_library_id[% END %]'; if ( tab_id == 'holdings' ) { default_filters[branch] = '[% Branches.GetLoggedInBranchcode() | html %]'; - } else if ( tab_id == 'group_holdings') { - default_filters[branch] = [ [% FOREACH branchcode IN libs_in_group %]"[% branchcode | html %]"[% UNLESS loop.last %], [% END%][% END %] ]; + } else if ( tab_id.includes('group_holdings') ) { + console.log(tab_id); + // default_filters[branch] = [ [% FOREACH branchcode IN libs_in_group %]"[% branchcode | html %]"[% UNLESS loop.last %], [% END%][% END %] ]; } else { default_filters[branch] = { '!=': '[% Branches.GetLoggedInBranchcode() | html %]' }; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index da22312f77..1e8871a44c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -332,9 +332,14 @@ Other holdings ([% other_holdings_count || 0 | html %]) [% END %] [% END %] - [% IF group_holdings_count %] - [% WRAPPER tab_item tabname= "group_holdings" %] - Group holdings ([% group_holdings_count || 0 | html %]) + [% IF library_groups && library_groups.size > 0 %] + [% FOREACH group IN library_groups %] + [% USE Dumper %] + groups: [% Dumper.dump_html(group.unblessed) %] + [% SET group_id_tab = "group_holdings_" _ group.id %] + [% WRAPPER tab_item tabname=group_id_tab %] + [% group.title | html %] Group () + [% END %] [% END %] [% END %] [% ELSE %] -- 2.39.5