...
####
use CGI ':standard';
use CGI ':cgi-lib';
use CGI::Carp qw(fatalsToBrowser);
use Switch;
use base 'CGI::Application';
use CGI::Application::Plugin::Session;
use Template;
use Template::Stash;
use strict;
use warnings;
...
sub reports_getReport{
my $self = shift;
my $q = $self->query;
...
switch($outputType){
case 'download'{
my $data=csvReport($report); #take the data and convert to comma delimited
$self->header_props(-type => 'application/octet-stream', -attachment => 'report.csv');
$self->header_add(-script=>{-type=>'text/javascript',-code=>' alert("hi there"); showWait(0); '});
return $data;
}
case 'screen'{#this works!!!
my $html=screenReport($report);
return $html;
}
case 'pdf'{
my $data=getReport($report);#$data is a pdf stream
$self->header_props(-type => 'application/pdf', -attachment => 'report.pdf');
$self->header_add(-script=>{-type=>'text/javascript',-code=>' alert("hi there"); showWait(0); '});
return $data;
}
else{}
}
}
sub screenReport{
my $report=shift;
my $html='';
$html.='
';
...
$html.='';
return $html;
}