Bugzilla – Attachment 54097 Details for
Bug 6934
New report Cash Register Statistics
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 6934: Make CSV header column translatable and add total amounts in csv file
PASSED-QA-Bug-6934-Make-CSV-header-column-translat.patch (text/plain), 5.18 KB, created by
Katrin Fischer
on 2016-08-07 08:23:29 UTC
(
hide
)
Description:
[PASSED QA] Bug 6934: Make CSV header column translatable and add total amounts in csv file
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2016-08-07 08:23:29 UTC
Size:
5.18 KB
patch
obsolete
>From 86622f6f8cf5bc73ba184891c419ecfc70415077 Mon Sep 17 00:00:00 2001 >From: Bouzid Fergani <bouzid.fergani@inlibro.com> >Date: Tue, 19 Jul 2016 14:56:41 -0400 >Subject: [PATCH] [PASSED QA] Bug 6934: Make CSV header column translatable and > add total amounts in csv file > >Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > .../csv_headers/reports/cash_register_stats.tt | 1 + > .../en/modules/reports/csv/cash_register_stats.tt | 14 ++++++ > reports/cash_register_stats.pl | 51 ++++++---------------- > 3 files changed, 29 insertions(+), 37 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/reports/cash_register_stats.tt > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/reports/csv/cash_register_stats.tt > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/reports/cash_register_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/reports/cash_register_stats.tt >new file mode 100644 >index 0000000..92f3400 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/reports/cash_register_stats.tt >@@ -0,0 +1 @@ >+mfirstname[% sep %]cardnumber[% sep %]bfirstname[% sep %]branchname[% sep %]date[% sep %]accounttype[% sep %]amount[% sep %]title[% sep %]barcode[% sep %]"itype" >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/csv/cash_register_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/csv/cash_register_stats.tt >new file mode 100644 >index 0000000..fc0b217 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/csv/cash_register_stats.tt >@@ -0,0 +1,14 @@ >+[% USE ItemTypes %] >+[% INCLUDE csv_headers/reports/cash_register_stats.tt %] >+[%- FOREACH row IN rows %] >+ [%- FOREACH field IN row; >+ field IF !loop.last; >+ ItemTypes.GetDescription(field) IF loop.last; >+ sep IF !loop.last; >+ END %] >+[% END -%] >+TOTAL >+[%- FOREACH field IN total; >+ field; >+ sep IF !loop.last; >+END %] >diff --git a/reports/cash_register_stats.pl b/reports/cash_register_stats.pl >index 00561c3..40ee489 100755 >--- a/reports/cash_register_stats.pl >+++ b/reports/cash_register_stats.pl >@@ -137,7 +137,6 @@ if ($do_it) { > total => $grantotal, > ); > } else{ >- binmode STDOUT, ':encoding(UTF-8)'; > my $q_errors; > my $format = 'csv'; > my $reportname = $input->param('basename'); >@@ -145,27 +144,9 @@ if ($do_it) { > #my $reportfilename = "$reportname.html" ; > my $delimiter = C4::Context->preference('delimiter') || ','; > my ( $content ); >- if ( $format eq 'csv' ) { >- my $csv = Text::CSV::Encoded->new({ encoding_out => 'UTF-8', sep_char => $delimiter}); >- $csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag(); >- my @headers = (); >- push @headers, "mfirstname", >- "cardnumber", >- "bfirstname", >- "branchname", >- "date", >- "accounttype", >- "amount", >- "title", >- "barcode", >- "itype"; >- if ($csv->combine(@headers)) { >- $content .= Encode::decode('UTF-8', $csv->string()) . "\n"; >- } else { >- push @$q_errors, { combine => 'HEADER ROW: ' . $csv->error_diag() } ; >- } >+ my @rows; > foreach my $row (@loopresult) { >- my @rowValues = (); >+ my @rowValues; > push @rowValues, $row->{mfirstname}, > $row->{cardnumber}, > $row->{bfirstname}, >@@ -176,24 +157,20 @@ if ($do_it) { > $row->{title}, > $row->{barcode}, > $row->{itype}; >- if ($csv->combine(@rowValues)) { >- $content .= Encode::decode('UTF-8',$csv->string()) . "\n"; >- } else { >- push @$q_errors, { combine => $csv->error_diag() } ; >+ push (@rows, \@rowValues) ; > } >- } >- } >+ my @total; >+ for (1..6){push(@total,"")}; >+ push(@total, $grantotal); > print $input->header( >- -type => 'text/csv', >- -attachment=> $reportfilename >- ); >- print $content; >- >- print $delimiter x 6; >- print $grantotal."\n"; >- foreach my $err (@$q_errors) { >- print "# ERROR: " . (map {$_ . ": " . $err->{$_}} keys %$err) . "\n"; >- } # here we print all the non-fatal errors at the end. Not super smooth, but better than nothing. >+ -type => 'text/csv', >+ -encoding => 'utf-8', >+ -attachment => $reportfilename, >+ -name => $reportfilename >+ ); >+ my $csvTemplate = C4::Templates::gettemplate('reports/csv/cash_register_stats.tt', 'intranet', $input); >+ $csvTemplate->param(sep => $delimiter, rows => \@rows, total => \@total ); >+ print $csvTemplate->output; > exit(1); > } > >-- >1.9.1
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 6934
:
5634
|
5635
|
5640
|
5641
|
9379
|
9419
|
12602
|
12660
|
31210
|
36476
|
42564
|
42565
|
44847
|
44853
|
45972
|
45973
|
45974
|
48634
|
48642
|
48704
|
48705
|
48706
|
48707
|
48708
|
50429
|
50437
|
50938
|
53496
|
53500
|
53570
|
53571
|
53572
|
53573
|
53574
|
53575
|
53576
|
53577
|
53578
|
53579
|
53581
|
53582
|
53583
|
53584
|
53585
|
53586
|
53587
|
53588
|
53589
|
53590
|
53591
|
53648
|
53650
|
53651
|
53652
|
53653
|
53778
|
53780
|
54010
|
54088
|
54089
|
54090
|
54091
|
54092
|
54093
|
54094
|
54095
|
54096
|
54097
|
54098
|
54099
|
54100
|
55939
|
55988
|
55989
|
55990
|
55991
|
55992
|
55993
|
55994
|
55995
|
55996
|
55997
|
55998
|
55999
|
56000
|
56001
|
56763
|
56764