Revision 15b4d5a3
Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt
SL/ReportGenerator.pm | ||
---|---|---|
181 | 181 |
print $self->generate_html_content(); |
182 | 182 |
|
183 | 183 |
} elsif ($format eq 'csv') { |
184 |
print qq|content-type: text/plain\n\n|;
|
|
185 |
# print qq|content-disposition: attachment; filename=${filename}.csv\n\n|;
|
|
184 |
print qq|content-type: text/csv\n|;
|
|
185 |
print qq|content-disposition: attachment; filename=${filename}.csv\n\n|; |
|
186 | 186 |
$self->generate_csv_content(); |
187 | 187 |
|
188 | 188 |
} elsif ($format eq 'pdf') { |
... | ... | |
202 | 202 |
return grep { my $c = $self->{columns}->{$_}; $c && $c->{visible} && (($c->{visible} == 1) || ($c->{visible} =~ /${format}/i)) } @{ $self->{column_order} }; |
203 | 203 |
} |
204 | 204 |
|
205 |
sub html_format { |
|
206 |
my $self = shift; |
|
207 |
my $value = shift; |
|
208 |
|
|
209 |
$value = $self->{form}->quote_html($value); |
|
210 |
$value =~ s/\r//g; |
|
211 |
$value =~ s/\n/<br>/g; |
|
212 |
|
|
213 |
return $value; |
|
214 |
} |
|
215 |
|
|
205 | 216 |
sub prepare_html_content { |
206 | 217 |
my $self = shift; |
207 | 218 |
|
... | ... | |
233 | 244 |
foreach my $row (@{ $row_set }) { |
234 | 245 |
$inner_idx++; |
235 | 246 |
|
247 |
map { $row->{$_}->{data} = $self->html_format($row->{$_}->{data}) } @visible_columns; |
|
248 |
|
|
236 | 249 |
my $row_data = { |
237 | 250 |
'COLUMNS' => [ map { $row->{$_} } @visible_columns ], |
238 | 251 |
'outer_idx' => $outer_idx, |
... | ... | |
253 | 266 |
|
254 | 267 |
my $variables = { |
255 | 268 |
'TITLE' => $opts->{title}, |
256 |
'TOP_INFO_TEXT' => $opts->{top_info_text},
|
|
269 |
'TOP_INFO_TEXT' => $self->html_format($opts->{top_info_text}),
|
|
257 | 270 |
'RAW_TOP_INFO_TEXT' => $opts->{raw_top_info_text}, |
258 |
'BOTTOM_INFO_TEXT' => $opts->{bottom_info_text},
|
|
271 |
'BOTTOM_INFO_TEXT' => $self->html_format($opts->{bottom_info_text}),
|
|
259 | 272 |
'RAW_BOTTOM_INFO_TEXT' => $opts->{raw_bottom_info_text}, |
260 | 273 |
'ALLOW_PDF_EXPORT' => $allow_pdf_export, |
261 | 274 |
'ALLOW_CSV_EXPORT' => $opts->{allow_csv_export}, |
Auch abrufbar als: Unified diff
Berichtsklasse:
1. Commit der vorher vergessenen HTML-Templates für die Berichte und die Exportoptionen.
2. HTML-Berichte: Zeilenumbrüche mit "\n" werden in "<br>" umgewandelt.
3. CSV-Export: Richtiger MIME-Type; Download der Datei forcieren; Option für die Spaltenüberschriften gefixt.