View | Details | Raw Unified | Return to bug 35746
Collapse All | Expand All

(-)a/C4/Reports/Guided.pm (-12 / +2 lines)
Lines 574-590 sub execute_query { Link Here
574
    my ( $is_sql_valid, $errors ) = Koha::Report->new({ savedsql => $sql })->is_sql_valid;
574
    my ( $is_sql_valid, $errors ) = Koha::Report->new({ savedsql => $sql })->is_sql_valid;
575
    return (undef, @{$errors}[0]) unless $is_sql_valid;
575
    return (undef, @{$errors}[0]) unless $is_sql_valid;
576
576
577
    foreach my $sql_param ( @$sql_params ){
577
578
        if ( $sql_param =~ m/\n/ ){
579
            my @list = split /\n/, $sql_param;
580
            my @quoted_list;
581
            foreach my $item ( @list ){
582
                $item =~ s/\r//;
583
              push @quoted_list, C4::Context->dbh->quote($item);
584
            }
585
            $sql_param = "(".join(",",@quoted_list).")";
586
        }
587
    }
588
578
589
    my ($useroffset, $userlimit);
579
    my ($useroffset, $userlimit);
590
580
Lines 974-980 sub GetParametersFromSQL { Link Here
974
964
975
    for ( my $i = 0; $i < ($#split/2) ; $i++ ) {
965
    for ( my $i = 0; $i < ($#split/2) ; $i++ ) {
976
        my ($name,$authval) = split(/\|/,$split[$i*2+1]);
966
        my ($name,$authval) = split(/\|/,$split[$i*2+1]);
977
        $authval =~ s/\:all$// if $authval;
967
        $authval =~ s/\:all$|\:in$// if $authval;
978
        push @sql_parameters, { 'name' => $name, 'authval' => $authval };
968
        push @sql_parameters, { 'name' => $name, 'authval' => $authval };
979
    }
969
    }
980
970
(-)a/Koha/Report.pm (-1 / +1 lines)
Lines 169-175 sub prep_report { Link Here
169
        #        }
169
        #        }
170
        #    ) if $quoted;
170
        #    ) if $quoted;
171
        #}
171
        #}
172
        unless ( $split[ $i * 2 + 1 ] =~ /\|\s*list\s*$/ && $quoted ) {
172
        unless ( $split[ $i * 2 + 1 ] =~ /\|\s*list\s*$\|\s*\:in\s*$/ && $quoted ) {
173
            $quoted = C4::Context->dbh->quote($quoted);
173
            $quoted = C4::Context->dbh->quote($quoted);
174
        }
174
        }
175
        else {
175
        else {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-2 / +22 lines)
Lines 842-848 Link Here
842
                [% END # /IF ( warn_authval_problem )%]
842
                [% END # /IF ( warn_authval_problem )%]
843
843
844
                [% IF ( enter_params ) %]
844
                [% IF ( enter_params ) %]
845
                    <form action='/cgi-bin/koha/reports/guided_reports.pl'>
845
                    <form action='/cgi-bin/koha/reports/guided_reports.pl' id='report_param_form'>
846
                        <input type='hidden' name='reports' value="[% reports | html %]" />
846
                        <input type='hidden' name='reports' value="[% reports | html %]" />
847
                        [% IF ( auth_val_error ) %]
847
                        [% IF ( auth_val_error ) %]
848
                            <input type='hidden' name='phase' value='Edit SQL' />
848
                            <input type='hidden' name='phase' value='Edit SQL' />
Lines 883-892 Link Here
883
                                        [% ELSE %]
883
                                        [% ELSE %]
884
                                            <li>
884
                                            <li>
885
                                                <label for="sql_params_[% sql_param.labelid | html %]">[% sql_param.entry | html %]:</label>
885
                                                <label for="sql_params_[% sql_param.labelid | html %]">[% sql_param.entry | html %]:</label>
886
                                                <select name="[%- sql_param.input.name | html -%]" tabindex="1"  id="[%- sql_param.input.id | html -%]">
886
                                                <select name="[%- sql_param.input.name | html -%]" tabindex="1"  id="[%- sql_param.input.id | html -%]" [%- sql_param.select_multiple | html -%]>
887
                                                    [% IF (sql_param.include_all) %]
887
                                                    [% IF (sql_param.include_all) %]
888
                                                        <option value="%">All</option>
888
                                                        <option value="%">All</option>
889
                                                    [% END %]
889
                                                    [% END %]
890
                                                    [% IF (sql_param.select_multiple) %]
891
                                                        <option value="null" hidden></option>
892
                                                    [% END %]
890
                                                    [% FOREACH value IN sql_param.input.values %]
893
                                                    [% FOREACH value IN sql_param.input.values %]
891
                                                        <option value="[%- value | html -%]">[%- sql_param.input.labels.$value | html -%]</option>
894
                                                        <option value="[%- value | html -%]">[%- sql_param.input.labels.$value | html -%]</option>
892
                                                    [% END %]
895
                                                    [% END %]
Lines 1535-1540 Link Here
1535
1538
1536
    <script>
1539
    <script>
1537
1540
1541
        //  if the report param form has multiselects overide default form submission
1542
        if( $('#report_param_form').find('select[multiple]').length ) {
1543
            $('#report_param_form').find('select[multiple]').each( function (i) {
1544
                $(this).on('change', function() {
1545
                    var $selected = $(this).val().join('\n');
1546
                    $(this).find('option:first').val($selected);
1547
                });
1548
            });
1549
1550
            $('#report_param_form').on('submit', function(e) {
1551
                $('#report_param_form').find('select[multiple]').each( function (i) {
1552
                    var $selected = $('option:first', this).val();
1553
                    $(this).val($selected);
1554
                });
1555
            });
1556
        }
1557
1538
        function hide_bar_element() {
1558
        function hide_bar_element() {
1539
            $('#chart-column-horizontal').hide()
1559
            $('#chart-column-horizontal').hide()
1540
            $('.chart-column-group').each(function( index ) {
1560
            $('.chart-column-group').each(function( index ) {
(-)a/reports/guided_reports.pl (-3 / +9 lines)
Lines 710-716 elsif ($phase eq 'Run this report'){ Link Here
710
                if( defined $uniq_params{$text.$sep.$authorised_value_all} ){
710
                if( defined $uniq_params{$text.$sep.$authorised_value_all} ){
711
                    next;
711
                    next;
712
                } else { $uniq_params{$text.$sep.$authorised_value_all} = "$i"; }
712
                } else { $uniq_params{$text.$sep.$authorised_value_all} = "$i"; }
713
                my ($authorised_value, $all) = split /:/, $authorised_value_all;
713
                my ($authorised_value, $param_options) = split /:/, $authorised_value_all;
714
                my $all;
715
                my $multiple;
716
                if ($param_options eq "all") {
717
                    $all = "all";
718
                } elsif ($param_options eq "in") {
719
                    $multiple = "multiple";
720
                }
714
                my $input;
721
                my $input;
715
                my $labelid;
722
                my $labelid;
716
                if ( not defined $authorised_value ) {
723
                if ( not defined $authorised_value ) {
Lines 829-835 elsif ($phase eq 'Run this report'){ Link Here
829
                    };
836
                    };
830
                }
837
                }
831
838
832
                push @tmpl_parameters, {'entry' => $text, 'input' => $input, 'labelid' => $labelid, 'name' => $text.$sep.$authorised_value_all, 'include_all' => $all };
839
                push @tmpl_parameters, {'entry' => $text, 'input' => $input, 'labelid' => $labelid, 'name' => $text.$sep.$authorised_value_all, 'include_all' => $all, 'select_multiple' => $multiple};
833
            }
840
            }
834
            $template->param('sql'         => $sql,
841
            $template->param('sql'         => $sql,
835
                            'name'         => $name,
842
                            'name'         => $name,
836
- 

Return to bug 35746