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
63 $FS::CurrentUser::CurrentUser->agentnums_sql( 'table' => 'cust_main' );
65 my @where = ( $agentnums_sql );
67 if ( $cgi->param('status') =~ /^(\w+)$/ ) {
68 push @where, "status = '$1'";
70 if ( $cgi->param('msgtype') =~ /^(\w+)$/ ) {
71 push @where, "msgtype = '$1'";
73 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
74 push @where, "custnum = $1";
76 my ($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, '');
77 push @where, "(_date >= $beginning AND _date <= $ending)";
79 my $order_by = '_date';
80 if ( $cgi->param('order_by') =~ /^(\w+)$/ ) {
84 my $where = ' WHERE '. join(' AND ', @where);
86 my $join_cust_main = ' LEFT JOIN cust_main USING ( custnum ) ';
89 'table' => 'cust_msg',
90 'select' => join(', ',
92 'msg_template.msgname',
94 'addl_from' => ' LEFT JOIN msg_template USING ( msgnum ) '. $join_cust_main,
96 'extra_sql' => $where,
97 'order_by' => "ORDER BY $order_by",
99 my $count_query = "SELECT COUNT(*) FROM cust_msg $join_cust_main $where";
101 my $sub_popup_link = sub {
102 my $custmsgnum = $_[0]->custmsgnum;
103 include('/elements/popup_link_onclick.html',
104 'action' => $p. 'view/cust_msg.html?' . $custmsgnum,
105 'actionlabel' => 'Message detail',
112 'failed' => 'FF0000',
115 'invoice' => '00CC00',
116 'receipt' => '0000CC',
120 my $statuscolor = sub { $color{$_[0]->status} };
121 my $typecolor = sub { $color{$_[0]->msgtype} };
123 my $html_init = qq!<FORM ACTION="$p/search/cust_msg.html" METHOD="GET">
124 <TABLE cellspacing="10">!.
126 include('/elements/input-date-field.html',
127 { 'name' => 'beginning', 'value' => $cgi->param('beginning') }
130 include('/elements/input-date-field.html',
131 { 'name' => 'ending', 'value' => ($cgi->param('ending') || ''),
135 include('/elements/select.html',
137 'curr_value' => $cgi->param('status') || '',
138 'options' => [ '', 'failed', 'sent', ],
139 'labels' => { '' => '(any)',
140 'failed' => 'failed',
144 include('/elements/select.html',
145 'field' => 'msgtype',
146 'curr_value' => $cgi->param('msgtype') || '',
147 'options' => [ '', 'invoice', 'receipt', 'admin' ],
148 'labels' => { '' => '(any)',
149 'invoice' => 'Invoices',
150 'receipt' => 'Receipts',
151 'admin' => 'Admin notices',
155 <TD><INPUT type="submit" value="Search"></TD></TR>
157 <STYLE type="text/css">
158 a:link {text-decoration: none}
159 a:visited {text-decoration: none}
160 a:hover {text-decoration: underline}