From fd8a7c99f3b78c233ec44d1b3f15e558e48e092a Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 17 Jun 2008 03:36:10 +0000 Subject: finish adding a feature to easily list all email addresses for an agent & send them email --- httemplate/misc/email-customers.html | 145 +++++++++++++++++++++++++++ httemplate/misc/process/email-customers.html | 9 ++ 2 files changed, 154 insertions(+) create mode 100644 httemplate/misc/email-customers.html create mode 100644 httemplate/misc/process/email-customers.html (limited to 'httemplate/misc') diff --git a/httemplate/misc/email-customers.html b/httemplate/misc/email-customers.html new file mode 100644 index 000000000..0d3d622c3 --- /dev/null +++ b/httemplate/misc/email-customers.html @@ -0,0 +1,145 @@ +<% 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 $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]; +} + + diff --git a/httemplate/misc/process/email-customers.html b/httemplate/misc/process/email-customers.html new file mode 100644 index 000000000..d254cfecb --- /dev/null +++ b/httemplate/misc/process/email-customers.html @@ -0,0 +1,9 @@ +<% $server->process %> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Bulk send customer notices'); + +my $server = new FS::UI::Web::JSRPC 'FS::cust_main::process_email_search_sql', $cgi; + + -- cgit v1.2.1