projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Übergabe des Templates an den ReportGenerator nicht über $form, sondern über ReportGe...
[kivitendo-erp.git]
/
SL
/
ReportGenerator.pm
diff --git
a/SL/ReportGenerator.pm
b/SL/ReportGenerator.pm
index
29e2d94
..
23dd508
100644
(file)
--- a/
SL/ReportGenerator.pm
+++ b/
SL/ReportGenerator.pm
@@
-7,6
+7,10
@@
use Text::Iconv;
use SL::Form;
use SL::Form;
+# Cause locales.pl to parse these files:
+# parse_html_template('report_generator/html_report')
+# parse_html_template('report_generator/pdf_report')
+
sub new {
my $type = shift;
sub new {
my $type = shift;
@@
-21,6
+25,8
@@
sub new {
'output_format' => 'HTML',
'allow_pdf_export' => 1,
'allow_csv_export' => 1,
'output_format' => 'HTML',
'allow_pdf_export' => 1,
'allow_csv_export' => 1,
+ 'html_template' => 'report_generator/html_report',
+ 'pdf_template' => 'report_generator/pdf_report',
'pdf_export' => {
'paper_size' => 'A4',
'orientation' => 'landscape',
'pdf_export' => {
'paper_size' => 'A4',
'orientation' => 'landscape',
@@
-44,7
+50,7
@@
sub new {
};
$self->{export} = {
'nextsub' => '',
};
$self->{export} = {
'nextsub' => '',
- 'variable_list' =>
''
,
+ 'variable_list' =>
[]
,
};
$self->{data_present} = 0;
};
$self->{data_present} = 0;
@@
-209,7
+215,7
@@
sub set_export_options {
$self->{export} = {
'nextsub' => shift,
$self->{export} = {
'nextsub' => shift,
- 'variable_list' =>
join(" ", @_)
,
+ 'variable_list' =>
[ @_ ]
,
};
}
};
}
@@
-343,7
+349,7
@@
sub prepare_html_content {
# will format the table cell (e.g. borders etc).
if (!scalar @{ $col->{CELL_ROWS} }) {
push @{ $col->{CELL_ROWS} }, { 'data' => ' ' };
# will format the table cell (e.g. borders etc).
if (!scalar @{ $col->{CELL_ROWS} }) {
push @{ $col->{CELL_ROWS} }, { 'data' => ' ' };
- } elsif ((1 == scalar @{ $col->{CELL_ROWS} }) &&
!$col->{CELL_ROWS}->[0]->{data}
) {
+ } elsif ((1 == scalar @{ $col->{CELL_ROWS} }) &&
(!defined $col->{CELL_ROWS}->[0]->{data} || ($col->{CELL_ROWS}->[0]->{data} eq ''))
) {
$col->{CELL_ROWS}->[0]->{data} = ' ';
}
}
$col->{CELL_ROWS}->[0]->{data} = ' ';
}
}
@@
-362,10
+368,7
@@
sub prepare_html_content {
}
}
}
}
- my @export_variables;
- foreach my $key (split m/ +/, $self->{export}->{variable_list}) {
- push @export_variables, { 'key' => $key, 'value' => $self->{form}->{$key} };
- }
+ my @export_variables = $self->{form}->flatten_variables(@{ $self->{export}->{variable_list} });
my $allow_pdf_export = $opts->{allow_pdf_export} && (-x $main::html2ps_bin) && (-x $main::ghostscript_bin);
my $allow_pdf_export = $opts->{allow_pdf_export} && (-x $main::html2ps_bin) && (-x $main::ghostscript_bin);
@@
-382,7
+385,7
@@
sub prepare_html_content {
'NUM_COLUMNS' => scalar @column_headers,
'ROWS' => \@rows,
'EXPORT_VARIABLES' => \@export_variables,
'NUM_COLUMNS' => scalar @column_headers,
'ROWS' => \@rows,
'EXPORT_VARIABLES' => \@export_variables,
- 'EXPORT_VARIABLE_LIST' =>
$self->{export}->{variable_list}
,
+ 'EXPORT_VARIABLE_LIST' =>
join(' ', @{ $self->{export}->{variable_list} })
,
'EXPORT_NEXTSUB' => $self->{export}->{nextsub},
'DATA_PRESENT' => $self->{data_present},
};
'EXPORT_NEXTSUB' => $self->{export}->{nextsub},
'DATA_PRESENT' => $self->{data_present},
};
@@
-394,7
+397,7
@@
sub generate_html_content {
my $self = shift;
my $variables = $self->prepare_html_content();
my $self = shift;
my $variables = $self->prepare_html_content();
- return $self->{form}->parse_html_template(
'report_generator/html_report'
, $variables);
+ return $self->{form}->parse_html_template(
$self->{options}->{html_template}
, $variables);
}
sub verify_paper_size {
}
sub verify_paper_size {
@@
-470,7
+473,7
@@
END
$form->error($locale->text('Could not write the temporary HTML file.'));
}
$form->error($locale->text('Could not write the temporary HTML file.'));
}
- $html_file->print($form->parse_html_template(
'report_generator/pdf_report'
, $variables));
+ $html_file->print($form->parse_html_template(
$self->{options}->{pdf_template}
, $variables));
$html_file->close();
my $cmdline =
$html_file->close();
my $cmdline =