From 138b3bee5dcb7f633947de5caf3b6e1e2cb7a8cb Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Mon, 24 Jun 2024 20:25:51 +0000 Subject: [PATCH] Bug 31606: [WIP] Add FundDropdownSortField system preference Libraries may want to sort the funds by modification/creation date, rather than by ID or code. Work in progress. --- C4/Budgets.pm | 7 ++++--- ..._31606_-_add_FundDropdownSortField_syspref.pl | 16 ++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../modules/admin/preferences/acquisitions.pref | 8 ++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_31606_-_add_FundDropdownSortField_syspref.pl diff --git a/C4/Budgets.pm b/C4/Budgets.pm index 26e4c49143d..62f187feb76 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -524,9 +524,10 @@ sub GetBudgetHierarchy { push @bind_params, $branchcode; } } - $query.=" WHERE ".join(' AND ', @where_strings) if @where_strings; - my $sth = $dbh->prepare($query); - $sth->execute(@bind_params); + $query .= " WHERE " . join( ' AND ', @where_strings ) if @where_strings; + $query .= " ORDER BY timestamp DESC" if C4::Context->preference('FundDropdownSortField') eq 'timestamp'; + my $sth = $dbh->prepare($query); + $sth->execute(@bind_params); my %links; # create hash with budget_id has key diff --git a/installer/data/mysql/atomicupdate/bug_31606_-_add_FundDropdownSortField_syspref.pl b/installer/data/mysql/atomicupdate/bug_31606_-_add_FundDropdownSortField_syspref.pl new file mode 100755 index 00000000000..e4a9ad40213 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_31606_-_add_FundDropdownSortField_syspref.pl @@ -0,0 +1,16 @@ +use Modern::Perl; + +return { + bug_number => "31606", + description => "Make acquisitions fund dropdown consistently show budget name", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('FundDropdownSortField','budget_code','budget_code|timestamp','Choose the display order of budgets and funds','Choice') } + ); + + say $out "Added system preference 'FundDropdownSortField'"; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 59fc38ed46d..e1ac18581c4 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -281,6 +281,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('finesMode','off','off|production','Choose the fines mode, \'off\' (no charges), \'production\' (accrue overdue fines). Requires accruefines cronjob.','Choice'), ('ForceLibrarySelection','0',NULL,'Force staff to select a library when logging into the staff interface.','YesNo'), ('FRBRizeEditions','0','','If ON, Koha will query one or more ISBN web services for associated ISBNs and display an Editions tab on the details pages','YesNo'), +('FundDropdownSortField','budget_code','budget_code|timestamp','Choose the display order of budgets and funds','Choice'); ('GenerateAuthorityField667', 'Machine generated authority record', NULL, 'When BiblioAddsAuthorities and AutoCreateAuthorities are enabled, use this as a default value for the 667$a field of MARC21 records', 'free'), ('GenerateAuthorityField670', 'Work cat.', NULL, 'When BiblioAddsAuthorities and AutoCreateAuthorities are enabled, use this as a default value for the 670$a field of MARC21 records', 'free'), ('GoogleJackets','0',NULL,'if ON, displays jacket covers from Google Books API','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref index 3584d9d59d5..629e513bbe6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref @@ -138,6 +138,14 @@ Acquisitions: class: email - 'when sending acquisitions order and claim notices.' - '
If left empty, it will fall back to the first defined address in the following list: library reply-to, library email, ReplytoDefault, KohaAdminEmailAddress.' + - + - When displaying the budgets and funds dropdown, sort by + - pref: FundDropdownSortField + default: budget_code + choices: + budget_code: "budget code" + timestamp: "last modified timestamp" + - "." Printing: - - Use the -- 2.39.2