From ec7cb3b8bedad5cf440eceb2dd125dc05f9f8ae5 Mon Sep 17 00:00:00 2001 From: Brendan Lawlor Date: Fri, 14 Jun 2024 19:11:56 +0000 Subject: [PATCH] Bug 37077: Fix report muti select for zero and single selections This patch updates the javascript overriding the form submission when reports have multi select parameters. When there are more than one multi selects, and the user selcts one value from each, it skips updating the value of the select, so it doens't send duplicate parameters anymore. If there are no selections made it will pass '%' for all values. This allows the multi select to be optional in the report. If no selections are made it is assumed that you are not using that parameter to limit the report. --- .../prog/en/modules/reports/guided_reports_start.tt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 50f7a65a4f..755f497bda 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 @@ -882,7 +882,7 @@ [% IF (sql_param.select_multiple) %] [% END %] @@ -1581,8 +1581,13 @@ $('#report_param_form').on('submit', function(e) { $('#report_param_form').find('select[multiple]').each( function (i) { - var $selected = $('option:first', this).val(); - $(this).val($selected); + if( $(this).find('option:selected').length === 0 ) { + $(this).val(['%']); + } + else if( $(this).find('option:selected').length > 1 ) { + var $selected = $('option:first', this).val(); + $(this).val($selected); + } }); }); } -- 2.39.2