X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fmsg_template.pm;h=50298d278010c414db904275a29a42abc64e2def;hb=7863d7a397e90a07d0d5139fa3de872651cc9ac6;hp=d1db17dbcc4f7dce53640de93dfe7c7581ce80f1;hpb=824b97e97e4e5ee914a4c936815a4413def71a4f;p=freeside.git diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm index d1db17dbc..50298d278 100644 --- a/FS/FS/msg_template.pm +++ b/FS/FS/msg_template.pm @@ -226,7 +226,7 @@ sub prepare { $_ } @$guts; - $body = ''; + $body = '{ use Date::Format qw(time2str); "" }'; while(@$skin || @$guts) { $body .= shift(@$skin) || ''; $body .= shift(@$guts) || ''; @@ -255,9 +255,10 @@ sub prepare { my $conf = new FS::Conf; ( - 'from' => $self->from || + 'from' => $self->from_addr || scalar( $conf->config('invoice_from', $cust_main->agentnum) ), 'to' => \@to, + 'bcc' => $self->bcc_addr || undef, 'subject' => $subject, 'html_body' => $body, 'text_body' => HTML::FormatText->new(leftmargin => 0, rightmargin => 70 @@ -314,7 +315,10 @@ sub substitutions { cust_status ucfirst_cust_status cust_statuscolor signupdate dundate + expdate + packages recurdates ), + # expdate is a special case [ signupdate_ymd => sub { time2str('%Y-%m-%d', shift->signupdate) } ], [ dundate_ymd => sub { time2str('%Y-%m-%d', shift->dundate) } ], [ paydate_my => sub { sprintf('%02d/%04d', shift->paydate_monthyear) } ], @@ -398,26 +402,27 @@ sub _upgrade_data { my ($self, %opts) = @_; my @fixes = ( - [ 'alerter_msgnum', 'alerter_template', '', '' ], - [ 'cancel_msgnum', 'cancelmessage', 'cancelsubject', '' ], - [ 'decline_msgnum', 'declinetemplate', '', '' ], - [ 'impending_recur_msgnum', 'impending_recur_template', '', '' ], - [ 'payment_receipt_msgnum', 'payment_receipt_email', '', '' ], - [ 'welcome_msgnum', 'welcome_email', 'welcome_email-subject', 'welcome_email-from' ], - [ 'warning_msgnum', 'warning_email', 'warning_email-subject', 'warning_email-from' ], + [ 'alerter_msgnum', 'alerter_template', '', '', '' ], + [ 'cancel_msgnum', 'cancelmessage', 'cancelsubject', '', '' ], + [ 'decline_msgnum', 'declinetemplate', '', '', '' ], + [ 'impending_recur_msgnum', 'impending_recur_template', '', '', 'impending_recur_bcc' ], + [ 'payment_receipt_msgnum', 'payment_receipt_email', '', '', '' ], + [ 'welcome_msgnum', 'welcome_email', 'welcome_email-subject', 'welcome_email-from', '' ], + [ 'warning_msgnum', 'warning_email', 'warning_email-subject', 'warning_email-from', '' ], ); my $conf = new FS::Conf; my @agentnums = ('', map {$_->agentnum} qsearch('agent', {})); foreach my $agentnum (@agentnums) { foreach (@fixes) { - my ($newname, $oldname, $subject, $from) = @$_; + my ($newname, $oldname, $subject, $from, $bcc) = @$_; if ($conf->exists($oldname, $agentnum)) { my $new = new FS::msg_template({ 'msgname' => $oldname, 'agentnum' => $agentnum, 'from_addr' => ($from && $conf->config($from, $agentnum)) || $conf->config('invoice_from', $agentnum), + 'bcc_addr' => ($bcc && $conf->config($from, $agentnum)) || '', 'subject' => ($subject && $conf->config($subject, $agentnum)) || '', 'mime_type' => 'text/html', 'body' => join('
',$conf->config($oldname, $agentnum)),