Bugzilla – Attachment 183642 Details for
Bug 35211
Make it possible to split holdings tab using library groups
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35211: Add group_holdings tab to Holdings table
Bug-35211-Add-groupholdings-tab-to-Holdings-table.patch (text/plain), 12.39 KB, created by
Eric Garcia
on 2025-06-30 15:15:13 UTC
(
hide
)
Description:
Bug 35211: Add group_holdings tab to Holdings table
Filename:
MIME Type:
Creator:
Eric Garcia
Created:
2025-06-30 15:15:13 UTC
Size:
12.39 KB
patch
obsolete
>From 17e44b0f5032d0e7977a5e6eaa5fd5b15e711880 Mon Sep 17 00:00:00 2001 >From: Eric Garcia <cubingguy714@gmail.com> >Date: Tue, 10 Jun 2025 16:29:33 +0000 >Subject: [PATCH] Bug 35211: Add group_holdings tab to Holdings table > >Add new system preference 'SeparateHoldingsByGroup' >Adds new tab to Group Holdings to Holdings table. >Separates holdings by library group. > >Test Plan: > 1. Apply patch, restart_all > 2. Koha Administration -> System preferences -> SeparateHoldingsByGroup > 3. Separate items display into two tabs and Separate holdings by library group. > 4. Save preference changes > 5. Koha Administration -> Library groups > 6. Create a library group and add check the 'Use for staff search groups' box. > 7. Add libraries to the new group including your logged in branch. > 8. Do a catalog search. > 9. Click on an item that libraries in your group own. > 10. Notice a new tab called Group Holdings that contains only the libraries in your group > > 11. Return to Koha Administration -> System preferences SeparateHoldingsByGroup > 12. Don't separate holdings by library group > 13. Return to the item you search for and notice the tab has been removed. >--- > catalogue/detail.pl | 30 ++++++++++++ > .../bug_35211_separate_holdings_by_group.pl | 22 +++++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../tables/items/catalogue_detail.inc | 6 ++- > .../admin/preferences/cataloguing.pref | 7 ++- > .../prog/en/modules/catalogue/detail.tt | 46 +++++++++++++++++++ > 6 files changed, 110 insertions(+), 2 deletions(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_35211_separate_holdings_by_group.pl > >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index c6445d4a20..b5a858416f 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -60,6 +60,8 @@ 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(); > >@@ -335,7 +337,35 @@ if ( C4::Context->preference('SeparateHoldings') ) { > my $other_holdings_count = > $items_to_display->search( { $SeparateHoldingsBranch => { '!=' => C4::Context->userenv->{branch} } } )->count; > $template->param( other_holdings_count => $other_holdings_count ); >+ >+ my $branchcode = C4::Context->userenv->{branch}; >+ my @all_search_groups = Koha::Library::Groups->get_search_groups( { interface => 'staff' } ); >+ >+ if ( C4::Context->preference('SeparateHoldingsByGroup') ) { >+ my @libs_in_group; >+ 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; >+ } >+ } >+ } >+ } >+ } >+ >+ my $group_holdings_count = >+ $items_to_display->search( { $SeparateHoldingsBranch => { -in => \@libs_in_group } } )->count; >+ $template->param( >+ libs_in_group => \@libs_in_group, >+ group_holdings_count => $group_holdings_count, >+ ); >+ } >+ > } >+ > $template->param( > count => $all_items->count, # FIXME 'count' is used in catalog-strings.inc > # But it's not a meaningful variable, we should rename it there >diff --git a/installer/data/mysql/atomicupdate/bug_35211_separate_holdings_by_group.pl b/installer/data/mysql/atomicupdate/bug_35211_separate_holdings_by_group.pl >new file mode 100755 >index 0000000000..572ddfe7d3 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_35211_separate_holdings_by_group.pl >@@ -0,0 +1,22 @@ >+use Modern::Perl; >+use Koha::Installer::Output qw(say_warning say_success say_info); >+ >+return { >+ bug_number => "35211", >+ description => "", >+ up => sub { >+ my ($args) = @_; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ >+ # Do you stuffs here >+ $dbh->do( >+ q{ >+ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) >+ VALUES ('SeparateHoldingsByGroup',NULL,'','Separate current branch holdings and holdings from libraries in the same library groups','YesNo') >+ } >+ ); >+ >+ # Other information >+ say_success( $out, "Added new system preference 'SeparateHoldingsByGroup'" ); >+ }, >+}; >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index b8f3565770..7e73fa8b3e 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -734,6 +734,7 @@ 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, 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 67440510e6..5dcb5aa322 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 >@@ -285,10 +285,12 @@ > otherholdings: [% TablesSettings.GetTableSettings('catalogue', 'detail','otherholdings_table','json') | $raw %], > }; > >- let user_colvis = {holdings: {}, otherholdings: {}}; >+ let user_colvis = {holdings: {}, otherholdings: {}, group_holdings: {}}; > let table_nodes = { > holdings: "[% PROCESS 'build_table' tab="holdings" | collapse | $tojson %]", > otherholdings: "[% PROCESS 'build_table' tab="otherholdings" | collapse | $tojson %]", >+ group_holdings: "[% PROCESS 'build_table' tab="group_holdings" | collapse | $tojson %]", >+ > }; > function build_items_table (tab_id, add_filters, dt_options, drawcallback) { > >@@ -310,6 +312,8 @@ > 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 { > default_filters[branch] = { '!=': '[% Branches.GetLoggedInBranchcode() | html %]' }; > } >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 9c62cae068..8965199497 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,6 +301,11 @@ 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 a third tab." > - > - pref: AlwaysShowHoldingsTableFilters > choices: >@@ -408,4 +413,4 @@ Cataloging: > - "<br/>" > - "All values of repeating tags and subfields will be printed with the given RIS tag." > - "<br/>" >- - "Use of TY ( record type ) as a key will <em>replace</em> the default TY with the field value of your choosing." >\ No newline at end of file >+ - "Use of TY ( record type ) as a key will <em>replace</em> the default TY with the field value of your choosing." >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 0fc818512a..da22312f77 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -332,6 +332,11 @@ > <span>Other holdings ([% other_holdings_count || 0 | html %])</span> > [% END %] > [% END %] >+ [% IF group_holdings_count %] >+ [% WRAPPER tab_item tabname= "group_holdings" %] >+ <span>Group holdings ([% group_holdings_count || 0 | html %])</span> >+ [% END %] >+ [% END %] > [% ELSE %] > [% WRAPPER tab_item tabname= "holdings" %] > <span>Holdings ([% items_to_display_count || 0 | html %])</span> >@@ -472,6 +477,9 @@ > [% END # /tab_panel %] > > [% IF Koha.Preference('SeparateHoldings') %] >+ [% WRAPPER tab_panel tabname="group_holdings" %] >+ [% PROCESS items_table tab="group_holdings" %] >+ [% END #/tab_panel %] > [% WRAPPER tab_panel tabname="otherholdings" %] > [% PROCESS items_table tab="otherholdings" %] > [% END # /tab_panel %] >@@ -2079,6 +2087,44 @@ > // End bundle handling > [% END # /IF bundlesEnabled %] > >+ let items_tab_ids = [ 'holdings', 'otherholdings', 'group_holdings' ]; >+ items_tab_ids.forEach( function( tab_id, index ) { >+ >+ // Early return if the tab is not shown (ie. no table) >+ if (!$("#%s-tab".format(tab_id)).length) return; >+ [% IF Koha.Preference('AlwaysShowHoldingsTableFilters') %] >+ build_items_table(tab_id, true, {}, build_items_table_drawncallback); >+ [% ELSE %] >+ build_items_table(tab_id, false, {}, build_items_table_drawncallback); >+ [% END %] >+ >+ [% IF bundlesEnabled %] >+ // Add event listener for opening and closing bundle details >+ $('#' + tab_id + '_table tbody').on('click', 'button.details-control', function () { >+ var button = $(this); >+ var tr = button.closest('tr'); >+ var dTable = button.closest('table').DataTable({ 'retrieve': true }); >+ >+ let row = dTable.row( tr ); >+ let data = row.data(); >+ let itemnumber = data.item_id; >+ let duedate = (data.checkout&&data.checkout.due_date) || null; >+ >+ if ( row.child.isShown() ) { >+ // This row is already open - close it >+ row.child.hide(); >+ tr.removeClass('shown'); >+ button.removeClass('active'); >+ } else { >+ // Open this row >+ createChild(row, itemnumber, duedate); >+ tr.addClass('shown'); >+ button.addClass('active'); >+ } >+ }); >+ [% END # /IF bundlesEnabled %] >+ }); >+ > [% IF Koha.Preference('AcquisitionDetails') %] > var table_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail', 'acquisitiondetails-table', 'json') | $raw %]; > var acquisitiondetails_table = $("#orders").kohaTable( >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35211
:
183075
|
183099
|
183143
|
183144
|
183420
|
183615
| 183642 |
183643