From: Moritz Bunkus Date: Wed, 23 Apr 2008 15:39:20 +0000 (+0000) Subject: ReportGenerator: Unterstützung für das Verbinden von Zellen mittels "colspan" für... X-Git-Tag: release-2.6.0beta1~161 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=078fa02aa17feb2560a76b54a9c98c8c98957de5;p=kivitendo-erp.git ReportGenerator: Unterstützung für das Verbinden von Zellen mittels "colspan" für HTML- und CSV-Ausgabe. --- diff --git a/SL/ReportGenerator.pm b/SL/ReportGenerator.pm index f3664624b..34ef2b5cf 100644 --- a/SL/ReportGenerator.pm +++ b/SL/ReportGenerator.pm @@ -322,7 +322,14 @@ sub prepare_html_content { foreach my $row (@{ $row_set }) { $inner_idx++; + my $output_columns = [ ]; + my $skip_next = 0; foreach my $col_name (@visible_columns) { + if ($skip_next) { + $skip_next--; + next; + } + my $col = $row->{$col_name}; $col->{CELL_ROWS} = [ ]; foreach my $i (0 .. scalar(@{ $col->{data} }) - 1) { @@ -339,10 +346,13 @@ sub prepare_html_content { } elsif ((1 == scalar @{ $col->{CELL_ROWS} }) && (!defined $col->{CELL_ROWS}->[0]->{data} || ($col->{CELL_ROWS}->[0]->{data} eq ''))) { $col->{CELL_ROWS}->[0]->{data} = ' '; } + + push @{ $output_columns }, $col; + $skip_next = $col->{colspan} ? $col->{colspan} - 1 : 0; } my $row_data = { - 'COLUMNS' => [ map { $row->{$_} } @visible_columns ], + 'COLUMNS' => $output_columns, 'outer_idx' => $outer_idx, 'outer_idx_odd' => $outer_idx % 2, 'inner_idx' => $inner_idx, @@ -696,8 +706,16 @@ sub generate_csv_content { $csv->print($stdout, [ map { $self->unescape_string($self->{columns}->{$_}->{text}) } @visible_columns ]); } else { - foreach my $custom_header_row (@{ $self->{custom_headers} }) { - $csv->print($stdout, [ map { $self->unescape_string($_->{text}) } @{ $custom_header_row } ]); + foreach my $row (@{ $self->{custom_headers} }) { + my $fields = [ ]; + my $skip_next = 0; + + foreach my $col (@{ $row }) { + my $num_output = ($col->{colspan} && ($col->{colspan} > 1)) ? $col->{colspan} : 1; + push @{ $fields }, ($self->unescape_string($col->{text})) x $num_output; + } + + $csv->print($stdout, $fields); } } } @@ -706,9 +724,20 @@ sub generate_csv_content { next if ('ARRAY' ne ref $row_set); foreach my $row (@{ $row_set }) { my @data; + my $skip_next = 0; foreach my $col (@visible_columns) { + if ($skip_next) { + $skip_next--; + next; + } + + my $num_output = ($col->{colspan} && ($col->{colspan} > 1)) ? $col->{colspan} : 1; + $skip_next = $num_output - 1; + push @data, join($eol, map { s/\r?\n/$eol/g; $_ } @{ $row->{$col}->{data} }); + push @data, ('') x $skip_next if ($skip_next); } + $csv->print($stdout, \@data); } } diff --git a/templates/webpages/report_generator/html_report_de.html b/templates/webpages/report_generator/html_report_de.html index ce7a7ebb6..0be715f09 100644 --- a/templates/webpages/report_generator/html_report_de.html +++ b/templates/webpages/report_generator/html_report_de.html @@ -41,7 +41,10 @@ [%- FOREACH row = HEADER_ROWS %] [% FOREACH col = row %] - + 1 %] colspan="[% HTML.escape(col.colspan) %]"[% END -%] + > [%- IF col.link -%][%- END -%] [%- col.text -%] [%- IF col.show_sort_indicator -%][%- END -%] @@ -59,6 +62,7 @@ [%- FOREACH col = row.COLUMNS %] 1 %] colspan="[% HTML.escape(col.colspan) %]"[% END -%] [%- SET tdclass = '' %] [%- IF row.BORDER_TOP %][%- SET tdclass = "$tdclass top_border" %][%- END %] [%- IF row.BORDER_BOTTOM %][%- SET tdclass = "$tdclass bottom_border" %][%- END %] diff --git a/templates/webpages/report_generator/html_report_master.html b/templates/webpages/report_generator/html_report_master.html index 68c1cdc89..b8d83d2a5 100644 --- a/templates/webpages/report_generator/html_report_master.html +++ b/templates/webpages/report_generator/html_report_master.html @@ -41,7 +41,10 @@ [%- FOREACH row = HEADER_ROWS %] [% FOREACH col = row %] - + 1 %] colspan="[% HTML.escape(col.colspan) %]"[% END -%] + > [%- IF col.link -%][%- END -%] [%- col.text -%] [%- IF col.show_sort_indicator -%][%- END -%] @@ -59,6 +62,7 @@ [%- FOREACH col = row.COLUMNS %] 1 %] colspan="[% HTML.escape(col.colspan) %]"[% END -%] [%- SET tdclass = '' %] [%- IF row.BORDER_TOP %][%- SET tdclass = "$tdclass top_border" %][%- END %] [%- IF row.BORDER_BOTTOM %][%- SET tdclass = "$tdclass bottom_border" %][%- END %]