internationalization/localization, RT12515
[freeside.git] / httemplate / view / cust_main / notes.html
1 % if ( scalar(@notes) ) {
2
3 <SCRIPT TYPE="text/javascript">
4
5     function display_notes_classnum(classnum){
6         document.getElementById('notes_'+classnum).style.display = 'block';
7         document.getElementById('notes_tablink_'+classnum).style.fontWeight = 'bold';
8
9         var divs = document.getElementsByTagName("div");
10         var i;
11         for(i=0; i < divs.length; i++){
12             var d = divs[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';
16                 }
17             }
18         }
19         
20         var as = document.getElementsByTagName("a");
21         for(i=0; i < as.length; i++){
22             var a = as[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';
26                 }
27             }
28         }
29     }
30
31 </SCRIPT>
32
33   <% include('/elements/init_overlib.html') %>
34
35 % my $bgcolor1 = '#eeeeee';
36 % my $bgcolor2 = '#ffffff';
37 % my $bgcolor = '';
38 % my $last_classnum = -1;
39 % my $skipheader = 0;
40 % my %classes = ();
41 %
42 % foreach my $note (@notes) {
43 %
44 %   if ( $bgcolor eq $bgcolor1 ) {
45 %     $bgcolor = $bgcolor2;
46 %   } else {
47 %     $bgcolor = $bgcolor1;
48 %   }
49 %
50 %   my $pop = popurl(3);
51 %   my $notenum = $note->notenum;
52 %   my $onclick = include( '/elements/popup_link_onclick.html',
53 %                            'action'      => popurl(2).
54 %                                             'edit/cust_main_note.cgi'.
55 %                                             "?custnum=$custnum".
56 %                                             ";notenum=$notenum",
57 %                            'actionlabel' => mt('Edit customer note'),
58 %                            'width'       => 616,
59 %                            'height'      => 538, #575
60 %                            'frame'       => 'top',
61 %                        );
62 %   my $clickjs = qq!onclick="$onclick"!;
63 %
64 %   my $edit = '';
65 %   if ($curuser->access_right('Edit customer note') ) {
66 %     my $editlabel = mt('edit');
67 %     $edit = qq! <A HREF="javascript:void(0);" $clickjs>($editlabel)</A>!;
68 %   }
69 %
70 % if ( $last_classnum != $note->classnum && !$skipheader ) {
71 % my $tmp_classnum = $note->classnum ? $note->classnum : 0;
72 % $classes{$tmp_classnum} = $note->classname ne '' ? $note->classname 
73 %                                                    : mt('Other');
74 % if ( $last_classnum != -1 ) {
75     </TABLE>
76   </DIV>
77 % }
78 % my $display = ($tmp_classnum == 0 || !$conf->exists('note-classes') 
79 %                                   || $conf->config('note-classes') < 2) 
80 %                                                           ? 'block' : 'none';
81         <DIV    id="notes_<% $tmp_classnum %>"
82                 style="display:<% $display %>"
83         >
84         <% include("/elements/table-grid.html") %>
85         <TR>
86             <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Date') |h %></TH>
87 %   if ( $conf->exists('cust_main_note-display_times') ) {
88             <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Time') |h %></TH>
89 %   }
90             <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Person') |h %></TH>
91 %   if ($conf->exists('note-classes') && $conf->config('note-classes') == 1) {
92             <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Class') |h %></TH>
93 %   }
94             <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Note') |h %></TH>
95 %   if ($curuser->access_right('Edit customer note') ) {
96             <TH CLASS="grid" BGCOLOR="#cccccc">&nbsp;</TH>
97 %   }
98         </TR>
99 % $skipheader = (!$conf->exists('note-classes') || $conf->config('note-classes') < 2);
100 % $last_classnum = $note->classnum;
101 % }
102
103     <TR>
104       <% note_datestr($note,$conf,$bgcolor) %>
105       <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
106         &nbsp;<% $note->usernum ? $note->access_user->name : $note->otaker %>
107       </TD>
108 % if ($conf->exists('note-classes') && $conf->config('note-classes') == 1) {
109       <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
110         <% $note->classname %>   
111       </TD>
112 % }
113       <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
114         <% $note->comments | defang %>
115       </TD>
116 % if($edit) {
117       <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $edit %></TD>
118 % }
119     </TR>
120
121 % } #end display notes
122
123 </TABLE>
124 </DIV>
125
126 % if ( $conf->exists('note-classes') && $conf->config('note-classes') == 2 ) {
127 %       my($classnum,$classname);
128 <% mt('Show notes of class:') |h %> &nbsp; 
129 %       foreach my $classnum ( sort { $b <=> $a } (keys %classes) ) {
130             <A  id="notes_tablink_<% $classnum %>"
131                 HREF="javascript:display_notes_classnum(<% $classnum %>)"
132                 style="font-weight: <% $classnum == 0 ? 'bold' : 'normal' %>"
133             ><% $classes{$classnum} %></A>
134 %       }
135     <BR>
136 % }
137
138 % }
139 <%init>
140
141 use HTML::Defang;
142
143 my $conf = new FS::Conf;
144 my $curuser = $FS::CurrentUser::CurrentUser;
145
146 my(%opt) = @_;
147
148 my $custnum = $opt{'custnum'};
149
150 my $cust_main = qsearchs('cust_main', {'custnum' => $custnum} );
151 die "Customer not found!" unless $cust_main;
152
153 my (@notes) = $cust_main->notes($conf->exists('note-classes') && $conf->config('note-classes') == 2);
154
155 #subroutines
156
157 sub note_datestr {
158   my($note, $conf, $bgcolor) = @_ or return '';
159   my $td = qq{<TD CLASS="grid" BGCOLOR="$bgcolor" ALIGN="right">};
160   my $format = "$td%b&nbsp;%o,&nbsp;%Y</TD>";
161   $format .= "$td%l:%M%P</TD>"
162     if $conf->exists('cust_main_note-display_times');
163   ( my $strip = time2str($format, $note->_date) ) =~ s/ (\d)/$1/g;
164   $strip;
165 }
166
167 </%init>