X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Femail-customers.html;h=1c22f8ffdc46c4ca150f854ad936d3e8123156e5;hb=62b18c75989a1b00a25079f8f110992aaad81bba;hp=c9a216c3ab9a86824cdd7c4c0ffe09dc29de914d;hpb=eb1796299a429ba5cd3b939a65bf5e95abf0086c;p=freeside.git diff --git a/httemplate/misc/email-customers.html b/httemplate/misc/email-customers.html index c9a216c3a..1c22f8ffd 100644 --- a/httemplate/misc/email-customers.html +++ b/httemplate/misc/email-customers.html @@ -46,6 +46,7 @@ should be used to set msgnum or from/subject/html_body cgi params + % if ( $cgi->param('action') eq 'send' ) { @@ -55,13 +56,12 @@ should be used to set msgnum or from/subject/html_body cgi params <& /elements/progress-init.html, 'OneTrueForm', [ qw( search table from subject html_body text_body - msgnum to_contact_classnum ) ], + msgnum to_contact_classnum emailtovoice_contact custnum ) ], $process_url, $pdest, &> % } elsif ( $cgi->param('action') eq 'preview' ) { - Preview notice @@ -71,6 +71,7 @@ should be used to set msgnum or from/subject/html_body cgi params + % if ( $msg_template ) { <% include('/elements/tr-fixed.html', 'label' => 'Template:', @@ -151,7 +152,11 @@ Template: &>
% # select destination contact classes -Send to contacts: +
+ + + + +
Send to contacts: +
<& /elements/checkboxes.html, 'style' => 'display: inline; vertical-align: top', 'disable_links' => 1, @@ -162,6 +167,24 @@ Send to contacts: $name eq 'invoice' #others default to unchecked }, &> +
+% if ($send_to_domain) { +
+ Email to voice +
+ +% } +

% # if sending a one-off message, show a form to edit it @@ -199,6 +222,7 @@ Send to contacts: %#Substitution vars: + % } #end not action or alternate form @@ -211,6 +235,18 @@ Send to contacts: % } + + <& /elements/footer.html &> <%init> @@ -219,22 +255,29 @@ my %opt = @_; $opt{'acl'} ||= 'Bulk send customer notices'; +my $email_to; + die "access denied" unless $FS::CurrentUser::CurrentUser->access_right($opt{'acl'}); my $conf = FS::Conf->new; my @no_search_fields = qw( action table from subject html_body text_body popup url ); +my $send_to_domain = $conf->config('email-to-voice_domain'); + my $form_action = $opt{'form_action'} || 'email-customers.html'; my $process_url = $opt{'process_url'} || 'process/email-customers.html'; my $title = $opt{'title'} || 'Send customer notices'; push( @no_search_fields, @{$opt{'no_search_fields'}} ) if $opt{'no_search_fields'}; +$m->comp('/elements/handle_uri_query'); + my $table = $cgi->param('table') or die "'table' required"; my $agent_virt_agentnum = $cgi->param('agent_virt_agentnum') || ''; my $popup = $cgi->param('popup'); my $url = $cgi->param('url'); +if (!$url && $cgi->param('custnum')) { $url = $fsurl."view/cust_main.cgi?".$cgi->param('custnum'); } my $pdest = { 'message' => "Notice sent" }; $pdest->{'url'} = $cgi->param('url') if $url; @@ -305,19 +348,40 @@ if ( $cgi->param('action') eq 'preview' ) { my %message = $msg_template->prepare(%msgopts); ($from, $subject, $html_body) = @message{'from', 'subject', 'html_body'}; } +} + +if ($cgi->param('action')) { # contact_class_X params in preview - foreach my $param ( $cgi->param ) { - if ( $param =~ /^contact_class_(\w+)$/ ) { - push @contact_classnum, $1; - if ( $1 eq 'invoice' ) { + if ($cgi->param('emailtovoice_contact')) { + $email_to = $cgi->param('emailtovoice_contact') . '@' . $send_to_domain; + push @contact_classnum, 'emailtovoice'; + push @contact_classname, $email_to; + } + elsif ($cgi->param('to_contact_classnum')) { + foreach my $c (split(/,/, $cgi->param('to_contact_classnum'))) { + push @contact_classnum, $c; + if ( $c eq 'invoice' ) { push @contact_classname, 'Invoice recipients'; } else { - my $contact_class = FS::contact_class->by_key($1); + my $contact_class = FS::contact_class->by_key($c); push @contact_classname, encode_entities($contact_class->classname); } } } + else { + foreach my $param ( $cgi->param ) { + if ( $param =~ /^contact_class_(\w+)$/ ) { + push @contact_classnum, $1; + if ( $1 eq 'invoice' ) { + push @contact_classname, 'Invoice recipients'; + } else { + my $contact_class = FS::contact_class->by_key($1); + push @contact_classname, encode_entities($contact_class->classname); + } + } + } + } } @@ -325,10 +389,12 @@ if ( $cgi->param('action') eq 'preview' ) { my @contact_checkboxes = ( [ 'invoice' => { label => 'Invoice recipients' } ] ); + foreach my $class (qsearch('contact_class', { disabled => '' })) { push @contact_checkboxes, [ $class->classnum, { label => $class->classname } ]; } +