From 521c9294cc726c4f494d0be2e0ba3c4c4effc021 Mon Sep 17 00:00:00 2001 From: Brendan Lawlor Date: Tue, 20 Feb 2024 15:37:40 +0000 Subject: [PATCH] Bug 35746: add multiselect to report dropdowns Rebased for changes to guided_reports_start.tt This patch adds the ability to use multi select in report dropdowns. It uses syntax similar to using a list and when using the :all option WHERE i.homebranch in <> GROUP BY i.homebranch 2. Save the report 3. Note that you get the error The authorized value category (branches:in) you selected does not exist. 4. Apply the patch and repeat steps 1 and 2 5. Note the report saves successfully 6. Run the report 7. Note the select dropdown is now a multiselect 8. Run the report with multiple selections 10. Click show SQL and note that multi select parameters get inserted into the query like: WHERE i.homebranch in ('CPL', 'FFL', 'FPL') 11. Test other types of queries with multiple multi selects and lists etc Sponsored-by: CLAMS Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Nick Clemens Signed-off-by: Lucas Gass Signed-off-by: Katrin Fischer --- C4/Reports/Guided.pm | 2 +- Koha/Report.pm | 2 +- .../modules/reports/guided_reports_start.tt | 24 +++++++++++++++++-- reports/guided_reports.pl | 11 +++++++-- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index a55cd17743..1d8b195b3c 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -974,7 +974,7 @@ sub GetParametersFromSQL { for ( my $i = 0; $i < ($#split/2) ; $i++ ) { my ($name,$authval) = split(/\|/,$split[$i*2+1]); - $authval =~ s/\:all$// if $authval; + $authval =~ s/\:all$|\:in$// if $authval; push @sql_parameters, { 'name' => $name, 'authval' => $authval }; } diff --git a/Koha/Report.pm b/Koha/Report.pm index 55daece836..8c9bd3b523 100644 --- a/Koha/Report.pm +++ b/Koha/Report.pm @@ -169,7 +169,7 @@ sub prep_report { # } # ) if $quoted; #} - unless ( $split[ $i * 2 + 1 ] =~ /\|\s*list\s*$/ && $quoted ) { + unless ( $split[ $i * 2 + 1 ] =~ /\|\s*list\s*$|\s*\:in\s*$/ && $quoted ) { $quoted = C4::Context->dbh->quote($quoted); } else { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt index 157c538b50..f79005ee58 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt @@ -849,7 +849,7 @@ Edit SQL [% ELSE # IF ( auth_val_error ) %] -
+

Enter parameters for report [% name | html %]:

[% IF ( notes ) %] @@ -876,10 +876,13 @@ [% ELSE %]
  • - [% IF (sql_param.include_all) %] [% END %] + [% IF (sql_param.select_multiple) %] + + [% END %] [% FOREACH value IN sql_param.input.values %] [% END %] @@ -1541,6 +1544,23 @@