This commit was manufactured by cvs2svn to create branch
[freeside.git] / FS / FS / msg_template.pm
index 4a1e345..65acd9a 100644 (file)
@@ -193,11 +193,6 @@ The I<from_addr> field in the template takes precedence over this.
 Destination address.  The default is to use the customer's 
 invoicing_list addresses.  Multiple addresses may be comma-separated.
 
-=item preview
-
-Set to true when preparing a message for previewing, rather than to actually 
-send it.  This turns off logging.
-
 =back
 
 =cut
@@ -254,7 +249,7 @@ sub prepare {
       } 
     } 
   } 
-  $_ = encode_entities($_) foreach values(%hash);
+  $_ = encode_entities($_ || '') foreach values(%hash);
 
 
   ###
@@ -318,16 +313,16 @@ sub prepare {
     $from_addr ||= scalar( $conf->config('invoice_from',
                                          $cust_main->agentnum) );
   }
-  my @cust_msg = ();
-  if ( $conf->exists('log_sent_mail') and !$opt{'preview'} ) {
-    my $cust_msg = FS::cust_msg->new({
-        'custnum' => $cust_main->custnum,
-        'msgnum'  => $self->msgnum,
-        'status'  => 'prepared',
-      });
-    $cust_msg->insert;
-    @cust_msg = ('cust_msg' => $cust_msg);
-  }
+#  my @cust_msg = ();
+#  if ( $conf->exists('log_sent_mail') and !$opt{'preview'} ) {
+#    my $cust_msg = FS::cust_msg->new({
+#        'custnum' => $cust_main->custnum,
+#        'msgnum'  => $self->msgnum,
+#        'status'  => 'prepared',
+#      });
+#    $cust_msg->insert;
+#    @cust_msg = ('cust_msg' => $cust_msg);
+#  }
 
   (
     'custnum' => $cust_main->custnum,
@@ -339,7 +334,6 @@ sub prepare {
     'html_body' => $body,
     'text_body' => HTML::FormatText->new(leftmargin => 0, rightmargin => 70
                     )->format( HTML::TreeBuilder->new_from_content($body) ),
-    @cust_msg,
   );
 
 }
@@ -392,12 +386,11 @@ 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) } ],
+      [ expdate           => sub { shift->paydate_epoch } ], #compatibility
+      [ signupdate_ymd    => sub { $ymd->(shift->signupdate) } ],
+      [ dundate_ymd       => sub { $ymd->(shift->dundate) } ],
       [ paydate_my        => sub { sprintf('%02d/%04d', shift->paydate_monthyear) } ],
       [ otaker_first      => sub { shift->access_user->first } ],
       [ otaker_last       => sub { shift->access_user->last } ],