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">Type</TH>
15 <TH CLASS="grid" BGCOLOR="#cccccc">Size</TH>
16 <TH CLASS="grid" BGCOLOR="#cccccc"></TH>
19 % my $bgcolor1 = '#eeeeee';
20 % my $bgcolor2 = '#ffffff';
22 % if($cgi->param('show_deleted')) {
23 % if ($curuser->access_right('View deleted attachments')) {
24 % @attachments = grep { $_->disabled } @attachments;
31 % @attachments = grep { not $_->disabled } @attachments;
34 % foreach my $attach (@attachments) {
36 % if ( $bgcolor eq $bgcolor1 ) {
37 % $bgcolor = $bgcolor2;
39 % $bgcolor = $bgcolor1;
42 % my $pop = popurl(3);
43 % my $attachnum = $attach->attachnum;
45 % if($attach->disabled) { # then you can undelete it or purge it.
46 % if ($curuser->access_right('Undelete attachment')) {
47 % my $clickjs = popup('edit/process/cust_main_attach.cgi?'.
48 % "custnum=$custnum;attachnum=$attachnum;".
50 % 'Undelete attachment');
51 % $edit .= qq! <A HREF="javascript:void(0);" $clickjs>(undelete)</A>!;
53 % if ($curuser->access_right('Purge attachment')) {
54 % my $clickjs = popup('edit/process/cust_main_attach.cgi?'.
55 % "custnum=$custnum;attachnum=$attachnum;".
57 % 'Purge attachment');
58 % $edit .= qq! <A HREF="javascript:void(0);" $clickjs>(purge)</A>!;
61 % else { # you can download or edit it
62 % if ($curuser->access_right('Edit attachment') ) {
63 % my $clickjs = popup('edit/cust_main_attach.cgi?'.
64 % "custnum=$custnum;attachnum=$attachnum",
65 % 'Edit attachment properties');
66 % $edit .= qq! <A HREF="javascript:void(0);" $clickjs>(edit)</A>!;
68 % if($curuser->access_right('Delete attachment') ) {
69 % my $clickjs = popup('edit/process/cust_main_attach.cgi?'.
70 % "custnum=$custnum;attachnum=$attachnum;".
72 % 'Delete attachment');
73 % $edit .= qq! <A HREF="javascript:void(0);" $clickjs>(delete)</A>!;
75 % if ($curuser->access_right('Download attachment') ) {
76 % $edit .= qq! <A HREF="!.popurl(1).'attachment.html?'.$attachnum.qq!">(download)</A>!;
81 <% note_datestr($attach,$conf,$bgcolor) %>
82 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
83 <% $attach->otaker%>
85 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
86 <% $attach->filename %>
88 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
89 <% $attach->mime_type %>
91 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
92 <% size_units( $attach->size ) %>
94 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
99 % } #end display notes
106 my $conf = new FS::Conf;
107 my $curuser = $FS::CurrentUser::CurrentUser;
111 my $custnum = $opt{'custnum'};
113 my $cust_main = qsearchs('cust_main', {'custnum' => $custnum} );
114 die "Customer not found!" unless $cust_main;
116 my (@attachments) = qsearch('cust_attachment', {'custnum' => $custnum});
121 my($note, $conf, $bgcolor) = @_ or return '';
122 my $td = qq{<TD CLASS="grid" BGCOLOR="$bgcolor" ALIGN="right">};
123 my $format = "$td%b %o, %Y</TD>";
124 $format .= "$td%l:%M%P</TD>"
125 if $conf->exists('cust_main_note-display_times');
126 ( my $strip = time2str($format, $note->_date) ) =~ s/ (\d)/$1/g;
132 return $bytes if $bytes < 1024;
133 return int($bytes / 1024)."K" if $bytes < 1048576;
134 return int($bytes / 1048576)."M";
138 my ($url, $label) = @_;
140 include('/elements/popup_link_onclick.html',
141 'action' => popurl(2).$url,
142 'actionlabel' => $label,
147 return qq!onclick="$onclick"!;