summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2016-03-31 16:51:19 -0700
committerMark Wells <mark@freeside.biz>2016-03-31 16:51:36 -0700
commit3a9052a3f2026b8ba2f94bf9f194a36c0a2b76e4 (patch)
treec884e572b636e558d056f95256ece72316f38203
parent900b2e6344ff3b0978542b967964ac7f2d4a54bd (diff)
fix invoice_email_pdf_msgnum template inclusion, #41502, from #21654
-rw-r--r--FS/FS/Template_Mixin.pm17
1 files changed, 13 insertions, 4 deletions
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') ) {