1 <% include('/elements/header-popup.html', "$action File Attachment") %>
3 <% include('/elements/error.html') %>
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 %>">
9 % if(defined $attach) {
10 % if($curuser->access_right("Download attachment")) {
11 <A HREF="<% $p.'view/attachment.html?'.$attachnum %>">Download this file</A><BR>
16 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
18 % if ( defined $attach ) {
19 <TR><TD> Filename </TD>
20 <TD><INPUT TYPE="text" NAME="file" SIZE=40 MAXLENGTH=255 VALUE="<% $cgi->param('file') || $attach->filename |h %>"<% $disabled %>></TD></TR>
21 <TR><TD> Description </TD>
22 <TD><INPUT TYPE="text" NAME="title" SIZE=40 MAXLENGTH=80 VALUE="<% $cgi->param('title') || $attach->title |h %>"<% $disabled %></TD></TR>
23 <TR><TD> MIME type </TD>
24 <TD><INPUT TYPE="text" NAME="mime_type" SIZE=40 VALUE="<% $cgi->param('mime_type') || $attach->mime_type |h %>"<% $disabled %></TD></TR>
25 <TR><TD> Size </TD><TD><% $attach->size %></TD></TR>
27 % else { # !defined $attach
28 <TR><TD> Filename </TD><TD><INPUT TYPE="file" SIZE=24 NAME="file"></TD></TR>
29 <TR><TD> Description </TD><TD><INPUT TYPE="text" NAME="title" SIZE=40 MAXLENGTH=80></TD></TR>
34 <INPUT TYPE="submit" NAME="submit"
35 VALUE="<% $attachnum ? emt("Apply changes") : emt("Upload File") %>">
37 % if(defined $attach and $curuser->access_right('Delete attachment')) {
39 <INPUT TYPE="submit" NAME="delete" value="Delete File"
40 onclick="return(confirm('Delete this file?'));">
49 my $curuser = $FS::CurrentUser::CurrentUser;
54 if ( $cgi->param('attachnum') =~ /^(\d+)$/ ) {
56 die "illegal query ". $cgi->keywords unless $attachnum;
57 $attach = qsearchs('cust_attachment', { 'attachnum' => $attachnum });
58 die "no such attachment: ". $attachnum unless $attach;
61 my $action = $attachnum ? 'Edit' : 'Add';
64 if(! $curuser->access_right("$action attachment")) {
65 $disabled = ' disabled="disabled"';
68 $cgi->param('custnum') =~ /^(\d+)$/ or die "illegal custnum";