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:13 -0700 |
commit | ac541a006ca3b90039d21dca39c76cee34092553 (patch) | |
tree | f613218b387e78bf78ae2f2161fbb28e27cf8ee3 /FS/FS/saved_search.pm | |
parent | 88904ee5a5529f7e80811f1e68216c92b028e7e9 (diff) |
add delivery of spreadsheet/CSV reports, #72101
Diffstat (limited to 'FS/FS/saved_search.pm')
-rw-r--r-- | FS/FS/saved_search.pm | 29 |
1 files changed, 20 insertions, 9 deletions
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'), |