Revision 84ba8214
Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt
SL/ReportGenerator.pm | ||
---|---|---|
189 | 189 |
}; |
190 | 190 |
} |
191 | 191 |
|
192 |
sub set_custom_headers { |
|
193 |
my $self = shift; |
|
194 |
|
|
195 |
if (@_) { |
|
196 |
$self->{custom_headers} = [ @_ ]; |
|
197 |
} else { |
|
198 |
delete $self->{custom_headers}; |
|
199 |
} |
|
200 |
} |
|
201 |
|
|
192 | 202 |
sub get_attachment_basename { |
193 | 203 |
my $self = shift; |
194 | 204 |
my $filename = $self->{options}->{attachment_basename} || 'report'; |
... | ... | |
269 | 279 |
push @column_headers, $header; |
270 | 280 |
} |
271 | 281 |
|
282 |
my $header_rows; |
|
283 |
if ($self->{custom_headers}) { |
|
284 |
$header_rows = $self->{custom_headers}; |
|
285 |
} else { |
|
286 |
$header_rows = [ \@column_headers ]; |
|
287 |
} |
|
288 |
|
|
272 | 289 |
my ($outer_idx, $inner_idx) = (0, 0); |
273 | 290 |
my $next_border_top; |
274 | 291 |
my @rows; |
... | ... | |
354 | 371 |
'ALLOW_PDF_EXPORT' => $allow_pdf_export, |
355 | 372 |
'ALLOW_CSV_EXPORT' => $opts->{allow_csv_export}, |
356 | 373 |
'SHOW_EXPORT_BUTTONS' => ($allow_pdf_export || $opts->{allow_csv_export}) && $self->{data_present}, |
357 |
'COLUMN_HEADERS' => \@column_headers,
|
|
374 |
'HEADER_ROWS' => $header_rows,
|
|
358 | 375 |
'NUM_COLUMNS' => scalar @column_headers, |
359 | 376 |
'ROWS' => \@rows, |
360 | 377 |
'EXPORT_VARIABLES' => \@export_variables, |
... | ... | |
390 | 407 |
|
391 | 408 |
my (@data, @column_props, @cell_props); |
392 | 409 |
|
393 |
my $data_row = []; |
|
394 |
my $cell_props_row = []; |
|
410 |
my ($data_row, $cell_props_row); |
|
395 | 411 |
my @visible_columns = $self->get_visible_columns('HTML'); |
412 |
my $num_columns = scalar @visible_columns; |
|
413 |
my $num_header_rows = 1; |
|
396 | 414 |
|
397 | 415 |
foreach $name (@visible_columns) { |
398 |
$column = $self->{columns}->{$name}; |
|
399 |
|
|
400 |
push @{ $data_row }, $column->{text}; |
|
401 |
push @{ $cell_props_row }, {}; |
|
402 |
push @column_props, { 'justify' => $column->{align} eq 'right' ? 'right' : 'left' }; |
|
416 |
push @column_props, { 'justify' => $self->{columns}->{$name}->{align} eq 'right' ? 'right' : 'left' }; |
|
403 | 417 |
} |
404 | 418 |
|
405 |
push @data, $data_row; |
|
406 |
push @cell_props, $cell_props_row; |
|
419 |
if (!$self->{custom_headers}) { |
|
420 |
$data_row = []; |
|
421 |
$cell_props_row = []; |
|
422 |
push @data, $data_row; |
|
423 |
push @cell_props, $cell_props_row; |
|
424 |
|
|
425 |
foreach $name (@visible_columns) { |
|
426 |
$column = $self->{columns}->{$name}; |
|
427 |
|
|
428 |
push @{ $data_row }, $column->{text}; |
|
429 |
push @{ $cell_props_row }, {}; |
|
430 |
} |
|
407 | 431 |
|
408 |
my $num_columns = scalar @column_props; |
|
432 |
} else { |
|
433 |
$num_header_rows = scalar @{ $self->{custom_headers} }; |
|
434 |
|
|
435 |
foreach my $custom_header_row (@{ $self->{custom_headers} }) { |
|
436 |
$data_row = []; |
|
437 |
$cell_props_row = []; |
|
438 |
push @data, $data_row; |
|
439 |
push @cell_props, $cell_props_row; |
|
440 |
|
|
441 |
foreach my $custom_header_col (@{ $custom_header_row }) { |
|
442 |
push @{ $data_row }, $custom_header_col->{text}; |
|
443 |
push @{ $cell_props_row }, {}; |
|
444 |
} |
|
445 |
} |
|
446 |
} |
|
409 | 447 |
|
410 | 448 |
foreach my $row_set (@{ $self->{data} }) { |
411 | 449 |
if ('HASH' eq ref $row_set) { |
... | ... | |
534 | 572 |
'font' => $font, |
535 | 573 |
'font_size' => $font_size, |
536 | 574 |
'font_color' => '#000000', |
575 |
'num_header_rows' => $num_header_rows, |
|
537 | 576 |
'header_props' => { |
538 | 577 |
'bg_color' => '#ffffff', |
539 | 578 |
'repeat' => 1, |
... | ... | |
656 | 695 |
my @visible_columns = $self->get_visible_columns('CSV'); |
657 | 696 |
|
658 | 697 |
if ($opts->{headers}) { |
659 |
$csv->print($stdout, [ map { $self->unescape_string($self->{columns}->{$_}->{text}) } @visible_columns ]); |
|
698 |
if (!$self->{custom_headers}) { |
|
699 |
$csv->print($stdout, [ map { $self->unescape_string($self->{columns}->{$_}->{text}) } @visible_columns ]); |
|
700 |
|
|
701 |
} else { |
|
702 |
foreach my $custom_header_row (@{ $self->{custom_headers} }) { |
|
703 |
$csv->print($stdout, [ map { $self->unescape_string($_->{text}) } @{ $custom_header_row } ]); |
|
704 |
} |
|
705 |
} |
|
660 | 706 |
} |
661 | 707 |
|
662 | 708 |
foreach my $row_set (@{ $self->{data} }) { |
Auch abrufbar als: Unified diff
ReportGenerator: Unterstützung für mehrzeilige und individuell festgelegte Tabellenköpfe/Spaltenüberschriften implementiert.