833c92e6756b4386b1add6d592488600ef9ad49d
[freeside.git] / httemplate / view / cust_main / notes.html
1 % if ( scalar(@notes) ) {
2
3   <% include('/elements/init_overlib.html') %>
4
5   <% include("/elements/table-grid.html") %>
6
7   <TR>
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>
11 %   }
12     <TH CLASS="grid" BGCOLOR="#cccccc">Person</TH>
13     <TH CLASS="grid" BGCOLOR="#cccccc">Note</TH>
14   </TR>
15
16 % my $bgcolor1 = '#eeeeee';
17 % my $bgcolor2 = '#ffffff';
18 % my $bgcolor = '';
19 %
20 % foreach my $note (@notes) {
21 %
22 %   if ( $bgcolor eq $bgcolor1 ) {
23 %     $bgcolor = $bgcolor2;
24 %   } else {
25 %     $bgcolor = $bgcolor1;
26 %   }
27 %
28 %   my $pop = popurl(3);
29 %   my $notenum = $note->notenum;
30 %   my $onclick = include( '/elements/popup_link_onclick.html',
31 %                            'action'      => popurl(2).
32 %                                             'edit/cust_main_note.cgi'.
33 %                                             "?custnum=$custnum".
34 %                                             ";notenum=$notenum",
35 %                            'actionlabel' => 'Edit customer note',
36 %                            'width'       => 616,
37 %                            'height'      => 408,
38 %                            'frame'       => 'top',
39 %                        );
40 %   my $clickjs = qq!onclick="$onclick"!;
41 %
42 %   my $edit = '';
43 %   if ($curuser->access_right('Edit customer note') ) {
44 %     $edit = qq! <A HREF="javascript:void(0);" $clickjs>(edit)</A>!;
45 %   }
46
47     <TR>
48       <% note_datestr($note,$conf,$bgcolor) %>
49       <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
50         &nbsp;<% $note->otaker%>
51       </TD>
52       <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
53         &nbsp;<%$note->comments%><% $edit %>
54       </TD>
55     </TR>
56
57 % } #end display notes
58
59 </TABLE>
60
61 % }
62 <%init>
63
64 my $conf = new FS::Conf;
65 my $curuser = $FS::CurrentUser::CurrentUser;
66
67 my(%opt) = @_;
68
69 my $custnum = $opt{'custnum'};
70
71 my $cust_main = qsearchs('cust_main', {'custnum' => $custnum} );
72 die "Custimer not found!" unless $cust_main;
73
74 my (@notes) = $cust_main->notes();
75
76 #subroutines
77
78 sub note_datestr {
79   my($note, $conf, $bgcolor) = @_ or return '';
80   my $td = qq{<TD CLASS="grid" BGCOLOR="$bgcolor" ALIGN="right">};
81   my $format = "$td%b&nbsp;%o,&nbsp;%Y</TD>";
82   $format .= "$td%l:%M%P</TD>"
83     if $conf->exists('cust_main_note-display_times');
84   ( my $strip = time2str($format, $note->_date) ) =~ s/ (\d)/$1/g;
85   $strip;
86 }
87
88 </%init>