communigate (phase 2): rules. RT#7514
[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 NAME="attach_edit" 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 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
12 % if(defined $attach) {
13 %   if($curuser->access_right("Download attachment")) {
14 <A HREF="<% $p.'view/attachment.html?'.$attachnum %>">Download this file</A><BR>
15 %   }
16 <TR><TD> Filename </TD>
17 <TD><INPUT TYPE="text" NAME="filename" SIZE=40 MAXLENGTH=255 VALUE="<% $attach->filename %>"<% $disabled %>></TD></TR>
18 <TR><TD> Description </TD>
19 <TD><INPUT TYPE="text" NAME="title" SIZE=40 MAXLENGTH=80 VALUE="<% $attach->title %>"<% $disabled %></TD></TR>
20 <TR><TD> MIME type </TD>
21 <TD><INPUT TYPE="text" NAME="mime_type" VALUE="<% $attach->mime_type %>"<% $disabled %></TD></TR>
22 <TR><TD> Size </TD><TD><% $attach->size %></TD></TR>
23 % }
24 % else { # !defined $attach
25 <TR><TD> Filename </TD><TD><INPUT TYPE="file" SIZE=24 NAME="file"></TD></TR>
26 <TR><TD> Description </TD><TD><INPUT TYPE="text" NAME="title" SIZE=40 MAXLENGTH=80></TD></TR>
27 % }
28 </TABLE>
29 <BR>
30 % if(! $disabled) {
31 <INPUT TYPE="submit" NAME="submit" 
32     VALUE="<% $attachnum ? "Apply Changes" : "Upload File" %>">
33 % }
34 % if(defined $attach and $curuser->access_right('Delete attachment')) {
35 <BR>
36 <INPUT TYPE="submit" NAME="delete" value="Delete File" 
37 onclick="return(confirm('Delete this file?'));">
38 % }
39
40 </FORM>
41 </BODY>
42 </HTML>
43
44 <%init>
45
46 my $curuser = $FS::CurrentUser::CurrentUser;
47
48 my $attachnum = '';
49 my $attach;
50 if ( $cgi->param('error') ) {
51   #$comment     = $cgi->param('comment');
52 } elsif ( $cgi->param('attachnum') =~ /^(\d+)$/ ) {
53   $attachnum = $1;
54   die "illegal query ". $cgi->keywords unless $attachnum;
55   $attach = qsearchs('cust_attachment', { 'attachnum' => $attachnum });
56   die "no such attachment: ". $attachnum unless $attach;
57 }
58
59 my $action = $attachnum ? 'Edit' : 'Add';
60
61 my $disabled='';
62 if(! $curuser->access_right("$action attachment")) {
63   $disabled = ' disabled="disabled"';
64 }
65
66 $cgi->param('custnum') =~ /^(\d+)$/ or die "illegal custnum";
67 my $custnum = $1;
68
69 </%init>
70