X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/75f43bc11fb40b5bac23b74465c44826cfb457a6..c1524c56c69d761f85a543ad66eac298e704b10c:/SL/ReportGenerator.pm diff --git a/SL/ReportGenerator.pm b/SL/ReportGenerator.pm index c5ef273c6..0a61195c9 100644 --- a/SL/ReportGenerator.pm +++ b/SL/ReportGenerator.pm @@ -7,6 +7,8 @@ use Text::CSV_XS; #use PDF::Table; use strict; +use SL::Helper::GlAttachments qw(append_gl_pdf_attachments); +use SL::Helper::CreatePDF qw(merge_pdfs); # Cause locales.pl to parse these files: # parse_html_template('report_generator/html_report') @@ -47,6 +49,7 @@ sub new { 'escape_char' => '"', 'eol_style' => 'Unix', 'headers' => 1, + 'encoding' => 'UTF-8', }, }; $self->{export} = { @@ -287,6 +290,7 @@ sub prepare_html_content { 'align' => $column->{align}, 'link' => $column->{link}, 'text' => $column->{text}, + 'raw_header_data' => $column->{raw_header_data}, 'show_sort_indicator' => $name eq $opts->{sort_indicator_column}, 'sort_indicator_direction' => $opts->{sort_indicator_direction}, }; @@ -497,7 +501,9 @@ sub generate_pdf_content { foreach (0 .. $num_columns - 1) { push @{ $cell_props_row }, { 'background_color' => '#666666', - 'font_color' => '#ffffff', + # BUG PDF:Table -> 0.9.12: + # font_color is used in next row, so dont set font_color + # 'font_color' => '#ffffff', 'colspan' => $_ == 0 ? -1 : undef, }; } } @@ -654,6 +660,11 @@ sub generate_pdf_content { my $content = $pdf->stringify(); + $main::lxdebug->message(LXDebug->DEBUG2(),"addattachments ?? =".$form->{report_generator_addattachments}." GL=".$form->{GL}); + if ( $form->{report_generator_addattachments} eq 'yes' && $form->{GL}) { + $content = $self->append_gl_pdf_attachments($form,$content); + } + my $printer_command; if ($pdfopts->{print} && $pdfopts->{printer_id}) { $form->{printer_id} = $pdfopts->{printer_id}; @@ -702,10 +713,10 @@ sub _print_content { } sub _handle_quoting_and_encoding { - my ($self, $text, $do_unquote) = @_; + my ($self, $text, $do_unquote, $encoding) = @_; $text = $main::locale->unquote_special_chars('HTML', $text) if $do_unquote; - $text = Encode::encode('UTF-8', $text); + $text = Encode::encode($encoding || 'UTF-8', $text); return $text; } @@ -744,7 +755,7 @@ sub _generate_csv_content { if ($opts->{headers}) { if (!$self->{custom_headers}) { - $csv->print($stdout, [ map { $self->_handle_quoting_and_encoding($self->{columns}->{$_}->{text}, 1) } @visible_columns ]); + $csv->print($stdout, [ map { $self->_handle_quoting_and_encoding($self->{columns}->{$_}->{text}, 1, $opts->{encoding}) } @visible_columns ]); } else { foreach my $row (@{ $self->{custom_headers} }) { @@ -752,7 +763,7 @@ sub _generate_csv_content { foreach my $col (@{ $row }) { my $num_output = ($col->{colspan} && ($col->{colspan} > 1)) ? $col->{colspan} : 1; - push @{ $fields }, ($self->_handle_quoting_and_encoding($col->{text}, 1)) x $num_output; + push @{ $fields }, ($self->_handle_quoting_and_encoding($col->{text}, 1, $opts->{encoding})) x $num_output; } $csv->print($stdout, $fields); @@ -774,7 +785,7 @@ sub _generate_csv_content { my $num_output = ($row->{$col}{colspan} && ($row->{$col}->{colspan} > 1)) ? $row->{$col}->{colspan} : 1; $skip_next = $num_output - 1; - push @data, join($eol, map { s/\r?\n/$eol/g; $self->_handle_quoting_and_encoding($_, 0) } @{ $row->{$col}->{data} }); + push @data, join($eol, map { s/\r?\n/$eol/g; $self->_handle_quoting_and_encoding($_, 0, $opts->{encoding}) } @{ $row->{$col}->{data} }); push @data, ('') x $skip_next if ($skip_next); } @@ -850,9 +861,10 @@ Adds data to the report. A given hash_ref is interpreted as a single line of data, every array_ref as a collection of lines. Every line will be expected to be in a key => value format. Note that the rows have to already have been sorted. -The ReportGenerator is only able to sort pre-sorted data by column direction -(ascending or descending), and provides links to sorting and a visual cue as to -which column was sorted by. + +The ReportGenerator is only able to display pre-sorted data and to indicate by +which column and in which direction the data has been sorted via visual clues +in the column headers. It also provides links to invert the sort direction. =item add_separator @@ -1024,6 +1036,10 @@ End of line style. Default is Unix. Include headers? Default is yes. +=item encoding + +Character encoding. Default is UTF-8. + =back =head1 SEE ALO