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
23 map { encode_entities($_->format) }
24 Email::Address->parse($_[0]->env_to)
28 sub { encode_entities($_[0]->error) },
30 'sort_fields' => [ '_date',
51 'html_init' => $html_init,
52 'really_disable_download' => 1,
53 'order_by' => '_date DESC',
58 unless $FS::CurrentUser::CurrentUser->access_right('View email logs');
60 my $conf = new FS::Conf;
62 my $title = 'Outgoing Message Log';
64 #here is the agent virtualization
65 my $agentnums_sql = $FS::CurrentUser::CurrentUser->agentnums_sql(
66 'table' => 'cust_main',
67 'null_right' => [ 'View system logs', 'Configuration' ],
70 my @where = ( $agentnums_sql );
72 if ( $cgi->param('status') =~ /^(\w+)$/ ) {
73 push @where, "status = '$1'";
75 if ( $cgi->param('msgtype') =~ /^(\w+)$/ ) {
76 push @where, "msgtype = '$1'";
78 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
79 push @where, "cust_msg.custnum = $1";
81 my ($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, '');
82 push @where, "(_date >= $beginning AND _date <= $ending)";
84 my $order_by = '_date';
85 if ( $cgi->param('order_by') =~ /^(\w+)$/ ) {
89 my $where = ' WHERE '. join(' AND ', @where);
91 my $join_cust_main = ' LEFT JOIN cust_main USING ( custnum ) ';
94 'table' => 'cust_msg',
95 'select' => join(', ',
97 'msg_template.msgname',
99 'addl_from' => ' LEFT JOIN msg_template USING ( msgnum ) '. $join_cust_main,
101 'extra_sql' => $where,
102 'order_by' => "ORDER BY $order_by",
104 my $count_query = "SELECT COUNT(*) FROM cust_msg $join_cust_main $where";
106 my $sub_popup_link = sub {
107 my $custmsgnum = $_[0]->custmsgnum;
108 include('/elements/popup_link_onclick.html',
109 'action' => $p. 'view/cust_msg.html?' . $custmsgnum,
110 'actionlabel' => 'Message detail',
117 'failed' => 'FF0000',
120 'invoice' => '00CC00',
121 'receipt' => '0000CC',
125 my $statuscolor = sub { $color{$_[0]->status} };
126 my $typecolor = sub { $color{$_[0]->msgtype} };
128 my $html_init = qq!<FORM ACTION="$p/search/cust_msg.html" METHOD="GET">
129 <TABLE cellspacing="10">!.
131 include('/elements/input-date-field.html',
132 { 'name' => 'beginning', 'value' => scalar($cgi->param('beginning')) }
135 include('/elements/input-date-field.html',
136 { 'name' => 'ending', 'value' => (scalar($cgi->param('ending')) || ''),
140 include('/elements/select.html',
142 'curr_value' => scalar($cgi->param('status')) || '',
143 'options' => [ '', 'failed', 'sent', ],
144 'labels' => { '' => '(any)',
145 'failed' => 'failed',
149 include('/elements/select.html',
150 'field' => 'msgtype',
151 'curr_value' => scalar($cgi->param('msgtype')) || '',
152 'options' => [ '', 'invoice', 'receipt', 'admin', 'report' ],
153 'labels' => { '' => '(any)',
154 'invoice' => 'Invoices',
155 'receipt' => 'Receipts',
156 'admin' => 'Admin notices',
157 'report' => 'Reports',
161 <TD><INPUT type="submit" value="Search"></TD></TR>
163 <STYLE type="text/css">
164 a:link {text-decoration: none}
165 a:visited {text-decoration: none}
166 a:hover {text-decoration: underline}