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,
50 'order_by' => '_date DESC',
55 unless $FS::CurrentUser::CurrentUser->access_right('View email logs');
57 my $conf = new FS::Conf;
59 my $title = 'Outgoing Message Log';
61 #here is the agent virtualization
62 my $agentnums_sql = $FS::CurrentUser::CurrentUser->agentnums_sql(
63 'table' => 'cust_main',
64 'null_right' => [ 'View system logs', 'Configuration' ],
67 my @where = ( $agentnums_sql );
69 if ( $cgi->param('status') =~ /^(\w+)$/ ) {
70 push @where, "status = '$1'";
72 if ( $cgi->param('msgtype') =~ /^(\w+)$/ ) {
73 push @where, "msgtype = '$1'";
75 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
76 push @where, "cust_msg.custnum = $1";
78 my ($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, '');
79 push @where, "(_date >= $beginning AND _date <= $ending)";
81 my $order_by = '_date';
82 if ( $cgi->param('order_by') =~ /^(\w+)$/ ) {
86 my $where = ' WHERE '. join(' AND ', @where);
88 my $join_cust_main = ' LEFT JOIN cust_main USING ( custnum ) ';
91 'table' => 'cust_msg',
92 'select' => join(', ',
94 'msg_template.msgname',
96 'addl_from' => ' LEFT JOIN msg_template USING ( msgnum ) '. $join_cust_main,
98 'extra_sql' => $where,
99 'order_by' => "ORDER BY $order_by",
101 my $count_query = "SELECT COUNT(*) FROM cust_msg $join_cust_main $where";
103 my $sub_popup_link = sub {
104 my $custmsgnum = $_[0]->custmsgnum;
105 include('/elements/popup_link_onclick.html',
106 'action' => $p. 'view/cust_msg.html?' . $custmsgnum,
107 'actionlabel' => 'Message detail',
114 'failed' => 'FF0000',
117 'invoice' => '00CC00',
118 'receipt' => '0000CC',
122 my $statuscolor = sub { $color{$_[0]->status} };
123 my $typecolor = sub { $color{$_[0]->msgtype} };
125 my $html_init = qq!<FORM ACTION="$p/search/cust_msg.html" METHOD="GET">
126 <TABLE cellspacing="10">!.
128 include('/elements/input-date-field.html',
129 { 'name' => 'beginning', 'value' => $cgi->param('beginning') }
132 include('/elements/input-date-field.html',
133 { 'name' => 'ending', 'value' => ($cgi->param('ending') || ''),
137 include('/elements/select.html',
139 'curr_value' => $cgi->param('status') || '',
140 'options' => [ '', 'failed', 'sent', ],
141 'labels' => { '' => '(any)',
142 'failed' => 'failed',
146 include('/elements/select.html',
147 'field' => 'msgtype',
148 'curr_value' => $cgi->param('msgtype') || '',
149 'options' => [ '', 'invoice', 'receipt', 'admin', 'report' ],
150 'labels' => { '' => '(any)',
151 'invoice' => 'Invoices',
152 'receipt' => 'Receipts',
153 'admin' => 'Admin notices',
154 'report' => 'Reports',
158 <TD><INPUT type="submit" value="Search"></TD></TR>
160 <STYLE type="text/css">
161 a:link {text-decoration: none}
162 a:visited {text-decoration: none}
163 a:hover {text-decoration: underline}