From: Mark Wells Date: Thu, 31 Mar 2016 23:51:19 +0000 (-0700) Subject: fix invoice_email_pdf_msgnum template inclusion, #41502, from #21654 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=3a9052a3f2026b8ba2f94bf9f194a36c0a2b76e4 fix invoice_email_pdf_msgnum template inclusion, #41502, from #21654 --- diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index 6974f7da3..a82d51deb 100644 --- a/FS/FS/Template_Mixin.pm +++ b/FS/FS/Template_Mixin.pm @@ -2116,13 +2116,22 @@ sub generate_email { my $msg_template = FS::msg_template->by_key($msgnum) or die "${tc}email_pdf_msgnum $msgnum not found\n"; - my %prepared = $msg_template->prepare( + my $cust_msg = $msg_template->prepare( cust_main => $self->cust_main, - object => $self + object => $self, + msgtype => 'invoice', ); - @text = split(/(?=\n)/, $prepared{'text_body'}); - $html = $prepared{'html_body'}; + # XXX hack to make this work in the new cust_msg era; consider replacing + # with cust_bill_send_with_notice events. + my @parts = $cust_msg->parts; + foreach my $part (@parts) { # will only have two parts, normally + if ( $part->mime_type eq 'text/plain' ) { + @text = @{ $part->body }; + } elsif ( $part->mime_type eq 'text/html' ) { + $html = $part->bodyhandle->as_string; + } + } } elsif ( my @note = $conf->config($tc.'email_pdf_note') ) {