<% include('/elements/header.html', $title) %>
% foreach my $key ( keys %search ) { % my @values = ref($search{$key}) ? @{$search{$key}} : ( $search{$key} ); % foreach my $value ( @values ) { % } % } % if ( $cgi->param('magic') eq 'send' ) { Sending notice <% include('/elements/progress-init.html', 'OneTrueForm', [ keys(%search), qw( from subject html_body text_body ) ], 'process/email-customers.html', { 'message' => "Notice sent" }, #would be nice to show #, but.. ) %> % } elsif ( $cgi->param('magic') eq 'preview' ) { Preview notice % } % if ( $cgi->param('magic') ) { <% include('/elements/tr-fixed.html', 'field' => 'from', 'label' => 'From:', 'value' => scalar( $cgi->param('from') ), ) %> <% include('/elements/tr-fixed.html', 'field' => 'subject', 'label' => 'Subject:', 'value' => scalar( $cgi->param('subject') ), ) %> % my $text_body = HTML::FormatText->new(leftmargin=>0)->format( % HTML::TreeBuilder->new_from_content( % $cgi->param('html_body') % ) % );
Message (HTML display): <% $cgi->param('html_body') %>
Message (Text display):
<% $text_body %>
% if ( $cgi->param('magic') eq 'preview' ) {
% } % } else { <% include('/elements/tr-input-text.html', 'field' => 'from', 'label' => 'From:', ) %> <% include('/elements/tr-input-text.html', 'field' => 'subject', 'label' => 'Subject:', ) %>
Message: <% include('/elements/htmlarea.html', 'field'=>'html_body') %>
%#Substitution vars:

% }
% if ( $cgi->param('magic') eq 'send' ) { % } <% include('/elements/footer.html') %> <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Bulk send customer notices'); my %search = $cgi->Vars; delete $search{$_} for qw( magic from subject html_body text_body ); $search{$_} = [ split(/\0/, $search{$_}) ] foreach grep { $_ eq 'payby' || $search{$_} =~ /\0/ } keys %search; my $title = 'Bulk send customer notices'; my $num_cust; if ( $cgi->param('magic') eq 'preview' ) { my $sql_query = FS::cust_main->search_sql(\%search); my $count_query = delete($sql_query->{'count_query'}); my $count_sth = dbh->prepare($count_query) or die "Error preparing $count_query: ". dbh->errstr; $count_sth->execute or die "Error executing $count_query: ". $count_sth->errstr; my $count_arrayref = $count_sth->fetchrow_arrayref; $num_cust = $count_arrayref->[0]; }