X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FReportGenerator.pm;h=2e12a2acc51dabf9fb74b1bdfbea016de3fb1cfd;hb=12f8fb507f7531f2e434214eb9a8c4d7a55c75d5;hp=c5ef273c64ffe9c8a836357a73e9e536ca071a0d;hpb=75f43bc11fb40b5bac23b74465c44826cfb457a6;p=kivitendo-erp.git diff --git a/SL/ReportGenerator.pm b/SL/ReportGenerator.pm index c5ef273c6..2e12a2acc 100644 --- a/SL/ReportGenerator.pm +++ b/SL/ReportGenerator.pm @@ -47,6 +47,7 @@ sub new { 'escape_char' => '"', 'eol_style' => 'Unix', 'headers' => 1, + 'encoding' => 'UTF-8', }, }; $self->{export} = { @@ -287,6 +288,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}, }; @@ -702,10 +704,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 +746,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 +754,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 +776,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 +852,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 +1027,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