X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main_Mixin.pm;h=473bdd2998679d63d497067de680be2bc6f52ab3;hb=bcc11e8b99854452cdccd9406918c015bee784cb;hp=28d894b1bdf684cd450f1a633f8900236a54c30b;hpb=1b7f832fbc874c1c0b80d22589752a601ce39c18;p=freeside.git diff --git a/FS/FS/cust_main_Mixin.pm b/FS/FS/cust_main_Mixin.pm index 28d894b1b..473bdd299 100644 --- a/FS/FS/cust_main_Mixin.pm +++ b/FS/FS/cust_main_Mixin.pm @@ -405,14 +405,21 @@ use Digest::SHA qw(sha1); # for duplicate checking sub email_search_result { my($class, $param) = @_; + my $conf = FS::Conf->new; + my $send_to_domain = $conf->config('email-to-voice_domain'); + my $msgnum = $param->{msgnum}; my $from = delete $param->{from}; my $subject = delete $param->{subject}; my $html_body = delete $param->{html_body}; my $text_body = delete $param->{text_body}; my $to_contact_classnum = delete $param->{to_contact_classnum}; + my $emailtovoice_name = delete $param->{emailtovoice_contact}; + my $error = ''; + my $to = $emailtovoice_name . '@' . $send_to_domain unless !$emailtovoice_name; + my $job = delete $param->{'job'} or die "email_search_result must run from the job queue.\n"; @@ -458,12 +465,15 @@ sub email_search_result { next; # unlinked object; nothing else we can do } + my %to = ( to => $to ) if $to; + if ( $msg_template ) { # Now supports other context objects. %message = $msg_template->prepare( 'cust_main' => $cust_main, 'object' => $obj, 'to_contact_classnum' => $to_contact_classnum, + %to ); } else { @@ -476,7 +486,7 @@ sub email_search_result { if (!@classes) { @classes = ( 'invoice' ); } - my @to = $cust_main->contact_list_email(@classes); + my @to = $to ? split(',', $to) : $cust_main->contact_list_email(@classes); next if !@to; %message = ( @@ -490,7 +500,7 @@ sub email_search_result { } #if $msg_template # For non-cust_main searches, we avoid duplicates based on message - # body text. + # body text. my $unique = $cust_main->custnum; $unique .= sha1($message{'text_body'}) if $class ne 'FS::cust_main'; if( $sent_to{$unique} ) { @@ -705,7 +715,9 @@ sub unsuspend_balance { } my $balance = $cust_main->balance || 0; if ($balance <= $maxbalance) { - my @errors = $cust_main->unsuspend; + my @errors = $cust_main->unsuspend( + 'reason_type' => $conf->config('unsuspend_reason_type') + ); # side-fx with nested transactions? upstack rolls back? warn "WARNING:Errors unsuspending customer ". $cust_main->custnum. ": ". join(' / ', @errors)