From 27bdd44b8c9c45f438138076938935df43977f86 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 15 Jun 2007 13:07:47 +0000 Subject: [PATCH] =?utf8?q?ReportGenerator:=20Die=20Spaltendatenfelder=20'd?= =?utf8?q?ata'=20und=20'link'=20k=C3=B6nnen=20jetzt=20auch=20Array-Referen?= =?utf8?q?zen=20sein,=20die=20in=20der=20Zelle=20zeilenweise=20ausgegeben?= =?utf8?q?=20werden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/ReportGenerator.pm | 36 ++++++++++++++----- bin/mozilla/gl.pl | 12 +++---- .../report_generator/html_report_de.html | 2 +- .../report_generator/html_report_master.html | 2 +- .../report_generator/pdf_report_de.html | 2 +- .../report_generator/pdf_report_master.html | 2 +- 6 files changed, 36 insertions(+), 20 deletions(-) diff --git a/SL/ReportGenerator.pm b/SL/ReportGenerator.pm index 8f1838533..28399f794 100644 --- a/SL/ReportGenerator.pm +++ b/SL/ReportGenerator.pm @@ -93,18 +93,26 @@ sub add_data { my $last_row_set; while (my $arg = shift) { + my $row_set; + if ('ARRAY' eq ref $arg) { - push @{ $self->{data} }, $arg; - $last_row_set = $arg; + $row_set = $arg; } elsif ('HASH' eq ref $arg) { - my $row_set = [ $arg ]; - push @{ $self->{data} }, $row_set; - $last_row_set = $row_set; + $row_set = [ $arg ]; } else { $self->{form}->error('Incorrect usage -- expecting hash or array ref'); } + + foreach my $row (@{ $row_set }) { + foreach my $field (qw(data link)) { + map { $row->{$_}->{$field} = [ $row->{$_}->{$field} ] if (ref $row->{$_}->{$field} ne 'ARRAY') } keys %{ $row }; + } + } + + push @{ $self->{data} }, $row_set; + $last_row_set = $row_set; } return $last_row_set; @@ -259,7 +267,16 @@ sub prepare_html_content { foreach my $row (@{ $row_set }) { $inner_idx++; - map { $row->{$_}->{data} = $self->html_format($row->{$_}->{data}) } @visible_columns; + foreach my $col_name (@visible_columns) { + my $col = $row->{$col_name}; + $col->{CELL_ROWS} = [ ]; + foreach my $i (0 .. scalar(@{ $col->{data} })) { + push @{ $col->{CELL_ROWS} }, { + 'data' => $self->html_format($col->{data}->[$i]), + 'link' => $col->{link}->[$i], + }; + }; + } my $row_data = { 'COLUMNS' => [ map { $row->{$_} } @visible_columns ], @@ -458,8 +475,11 @@ sub generate_csv_content { foreach my $row_set (@{ $self->{data} }) { next if ('ARRAY' ne ref $row_set); foreach my $row (@{ $row_set }) { - map { $row->{$_}->{data} =~ s/\r?\n/$eol/g } @visible_columns; - $csv->print($stdout, [ map { $row->{$_}->{data} } @visible_columns ]); + my @data; + foreach my $col (@visible_columns) { + push @data, join($eol, map { s/\r?\n/$eol/g; $_ } @{ $row->{$col}->{data} }); + } + $csv->print($stdout, \@data); } } } diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 0fd863e51..b90f29c14 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -580,18 +580,14 @@ sub generate_report { map { $row->{$_}->{data} = $ref->{$_} } qw(id reference description source notes); - map { $row->{$_}->{data} = join "\n", @{ $rows{$_} }; } qw(transdate debit credit); - - map { $row->{$_}->{data} = join "\n", @{ $rows{$_} } if ($ref->{"${_}_accno"} ne "") } qw(debit_tax credit_tax); + map { $row->{$_}->{data} = \@{ $rows{$_} }; } qw(transdate debit credit debit_accno credit_accno debit_tax_accno credit_tax_accno); foreach my $col (qw(debit_accno credit_accno debit_tax_accno credit_tax_accno)) { - if (lc $report->{options}->{output_format} eq 'html') { - $row->{$col}->{raw_data} = join "
", map { "$_" } @{ $rows{$col} }; - } else { - $row->{$col}->{data} = join "\n", @{ $rows{$col} }; - } + $row->{$col}->{link} = [ map { "${callback}&accno=" . E($_) } @{ $rows{$col} } ]; } + map { $row->{$_}->{data} = \@{ $rows{$_} } if ($ref->{"${_}_accno"} ne "") } qw(debit_tax credit_tax); + $row->{reference}->{link} = build_std_url("script=$ref->{module}.pl", 'action=edit', 'id=' . E($ref->{id}), 'callback'); my $row_set = [ $row ]; diff --git a/templates/webpages/report_generator/html_report_de.html b/templates/webpages/report_generator/html_report_de.html index c5f4b83b8..9673a484a 100644 --- a/templates/webpages/report_generator/html_report_de.html +++ b/templates/webpages/report_generator/html_report_de.html @@ -35,7 +35,7 @@
- align="" valign="" class=""> + align="" valign="" class="">
diff --git a/templates/webpages/report_generator/html_report_master.html b/templates/webpages/report_generator/html_report_master.html index 83e0ef7d2..01e7c61da 100644 --- a/templates/webpages/report_generator/html_report_master.html +++ b/templates/webpages/report_generator/html_report_master.html @@ -35,7 +35,7 @@
- align="" valign="" class=""> + align="" valign="" class="">
diff --git a/templates/webpages/report_generator/pdf_report_de.html b/templates/webpages/report_generator/pdf_report_de.html index b61b3be23..2f3746faa 100644 --- a/templates/webpages/report_generator/pdf_report_de.html +++ b/templates/webpages/report_generator/pdf_report_de.html @@ -17,7 +17,7 @@ - align="" valign=""> + align="" valign="">
diff --git a/templates/webpages/report_generator/pdf_report_master.html b/templates/webpages/report_generator/pdf_report_master.html index b61b3be23..2f3746faa 100644 --- a/templates/webpages/report_generator/pdf_report_master.html +++ b/templates/webpages/report_generator/pdf_report_master.html @@ -17,7 +17,7 @@ - align="" valign=""> + align="" valign="">
-- 2.20.1