From 5c68c43be829fd926ea148552c6bb87cdcafd7a1 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Fri, 23 Aug 2013 15:24:24 -0700 Subject: [PATCH] pass correct arguments to msg_template::prepare, #24659 --- FS/FS/Cron/alert_expiration.pm | 3 ++- FS/FS/Cron/notify.pm | 3 ++- FS/FS/msg_template.pm | 8 ++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/FS/FS/Cron/alert_expiration.pm b/FS/FS/Cron/alert_expiration.pm index eb53ea880..5961e6155 100644 --- a/FS/FS/Cron/alert_expiration.pm +++ b/FS/FS/Cron/alert_expiration.pm @@ -100,7 +100,8 @@ sub alert_expiration { if ( $msgnum ) { # new hotness my $msg_template = qsearchs('msg_template', { msgnum => $msgnum } ); $customer->setfield('expdate', $expire_time); - $error = $msg_template->send('cust_main' => $customer); + $error = $msg_template->send('cust_main' => $customer, + 'object' => $customer); } else { #!$msgnum, the hard way $mail_sender = $conf->config('invoice_from', $agentnum); diff --git a/FS/FS/Cron/notify.pm b/FS/FS/Cron/notify.pm index 9ad7a49ac..1859fcaf7 100644 --- a/FS/FS/Cron/notify.pm +++ b/FS/FS/Cron/notify.pm @@ -108,7 +108,8 @@ END my $msg_template = qsearchs('msg_template', { msgnum => $msgnum }); $cust_main->setfield('packages', \\@packages); $cust_main->setfield('recurdates', \\@recurdates); - $error = $msg_template->send('cust_main' => $cust_main); + $error = $msg_template->send('cust_main' => $cust_main, + 'object' => $cust_main); } else { $error = $cust_main->notify( 'impending_recur_template', diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm index 2f5e4762a..bef2b4b55 100644 --- a/FS/FS/msg_template.pm +++ b/FS/FS/msg_template.pm @@ -16,6 +16,7 @@ use Date::Format qw( time2str ); use HTML::Entities qw( decode_entities encode_entities ) ; use HTML::FormatText; use HTML::TreeBuilder; +use Encode; use File::Temp; use IPC::Run qw(run); @@ -410,6 +411,10 @@ sub prepare { # @cust_msg = ('cust_msg' => $cust_msg); # } + my $text_body = encode('UTF-8', + HTML::FormatText->new(leftmargin => 0, rightmargin => 70) + ->format( HTML::TreeBuilder->new_from_content($body) ) + ); ( 'custnum' => $cust_main->custnum, 'msgnum' => $self->msgnum, @@ -418,8 +423,7 @@ sub prepare { 'bcc' => $self->bcc_addr || undef, 'subject' => $subject, 'html_body' => $body, - 'text_body' => HTML::FormatText->new(leftmargin => 0, rightmargin => 70 - )->format( HTML::TreeBuilder->new_from_content($body) ), + 'text_body' => $text_body ); } -- 2.11.0