From 1854eaaa360398df090b6b301a1dc4140a753db5 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 | 27 +- .../intranet-tmpl/prog/css/src/staff-global.scss | 4 + .../prog/en/modules/ill/ill-requests.tt | 329 +++++++++++++++++++-- 3 files changed, 324 insertions(+), 36 deletions(-) diff --git a/Koha/REST/V1/Illrequests.pm b/Koha/REST/V1/Illrequests.pm index 6e3eace01d..2a41987fb2 100644 --- a/Koha/REST/V1/Illrequests.pm +++ b/Koha/REST/V1/Illrequests.pm @@ -21,6 +21,7 @@ use Mojo::Base 'Mojolicious::Controller'; use Koha::Illrequests; use Koha::Libraries; +use Koha::DateUtils qw( format_sqldatetime ); =head1 NAME @@ -40,6 +41,7 @@ sub list { 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,18 +56,31 @@ sub list { $filter->{$filter_param} = \@values; } - my $requests = Koha::Illrequests->search($filter); + my @req_list = Koha::Illrequests->search($filter)->as_list; if ( scalar (keys %embed) ) { # Need to embed stuff - my @results = map { $_->TO_JSON(\%embed) } $requests->as_list; - return $c->render( status => 200, openapi => \@results ); + @req_list = map { $_->TO_JSON(\%embed) } @req_list; } - else - { - return $c->render( status => 200, openapi => $requests ); + + # Create new "formatted" columns for each date column + # that needs formatting + foreach(@req_list) { + foreach my $field(@format_dates) { + if (defined $_->{$field}) { + $_->{$field . "_formatted"} = format_sqldatetime( + $_->{$field}, + undef, + undef, + 1 + ); + } + } + } + + return $c->render( status => 200, openapi => \@req_list ); } 1; 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 2fc5b84410..6769e9b170 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -4014,7 +4014,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 8bc9268364..b7b0d788de 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' %] @@ -299,6 +525,45 @@
+ [% IF query_type == 'illlist' %] +
+
+
+

Filters

+
    +
  1. + + +
  2. +
  3. + + +
  4. +
  5. + + +
  6. +
  7. + + +
  8. +
  9. + + +
  10. +
+
+ + +
+
+
+
+ [% END %]
[% IF !backends_available %] @@ -605,11 +870,15 @@ Author Title - Patron + Patron name + Patron barcode Biblio ID Library Status - Updated on +   + Date placed +   + Updated on Request number -- 2.11.0