From aea16f7222cd5adcb1b12af04991fa5252fd1938 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 +- koha-tmpl/intranet-tmpl/prog/css/staff-global.css | 5 + .../prog/en/modules/ill/ill-requests.tt | 329 +++++++++++++++++++-- 3 files changed, 325 insertions(+), 36 deletions(-) diff --git a/Koha/REST/V1/Illrequests.pm b/Koha/REST/V1/Illrequests.pm index 6e3eace..2a41987 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/staff-global.css b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css index c68bff6..3000f74 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css @@ -3164,6 +3164,11 @@ table#ill-requests { width: 100% !important; } +#illfilter_dateplaced, +#illfilter_datemodified { + width: 80%; +} + #helper span { display: none; } 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 70f31ca..c34a451 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 @@ -9,12 +9,30 @@ [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") %] [% Asset.css("css/datatables.css") %] [% INCLUDE 'datatables.inc' %] +[% INCLUDE 'calendar.inc' %] @@ -298,6 +524,45 @@
+ [% IF query_type == 'illlist' %] +
+
+
+

Filters

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