Add cust_attachment stuff
[freeside.git] / httemplate / view / attachment.html
diff --git a/httemplate/view/attachment.html b/httemplate/view/attachment.html
new file mode 100644 (file)
index 0000000..c85b137
--- /dev/null
@@ -0,0 +1,16 @@
+<%init>
+my ($query) = $cgi->keywords;
+$query =~ /^(\d+)$/;
+my $attachnum = $1 or die 'Invalid attachment number';
+$FS::CurrentUser::CurrentUser->access_right('Download attachment') or die 'access denied';
+
+my $attach = qsearchs('cust_attachment', { attachnum => $attachnum }) or die 'Attachment not found: $attachnum';
+
+$m->clear_buffer;
+$r->content_type($attach->mime_type || 'text/plain');
+$r->headers_out->add('Content-Disposition' => 'attachment;filename=' . $attach->filename);
+
+binmode STDOUT;
+print STDOUT $attach->body;
+
+</%init>