1 <& 'elements/search.html',
3 'name_singular' => 'message',
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) },
27 'sort_fields' => [ '_date',
48 'html_init' => $html_init,
49 'really_disable_download' => 1,
55 unless $FS::CurrentUser::CurrentUser->access_right('View email logs');
57 my $conf = new FS::Conf;
59 my $title = 'Outgoing Message Log';
62 if ( $cgi->param('status') =~ /^(\w+)$/ ) {
63 push @where, "status = '$1'";
65 if ( $cgi->param('msgtype') =~ /^(\w+)$/ ) {
66 push @where, "msgtype = '$1'";
68 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
69 push @where, "custnum = $1";
71 my ($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, '');
72 push @where, "(_date >= $beginning AND _date <= $ending)";
74 my $order_by = '_date';
75 if ( $cgi->param('order_by') =~ /^(\w+)$/ ) {
80 $where = ' WHERE '.join(' AND ', @where) if @where;
82 'table' => 'cust_msg',
83 'select' => join(', ',
85 'msg_template.msgname',
87 'addl_from' => ' LEFT JOIN msg_template USING ( msgnum )',
89 'extra_sql' => $where,
90 'order_by' => "ORDER BY $order_by",
92 my $count_query = 'SELECT COUNT(*) FROM cust_msg'.$where;
94 my $sub_popup_link = sub {
95 my $custmsgnum = $_[0]->custmsgnum;
96 include('/elements/popup_link_onclick.html',
97 'action' => $p. 'view/cust_msg.html?' . $custmsgnum,
98 'actionlabel' => 'Message detail',
105 'failed' => 'FF0000',
108 'invoice' => '00CC00',
109 'receipt' => '0000CC',
113 my $statuscolor = sub { $color{$_[0]->status} };
114 my $typecolor = sub { $color{$_[0]->msgtype} };
116 my $html_init = qq!<FORM ACTION="$p/search/cust_msg.html" METHOD="GET">
117 <TABLE cellspacing="10">!.
119 include('/elements/input-date-field.html',
120 { 'name' => 'beginning', 'value' => $cgi->param('beginning') }
123 include('/elements/input-date-field.html',
124 { 'name' => 'ending', 'value' => ($cgi->param('ending') || ''),
128 include('/elements/select.html',
130 'curr_value' => $cgi->param('status') || '',
131 'options' => [ '', 'failed', 'sent', ],
132 'labels' => { '' => '(any)',
133 'failed' => 'failed',
137 include('/elements/select.html',
138 'field' => 'msgtype',
139 'curr_value' => $cgi->param('msgtype') || '',
140 'options' => [ '', 'invoice', 'receipt', 'admin' ],
141 'labels' => { '' => '(any)',
142 'invoice' => 'Invoices',
143 'receipt' => 'Receipts',
144 'admin' => 'Admin notices',
148 <TD><INPUT type="submit" value="Search"></TD></TR>
150 <STYLE type="text/css">
151 a:link {text-decoration: none}
152 a:visited {text-decoration: none}
153 a:hover {text-decoration: underline}