1 % if ( scalar(@notes) ) {
2 <SCRIPT TYPE="text/javascript">
4 function display_notes_classnum (classnum) {
6 var bgcolor1 = '#eeeeee';
7 var bgcolor2 = '#ffffff';
8 var sticky_color = { '#eeeeee' : '#ffff66',
9 '#ffffff' : '#ffffb8' };
10 var notes_bgcolor = '';
12 var trs = document.getElementsByTagName("TR");
13 for (var i=0; i < trs.length; i++) {
14 if (trs[i].id.length > 6 && trs[i].id.substring(0,6) == 'notes_') {
15 if (( classnum == '-1' ) || ( trs[i].getAttribute('data-classnum') == classnum )) {
16 trs[i].style.display = 'table-row';
17 if ( notes_bgcolor == bgcolor1 ) {
18 notes_bgcolor = bgcolor2;
20 notes_bgcolor = bgcolor1;
22 trs[i].style.backgroundColor = (trs[i].getAttribute('data-sticky') == '1') ? sticky_color[notes_bgcolor] : notes_bgcolor;
24 trs[i].style.display = 'none';
28 % if ($note_classes_conf) {
30 var as = document.getElementsByTagName("a");
31 for (var i=0; i < as.length; i++) {
32 if(as[i].id.length > 14 && as[i].id.substring(0,14) == 'notes_tablink_') {
33 if(as[i].id == 'notes_tablink_'+classnum) {
34 as[i].style.fontWeight = 'bold';
36 as[i].style.fontWeight = 'normal';
40 % } # if note_classes_conf
46 <& /elements/init_overlib.html &>
48 % if ( $note_classes_conf ) {
49 <% mt('Show notes of class:') |h %>
50 % # list unclassified last
51 % foreach my $classnum ( (grep { $_ != 0} sort { $a <=> $b } (keys %classes)), '0' ) {
52 <A id="notes_tablink_<% $classnum %>"
53 HREF="javascript:display_notes_classnum(<% $classnum %>)"
54 style="font-weight: <% $classnum == -1 ? 'bold' : 'normal' %>"
55 ><% $classes{$classnum} %></A>
60 <& /elements/table-grid.html &>
62 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Date') |h %></TH>
63 % if ( $conf->exists('cust_main_note-display_times') ) {
64 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Time') |h %></TH>
66 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Person') |h %></TH>
67 % if ($note_classes_conf) {
68 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Class') |h %></TH>
70 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Note') |h %></TH>
71 % if ($curuser->access_right('Edit customer note') ) {
72 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"> </TH>
78 % foreach my $note (@notes) {
80 % my $pop = popurl(3);
81 % my $notenum = $note->notenum;
82 % my $onclick = include( '/elements/popup_link_onclick.html',
83 % 'action' => popurl(2).
84 % 'edit/cust_main_note.cgi'.
85 % "?custnum=$custnum".
86 % ";notenum=$notenum",
87 % 'actionlabel' => emt('Edit customer note'),
92 % my $clickjs = qq!onclick="$onclick"!;
95 % if ($curuser->access_right('Edit customer note') ) {
96 % my $delete_url = $fsurl.'misc/delete-note.html?'.$notenum;
97 % $edit = qq! <A HREF="javascript:void(0);" $clickjs>(!.emt('edit').')</A>'.
98 % qq! <A HREF="$delete_url" !.
99 % qq! onclick="return confirm('Delete this note?')">!.
100 % '('.emt('delete').')</A>';
103 <TR ID="notes_<% $note->notenum %>"
104 data-sticky="<% $note->sticky ? 1 : 0 %>"
105 <% $note_classes_conf ? ' data-classnum="'.($note->classnum || 0).'"' : '' %>>
107 <% note_datestr($note,$conf) %>
109 <% $note->usernum ? $note->access_user->name : $note->otaker %>
111 % if ($note_classes_conf) {
113 <% $note->classname %>
117 <% $note->comments | defang %>
120 <TD CLASS="grid"><% $edit %></TD>
123 % } #end foreach note
127 <SCRIPT>display_notes_classnum('-1')</SCRIPT>
133 my $conf = new FS::Conf;
134 my $curuser = $FS::CurrentUser::CurrentUser;
138 my $cust_main = $opt{'cust_main'};
139 my $custnum = $cust_main->custnum;
141 my $note_classes_conf = $conf->exists('note-classes') ? $conf->config('note-classes') : '';
143 my (@notes) = $cust_main->notes();
145 my %classes = map { ($_->classnum || 0) => ( $_->classname ne '' ? $_->classname : '('.emt('unclassified').')' ) } @notes;
146 $classes{'-1'} = 'All';
151 my($note, $conf) = @_ or return '';
152 my $td = qq{<TD CLASS="grid" ALIGN="right">};
153 my $format = "$td%b %o, %Y</TD>";
154 $format .= "$td%l:%M%P</TD>"
155 if $conf->exists('cust_main_note-display_times');
156 ( my $strip = time2str($format, $note->_date) ) =~ s/ (\d)/$1/g;