Bugzilla – Attachment 155727 Details for
Bug 28224
Make date range for order search configurable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28224: Make date range for order search configurable
Bug-28224-Make-date-range-for-order-search-configu.patch (text/plain), 6.99 KB, created by
David Nind
on 2023-09-16 01:37:28 UTC
(
hide
)
Description:
Bug 28224: Make date range for order search configurable
Filename:
MIME Type:
Creator:
David Nind
Created:
2023-09-16 01:37:28 UTC
Size:
6.99 KB
patch
obsolete
>From 8fba14c4e7a3441bafe67745ca2b29d2bd64f36c Mon Sep 17 00:00:00 2001 >From: Katrin Fischer <katrin.fischer@bsz-bw.de> >Date: Fri, 15 Sep 2023 15:59:53 +0000 >Subject: [PATCH] Bug 28224: Make date range for order search configurable > >When searching orders in the acquisitions module the search >is automatically limited to orders created within the last year. > >In some circumstances, like when testing migration data or >when working with standing orders, this can get annoying and >is not very useful. > >This patch adds the OrderSearchFromDate system preference to >make this date configurable. > >To test: >* Go to acquisitions > order search > config icon > advanced search >* Verify the From date is from one year ago >* Apply patch and run database update >* Verify the date is still the same >* Update the OrderSearchFromDate system preference to x days ago > Example: 3 >* Verify the date on the search form changes accordingly >* Add a basket with an order line >* Add another basket, add an order line using "From existing orders (copy)" >* Verify the date on the form is calculated correctly to the pref setting >* Copy your existing order >* Use the order search and send it empty - your 2 order lines should be shown > >To test the search itself, you need baskets with different creation dates, >as the search searches aqbasket.creationdate. > UPDATE aqbasket SET creationdate = "YYYY-MM-DD" WHERE basketno = X; > >* Verify the search form and the top bar search respect the new from setting. > >Sponsored by: The Research University in the Helmholtz Association (KIT) > >Signed-off-by: David Nind <david@davidnind.com> >--- > acqui/duplicate_orders.pl | 10 ++++++++-- > acqui/histsearch.pl | 11 ++++++++-- > .../bug_28224_order_search_from_date.pl | 20 +++++++++++++++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../admin/preferences/acquisitions.pref | 6 ++++++ > 5 files changed, 44 insertions(+), 4 deletions(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_28224_order_search_from_date.pl > >diff --git a/acqui/duplicate_orders.pl b/acqui/duplicate_orders.pl >index c0b82f5431..04b049c31a 100755 >--- a/acqui/duplicate_orders.pl >+++ b/acqui/duplicate_orders.pl >@@ -73,8 +73,14 @@ my $to_placed_on = > eval { dt_from_string( scalar $input->param('to') ) } || dt_from_string; > > unless ( $input->param('from') ) { >- # Fill the form with year-1 >- $from_placed_on->set_time_zone('floating')->subtract( years => 1 ); >+ if ( C4::Context->preference('OrderSearchFromDate') ) { >+ my $from_days = C4::Context->preference('OrderSearchFromDate'); >+ $from_placed_on->set_time_zone('floating')->subtract( days => $from_days ); >+ } else { >+ >+ # Fill the form with year-1 >+ $from_placed_on->set_time_zone('floating')->subtract( years => 1 ); >+ } > } > $filters->{from_placed_on} = $from_placed_on; > $filters->{to_placed_on} = $to_placed_on; >diff --git a/acqui/histsearch.pl b/acqui/histsearch.pl >index 097fa3b217..4a7f47ed9f 100755 >--- a/acqui/histsearch.pl >+++ b/acqui/histsearch.pl >@@ -95,9 +95,16 @@ my $filters = { > my $from_placed_on = eval { dt_from_string( scalar $input->param('from') ) } || dt_from_string; > my $to_placed_on = eval { dt_from_string( scalar $input->param('to') ) } || dt_from_string; > unless ( $input->param('from') ) { >- # Fill the form with year-1 >- $from_placed_on->set_time_zone('floating')->subtract( years => 1 ); >+ if ( C4::Context->preference('OrderSearchFromDate') ) { >+ my $from_days = C4::Context->preference('OrderSearchFromDate'); >+ $from_placed_on->set_time_zone('floating')->subtract( days => $from_days ); >+ } else { >+ >+ # Fill the form with year-1 >+ $from_placed_on->set_time_zone('floating')->subtract( years => 1 ); >+ } > } >+ > $filters->{from_placed_on} = $from_placed_on; > $filters->{to_placed_on} = $to_placed_on; > my $additional_fields = Koha::AdditionalFields->search( { tablename => 'aqbasket', searchable => 1 } ); >diff --git a/installer/data/mysql/atomicupdate/bug_28224_order_search_from_date.pl b/installer/data/mysql/atomicupdate/bug_28224_order_search_from_date.pl >new file mode 100755 >index 0000000000..13172b5a1c >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_28224_order_search_from_date.pl >@@ -0,0 +1,20 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "28224", >+ description => "Customize the from date on the acq adcanced search form", >+ 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 >+ ('OrderSearchFromDate','',NULL,'Set the default from date for the order search to this many days ago. If empty, date will be set to one year ago.','Integer')} >+ ); >+ >+ # sysprefs >+ say $out "Added new system preference 'OrderSearchFromDate'"; >+ >+ }, >+}; >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index fad32d896e..b9c916effa 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -544,6 +544,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('OPACOpenURLItemTypes', '', NULL, 'Show the OpenURL link only for these item types', 'Free'), > ('OrderPdfFormat','pdfformat::layout3pages','Controls what script is used for printing (basketgroups)','','free'), > ('OrderPriceRounding','','|nearest_cent','Local preference for rounding orders before calculations to ensure correct calculations','Choice'), >+('OrderSearchFromDate','',NULL,'Set the default from date for the order search to this many days ago. If empty, date will be set to one year ago.','Integer'), > ('OverDriveCirculation','0','Enable client to see their OverDrive account','','YesNo'), > ('OverDriveClientKey','','Client key for OverDrive integration','30','Free'), > ('OverDriveClientSecret','','Client key for OverDrive integration','30','Free'), >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 4e2c18512e..d44b06b05c 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 >@@ -113,6 +113,12 @@ Acquisitions: > - '<br>If you choose <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=EmailAddressForSuggestions">EmailAddressForSuggestions</a> you have to enter a valid email address:' > - pref: EmailAddressForSuggestions > class: email >+ - >+ - "Set the default 'From' date in the acquisition adavanced search form to a date" >+ - pref: OrderSearchFromDate >+ default: '' >+ class: integer >+ - "days ago. If left empty, the date will be set to be one year ago." > Printing: > - > - Use the >-- >2.30.2
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 28224
:
155697
| 155727 |
155728