1 % if ( scalar(@attachments) ) {
3 <& /elements/init_overlib.html &>
5 <& /elements/table-grid.html &>
8 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Date') |h %></TH>
9 % if ( $conf->exists('cust_main_note-display_times') ) {
10 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Time') |h %></TH>
12 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Person') |h %></TH>
13 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Filename') |h %></TH>
14 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Description') |h %></TH>
15 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Type') |h %></TH>
16 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Size') |h %></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 % emt('Undelete attachment'));
52 % $edit .= linkstr($clickjs, emt('undelete'));
54 % if ($curuser->access_right('Purge attachment')) {
55 % my $clickjs = popup('edit/process/cust_main_attach.cgi?'.
56 % "custnum=$custnum;attachnum=$attachnum;".
58 % emt('Purge attachment'),
59 % emt('Permanently remove this file?') );
60 % $edit .= linkstr($clickjs,emt('purge'));
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 % emt('Edit attachment properties'));
68 % $edit .= linkstr($clickjs,emt('edit'));
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 .= linkstr($clickjs,emt('delete'));
77 % if ($curuser->access_right('Download attachment') ) {
78 % $edit .= qq! <A HREF="!.popurl(1).'attachment.html?'.$attachnum.qq!">(!
79 % . emt('download') .')</A>';
84 <% note_datestr($attach,$conf,$bgcolor) %>
85 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
86 <% $attach->usernum ? $attach->access_user->name : $attach->otaker %>
88 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
89 <% $attach->filename |h %>
91 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
92 <% $attach->title |h %>
93 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
94 <% $attach->mime_type |h %>
96 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
97 <% size_units( $attach->size ) %>
99 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
104 % } #end display notes
111 my $conf = new FS::Conf;
112 my $curuser = $FS::CurrentUser::CurrentUser;
113 die "access denied" if !$curuser->access_right('View attachments');
116 my $cust_main = $opt{'cust_main'};
117 my $custnum = $cust_main->custnum;
119 my (@attachments) = qsearch('cust_attachment', {'custnum' => $custnum});
124 my($note, $conf, $bgcolor) = @_ or return '';
125 my $td = qq{<TD CLASS="grid" BGCOLOR="$bgcolor" ALIGN="right">};
126 my $format = "$td%b %o, %Y</TD>";
127 $format .= "$td%l:%M%P</TD>"
128 if $conf->exists('cust_main_note-display_times');
129 ( my $strip = time2str($format, $note->_date) ) =~ s/ (\d)/$1/g;
134 my ($clickjs, $label) = (shift,shift);
135 ' <A HREF="javascript:void(0);" '. $clickjs . '>(' . emt($label) . ')</A>';
140 return $bytes if $bytes < 1024;
141 return int($bytes / 1024)."K" if $bytes < 1048576;
142 return int($bytes / 1048576)."M";
146 my ($url, $label, $confirm) = @_;
148 include('/elements/popup_link_onclick.html',
149 'action' => popurl(2).$url,
150 'actionlabel' => $label,
155 $onclick = qq!if(confirm('$confirm')) { $onclick }! if $confirm;
156 return qq!onclick="$onclick"!;