diff options
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/elements/menu.html | 2 | ||||
-rw-r--r-- | httemplate/misc/email-customers.html | 2 | ||||
-rw-r--r-- | httemplate/search/cust_msg.html | 122 | ||||
-rwxr-xr-x | httemplate/view/cust_msg.html | 55 |
4 files changed, 180 insertions, 1 deletions
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index 437392237..d0632a971 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -414,6 +414,8 @@ $tools_menu{'Time Queue'} = [ $fsurl.'search/report_timeworked.html', 'View pen if $curuser->access_right('Time queue'); $tools_menu{'Attachments'} = [ $fsurl.'browse/cust_attachment.html', 'View customer attachments' ] if !$conf->config('disable_cust_attachment') and $curuser->access_right('View attachments') and $curuser->access_right('Browse attachments'); +$tools_menu{'Outgoing messages'} = [ $fsurl.'search/cust_msg.html', 'View outgoing message log' ] + if $curuser->access_right('View customers of all agents'); $tools_menu{'Importing'} = [ \%tools_importing, 'Import tools' ] if $curuser->access_right('Import'); $tools_menu{'Exporting'} = [ \%tools_exporting, 'Export tools' ] diff --git a/httemplate/misc/email-customers.html b/httemplate/misc/email-customers.html index 759c8bf94..97ad8d8d4 100644 --- a/httemplate/misc/email-customers.html +++ b/httemplate/misc/email-customers.html @@ -186,7 +186,7 @@ if ( $cgi->param('action') eq 'preview' ) { $sql_query->{'extra_sql'} .= ' LIMIT 1'; $sql_query->{'order_by'} = ''; my $cust = qsearchs($sql_query)->cust_main; - my %message = $msg_template->prepare( 'cust_main' => $cust ); + my %message = $msg_template->prepare( 'cust_main' => $cust, 'preview' => 1 ); ($from, $subject, $html_body) = @message{'from', 'subject', 'html_body'}; } } diff --git a/httemplate/search/cust_msg.html b/httemplate/search/cust_msg.html new file mode 100644 index 000000000..7932ab3a2 --- /dev/null +++ b/httemplate/search/cust_msg.html @@ -0,0 +1,122 @@ +<& 'elements/search.html', + 'title' => $title, + 'name' => 'messages', + 'query' => $query, + 'count_query' => $count_query, + 'header' => [ + 'Date', + 'Template', + 'Destination', + 'Status', + '', #error + ], + 'fields' => [ + sub { + my $date = $_[0]->_date; + $date ? time2str('%Y-%m-%d %T',$_[0]->_date) : '' + }, + 'msgname', + 'env_to', + 'status', + sub { encode_entities($_[0]->error) }, + ], + 'align' => 'rllcl', + 'links' => [ ], + 'link_onclicks' => [ + $sub_popup_link, + $sub_popup_link, + $sub_popup_link, + '', + '', + ], + 'color' => [ ('') x 3, + $statuscolor, + $statuscolor, + ], + 'html_init' => $html_init, + 'really_disable_download' => 1, +&> +<%init> +#hmm... +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('View customers of all agents'); + +my $conf = new FS::Conf; + +my $title = 'Outgoing Message Log'; + +my @where; +if ( $cgi->param('status') =~ /^(\w+)$/ ) { + push @where, "status = '$1'"; +} +my ($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, ''); +push @where, "(_date >= $beginning AND _date <= $ending)"; + +my $order_by = '_date'; +if ( $cgi->param('order_by') =~ /^(\w+)$/ ) { + $order_by = $1; +} + +my $where = ''; +$where = ' WHERE '.join(' AND ', @where) if @where; +my $query = { + 'table' => 'cust_msg', + 'select' => join(', ', + 'cust_msg.*', + 'msg_template.msgname', + ), + 'addl_from' => ' LEFT JOIN msg_template USING ( msgnum )', + 'hashref' => {}, + 'extra_sql' => $where, + 'order_by' => "ORDER BY $order_by", +}; +my $count_query = 'SELECT COUNT(*) FROM cust_msg'.$where; + +my $sub_popup_link = sub { + my $custmsgnum = $_[0]->custmsgnum; + include('/elements/popup_link_onclick.html', + 'action' => $p. 'view/cust_msg.html?' . $custmsgnum, + 'actionlabel' => 'Message detail', + 'width' => 600, + 'height' => 500, + ); +}; + +my %color = ( + 'prepared' => '0000FF', + 'failed' => 'FF0000', + 'sent' => '', +); +my $statuscolor = sub { $color{$_[0]->status} }; + +my $html_init = qq!<FORM ACTION="$p/search/cust_msg.html" METHOD="GET"> +<TABLE cellspacing="10">!. +'<TR><TD>From '. +include('/elements/input-date-field.html', + { 'name' => 'beginning', 'value' => $cgi->param('beginning') } +). +'</TD><TD> To '. +include('/elements/input-date-field.html', + { 'name' => 'ending', 'value' => ($cgi->param('ending') || ''), + 'noinit' => 1, } +). +'</TD><TD> Status '. +include('/elements/select.html', + 'field' => 'status', + 'curr_value' => $cgi->param('status') || '', + 'options' => [ '', 'failed', 'sent', 'prepared' ], + 'labels' => { '' => '(any)', + 'failed' => 'failed', + 'sent' => 'sent', + 'prepared'=> 'prepared' }, +) . +'</TD> +<TD><INPUT type="submit" value="Search"></TD></TR> +</TABLE></FORM><BR> +<STYLE type="text/css"> +a:link {text-decoration: none} +a:visited {text-decoration: none} +a:hover {text-decoration: underline} +</STYLE>'; + +</%init> diff --git a/httemplate/view/cust_msg.html b/httemplate/view/cust_msg.html new file mode 100755 index 000000000..a5846109a --- /dev/null +++ b/httemplate/view/cust_msg.html @@ -0,0 +1,55 @@ +<& /elements/header-popup.html &> +<TABLE> +<TR><TD>From:</TD><TD><% $cust_msg->env_from %></TD></TR> +<TR><TD>To:</TD><TD><% $env_to %></TD></TR> +% if ( $date ) { +<TR><TD><% $label{$cust_msg->status} %></TD><TD><% $date %></TD></TR> +% } +% if ( $cust_msg->error ) { +<TR><TD>Error:</TD><TD><% encode_entities($cust_msg->error) %></TD></TR> +% } +<TR><TD colspan=2> +<FORM name="myform"> +<SCRIPT type="text/javascript"> +function toggle_display(obj) { + document.getElementById('content-header').style.display = + (obj.value == 'header' ? 'block' : 'none'); + document.getElementById('content-body').style.display = + (obj.value == 'body' ? 'block' : 'none'); +} +</SCRIPT> +<INPUT type="radio" name="what_to_show" onchange="toggle_display(this)" value="header" checked> Header +<INPUT type="radio" name="what_to_show" onchange="toggle_display(this)" value="body"> Body +</FORM> +</TR> +<TR><TD colspan=2 style="text-align:center"> +<TEXTAREA id="content-header" style="font-family:monospace" +readonly=1 cols=80 rows=20> +<% encode_entities($cust_msg->header) %> +</TEXTAREA> +<TEXTAREA id="content-body" style="font-family:monospace;display:none" +readonly=1 cols=80 rows=20> +<% encode_entities($cust_msg->body) %> +</TEXTAREA> +</TD></TR> +</TABLE> + +<& /elements/footer.html &> +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; +die "access denied" if !$curuser->access_right('View customers of all agents'); + +my ($custmsgnum) = $cgi->keywords; +$custmsgnum =~ /^(\d+)$/ or die "illegal custmsgnum"; +my $cust_msg = qsearchs('cust_msg', { 'custmsgnum' => $custmsgnum }); +my $date = ''; +$date = time2str('%Y-%m-%d %T', $cust_msg->_date) if ( $cust_msg->_date ); +my $env_to = join('</TD></TR><TR><TD></TD><TD>', split(',', $cust_msg->env_to)); + +my %label = ( + 'sent' => 'Sent:', + 'failed' => 'Attempted: ', + 'prepared' => 'Not sent', +); +</%init> |