From 95606bc9db41352511c886773a311f2166cc6cf2 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Wed, 6 May 2015 16:43:45 -0700 Subject: display N most recent emails in customer view, #30164 --- httemplate/view/cust_main/notes/email.html | 106 +++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 httemplate/view/cust_main/notes/email.html (limited to 'httemplate/view/cust_main/notes') diff --git a/httemplate/view/cust_main/notes/email.html b/httemplate/view/cust_main/notes/email.html new file mode 100644 index 000000000..da2c352b6 --- /dev/null +++ b/httemplate/view/cust_main/notes/email.html @@ -0,0 +1,106 @@ +% if ( scalar(@rows) ) { + +
+ <% mt('Email sent to this customer') %>
+% if ($maxrecords < $total) { +<% mt('Showing [_1] most recent of [quant,_2,total message]', $maxrecords, $total) %> + + (<% mt('view all') %>) + +% } else { +<% mt('[quant,_1,total message]', $total) %> +% } +
+<& /elements/table-grid.html &> + + <% mt('Date') %> + <% mt('Type') %> + <% mt('Destination') %> + <% mt('Subject') %> + + +% my $i = 0; +% foreach my $row (@rows) { +% my $onclick = $sub_popup_link->($row); +% my $link = qq!!; + + <% $link %> + <% $row->_date ? time2str('%Y-%m-%d %T', $row->_date) : '' %> + + <% $link %> + <% ucfirst($row->msgtype) || $row->msgname %> + + <% $link %> + <% join('
', split(/,\s*/, $row->env_to)) %> + + + <% $row->status %> + + + <% $row->error |h %> + + +% $i = 1 - $i; +% } + +
+% } +<%init> +my %opt = @_; + +my $curuser = $FS::CurrentUser::CurrentUser; +my $cust_main = $opt{'cust_main'} + or die "cust_main required"; +my $custnum = $cust_main->custnum; + +my $where = "WHERE cust_msg.custnum = $custnum"; +my $maxrecords = $curuser->option('customer_view_emails') || 10; + +my $order_by = '_date DESC'; + +my $query = { + 'table' => 'cust_msg', + 'select' => join(', ', + 'cust_msg.*', + 'msg_template.msgname', + ), + 'addl_from' => ' LEFT JOIN msg_template USING ( msgnum ) ', + 'hashref' => {}, + 'extra_sql' => $where, + 'order_by' => "ORDER BY $order_by LIMIT $maxrecords", +}; +my $count_query = "SELECT COUNT(*) FROM cust_msg $where"; + +my @rows = qsearch($query); +my $total = FS::Record->scalar_sql($count_query); + +my $sub_popup_link = sub { + my $custmsgnum = $_[0]->custmsgnum; + include('/elements/popup_link_onclick.html', + 'action' => $p. 'view/cust_msg.html?' . $custmsgnum, + 'actionlabel' => 'Message detail', + 'width' => 680, + 'height' => 550, + ); +}; + +my %color = ( + 'failed' => '#FF0000', + 'sent' => '#000000', + + 'invoice' => '#00CC00', + 'receipt' => '#0000CC', + 'admin' => '#CC0000', + '' => '#000000', +); +my $statuscolor = sub { $color{$_[0]->status} }; +my $typecolor = sub { $color{$_[0]->msgtype} }; + + -- cgit v1.2.1