X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main_Mixin.pm;h=ccd1b84c9ff6dd7e33bb5cb3f12181e151d1edf8;hb=f9ea5ad4c0ab886ee546012e8a6adec5a3dbf763;hp=6e9111ea813418feedc3939a203779e6467a07a5;hpb=1eff559d376d03ceb8de01dbc9dee9bf83bc647f;p=freeside.git diff --git a/FS/FS/cust_main_Mixin.pm b/FS/FS/cust_main_Mixin.pm index 6e9111ea8..ccd1b84c9 100644 --- a/FS/FS/cust_main_Mixin.pm +++ b/FS/FS/cust_main_Mixin.pm @@ -248,6 +248,17 @@ sub cust_statuscolor { : '000000'; } +=item agent_name + +=cut + +sub agent_name { + my $self = shift; + $self->cust_linked + ? $self->cust_main->agent_name + : $self->cust_unlinked_msg; +} + =item prospect_sql =item active_sql @@ -394,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"; @@ -447,12 +465,16 @@ sub email_search_result { next; # unlinked object; nothing else we can do } + my %to = {}; + if ($to) { $to{'to'} = $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 { @@ -465,7 +487,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 = ( @@ -479,7 +501,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} ) {