diff options
author | Mark Wells <mark@freeside.biz> | 2016-09-08 14:40:13 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2016-09-08 14:40:35 -0700 |
commit | cda0cfbe3c69fa260ba7e5ce9b50853dfba7cc97 (patch) | |
tree | 1a1023c6affeb9c8b85acc6afde130d393555cc9 /FS/FS | |
parent | 9c0ba3e16a066851dec5488b4a95565e271ae325 (diff) |
add delivery of spreadsheet/CSV reports, #72101
Diffstat (limited to 'FS/FS')
-rw-r--r-- | FS/FS/CGI.pm | 18 | ||||
-rw-r--r-- | FS/FS/saved_search.pm | 29 |
2 files changed, 27 insertions, 20 deletions
diff --git a/FS/FS/CGI.pm b/FS/FS/CGI.pm index fc0f652..098cdf0 100644 --- a/FS/FS/CGI.pm +++ b/FS/FS/CGI.pm @@ -78,21 +78,17 @@ Sets an http header. sub http_header { my ( $header, $value ) = @_; - if (exists $ENV{MOD_PERL}) { - if ( defined $HTML::Mason::Commands::r ) { #Mason - ## is this the correct pacakge for $r ??? for 1.0x and 1.1x ? - if ( $header =~ /^Content-Type$/ ) { - $HTML::Mason::Commands::r->content_type($value); - } else { - $HTML::Mason::Commands::r->header_out( $header => $value ); - } + if ( defined $HTML::Mason::Commands::r ) { #Mason + apache + if ( $header =~ /^Content-Type$/ ) { + $HTML::Mason::Commands::r->content_type($value); } else { - die "http_header called in unknown environment"; + $HTML::Mason::Commands::r->header_out( $header => $value ); } + } elsif ( defined $HTML::Mason::Commands::m ) { + $HTML::Mason::Commands::m->notes(lc("header-$header"), $value); } else { - die "http_header called not running under mod_perl"; + warn "http_header($header, $value) called with no way to set headers\n"; } - } =item menubar ITEM, URL, ... diff --git a/FS/FS/saved_search.pm b/FS/FS/saved_search.pm index caaf7fe..fd82439 100644 --- a/FS/FS/saved_search.pm +++ b/FS/FS/saved_search.pm @@ -242,7 +242,25 @@ sub render { <p>' . $_ . '</p>'; } - return $outbuf; + my %mime = ( + Data => $outbuf, + Type => $mason_request->notes('header-content-type') + || 'text/html', + Disposition => 'inline', + ); + if (my $disp = $mason_request->notes('header-content-disposition') ) { + $disp =~ /^(attachment|inline)\s*;\s*filename=(.*)$/; + $mime{Disposition} = $1; + my $filename = $2; + $filename =~ s/^"(.*)"$/$1/; + $mime{Filename} = $filename; + } + if ($mime{Type} =~ /^text/) { + $mime{Encoding} = 'quoted-printable'; + } else { + $mime{Encoding} = 'base64'; + } + return MIME::Entity->build(%mime); } =item send @@ -265,14 +283,7 @@ sub send { return $error; } $log->debug('Rendering saved search'); - my $content = $self->render; - # XXX come back to this for content-type options - my $part = MIME::Entity->build( - 'Type' => 'text/html', - 'Encoding' => 'quoted-printable', # change this for spreadsheet - 'Disposition' => 'inline', - 'Data' => $content, - ); + my $part = $self->render; my %email_param = ( 'from' => $conf->config('invoice_from'), |