summaryrefslogtreecommitdiff
path: root/httemplate/view/cust_main/notes.html
blob: a39610ac525a76a2c234d588f22cb3186ccf9545 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
% if ( scalar(@notes) ) {

  <% include('/elements/init_overlib.html') %>

  <% include("/elements/table-grid.html") %>

  <TR>
    <TH CLASS="grid" BGCOLOR="#cccccc">Date</TH>
%   if ( $conf->exists('cust_main_note-display_times') ) {
      <TH CLASS="grid" BGCOLOR="#cccccc">Time</TH>
%   }
    <TH CLASS="grid" BGCOLOR="#cccccc">Person</TH>
    <TH CLASS="grid" BGCOLOR="#cccccc">Note</TH>
%   if ($curuser->access_right('Edit customer note') ) {
    <TH CLASS="grid" BGCOLOR="#cccccc">&nbsp;</TH>
%   }
  </TR>

% my $bgcolor1 = '#eeeeee';
% my $bgcolor2 = '#ffffff';
% my $bgcolor = '';
%
% foreach my $note (@notes) {
%
%   if ( $bgcolor eq $bgcolor1 ) {
%     $bgcolor = $bgcolor2;
%   } else {
%     $bgcolor = $bgcolor1;
%   }
%
%   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' => 'Edit customer note',
%                            'width'       => 616,
%                            'height'      => 580,
%                            'frame'       => 'top',
%                        );
%   my $clickjs = qq!onclick="$onclick"!;
%
%   my $edit = '';
%   if ($curuser->access_right('Edit customer note') ) {
%     $edit = qq! <A HREF="javascript:void(0);" $clickjs>(edit)</A>!;
%   }

    <TR>
      <% note_datestr($note,$conf,$bgcolor) %>
      <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
        &nbsp;<% $note->otaker%>
      </TD>
      <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
        &nbsp;<% $note->comments | defang %>
      </TD>
% if($edit) {
      <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $edit %></TD>
% }
    </TR>

% } #end display notes

</TABLE>

% }
<%init>

use HTML::Defang;

my $conf = new FS::Conf;
my $curuser = $FS::CurrentUser::CurrentUser;

my(%opt) = @_;

my $custnum = $opt{'custnum'};

my $cust_main = qsearchs('cust_main', {'custnum' => $custnum} );
die "Custimer not found!" unless $cust_main;

my (@notes) = $cust_main->notes();

#subroutines

sub note_datestr {
  my($note, $conf, $bgcolor) = @_ or return '';
  my $td = qq{<TD CLASS="grid" BGCOLOR="$bgcolor" ALIGN="right">};
  my $format = "$td%b&nbsp;%o,&nbsp;%Y</TD>";
  $format .= "$td%l:%M%P</TD>"
    if $conf->exists('cust_main_note-display_times');
  ( my $strip = time2str($format, $note->_date) ) =~ s/ (\d)/$1/g;
  $strip;
}

</%init>