Bugzilla – Attachment 93555 Details for
Bug 23389
Add 'All' option to report value dropdowns
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23389: Add 'All' option to report dropdowns
Bug-23389-Add-All-option-to-report-dropdowns.patch (text/plain), 5.47 KB, created by
Katrin Fischer
on 2019-10-03 11:09:53 UTC
(
hide
)
Description:
Bug 23389: Add 'All' option to report dropdowns
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2019-10-03 11:09:53 UTC
Size:
5.47 KB
patch
obsolete
>From c868a7bb22b7c56be03bfbefa381c9339684f07f Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 30 Jul 2019 15:20:27 +0000 >Subject: [PATCH] Bug 23389: Add 'All' option to report dropdowns > >This patch optionally adds an 'all' option to report dropdowns > >Note you will need to use 'LIKE' instead of '=' to allow 'All' to work > >To test: > 1 - Write a report: > SELECT branchname FROM branches WHERE branchcode LIKE <<Branch|branches>> > 2 - Run it > 3 - Select a branch > 4 - You get one branch info > 5 - Note you cannot select all > 6 - Apply patch > 7 - Run report > 8 - No change > 9 - Update report like: > SELECT branchname FROM branches WHERE branchcode LIKE <<Branch|branches:all>> >10 - Run report >11 - Select 'All' >12 - You get all branches >13 - Select one branch >14 - You get one branch >15 - Test with other authorised categories (itemtypes, YES_NO, etc.) >16 - Confirm it works as expected >17 - Prove -v t/db_dependent/Reports/Guided.t > >Signed-off-by: Lisette Scheer <lisetteslatah@gmail.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > C4/Reports/Guided.pm | 1 + > .../prog/en/modules/reports/guided_reports_start.tt | 1 + > reports/guided_reports.pl | 11 ++++++----- > t/db_dependent/Reports/Guided.t | 6 ++++-- > 4 files changed, 12 insertions(+), 7 deletions(-) > >diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm >index 6f77f5dfe9..705984d397 100644 >--- a/C4/Reports/Guided.pm >+++ b/C4/Reports/Guided.pm >@@ -919,6 +919,7 @@ sub GetParametersFromSQL { > > for ( my $i = 0; $i < ($#split/2) ; $i++ ) { > my ($name,$authval) = split(/\|/,$split[$i*2+1]); >+ $authval =~ s/\:all$// if $authval; > push @sql_parameters, { 'name' => $name, 'authval' => $authval }; > } > >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 de0409868a..5ae50b6504 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 >@@ -701,6 +701,7 @@ canned reports and writing custom SQL reports.</p> > [% ELSE %] > <li><label for="sql_params_[% sql_param.labelid | html %]">[% sql_param.entry | html %]:</label> > <select name="[%- sql_param.input.name | html -%]" tabindex="1" size="1" id="[%- sql_param.input.id | html -%]"> >+ [% IF (sql_param.include_all) %]<option value="%">All</option>[% END %] > [% FOREACH value IN sql_param.input.values %] > <option value="[%- value | html -%]">[%- sql_param.input.labels.$value | html -%]</option> > [% END %] >diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl >index bb4e87efe4..f1434441e2 100755 >--- a/reports/guided_reports.pl >+++ b/reports/guided_reports.pl >@@ -719,11 +719,12 @@ elsif ($phase eq 'Run this report'){ > my @authval_errors; > my %uniq_params; > for(my $i=0;$i<($#split/2);$i++) { >- my ($text,$authorised_value) = split /\|/,$split[$i*2+1]; >- my $sep = $authorised_value ? "|" : ""; >- if( defined $uniq_params{$text.$sep.$authorised_value} ){ >+ my ($text,$authorised_value_all) = split /\|/,$split[$i*2+1]; >+ my $sep = $authorised_value_all ? "|" : ""; >+ if( defined $uniq_params{$text.$sep.$authorised_value_all} ){ > next; >- } else { $uniq_params{$text.$sep.$authorised_value} = "$i"; } >+ } else { $uniq_params{$text.$sep.$authorised_value_all} = "$i"; } >+ my ($authorised_value, $all) = split /:/, $authorised_value_all; > my $input; > my $labelid; > if ( not defined $authorised_value ) { >@@ -815,7 +816,7 @@ elsif ($phase eq 'Run this report'){ > }; > } > >- push @tmpl_parameters, {'entry' => $text, 'input' => $input, 'labelid' => $labelid, 'name' => $text.$sep.$authorised_value }; >+ push @tmpl_parameters, {'entry' => $text, 'input' => $input, 'labelid' => $labelid, 'name' => $text.$sep.$authorised_value_all, 'include_all' => $all }; > } > $template->param('sql' => $sql, > 'name' => $name, >diff --git a/t/db_dependent/Reports/Guided.t b/t/db_dependent/Reports/Guided.t >index e0aacfd29e..5a8b6fa007 100644 >--- a/t/db_dependent/Reports/Guided.t >+++ b/t/db_dependent/Reports/Guided.t >@@ -146,13 +146,15 @@ subtest 'GetParametersFromSQL+ValidateSQLParameters' => sub { > FROM old_issues > WHERE YEAR(timestamp) = <<Year|custom_list>> AND > branchcode = <<Branch|branches>> AND >- borrowernumber = <<Borrower>> >+ borrowernumber = <<Borrower>> AND >+ itemtype = <<Item type|itemtypes:all>> > "; > > my @test_parameters_with_custom_list = ( > { 'name' => 'Year', 'authval' => 'custom_list' }, > { 'name' => 'Branch', 'authval' => 'branches' }, >- { 'name' => 'Borrower', 'authval' => undef } >+ { 'name' => 'Borrower', 'authval' => undef }, >+ { 'name' => 'Item type', 'authval' => 'itemtypes' } > ); > > is_deeply( GetParametersFromSQL($test_query_1), \@test_parameters_with_custom_list, >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23389
:
91848
|
91881
|
91887
| 93555