1 % if ( scalar(@attachments) ) {
3 <% include('/elements/init_overlib.html') %>
5 <% include("/elements/table-grid.html") %>
8 <TH CLASS="grid" BGCOLOR="#cccccc">Date</TH>
9 % if ( $conf->exists('cust_main_note-display_times') ) {
10 <TH CLASS="grid" BGCOLOR="#cccccc">Time</TH>
12 <TH CLASS="grid" BGCOLOR="#cccccc">Person</TH>
13 <TH CLASS="grid" BGCOLOR="#cccccc">Filename</TH>
14 <TH CLASS="grid" BGCOLOR="#cccccc">Description</TH>
15 <TH CLASS="grid" BGCOLOR="#cccccc">Type</TH>
16 <TH CLASS="grid" BGCOLOR="#cccccc">Size</TH>
17 <TH CLASS="grid" BGCOLOR="#cccccc"></TH>
20 % my $bgcolor1 = '#eeeeee';
21 % my $bgcolor2 = '#ffffff';
23 % if($cgi->param('show_deleted')) {
24 % if ($curuser->access_right('View deleted attachments')) {
25 % @attachments = grep { $_->disabled } @attachments;
32 % @attachments = grep { not $_->disabled } @attachments;
35 % foreach my $attach (@attachments) {
37 % if ( $bgcolor eq $bgcolor1 ) {
38 % $bgcolor = $bgcolor2;
40 % $bgcolor = $bgcolor1;
43 % my $pop = popurl(3);
44 % my $attachnum = $attach->attachnum;
46 % if($attach->disabled) { # then you can undelete it or purge it.
47 % if ($curuser->access_right('Undelete attachment')) {
48 % my $clickjs = popup('edit/process/cust_main_attach.cgi?'.
49 % "custnum=$custnum;attachnum=$attachnum;".
51 % 'Undelete attachment');
52 % $edit .= qq! <A HREF="javascript:void(0);" $clickjs>(undelete)</A>!;
54 % if ($curuser->access_right('Purge attachment')) {
55 % my $clickjs = popup('edit/process/cust_main_attach.cgi?'.
56 % "custnum=$custnum;attachnum=$attachnum;".
59 % 'Permanently remove this file?');
60 % $edit .= qq! <A HREF="javascript:void(0);" $clickjs>(purge)</A>!;
63 % else { # you can download or edit it
64 % if ($curuser->access_right('Edit attachment') ) {
65 % my $clickjs = popup('edit/cust_main_attach.cgi?'.
66 % "custnum=$custnum;attachnum=$attachnum",
67 % 'Edit attachment properties');
68 % $edit .= qq! <A HREF="javascript:void(0);" $clickjs>(edit)</A>!;
70 % if($curuser->access_right('Delete attachment') ) {
71 % my $clickjs = popup('edit/process/cust_main_attach.cgi?'.
72 % "custnum=$custnum;attachnum=$attachnum;delete=1",
73 % 'Delete attachment',
74 % 'Delete this file?');
75 % $edit .= qq! <A HREF="javascript:void(0);" $clickjs>(delete)</A>!;
77 % if ($curuser->access_right('Download attachment') ) {
78 % $edit .= qq! <A HREF="!.popurl(1).'attachment.html?'.$attachnum.qq!">(download)</A>!;
83 <% note_datestr($attach,$conf,$bgcolor) %>
84 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
85 <% $attach->usernum ? $attach->access_user->name : $attach->otaker %>
87 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
88 <% $attach->filename |h %>
90 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
91 <% $attach->title |h %>
92 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
93 <% $attach->mime_type |h %>
95 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
96 <% size_units( $attach->size ) %>
98 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
103 % } #end display notes
110 my $conf = new FS::Conf;
111 my $curuser = $FS::CurrentUser::CurrentUser;
112 die "access denied" if !$curuser->access_right('View attachments');
115 my $custnum = $opt{'custnum'};
117 my $cust_main = qsearchs('cust_main', {'custnum' => $custnum} );
118 die "Customer not found!" unless $cust_main;
120 my (@attachments) = qsearch('cust_attachment', {'custnum' => $custnum});
125 my($note, $conf, $bgcolor) = @_ or return '';
126 my $td = qq{<TD CLASS="grid" BGCOLOR="$bgcolor" ALIGN="right">};
127 my $format = "$td%b %o, %Y</TD>";
128 $format .= "$td%l:%M%P</TD>"
129 if $conf->exists('cust_main_note-display_times');
130 ( my $strip = time2str($format, $note->_date) ) =~ s/ (\d)/$1/g;
136 return $bytes if $bytes < 1024;
137 return int($bytes / 1024)."K" if $bytes < 1048576;
138 return int($bytes / 1048576)."M";
142 my ($url, $label, $confirm) = @_;
144 include('/elements/popup_link_onclick.html',
145 'action' => popurl(2).$url,
146 'actionlabel' => $label,
151 $onclick = qq!if(confirm('$confirm')) { $onclick }! if $confirm;
152 return qq!onclick="$onclick"!;