summaryrefslogtreecommitdiff
path: root/httemplate/view/cust_main/notes/notes.html
blob: c643003842cb5f4482d18bb6ba1a3efa5ad7ab53 (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
% if ( scalar(@notes) ) {
<SCRIPT TYPE="text/javascript">

function display_notes_classnum (classnum) {
  // hide/show
  var $custnote = $('.custnote');
  if (classnum >= 0) {
    $custnote.hide();
    $('tr[data-classnum=' + classnum + ']').show();
  } else {
    $custnote.show();
  }
  // restripe
  var $shownote = $custnote.filter(':visible');
  var $shownote_even = $shownote.filter(':even');
  var $shownote_odd = $shownote.filter(':odd');
  $shownote_even.css('background-color','#eeeeee');
  $shownote_even.filter('.stickynote').css('background-color','#ffff66');
  $shownote_odd.css('background-color','#ffffff');
  $shownote_odd.filter('.stickynote').css('background-color','#ffffb8');
%   if ($use_class_tabs) {
  // update links
  var $tablink = $('.notes_tablink');
  $tablink.css('font-weight','normal');
  $tablink.filter('a[data-classnum=' + classnum + ']').css('font-weight','bold');
%   }
}
</SCRIPT>

  <& /elements/init_overlib.html &>

%   if ( $use_class_tabs ) {
<% mt('Show notes of class:') |h %> &nbsp; 
%   # list unclassified last
% 	  foreach my $classnum ( (grep { $_ != 0} sort { $a <=> $b } (keys %classes)), '0' ) {
	    <A CLASS="notes_tablink"
        data-classnum="<% $classnum %>"
		HREF="javascript:display_notes_classnum(<% $classnum %>)"
	    ><% $classes{$classnum} %></A>
% 	  }
    <BR>
%   }

<& /elements/table-grid.html &>
  <TR>
    <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Date') |h %></TH>
%   if ( $conf->exists('cust_main_note-display_times') ) {
    <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Time') |h %></TH>
%   }
    <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Employee') |h %></TH>
%   if ($use_classes) {
    <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Class') |h %></TH>
%   }
    <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Note') |h %></TH>
%   if ($curuser->access_right('Edit customer note') ) {
    <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em">&nbsp;</TH>
%   }
  </TR>

% } # 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'       => 875,
%                            'height'      => 548,
%                            'frame'       => 'top',
%                        );
%   my $clickjs = qq!onclick="$onclick"!;
%
%   my $edit = '';
%   if ( $curuser->access_right('Edit customer note') ) {
%     $edit = qq! <A HREF="javascript:void(0);" $clickjs>(!.emt('edit').')</A>';
%   }
%   if ( $curuser->access_right('Delete customer note') ) {
%     my $delete_url = $fsurl.'misc/delete-note.html?'.$notenum;
%     $edit .= qq! <A HREF="$delete_url" !.
%              qq! onclick="return confirm('Delete this note?')">!.
%              '('.emt('delete').')</A>';
%   }
%
    <TR CLASS="grid custnote<% $note->sticky ? ' stickynote' : '' %>"
        <% $use_class_tabs ? ' data-classnum="'.($note->classnum || 0).'"' : '' %>>

      <% note_datestr($note,$conf) %>
      <TD CLASS="grid">
        &nbsp;<% $note->usernum ? $note->access_user->name : $note->otaker %>
      </TD>
%   if ($use_classes) {
      <TD CLASS="grid">
	<% $note->classname %>   
      </TD>
%   }
      <TD CLASS="grid">
        <% $note->comments | defang %>
      </TD>
%   if ($edit) {
      <TD CLASS="grid"><% $edit %></TD>
%   }
    </TR>
% } #end foreach note

% if (@notes) {
</TABLE>

<SCRIPT>display_notes_classnum('-1')</SCRIPT>
% } else {
<P><I><% emt('No notes for this customer') %></I></P>
% }

<%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{<TD CLASS="grid" 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>