From 58914262a7b9c8af36258452cc7fa48601c9923f 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 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 --- 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 1b639d26c6..30b2b5f143 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 @@ -843,7 +843,7 @@ [% END # /IF ( warn_authval_problem )%] [% IF ( enter_params ) %] -
+ [% IF ( auth_val_error ) %] @@ -884,10 +884,13 @@ [% ELSE %]
  • - [% IF (sql_param.include_all) %] [% END %] + [% IF (sql_param.select_multiple) %] + + [% END %] [% FOREACH value IN sql_param.input.values %] [% END %] @@ -1536,6 +1539,23 @@