% if ( scalar(@notes) ) {
<& /elements/init_overlib.html &>
% if ( $note_classes_conf ) {
<% 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 ($note_classes_conf) {
<% 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 ($note_classes_conf) {
<% $note->classname %>
|
% }
<% $note->comments | defang %>
|
% if ($edit) {
<% $edit %> |
% }
% } #end foreach note
<%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 $note_classes_conf = $conf->exists('note-classes') ? $conf->config('note-classes') : '';
my (@notes) = $cust_main->notes();
my %classes = map { ($_->classnum || 0) => ( $_->classname ne '' ? $_->classname : '('.emt('unclassified').')' ) } @notes;
$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;
}
%init>