From 5338fc4395532e5bc9d4044068a73f60204b3f74 Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Wed, 5 Dec 2018 10:40:35 +0000 Subject: [PATCH] Bug 21460: Fix patron ILL request filtering This patch fixes the non-functioning filtering of ILL requests by borrowernumber. As Magnus mentioned, this fix was originally created as part of a larger peice in bug 18589. So the relevant parts of that bug have been backported here. Important: As such, once this bug is in master, I will need to remove the fix from bug 18589 as, due to the other things that bug does, it will conflict. Test plan: 1) Test on an instance that has ILL requests from multiple borrowers 2) Navigate to a borrower's profile page 3) Click the "Interlibrary loans" link 4) TEST => Note that the requests displayed only apply to that user 5) Navigate to the main ILL requests list page 6) TEST => Note that all requests for all users are displayed Signed-off-by: Magnus Enger Works as advertised. --- Koha/REST/V1/Illrequests.pm | 10 +++++++++- ill/ill-requests.pl | 5 ++--- koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt | 4 ++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Koha/REST/V1/Illrequests.pm b/Koha/REST/V1/Illrequests.pm index a3a0d61c1c..d07045ff1b 100644 --- a/Koha/REST/V1/Illrequests.pm +++ b/Koha/REST/V1/Illrequests.pm @@ -52,7 +52,15 @@ sub list { } # Get all requests - my @requests = Koha::Illrequests->as_list; + # If necessary, only get those from a specified patron + my @requests; + if ($args->{borrowernumber}) { + @requests = Koha::Illrequests->search( + { borrowernumber => $args->{borrowernumber} } + ); + } else { + @requests = Koha::Illrequests->as_list; + } # Identify patrons & branches that # we're going to need and get them diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl index 28e8cc634f..dc9b54db13 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -236,13 +236,12 @@ if ( $backends_available ) { my $active_filters = []; foreach my $filter(@{$possible_filters}) { if ($params->{$filter}) { - push @{$active_filters}, - { name => $filter, value => $params->{$filter}}; + push @{$active_filters}, "$filter=$params->{$filter}"; } } if (scalar @{$active_filters} > 0) { $template->param( - prefilters => $active_filters + prefilters => join(",", @{$active_filters}) ); } 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 f2a833f4f0..0f18d725c8 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 @@ -37,6 +37,8 @@ 'patron' ]; + var prefilters = '[% prefilters %]'; + // Expanded fields // This is auto populated var expanded = {}; @@ -246,8 +248,10 @@ // Get our data from the API and process it prior to passing // it to datatables + var filterParam = prefilters ? '&' + prefilters : ''; var ajax = $.ajax( '/api/v1/illrequests?embed=metadata,patron,capabilities,library,comments' + + filterParam ).done(function() { var data = JSON.parse(ajax.responseText); // Make a copy, we'll be removing columns next and need -- 2.11.0