fix translation escaping
[freeside.git] / httemplate / view / cust_main / notes / email.html
1 % if ( scalar(@rows) ) {
2 <STYLE type="text/css">
3 #cust_msg td.grid a:link {text-decoration: none}
4 #cust_msg td.grid a:visited {text-decoration: none}
5 #cust_msg td.grid a:hover {text-decoration: underline}
6 #cust_msg th {background-color: #cccccc}
7 .row0 {background-color: #eeeeee}
8 .row1 {background-color: #ffffff}
9 </STYLE>
10 <DIV id="cust_msg">
11 <FONT SIZE="+1"> <% emt('Email sent to this customer') %> </FONT><BR>
12 %   if ($maxrecords < $total) {
13 <% emt('Showing [_1] most recent of [quant,_2,total message]', $maxrecords, $total) %>
14   <A HREF="<%$p%>search/cust_msg.html?custnum=<%$custnum%>">
15   <i>(<% emt('view all') %>)</i>
16   </A>
17 %   } else {
18 <% emt('[quant,_1,total message]', $total) %>
19 %   }
20 <BR>
21 <& /elements/table-grid.html &>
22   <TR>
23     <TH CLASS="grid"><% emt('Date') %></TH>
24     <TH CLASS="grid"><% emt('Type') %></TH>
25     <TH CLASS="grid"><% emt('Destination') %></TH>
26     <TH CLASS="grid"><% emt('Subject') %></TH>
27     <TH CLASS="grid"></TH>
28   </TR>
29 %   my $i = 0;
30 %   foreach my $row (@rows) {
31 %     my $onclick = $sub_popup_link->($row);
32 %     my $link = qq!<A onclick="$onclick">!;
33   <TR CLASS="row<%$i%>">
34     <TD CLASS="grid"><% $link %>
35       <% $row->_date ? time2str('%Y-%m-%d %T', $row->_date) : '' %>
36     </A></TD>
37     <TD CLASS="grid" STYLE="color: <% $typecolor->($row) %>"><% $link %>
38       <% ucfirst($row->msgtype) || $row->msgname %>
39     </A></TD>
40     <TD CLASS="grid"><% $link %>
41       <% join('<BR>', split(/,\s*/, $row->env_to)) %>
42     </A></TD>
43     <TD CLASS="grid" STYLE="color: <% $statuscolor->($row) %>">
44       <% $row->status %>
45     </TD>
46     <TD CLASS="grid">
47       <% $row->error |h %>
48     </TD>
49   </TR>
50 %     $i = 1 - $i;
51 %   }
52 </TABLE>
53 </DIV>
54 % }
55 <%init>
56 my %opt = @_;
57
58 my $curuser = $FS::CurrentUser::CurrentUser;
59 my $cust_main = $opt{'cust_main'}
60   or die "cust_main required";
61 my $custnum = $cust_main->custnum;
62
63 my $where = "WHERE cust_msg.custnum = $custnum";
64 my $maxrecords = $curuser->option('customer_view_emails') || 10;
65
66 my $order_by = '_date DESC';
67
68 my $query = {
69   'table'     => 'cust_msg',
70   'select'    => join(', ',
71                    'cust_msg.*',
72                    'msg_template.msgname',
73                  ),
74   'addl_from' => ' LEFT JOIN msg_template USING ( msgnum ) ',
75   'hashref'   => {},
76   'extra_sql' => $where,
77   'order_by'  => "ORDER BY $order_by LIMIT $maxrecords",
78 };
79 my $count_query = "SELECT COUNT(*) FROM cust_msg $where";
80
81 my @rows = qsearch($query);
82 my $total = FS::Record->scalar_sql($count_query);
83
84 my $sub_popup_link = sub {
85   my $custmsgnum = $_[0]->custmsgnum;
86   include('/elements/popup_link_onclick.html',
87     'action'      => $p. 'view/cust_msg.html?' . $custmsgnum,
88     'actionlabel' => 'Message detail',
89     'width'       => 680,
90     'height'      => 550,
91   );
92 };
93
94 my %color = (
95   'failed'   => '#FF0000',
96   'sent'     => '#000000',
97
98   'invoice'  => '#00CC00',
99   'receipt'  => '#0000CC',
100   'admin'    => '#CC0000',
101   ''         => '#000000',
102 );
103 my $statuscolor = sub { $color{$_[0]->status} };
104 my $typecolor = sub { $color{$_[0]->msgtype} };
105
106 </%init>