% if ( scalar(@notes) ) { <& /elements/init_overlib.html &> % if ( $use_class_tabs ) { <% mt('Show notes of class:') |h %>   % # list unclassified last % foreach my $classnum ( (grep { $_ != 0} sort { $a <=> $b } (keys %classes)), '0' ) { <% $classes{$classnum} %> % }
% } <& /elements/table-grid.html &> <% mt('Date') |h %> % if ( $conf->exists('cust_main_note-display_times') ) { <% mt('Time') |h %> % } <% mt('Employee') |h %> % if ($use_classes) { <% mt('Class') |h %> % } <% mt('Note') |h %> % if ($curuser->access_right('Edit customer note') ) {   % } % } # end if @notes % foreach my $note (@notes) { % % my $pop = popurl(3); % my $notenum = $note->notenum; % my $onclick = include( '/elements/popup_link_onclick.html', % 'action' => popurl(2). % 'edit/cust_main_note.cgi'. % "?custnum=$custnum". % ";notenum=$notenum", % 'actionlabel' => emt('Edit customer note'), % 'width' => 616, % 'height' => 575, % 'frame' => 'top', % ); % my $clickjs = qq!onclick="$onclick"!; % % my $edit = ''; % if ($curuser->access_right('Edit customer note') ) { % my $delete_url = $fsurl.'misc/delete-note.html?'.$notenum; % $edit = qq! (!.emt('edit').')'. % qq! !. % '('.emt('delete').')'; % } % > <% note_datestr($note,$conf) %>  <% $note->usernum ? $note->access_user->name : $note->otaker %> % if ($use_classes) { <% $note->classname %> % } <% $note->comments | defang %> % if ($edit) { <% $edit %> % } % } #end foreach note % if (@notes) { % } else {

<% emt('No notes for this customer') %>

% } <%init> use HTML::Defang; my $conf = new FS::Conf; my $curuser = $FS::CurrentUser::CurrentUser; my(%opt) = @_; my $cust_main = $opt{'cust_main'}; my $custnum = $cust_main->custnum; my (@notes) = $cust_main->notes(); my %classes = map { ($_->classnum || 0) => ( $_->classname ne '' ? $_->classname : '('.emt('unclassified').')' ) } @notes; my $use_classes = grep { $_ > 0 } keys %classes; # show class column my $use_class_tabs = (keys %classes > 1) ? 1 : 0; # use class tabs $classes{'-1'} = 'All'; #subroutines sub note_datestr { my($note, $conf) = @_ or return ''; my $td = qq{}; my $format = "$td%b %o, %Y"; $format .= "$td%l:%M%P" if $conf->exists('cust_main_note-display_times'); ( my $strip = time2str($format, $note->_date) ) =~ s/ (\d)/$1/g; $strip; }