summaryrefslogtreecommitdiff
path: root/httemplate/view/cust_msg_part.html
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2014-06-11 13:53:25 -0700
committerMark Wells <mark@freeside.biz>2014-06-11 13:53:25 -0700
commitc16ef0145a0049c3f20377e2c5076087e999cde0 (patch)
tree698c7c51c74e33ab84876b09e1253c85bf9774fe /httemplate/view/cust_msg_part.html
parentd2d137731f88b8a0d35294284ec3571f46bd18b5 (diff)
display sent mail on customer notes page, and improve sent mail log UI, #29250
Diffstat (limited to 'httemplate/view/cust_msg_part.html')
-rw-r--r--httemplate/view/cust_msg_part.html23
1 files changed, 23 insertions, 0 deletions
diff --git a/httemplate/view/cust_msg_part.html b/httemplate/view/cust_msg_part.html
new file mode 100644
index 000000000..0be5705cb
--- /dev/null
+++ b/httemplate/view/cust_msg_part.html
@@ -0,0 +1,23 @@
+<%init>
+die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('View email logs');
+# invoke this as "view/cust_msg_part.html?$custmsgnum+$partnum"
+my ($custmsgnum, $partnum) = $cgi->keywords;
+$custmsgnum =~ /^\d+$/ or die "bad custmsgnum";
+$partnum =~ /^\d+$/ or die "bad partnum";
+my $cust_msg = FS::cust_msg->by_key($custmsgnum)
+ or die "message not found";
+my $part = ($cust_msg->parts)[$partnum]
+ or die "message part $partnum does not exist";
+
+my $filename = $part->head->recommended_filename;
+if (!$filename) {
+ # for lack of a better idea
+ $part->bodyhandle->{MB_Path} =~ /.*\/(.*)/;
+ $filename = $1;
+}
+
+$m->clear_buffer;
+$r->content_type($part->mime_type || 'application/octet-stream');
+$r->headers_out->add('Content-Disposition' => 'attachment;filename=' . $filename);
+$m->print($part->bodyhandle->as_string);
+</%init>