add skip_dcontext_suffix to skip CDRs with dcontext ending in a definable string...
[freeside.git] / FS / FS / Template_Mixin.pm
index 6974f7d..5153f87 100644 (file)
@@ -147,6 +147,10 @@ sub print_latex {
   $template ||= $self->_agent_template
     if $self->can('_agent_template');
 
+  #the new way
+  $self->set('mode', $params{mode})
+    if $params{mode};
+
   my $pkey = $self->primary_key;
   my $tmp_template = $self->table. '.'. $self->$pkey. '.XXXXXXXX';
 
@@ -2116,13 +2120,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') ) {
 
@@ -2366,6 +2379,7 @@ service.
 =cut
 
 use CAM::PDF;
+use IO::Socket::SSL;
 use LWP::UserAgent;
 use HTTP::Request::Common qw( POST );
 use Cpanel::JSON::XS;
@@ -2406,7 +2420,12 @@ sub postal_mail_fsinc {
   my $file = $self->print_pdf(%opt, 'no_addresses' => 1);
   my $pages = CAM::PDF->new($file)->numPages;
 
-  my $ua = LWP::UserAgent->new( 'ssl_opts' => { 'verify_hostname'=>0 });
+  my $ua = LWP::UserAgent->new(
+    'ssl_opts' => { 
+      verify_hostname => 0,
+      SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE,
+    }
+  );
   my $response = $ua->request( POST $url, [
     'support-key'      => scalar($conf->config('support-key')),
     'file'             => encode_base64($file),