From 8e20b1463313aeb8f8b61df0912805a3d25d3bef Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Fri, 9 Jan 2026 20:25:15 +0000 Subject: [PATCH] Bug 41624: Improve how branchcodes are handled -This patch is an attempt to improve how we retrive branchcodes. Too much of this logic is unnesseary done in the template. -This also removed the unneeded "use Koha::Library::Group;" --- catalogue/detail.pl | 10 +++++++--- .../html_helpers/tables/items/catalogue_detail.inc | 14 +++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 9aea2a670b4..eca6dce2ce2 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -60,7 +60,6 @@ use Koha::Reviews; use Koha::SearchEngine::Search; use Koha::SearchEngine::QueryBuilder; use Koha::Serial::Items; -use Koha::Library::Group; use Koha::Library::Groups; my $query = CGI->new(); @@ -348,11 +347,13 @@ $template->param( items_to_display_count => $items_to_display->count, branch_holdings_count => $branch_holdings_count, ); + +my %branchcode_hash; + if ( C4::Context->preference('SeparateHoldingsByGroup') ) { my $branchcode = C4::Context->userenv->{branch}; my @all_search_groups = Koha::Library::Groups->get_search_groups( { interface => 'staff' } ); my @lib_groups; - my %branchcode_hash; my %holdings_count; foreach my $search_group (@all_search_groups) { @@ -389,13 +390,16 @@ if ( C4::Context->preference('SeparateHoldingsByGroup') ) { $template->param( lib_groups => \@lib_groups, - branchcodes => \%branchcode_hash, holdings_count_hash => \%holdings_count, total_group_holdings_count => $total_group_holdings_count, other_holdings_count => $other_holdings_count, ); } +$template->param( + branchcode_hash => \%branchcode_hash, +); + my $some_private_shelves = Koha::Virtualshelves->get_some_shelves( { borrowernumber => $borrowernumber, 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 01f57749716..565c5c0af2a 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 @@ -297,15 +297,11 @@ otherholdings: "[% PROCESS 'build_table' tab="otherholdings" | collapse | $tojson %]", }; - const branchcodes = { - [% FOREACH key IN branchcodes.keys %] - "[% key | html %]": [ - [% FOREACH code IN branchcodes.$key %] - "[% code | html %]"[% UNLESS loop.last %], [% END %] - [% END %] - ][% UNLESS loop.last %], [% END %] - [% END %] - }; + [% IF branchcode_hash %] + const branchcodes = [% To.json(branchcode_hash) | $raw %]; + [% ELSE %] + const branchcodes = {}; + [% END %] function build_items_table (tab_id, add_filters, dt_options, drawcallback) { -- 2.39.5