1 % if ( scalar(@notes) ) {
2 <SCRIPT TYPE="text/javascript">
4 function display_notes_classnum (classnum) {
6 var $custnote = $('.custnote');
9 $('tr[data-classnum=' + classnum + ']').show();
14 var $shownote = $custnote.filter(':visible');
15 var $shownote_even = $shownote.filter(':even');
16 var $shownote_odd = $shownote.filter(':odd');
17 $shownote_even.css('background-color','#eeeeee');
18 $shownote_even.filter('.stickynote').css('background-color','#ffff66');
19 $shownote_odd.css('background-color','#ffffff');
20 $shownote_odd.filter('.stickynote').css('background-color','#ffffb8');
21 % if ($use_class_tabs) {
23 var $tablink = $('.notes_tablink');
24 $tablink.css('font-weight','normal');
25 $tablink.filter('a[data-classnum=' + classnum + ']').css('font-weight','bold');
30 <& /elements/init_overlib.html &>
32 % if ( $use_class_tabs ) {
33 <% mt('Show notes of class:') |h %>
34 % # list unclassified last
35 % foreach my $classnum ( (grep { $_ != 0} sort { $a <=> $b } (keys %classes)), '0' ) {
36 <A CLASS="notes_tablink"
37 data-classnum="<% $classnum %>"
38 HREF="javascript:display_notes_classnum(<% $classnum %>)"
39 ><% $classes{$classnum} %></A>
44 <& /elements/table-grid.html &>
46 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Date') |h %></TH>
47 % if ( $conf->exists('cust_main_note-display_times') ) {
48 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Time') |h %></TH>
50 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Employee') |h %></TH>
52 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Class') |h %></TH>
54 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Note') |h %></TH>
55 % if ($curuser->access_right('Edit customer note') ) {
56 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"> </TH>
62 % foreach my $note (@notes) {
64 % my $pop = popurl(3);
65 % my $notenum = $note->notenum;
66 % my $onclick = include( '/elements/popup_link_onclick.html',
67 % 'action' => popurl(2).
68 % 'edit/cust_main_note.cgi'.
69 % "?custnum=$custnum".
70 % ";notenum=$notenum",
71 % 'actionlabel' => emt('Edit customer note'),
76 % my $clickjs = qq!onclick="$onclick"!;
79 % if ( $curuser->access_right('Edit customer note') ) {
80 % $edit = qq! <A HREF="javascript:void(0);" $clickjs>(!.emt('edit').')</A>';
82 % if ( $curuser->access_right('Delete customer note') ) {
83 % my $delete_url = $fsurl.'misc/delete-note.html?'.$notenum;
84 % $edit .= qq! <A HREF="$delete_url" !.
85 % qq! onclick="return confirm('Delete this note?')">!.
86 % '('.emt('delete').')</A>';
89 <TR CLASS="grid custnote<% $note->sticky ? ' stickynote' : '' %>"
90 <% $use_class_tabs ? ' data-classnum="'.($note->classnum || 0).'"' : '' %>>
92 <% note_datestr($note,$conf) %>
94 <% $note->usernum ? $note->access_user->name : $note->otaker %>
98 <% $note->classname %>
102 <% $note->comments | defang %>
105 <TD CLASS="grid"><% $edit %></TD>
108 % } #end foreach note
113 <SCRIPT>display_notes_classnum('-1')</SCRIPT>
115 <P><I><% emt('No notes for this customer') %></I></P>
122 my $conf = new FS::Conf;
123 my $curuser = $FS::CurrentUser::CurrentUser;
127 my $cust_main = $opt{'cust_main'};
128 my $custnum = $cust_main->custnum;
130 my (@notes) = $cust_main->notes();
132 my %classes = map { ($_->classnum || 0) => ( $_->classname ne '' ? $_->classname : '('.emt('unclassified').')' ) } @notes;
133 my $use_classes = grep { $_ > 0 } keys %classes; # show class column
134 my $use_class_tabs = (keys %classes > 1) ? 1 : 0; # use class tabs
135 $classes{'-1'} = 'All';
140 my($note, $conf) = @_ or return '';
141 my $td = qq{<TD CLASS="grid" ALIGN="right">};
142 my $format = "$td%b %o, %Y</TD>";
143 $format .= "$td%l:%M%P</TD>"
144 if $conf->exists('cust_main_note-display_times');
145 ( my $strip = time2str($format, $note->_date) ) =~ s/ (\d)/$1/g;