X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/786b3862388eb8d4cdcc5dfc663a37fe0e9a82a1..330cfa6d7507da52bc1c2a3874b46eb23255538f:/SL/ReportGenerator.pm diff --git a/SL/ReportGenerator.pm b/SL/ReportGenerator.pm index f3664624b..2273c2e6b 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, @@ -444,8 +454,17 @@ sub generate_pdf_content { push @cell_props, $cell_props_row; foreach my $custom_header_col (@{ $custom_header_row }) { - push @{ $data_row }, $custom_header_col->{text}; - push @{ $cell_props_row }, {}; + push @{ $data_row }, $custom_header_col->{text}; + + my $num_output = ($custom_header_col->{colspan} * 1 > 1) ? $custom_header_col->{colspan} : 1; + if ($num_output > 1) { + push @{ $data_row }, ('') x ($num_output - 1); + push @{ $cell_props_row }, { 'colspan' => $num_output }; + push @{ $cell_props_row }, ({ }) x ($num_output - 1); + + } else { + push @{ $cell_props_row }, {}; + } } } } @@ -468,8 +487,11 @@ sub generate_pdf_content { } foreach my $row (@{ $row_set }) { - $data_row = []; - push @data, $data_row; + $data_row = []; + $cell_props_row = []; + + push @data, $data_row; + push @cell_props, $cell_props_row; my $col_idx = 0; foreach my $col_name (@visible_columns) { @@ -478,14 +500,14 @@ sub generate_pdf_content { $column_props[$col_idx]->{justify} = 'right' if ($col->{align} eq 'right'); - $col_idx++; - } + my $cell_props = { }; + push @{ $cell_props_row }, $cell_props; - $cell_props_row = []; - push @cell_props, $cell_props_row; + if ($col->{colspan} && $col->{colspan} > 1) { + $cell_props->{colspan} = $col->{colspan}; + } - foreach (0 .. $num_columns - 1) { - push @{ $cell_props_row }, { }; + $col_idx++; } } } @@ -585,6 +607,7 @@ sub generate_pdf_content { }, 'column_props' => \@column_props, 'cell_props' => \@cell_props, + 'max_word_length' => 60, ); foreach my $page_num (1..$pdf->pages()) { @@ -696,8 +719,15 @@ 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 = [ ]; + + 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 +736,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); } }