From bb119c4cc86e906f698a205437790bd8f96bb3d0 Mon Sep 17 00:00:00 2001 From: mark Date: Fri, 20 May 2011 20:19:44 +0000 Subject: logging of template-generated mail, #12809 --- httemplate/search/cust_msg.html | 122 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 httemplate/search/cust_msg.html (limited to 'httemplate/search') diff --git a/httemplate/search/cust_msg.html b/httemplate/search/cust_msg.html new file mode 100644 index 000000000..7932ab3a2 --- /dev/null +++ b/httemplate/search/cust_msg.html @@ -0,0 +1,122 @@ +<& 'elements/search.html', + 'title' => $title, + 'name' => 'messages', + 'query' => $query, + 'count_query' => $count_query, + 'header' => [ + 'Date', + 'Template', + 'Destination', + 'Status', + '', #error + ], + 'fields' => [ + sub { + my $date = $_[0]->_date; + $date ? time2str('%Y-%m-%d %T',$_[0]->_date) : '' + }, + 'msgname', + 'env_to', + 'status', + sub { encode_entities($_[0]->error) }, + ], + 'align' => 'rllcl', + 'links' => [ ], + 'link_onclicks' => [ + $sub_popup_link, + $sub_popup_link, + $sub_popup_link, + '', + '', + ], + 'color' => [ ('') x 3, + $statuscolor, + $statuscolor, + ], + 'html_init' => $html_init, + 'really_disable_download' => 1, +&> +<%init> +#hmm... +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('View customers of all agents'); + +my $conf = new FS::Conf; + +my $title = 'Outgoing Message Log'; + +my @where; +if ( $cgi->param('status') =~ /^(\w+)$/ ) { + push @where, "status = '$1'"; +} +my ($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, ''); +push @where, "(_date >= $beginning AND _date <= $ending)"; + +my $order_by = '_date'; +if ( $cgi->param('order_by') =~ /^(\w+)$/ ) { + $order_by = $1; +} + +my $where = ''; +$where = ' WHERE '.join(' AND ', @where) if @where; +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", +}; +my $count_query = 'SELECT COUNT(*) FROM cust_msg'.$where; + +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' => 600, + 'height' => 500, + ); +}; + +my %color = ( + 'prepared' => '0000FF', + 'failed' => 'FF0000', + 'sent' => '', +); +my $statuscolor = sub { $color{$_[0]->status} }; + +my $html_init = qq!
+!. +' + +
From '. +include('/elements/input-date-field.html', + { 'name' => 'beginning', 'value' => $cgi->param('beginning') } +). +' To '. +include('/elements/input-date-field.html', + { 'name' => 'ending', 'value' => ($cgi->param('ending') || ''), + 'noinit' => 1, } +). +' Status '. +include('/elements/select.html', + 'field' => 'status', + 'curr_value' => $cgi->param('status') || '', + 'options' => [ '', 'failed', 'sent', 'prepared' ], + 'labels' => { '' => '(any)', + 'failed' => 'failed', + 'sent' => 'sent', + 'prepared'=> 'prepared' }, +) . +'

+'; + + -- cgit v1.2.1