$self->{options} = {
'std_column_visibility' => 0,
'output_format' => 'HTML',
+ 'controller_class ' => '',
'allow_pdf_export' => 1,
'allow_csv_export' => 1,
'html_template' => 'report_generator/html_report',
$column->{visible} = $self->{options}->{std_column_visibility} unless defined $column->{visible};
}
+ if( $::form->{report_generator_csv_options_for_import} ) {
+ foreach my $key (keys %{ $self->{columns} }) {
+ $self->{columns}{$key}{text} = $key;
+ }
+ }
+
$self->set_column_order(sort keys %{ $self->{columns} });
}
sub get_attachment_basename {
my $self = shift;
my $filename = $self->{options}->{attachment_basename} || 'report';
+
+ # FIXME: this is bonkers. add a real sluggify method somewhere or import one.
$filename =~ s|.*\\||;
$filename =~ s|.*/||;
+ $filename =~ s| |_|g;
return $filename;
}
sub generate_with_headers {
- my $self = shift;
+ my ($self, %params) = @_;
my $format = lc $self->{options}->{output_format};
my $form = $self->{form};
if ($format eq 'html') {
my $title = $form->{title};
$form->{title} = $self->{title} if ($self->{title});
- $form->header();
+ $form->header(no_layout => $params{no_layout});
$form->{title} = $title;
print $self->generate_html_content();
} elsif ($format eq 'csv') {
+ # FIXME: don't do mini http in here
my $filename = $self->get_attachment_basename();
print qq|content-type: text/csv\n|;
print qq|content-disposition: attachment; filename=${filename}.csv\n\n|;
'EXPORT_VARIABLE_LIST' => join(' ', @{ $self->{export}->{variable_list} }),
'EXPORT_NEXTSUB' => $self->{export}->{nextsub},
'DATA_PRESENT' => $self->{data_present},
+ 'CONTROLLER_DISPATCH' => $opts->{controller_class},
};
return $variables;
my $self = shift;
my $variables = $self->prepare_html_content();
- return $self->{form}->parse_html_template($self->{options}->{html_template}, $variables);
+ my $stuff = $self->{form}->parse_html_template($self->{options}->{html_template}, $variables);
+ return $stuff;
}
sub _cm2bp {
my $font_height = $font_size + 2 * $padding;
my $title_font_height = $font_size + 2 * $padding;
- my $header_height = 2 * $title_font_height if ($opts->{title});
- my $footer_height = 2 * $font_height if ($pdfopts->{number});
+ my $header_height = $opts->{title} ? 2 * $title_font_height : undef;
+ my $footer_height = $pdfopts->{number} ? 2 * $font_height : undef;
my $top_text_height = 0;
}
}
+sub check_for_pdf_api {
+ return eval { require PDF::API2; 1; } ? 1 : 0;
+}
+
1;
__END__
The template to be used for HTML reports. Default is 'report_generator/html_report'.
+=item controller_class
+
+If this is used from a C<SL::Controller::Base> based controller class, pass the
+class name here and make sure C<SL::Controller::Helper::ReportGenerator> is
+used in the controller. That way the exports stay functional.
+
=back
=head2 PDF Options