1 % if ( scalar(@notes) ) {
3 <SCRIPT TYPE="text/javascript">
5 function display_notes_classnum(classnum){
6 document.getElementById('notes_'+classnum).style.display = 'block';
7 document.getElementById('notes_tablink_'+classnum).style.fontWeight = 'bold';
9 var divs = document.getElementsByTagName("div");
11 for(i=0; i < divs.length; i++){
13 if(d.id.length > 6 && d.id.substring(0,6) == 'notes_') {
14 if(divs[i].id != 'notes_'+classnum) {
15 divs[i].style.display = 'none';
20 var as = document.getElementsByTagName("a");
21 for(i=0; i < as.length; i++){
23 if(a.id.length > 14 && a.id.substring(0,14) == 'notes_tablink_') {
24 if(as[i].id != 'notes_tablink_'+classnum) {
25 as[i].style.fontWeight = 'normal';
33 <& /elements/init_overlib.html &>
35 % my $bgcolor1 = '#eeeeee';
36 % my $bgcolor2 = '#ffffff';
37 % my %sticky_color = ( '#eeeeee' => '#ffff66',
38 % '#ffffff' => '#ffffb8',
42 % my $last_classnum = -1;
46 % foreach my $note (@notes) {
48 % if ( $bgcolor eq $bgcolor1 ) {
49 % $bgcolor = $bgcolor2;
51 % $bgcolor = $bgcolor1;
54 % my $pop = popurl(3);
55 % my $notenum = $note->notenum;
56 % my $onclick = include( '/elements/popup_link_onclick.html',
57 % 'action' => popurl(2).
58 % 'edit/cust_main_note.cgi'.
59 % "?custnum=$custnum".
60 % ";notenum=$notenum",
61 % 'actionlabel' => emt('Edit customer note'),
66 % my $clickjs = qq!onclick="$onclick"!;
69 % if ($curuser->access_right('Edit customer note') ) {
70 % my $delete_url = $fsurl.'misc/delete-note.html?'.$notenum;
71 % $edit = qq! <A HREF="javascript:void(0);" $clickjs>(!.emt('edit').')</A>'.
72 % qq! <A HREF="$delete_url" !.
73 % qq! onclick="return confirm('Delete this note?')">!.
74 % '('.emt('delete').')</A>';
77 % if ( $last_classnum != $note->classnum && !$skipheader ) {
78 % my $tmp_classnum = $note->classnum ? $note->classnum : 0;
79 % $classes{$tmp_classnum} = $note->classname ne '' ? $note->classname
81 % if ( $last_classnum != -1 ) {
85 % my $display = ($tmp_classnum == 0 || !$conf->exists('note-classes')
86 % || $conf->config('note-classes') < 2)
88 <DIV id="notes_<% $tmp_classnum %>"
89 style="display:<% $display %>"
91 <& /elements/table-grid.html &>
93 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Date') |h %></TH>
94 % if ( $conf->exists('cust_main_note-display_times') ) {
95 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Time') |h %></TH>
97 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Person') |h %></TH>
98 % if ($conf->exists('note-classes') && $conf->config('note-classes') == 1) {
99 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Class') |h %></TH>
101 <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Note') |h %></TH>
102 % if ($curuser->access_right('Edit customer note') ) {
103 <TH CLASS="grid" BGCOLOR="#cccccc"> </TH>
106 % $skipheader = (!$conf->exists('note-classes') || $conf->config('note-classes') < 2);
107 % $last_classnum = $note->classnum;
110 % my $color = $note->sticky ? $sticky_color{$bgcolor} : $bgcolor;
113 <% note_datestr($note,$conf,$color) %>
114 <TD CLASS="grid" BGCOLOR="<% $color %>">
115 <% $note->usernum ? $note->access_user->name : $note->otaker %>
117 % if ($conf->exists('note-classes') && $conf->config('note-classes') == 1) {
118 <TD CLASS="grid" BGCOLOR="<% $color %>">
119 <% $note->classname %>
122 <TD CLASS="grid" BGCOLOR="<% $color %>">
123 <% $note->comments | defang %>
126 <TD CLASS="grid" BGCOLOR="<% $color %>"><% $edit %></TD>
130 % } #end display notes
135 % if ( $conf->exists('note-classes') && $conf->config('note-classes') == 2 ) {
136 % my($classnum,$classname);
137 <% mt('Show notes of class:') |h %>
138 % foreach my $classnum ( sort { $b <=> $a } (keys %classes) ) {
139 <A id="notes_tablink_<% $classnum %>"
140 HREF="javascript:display_notes_classnum(<% $classnum %>)"
141 style="font-weight: <% $classnum == 0 ? 'bold' : 'normal' %>"
142 ><% $classes{$classnum} %></A>
152 my $conf = new FS::Conf;
153 my $curuser = $FS::CurrentUser::CurrentUser;
157 my $cust_main = $opt{'cust_main'};
158 my $custnum = $cust_main->custnum;
160 my (@notes) = $cust_main->notes($conf->exists('note-classes') && $conf->config('note-classes') == 2);
165 my($note, $conf, $bgcolor) = @_ or return '';
166 my $td = qq{<TD CLASS="grid" BGCOLOR="$bgcolor" ALIGN="right">};
167 my $format = "$td%b %o, %Y</TD>";
168 $format .= "$td%l:%M%P</TD>"
169 if $conf->exists('cust_main_note-display_times');
170 ( my $strip = time2str($format, $note->_date) ) =~ s/ (\d)/$1/g;