1 % if ( scalar(@notes) ) {
2 <SCRIPT SRC="<% $fsurl %>elements/jquery.js"></SCRIPT>
3 <SCRIPT TYPE="text/javascript">
5 function display_notes_classnum (classnum) {
7 var $custnote = $('.custnote');
10 $('tr[data-classnum=' + classnum + ']').show();
15 var $shownote = $custnote.filter(':visible');
16 var $shownote_even = $shownote.filter(':even');
17 var $shownote_odd = $shownote.filter(':odd');
18 $shownote_even.css('background-color','#eeeeee');
19 $shownote_even.filter('.stickynote').css('background-color','#ffff66');
20 $shownote_odd.css('background-color','#ffffff');
21 $shownote_odd.filter('.stickynote').css('background-color','#ffffb8');
22 % if ($use_class_tabs) {
24 var $tablink = $('.notes_tablink');
25 $tablink.css('font-weight','normal');
26 $tablink.filter('a[data-classnum=' + classnum + ']').css('font-weight','bold');
31 <& /elements/init_overlib.html &>
33 % if ( $use_class_tabs ) {
34 <% mt('Show notes of class:') |h %>
35 % # list unclassified last
36 % foreach my $classnum ( (grep { $_ != 0} sort { $a <=> $b } (keys %classes)), '0' ) {
37 <A CLASS="notes_tablink"
38 data-classnum="<% $classnum %>"
39 HREF="javascript:display_notes_classnum(<% $classnum %>)"
40 ><% $classes{$classnum} %></A>
45 <& /elements/table-grid.html &>
47 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Date') |h %></TH>
48 % if ( $conf->exists('cust_main_note-display_times') ) {
49 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Time') |h %></TH>
51 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Person') |h %></TH>
53 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Class') |h %></TH>
55 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Note') |h %></TH>
56 % if ($curuser->access_right('Edit customer note') ) {
57 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"> </TH>
63 % foreach my $note (@notes) {
65 % my $pop = popurl(3);
66 % my $notenum = $note->notenum;
67 % my $onclick = include( '/elements/popup_link_onclick.html',
68 % 'action' => popurl(2).
69 % 'edit/cust_main_note.cgi'.
70 % "?custnum=$custnum".
71 % ";notenum=$notenum",
72 % 'actionlabel' => emt('Edit customer note'),
77 % my $clickjs = qq!onclick="$onclick"!;
80 % if ($curuser->access_right('Edit customer note') ) {
81 % my $delete_url = $fsurl.'misc/delete-note.html?'.$notenum;
82 % $edit = qq! <A HREF="javascript:void(0);" $clickjs>(!.emt('edit').')</A>'.
83 % qq! <A HREF="$delete_url" !.
84 % qq! onclick="return confirm('Delete this note?')">!.
85 % '('.emt('delete').')</A>';
88 <TR CLASS="grid custnote<% $note->sticky ? ' stickynote' : '' %>"
89 <% $use_class_tabs ? ' data-classnum="'.($note->classnum || 0).'"' : '' %>>
91 <% note_datestr($note,$conf) %>
93 <% $note->usernum ? $note->access_user->name : $note->otaker %>
97 <% $note->classname %>
101 <% $note->comments | defang %>
104 <TD CLASS="grid"><% $edit %></TD>
107 % } #end foreach note
112 <SCRIPT>display_notes_classnum('-1')</SCRIPT>
114 <P><I><% emt('No notes for this customer') %></I></P>
121 my $conf = new FS::Conf;
122 my $curuser = $FS::CurrentUser::CurrentUser;
126 my $cust_main = $opt{'cust_main'};
127 my $custnum = $cust_main->custnum;
129 my (@notes) = $cust_main->notes();
131 my %classes = map { ($_->classnum || 0) => ( $_->classname ne '' ? $_->classname : '('.emt('unclassified').')' ) } @notes;
132 my $use_classes = grep { $_ > 0 } keys %classes; # show class column
133 my $use_class_tabs = (keys %classes > 1) ? 1 : 0; # use class tabs
134 $classes{'-1'} = 'All';
139 my($note, $conf) = @_ or return '';
140 my $td = qq{<TD CLASS="grid" ALIGN="right">};
141 my $format = "$td%b %o, %Y</TD>";
142 $format .= "$td%l:%M%P</TD>"
143 if $conf->exists('cust_main_note-display_times');
144 ( my $strip = time2str($format, $note->_date) ) =~ s/ (\d)/$1/g;