summaryrefslogtreecommitdiff
path: root/httemplate/edit/cust_main_attach.cgi
blob: 0880c760ae5af1ecffdab18050c4477be78a3473 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<% include('/elements/header-popup.html', "$action File Attachment") %>

<% include('/elements/error.html') %>

<FORM NAME="attach_edit" ACTION="<% popurl(1) %>process/cust_main_attach.cgi" METHOD=POST ENCTYPE="multipart/form-data">
<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
<INPUT TYPE="hidden" NAME="attachnum" VALUE="<% $attachnum %>">

% if(defined $attach) {
%   if($curuser->access_right("Download attachment")) {
<A HREF="<% $p.'view/attachment.html?'.$attachnum %>">Download this file</A><BR>
%   }
% }

<BR>
<TABLE BGCOLOR="#cccccc" CELLSPACING=0>

% if ( defined $attach ) {
<TR><TD> Filename </TD>
<TD><INPUT TYPE="text" NAME="file" SIZE=40 MAXLENGTH=255 VALUE="<% $cgi->param('file') || $attach->filename |h %>"<% $disabled %>></TD></TR>
<TR><TD> Description </TD>
<TD><INPUT TYPE="text" NAME="title" SIZE=40 MAXLENGTH=80 VALUE="<% $cgi->param('title') || $attach->title |h %>"<% $disabled %></TD></TR>
<TR><TD> MIME type </TD>
<TD><INPUT TYPE="text" NAME="mime_type" SIZE=40 VALUE="<% $cgi->param('mime_type') || $attach->mime_type |h %>"<% $disabled %></TD></TR>
<TR><TD> Size </TD><TD><% $attach->size %></TD></TR>
% }
% else { # !defined $attach
<TR><TD> Filename </TD><TD><INPUT TYPE="file" SIZE=24 NAME="file"></TD></TR>
<TR><TD> Description </TD><TD><INPUT TYPE="text" NAME="title" SIZE=40 MAXLENGTH=80></TD></TR>
% }
</TABLE>
<BR>
% if(! $disabled) {
<INPUT TYPE="submit" NAME="submit" 
    VALUE="<% $attachnum ? emt("Apply changes") : emt("Upload File") %>">
% }
% if(defined $attach and $curuser->access_right('Delete attachment')) {
<BR>
<INPUT TYPE="submit" NAME="delete" value="Delete File" 
onclick="return(confirm('Delete this file?'));">
% }

</FORM>
</BODY>
</HTML>

<%init>

my $curuser = $FS::CurrentUser::CurrentUser;

my $attachnum = '';
my $attach;

if ( $cgi->param('attachnum') =~ /^(\d+)$/ ) {
  $attachnum = $1;
  die "illegal query ". $cgi->keywords unless $attachnum;
  $attach = qsearchs('cust_attachment', { 'attachnum' => $attachnum });
  die "no such attachment: ". $attachnum unless $attach;
}

my $action = $attachnum ? 'Edit' : 'Add';

my $disabled='';
if(! $curuser->access_right("$action attachment")) {
  $disabled = ' disabled="disabled"';
}

$cgi->param('custnum') =~ /^(\d+)$/ or die "illegal custnum";
my $custnum = $1;

</%init>