};
}
+sub get_attachment_basename {
+ my $self = shift;
+ my $filename = $self->{options}->{attachment_basename} || 'report';
+ $filename =~ s|.*\\||;
+ $filename =~ s|.*/||;
+
+ return $filename;
+}
+
sub generate_with_headers {
my $self = shift;
my $format = lc $self->{options}->{output_format};
+ my $form = $self->{form};
if (!$self->{columns}) {
- $self->{form}->error('Incorrect usage -- no columns specified');
+ $form->error('Incorrect usage -- no columns specified');
}
- my $filename = $self->{options}->{attachment_basename} || 'report';
- $filename =~ s|.*\\||;
- $filename =~ s|.*/||;
-
if ($format eq 'html') {
- $self->{form}->{title} = $self->{title};
- $self->{form}->header();
+ my $title = $form->{title};
+ $form->{title} = $self->{title} if ($self->{title});
+ $form->header();
+ $form->{title} = $title;
+
print $self->generate_html_content();
} elsif ($format eq 'csv') {
+ my $filename = $self->get_attachment_basename();
print qq|content-type: text/csv\n|;
print qq|content-disposition: attachment; filename=${filename}.csv\n\n|;
$self->generate_csv_content();
$self->generate_pdf_content();
} else {
- $self->{form}->error('Incorrect usage -- unknown format (supported are HTML, CSV, PDF)');
+ $form->error('Incorrect usage -- unknown format (supported are HTML, CSV, PDF)');
}
}
my $content;
if (!$printer_command) {
+ my $filename = $self->get_attachment_basename();
print qq|content-type: application/pdf\n|;
print qq|content-disposition: attachment; filename=${filename}.pdf\n\n|;