don't link to deleted attachments if there aren't any
[freeside.git] / httemplate / view / cust_main / notes.html
1 % # Customer comments
2 % if ( $cust_main->comments =~ /[^\s\n\r]/ ) {
3 <BR><% mt('Comments') |h %>
4 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
5 <TR>
6   <TD BGCOLOR="#ffffff">
7     <PRE><% encode_entities($cust_main->comments) %></PRE>
8   </TD>
9 </TR>
10 </TABLE></TABLE>
11 <BR><BR>
12 % }
13
14 % # Notes, if any
15 <A NAME="notes">
16 % my $notecount = scalar($cust_main->notes(0));
17 % if ( ! $conf->exists('cust_main-disable_notes') || $notecount) {
18
19 % # actually display notes
20 <& notes/notes.html, 'cust_main' => $cust_main &>
21 <BR>
22 % } # end of notes
23
24 % # Attachments
25 % # XXX at some point move all of this into notes/attachments.html
26 % if( $curuser->access_right('View attachments') ) {
27 % # List attachments
28 <& notes/attachments.html, 'cust_main' => $cust_main &>
29 %   if ($cgi->param('show_deleted')) {
30 <A HREF="<% $p.'view/cust_main.cgi?custnum=' . $cust_main->custnum .
31            ($view ? ";show=$view" : '') . '#notes' 
32            %>"><I>(<% mt('Show active attachments') |h %>)</I></A>
33 %   } elsif ( $curuser->access_right('View deleted attachments')
34 %               && FS::Record->scalar_sql(
35 %                    'SELECT 1 FROM cust_attachment WHERE custnum = ? '.
36 %                      ' AND disabled IS NOT NULL AND disabled > 0 LIMIT 1',
37 %                    $custnum )
38 %           )
39 %   {
40 <A HREF="<% $p.'view/cust_main.cgi?custnum=' . $cust_main->custnum .
41            ($view ? ";show=$view" : '') . ';show_deleted=1#notes'
42            %>"><I>(<% mt('Show deleted attachments') |h %>)</I></A>
43 %   }
44 % }
45
46 <BR>
47 % if ( $curuser->access_right('View email logs')
48 %      and FS::cust_msg->count("custnum = $custnum")) {
49 <BR>
50 <& notes/email.html, 'cust_main' => $cust_main &>
51 <BR>
52 % }
53 <%init>
54
55 use HTML::Defang;
56
57 my $conf = new FS::Conf;
58 my $curuser = $FS::CurrentUser::CurrentUser;
59
60 my(%opt) = @_;
61
62 my $cust_main = $opt{'cust_main'};
63 my $custnum = $cust_main->custnum;
64
65 my $view =  $cgi->param('show') || $curuser->default_customer_view;
66
67 </%init>