From 5db25a2f36807b9a680fdd5a9a31368d0fa34a48 Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Fri, 20 Apr 2018 14:25:49 +0100 Subject: [PATCH] Bug 20600: Add filtering of ILL requests in list This patch adds the ability for the ILL request list in the staff interface to be filtered by a number of criteria: - Status - Date placed - Date modified - Pickup branch - Borrower card number To test: 1) Apply patch 2) Ensure you have a reasonable range of ILL requests created 3) Navigate to the "View ILL requests" page 4) Choose one or more filtering criteria 5) Click "Search" 6) Observe the results are filtered to match the selected criteria 7) Click "Clear" 8) Observe your results are returned to their initial state 9) Repeat steps 4 -> 6 until you are happy. Dates supplied by the /api/v1/illrequests API route were not conforming to the preference specified by the dateformat syspref. This patch addresses that. It has been addressed as part of this bug since we are adding filtering of requests by some date fields and, therefore, needed dates in a predictable format. To test: 1) Apply the patch 2) Ensure you have at least one ILL request created 3) Make a request to the /api/v1/illrequests endpoint 4) Observe that dates supplied for "placed_formatted" & "updated_formatted" conform to your dateformat syspref. 5) Change your date format syspref, repeat steps 3 & 4 Signed-off-by: Magnus Enger Works as advertised. Nice enh! Signed-off-by: Owen Leonard --- Koha/REST/V1/Illrequests.pm | 20 ++ .../intranet-tmpl/prog/css/src/staff-global.scss | 4 + .../prog/en/modules/ill/ill-requests.tt | 326 +++++++++++++++++++-- 3 files changed, 321 insertions(+), 29 deletions(-) diff --git a/Koha/REST/V1/Illrequests.pm b/Koha/REST/V1/Illrequests.pm index 0b4c8f0d2a..cfc353d2f8 100644 --- a/Koha/REST/V1/Illrequests.pm +++ b/Koha/REST/V1/Illrequests.pm @@ -24,6 +24,7 @@ use Koha::Illrequestattributes; use Koha::Libraries; use Koha::Patrons; use Koha::Libraries; +use Koha::DateUtils qw( format_sqldatetime ); =head1 NAME @@ -41,6 +42,9 @@ sub list { my $c = shift->openapi->valid_input or return; my $args = $c->req->params->to_hash // {}; + my $filter; + my $output = []; + my @format_dates = ( 'placed', 'updated' ); # Create a hash where all keys are embedded values # Enables easy checking @@ -54,6 +58,22 @@ sub list { # Get all requests my @requests = Koha::Illrequests->as_list; + # Create new "formatted" columns for each date column + # that needs formatting + foreach(@requests) { + foreach my $field(@format_dates) { + if (defined $_->{$field}) { + $_->{$field . "_formatted"} = format_sqldatetime( + $_->{$field}, + undef, + undef, + 1 + ); + } + } + + } + # Identify patrons & branches that # we're going to need and get them my $to_fetch = { diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index 73329e001d..26d77b323a 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -4021,7 +4021,11 @@ span { margin-bottom: 1em; } } +} +#illfilter_dateplaced, +#illfilter_datemodified { + width: 80%; } #requestattributes { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt index 931cef50cd..8559567c6e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt @@ -10,12 +10,30 @@ [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %] [% Asset.css("css/datatables.css") | $raw %] [% INCLUDE 'datatables.inc' %] +[% INCLUDE 'calendar.inc' %] @@ -326,6 +552,45 @@
+ [% IF query_type == 'illlist' %] +
+
+
+

Filters

+
    +
  1. + + +
  2. +
  3. + + +
  4. +
  5. + + +
  6. +
  7. + + +
  8. +
  9. + + +
  10. +
+
+ + +
+
+
+
+ [% END %]
[% IF !backends_available || !has_branch %] @@ -678,7 +943,10 @@ Bibliographic record ID Library Status - Updated on +   + Date placed +   + Updated on Request number Comments -- 2.11.0