X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_main_Mixin.pm;h=94e6eaa29f903d0f055b12d3912e4f094e10f47a;hp=96e520d52261815585dd3cf9d2d7dac9c26a9f73;hb=755159a8654a2eda89badd1498f8def3a472cb15;hpb=bd714630f4747b3f411ae53515a734e9e771c6b3 diff --git a/FS/FS/cust_main_Mixin.pm b/FS/FS/cust_main_Mixin.pm index 96e520d52..94e6eaa29 100644 --- a/FS/FS/cust_main_Mixin.pm +++ b/FS/FS/cust_main_Mixin.pm @@ -380,6 +380,12 @@ HTML body Text body +=item to_contact_classnum + +The customer contact class (or classes, as a comma-separated list) to send +the message to. If unspecified, will be sent to any contacts that are marked +as invoice destinations (the equivalent of specifying 'invoice'). + =back Returns an error message, or false for success. @@ -403,6 +409,7 @@ sub email_search_result { 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 $error = ''; my $job = delete $param->{'job'} @@ -455,10 +462,21 @@ sub email_search_result { %message = $msg_template->prepare( 'cust_main' => $cust_main, 'object' => $obj, + 'to_contact_classnum' => $to_contact_classnum, ); - } - else { - my @to = $cust_main->invoicing_list_emailonly; + + } else { + # 3.x: false laziness with msg_template.pm; on 4.x, all email notices + # are generated from templates and this case goes away + my @classes; + if ( $opt{'to_contact_classnum'} ) { + my $classnum = $opt{'to_contact_classnum'}; + @classes = ref($classnum) ? @$classnum : split(',', $classnum); + } + if (!@classes) { + @classes = ( 'invoice' ); + } + my @to = $cust_main->contact_list_email(@classes); next if !@to; %message = (