Add cust_attachment stuff
[freeside.git] / httemplate / edit / cust_main_attach.cgi
1 <% include('/elements/header-popup.html', "$action File Attachment") %>
2
3 <% include('/elements/error.html') %>
4
5 <FORM ACTION="<% popurl(1) %>process/cust_main_attach.cgi" METHOD=POST ENCTYPE="multipart/form-data">
6 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
7 <INPUT TYPE="hidden" NAME="attachnum" VALUE="<% $attachnum %>">
8
9 <BR><BR>
10
11 % if(defined $attach) {
12 Filename <INPUT TYPE="text" NAME="filename" VALUE="<% $attach->filename %>"><BR>
13 MIME type <INPUT TYPE="text" NAME="mime_type" VALUE="<% $attach->mime_type %>"<BR>
14 Size: <% $attach->size %><BR>
15
16 % }
17 % else { # !defined $attach
18
19 Filename <INPUT TYPE="file" NAME="file"><BR>
20
21 % }
22
23 <BR>
24 <INPUT TYPE="submit" NAME="submit" 
25     VALUE="<% $attachnum ? "Apply Changes" : "Upload File" %>">
26
27 % if(defined $attach) {
28 <BR>
29 <INPUT TYPE="submit" NAME="delete" value="Delete File">
30 % }
31
32 </FORM>
33 </BODY>
34 </HTML>
35
36 <%init>
37
38 my $attachnum = '';
39 my $attach;
40 if ( $cgi->param('error') ) {
41   #$comment     = $cgi->param('comment');
42 } elsif ( $cgi->param('attachnum') =~ /^(\d+)$/ ) {
43   $attachnum = $1;
44   die "illegal query ". $cgi->keywords unless $attachnum;
45   $attach = qsearchs('cust_attachment', { 'attachnum' => $attachnum });
46   die "no such attachment: ". $attachnum unless $attach;
47 }
48
49 $cgi->param('custnum') =~ /^(\d+)$/ or die "illegal custnum";
50 my $custnum = $1;
51
52 my $action = $attachnum ? 'Edit' : 'Add';
53
54 die "access denied"
55   unless $FS::CurrentUser::CurrentUser->access_right("$action customer note");
56
57 </%init>
58