From 52dd1fc8cd7c848b7336594d06c33d708218512c Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Wed, 4 Feb 2026 16:41:24 +0000 Subject: [PATCH] Bug 41624: Revert bug 35211 Bug 41624: Revert "Bug 35211: (QA follow-up) Fix counting" This reverts commit 97a022054db86f076844228e01e31e3aac045d9a. Bug 41624: Revert "Bug 35211: (QA follow-up) fix display of other results tab and move template toolkit logic outside of script array" This reverts commit c4c2a4b235ccefee0c54892c1ca1057465987918. Bug 41624: Revert "Bug 35211: Removed local items from group tabs and removed group items from other holdings tab" This reverts commit 124c6c867065d4230ffa5553ca2b629e05b269a0. Bug 41624: Revert "Bug 35211: Fixed group tab item building logic" This reverts commit 23eb2dbd39ab7f46c19b299cef3db435a9ed4b7e. Bug 41624: Revert "Bug 35211: Fix tab building" This reverts commit f438535b5cfe868784bb6881839c58242432da71. Bug 41624: Revert "Bug 35211: Set SeparateHoldingsByGroup to separate based on SeparateHoldingsBranch syspref" This reverts commit d2a0527d86e82ff1edf0c31035f5ac9da232b5fe. Bug 41624: Revert "Bug 35211: Fixed count on logged in holdings" This reverts commit 96c7eb3459770c354f59fcc1d4c22ebc4eb2a559. Bug 41624: Revert "Bug 35211: Reordered tabs in Holdings Table and fixed group tabnames" This reverts commit 5c2b0fd49689b4bdaa392fc165a8fc97c1fafa1e. Bug 41624: Revert "Bug 35211: Separate group holdings into individual tabs" This reverts commit 08045c8009c52596d8df83e5da12d9e4e9abb9ae. Bug 41624: DB update to remove the pref Signed-off-by: Jonathan Druart --- catalogue/detail.pl | 61 ++----------------- .../data/mysql/atomicupdate/bug_41624.pl | 31 ++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 - .../tables/items/catalogue_detail.inc | 28 +-------- .../admin/preferences/cataloguing.pref | 8 +-- .../prog/en/modules/catalogue/detail.tt | 54 +++------------- 6 files changed, 45 insertions(+), 138 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_41624.pl diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 05a2d141402..d6ff6220315 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -61,8 +61,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(); @@ -333,69 +331,18 @@ if ( defined $dat->{'itemtype'} ) { $dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }->imageurl ); } -my $total_group_holdings_count = 0; -my $other_holdings_count = 0; -my $branch_holdings_count = 0; if ( C4::Context->preference('SeparateHoldings') ) { my $SeparateHoldingsBranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch'; - $branch_holdings_count = - $items_to_display->search( { $SeparateHoldingsBranch => { '=' => C4::Context->userenv->{branch} } } )->count; - $other_holdings_count = $items_to_display->count - $branch_holdings_count; + my $other_holdings_count = + $items_to_display->search( { $SeparateHoldingsBranch => { '!=' => C4::Context->userenv->{branch} } } )->count; + $template->param( other_holdings_count => $other_holdings_count ); } $template->param( count => $all_items->count, # FIXME 'count' is used in catalog-strings.inc - other_holdings_count => $other_holdings_count, # But it's not a meaningful variable, we should rename it there + # But it's not a meaningful variable, we should rename it there all_items_count => $all_items->count, items_to_display_count => $items_to_display->count, - branch_holdings_count => $branch_holdings_count, ); -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) { - while ( my $group = $search_group->next ) { - my @all_libs = $group->all_libraries; - - # Check if library is in group - if ( grep { $_->branchcode eq $branchcode } @all_libs ) { - - # Get other libraries in group - my @other_libs = grep { $_->branchcode ne $branchcode } @all_libs; - - my @libs_branchcodes; - push @libs_branchcodes, $branchcode; - - foreach my $lib (@other_libs) { - push @libs_branchcodes, $lib->branchcode; - } - - # Build group branchcode hash - $branchcode_hash{ $group->id } = \@libs_branchcodes; - - my $SeparateHoldingsBranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch'; - my $group_holdings_count = - $items_to_display->search( { $SeparateHoldingsBranch => { '-in' => \@libs_branchcodes } } )->count; - $holdings_count{ $group->id } = $group_holdings_count; - $total_group_holdings_count += $group_holdings_count; - - push @lib_groups, $group; - $other_holdings_count = ( $items_to_display->count ) - $total_group_holdings_count; - } - } - } - - $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, - ); -} my $some_private_shelves = Koha::Virtualshelves->get_some_shelves( { diff --git a/installer/data/mysql/atomicupdate/bug_41624.pl b/installer/data/mysql/atomicupdate/bug_41624.pl new file mode 100644 index 00000000000..4387a7f683a --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_41624.pl @@ -0,0 +1,31 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "41624", + description => "Remove SeparateHoldingsByGroup system preference", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Check if the preference exists before removing + my ($exists) = $dbh->selectrow_array( + q{ + SELECT COUNT(*) + FROM systempreferences + WHERE variable = 'SeparateHoldingsByGroup' + } + ); + + if ($exists) { + $dbh->do( + q{ + DELETE FROM systempreferences + WHERE variable = 'SeparateHoldingsByGroup' + } + ); + } + + say_success( $out, "Removed system preference 'SeparateHoldingsByGroup'" ); + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 266d330eda7..0f2f582faf2 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -742,7 +742,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','Free'), ('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'), ('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'), -('SeparateHoldingsByGroup','0',NULL,'Separate current branch holdings and holdings from libraries in the same library groups','YesNo'), ('SerialsDefaultEmailAddress', '', NULL, 'Default email address used as reply-to for notices sent by the serials module.', 'Free'), ('SerialsDefaultReplyTo', '', NULL, 'Default email address that serials notices are sent from.', 'Free'), ('SerialsSearchResultsLimit', '', NULL, 'Serials search results limit', 'Integer'), 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 9ffce4036bd..9a1a3eaf65c 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 @@ -296,17 +296,6 @@ holdings: "[% PROCESS 'build_table' tab="holdings" | collapse | $tojson %]", 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 %] - }; - function build_items_table (tab_id, add_filters, dt_options, drawcallback) { let table_dt; @@ -328,22 +317,7 @@ if ( tab_id == 'holdings' ) { default_filters[branch] = '[% Branches.GetLoggedInBranchcode() | html %]'; } else { - let all_branchcodes = Object.values(branchcodes).flat(); - all_branchcodes.push('[% Branches.GetLoggedInBranchcode() | html %]'); - default_filters[branch] = { '-not_in' : all_branchcodes }; - } - [% END %] - - [% IF Koha.Preference('SeparateHoldingsByGroup') %] - if ( tab_id.includes('group_holdings') ) { - user_colvis[tab_id] = {}; - items_table_settings[tab_id] = [% TablesSettings.GetTableSettings('catalogue', 'detail','otherholdings_table','json') | $raw %]; - - const id = tab_id.replace("group_holdings_", ""); - - let branch = '[% IF SeparateHoldingsBranch == 'homebranch' %]me.home_library_id[% ELSE %]me.holding_library_id[% END %]'; - default_filters[branch] = branchcodes[id]; - + default_filters[branch] = { '!=': '[% Branches.GetLoggedInBranchcode() | html %]' }; } [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref index 33043ed714c..9c62cae0688 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -301,12 +301,6 @@ Cataloging: homebranch: 'home library' holdingbranch: 'holding library' - "is the logged in user's library. The second tab will contain all other items." - - - - pref: SeparateHoldingsByGroup - choices: - 1: Separate - 0: "Don't separate" - - "holdings by library group in subsequent tabs that contain items whose home library is the logged in library branch." - - pref: AlwaysShowHoldingsTableFilters choices: @@ -414,4 +408,4 @@ Cataloging: - "
" - "All values of repeating tags and subfields will be printed with the given RIS tag." - "
" - - "Use of TY ( record type ) as a key will replace the default TY with the field value of your choosing." + - "Use of TY ( record type ) as a key will replace the default TY with the field value of your choosing." \ No newline at end of file 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 591800e408d..763cda06baf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -335,35 +335,21 @@ [% WRAPPER tabs id= "bibliodetails" %] [% WRAPPER tabs_nav %] [% IF Koha.Preference('SeparateHoldings') %] - [% IF branch_holdings_count %] + [% IF items_to_display_count - ( other_holdings_count || 0 ) %] [% WRAPPER tab_item tabname= "holdings" %] - [% Branches.GetLoggedInBranchname | html %] holdings ([% branch_holdings_count | html %]) - [% END %] - [% END %] - [% ELSE %] - [% WRAPPER tab_item tabname= "holdings" %] - Holdings ([% items_to_display_count || 0 | html %]) - [% END %] - [% END %] - - [% IF Koha.Preference('SeparateHoldingsByGroup') && lib_groups %] - [% FOREACH group IN lib_groups %] - [% IF ( holdings_count_hash.${group.id} > 0 ) %] - [% WRAPPER tab_item tabname="group_holdings_" _ group.id %] - [% group.title | html %] holdings ([% holdings_count_hash.${group.id} | html %]) - [% END %] + [% Branches.GetLoggedInBranchname | html %] holdings ([% items_to_display_count - ( other_holdings_count || 0 ) - ( hidden_count || 0 ) || 0 | html %]) [% END %] [% END %] - [% END %] - - [% IF Koha.Preference('SeparateHoldings') %] - [% IF other_holdings_count > 0 %] + [% IF other_holdings_count %] [% WRAPPER tab_item tabname= "otherholdings" %] Other holdings ([% other_holdings_count || 0 | html %]) [% END %] [% END %] + [% ELSE %] + [% WRAPPER tab_item tabname= "holdings" %] + Holdings ([% items_to_display_count || 0 | html %]) + [% END %] [% END %] - [% IF Koha.Preference('EnableItemGroups') %] [% WRAPPER tab_item tabname= "item_groups" %] Item groups @@ -503,16 +489,6 @@ [% PROCESS items_table tab="otherholdings" %] [% END # /tab_panel %] [% END %] - [% IF Koha.Preference('SeparateHoldingsByGroup') && lib_groups %] - [% FOREACH group IN lib_groups %] - [% IF ( holdings_count_hash.${group.id} > 0 ) %] - [% SET group_tab = "group_holdings_" _ group.id %] - [% WRAPPER tab_panel tabname=group_tab %] - [% PROCESS items_table tab=group_tab %] - [% END # /tab_panel %] - [% END %] - [% END %] - [% END %] [% IF ( MARCNOTES ) %] [% WRAPPER tab_panel tabname="description" %] @@ -1763,29 +1739,15 @@ [% END %]