From: mark Date: Mon, 11 Apr 2011 21:33:54 +0000 (+0000) Subject: per-agent payment receipt addresses, #10797 X-Git-Tag: freeside_2_3_0~409 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=6e3e6b1051bf8bc603a437a72d5272f61330af18 per-agent payment receipt addresses, #10797 --- diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 7844ff0fd..15d64bc59 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1318,6 +1318,14 @@ and customer address. Include units.', 'description' => 'Template to use for payment receipts.', %msg_template_options, }, + + { + 'key' => 'payment_receipt_from', + 'section' => 'notification', + 'description' => 'From: address for payment receipts, if not specified in the template.', + 'type' => 'text', + 'per_agent' => 1, + }, { 'key' => 'payment_receipt_email', diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 29f3ddcbb..c80729a4e 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -551,7 +551,11 @@ sub send_receipt { my $msgnum = $conf->config('payment_receipt_msgnum', $cust_main->agentnum); if ( $msgnum ) { my $msg_template = FS::msg_template->by_key($msgnum); - $error = $msg_template->send('cust_main'=> $cust_main, 'object'=> $self); + $error = $msg_template->send( + 'cust_main' => $cust_main, + 'object' => $self, + 'from_config' => 'payment_receipt_from', + ); } elsif ( $conf->exists('payment_receipt_email') ) { diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm index a35b2d19f..0b9746a03 100644 --- a/FS/FS/msg_template.pm +++ b/FS/FS/msg_template.pm @@ -175,6 +175,14 @@ objects will be available for substitution, with their field names prefixed with 'new_' and 'old_' respectively. This is used in the rt_ticket export when exporting "replace" events. +=item from_config + +Configuration option to use as the source address, based on the customer's +agentnum. If unspecified (or the named option is empty), 'invoice_from' +will be used. + +The I field in the template takes precedence over this. + =item to Destination address. The default is to use the customer's @@ -291,10 +299,19 @@ sub prepare { # no warning when preparing with no destination my $conf = new FS::Conf; + my $from_addr = $self->from_addr; + + if ( !$from_addr ) { + if ( $opt{'from_config'} ) { + $from_addr = scalar( $conf->config($opt{'from_config'}, + $cust_main->agentnum) ); + } + $from_addr ||= scalar( $conf->config('invoice_from', + $cust_main->agentnum) ); + } ( - 'from' => $self->from_addr || - scalar( $conf->config('invoice_from', $cust_main->agentnum) ), + 'from' => $from_addr, 'to' => \@to, 'bcc' => $self->bcc_addr || undef, 'subject' => $subject,