1 <& 'elements/search.html',
5 'count_query' => $count_query,
15 my $date = $_[0]->_date;
16 $date ? time2str('%Y-%m-%d %T',$_[0]->_date) : ''
19 ucfirst($_[0]->msgtype) || $_[0]->msgname
22 join('<BR>', split(/,\s*/, $_[0]->env_to) )
25 sub { encode_entities($_[0]->error) },
42 'html_init' => $html_init,
43 'really_disable_download' => 1,
48 unless $FS::CurrentUser::CurrentUser->access_right('View email logs');
50 my $conf = new FS::Conf;
52 my $title = 'Outgoing Message Log';
55 if ( $cgi->param('status') =~ /^(\w+)$/ ) {
56 push @where, "status = '$1'";
58 if ( $cgi->param('msgtype') =~ /^(\w+)$/ ) {
59 push @where, "msgtype = '$1'";
61 my ($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, '');
62 push @where, "(_date >= $beginning AND _date <= $ending)";
64 my $order_by = '_date';
65 if ( $cgi->param('order_by') =~ /^(\w+)$/ ) {
70 $where = ' WHERE '.join(' AND ', @where) if @where;
72 'table' => 'cust_msg',
73 'select' => join(', ',
75 'msg_template.msgname',
77 'addl_from' => ' LEFT JOIN msg_template USING ( msgnum )',
79 'extra_sql' => $where,
80 'order_by' => "ORDER BY $order_by",
82 my $count_query = 'SELECT COUNT(*) FROM cust_msg'.$where;
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',
98 'invoice' => '00CC00',
99 'receipt' => '0000CC',
103 my $statuscolor = sub { $color{$_[0]->status} };
104 my $typecolor = sub { $color{$_[0]->msgtype} };
106 my $html_init = qq!<FORM ACTION="$p/search/cust_msg.html" METHOD="GET">
107 <TABLE cellspacing="10">!.
109 include('/elements/input-date-field.html',
110 { 'name' => 'beginning', 'value' => $cgi->param('beginning') }
113 include('/elements/input-date-field.html',
114 { 'name' => 'ending', 'value' => ($cgi->param('ending') || ''),
118 include('/elements/select.html',
120 'curr_value' => $cgi->param('status') || '',
121 'options' => [ '', 'failed', 'sent', ],
122 'labels' => { '' => '(any)',
123 'failed' => 'failed',
127 include('/elements/select.html',
128 'field' => 'msgtype',
129 'curr_value' => $cgi->param('msgtype') || '',
130 'options' => [ '', 'invoice', 'receipt', 'admin' ],
131 'labels' => { '' => '(any)',
132 'invoice' => 'Invoices',
133 'receipt' => 'Receipts',
134 'admin' => 'Admin notices',
138 <TD><INPUT type="submit" value="Search"></TD></TR>
140 <STYLE type="text/css">
141 a:link {text-decoration: none}
142 a:visited {text-decoration: none}
143 a:hover {text-decoration: underline}