msg_template improvements, RT#8324
[freeside.git] / FS / FS / Cron / notify.pm
index 5b0e186..74840a6 100644 (file)
@@ -21,6 +21,8 @@ sub notify_flat_delay {
   
   #we're at now now (and later).
   my($time) = $^T;
+  my $conf = new FS::Conf;
+  my $error = '';
 
   my $integer = driver_name =~ /^mysql/ ? 'SIGNED' : 'INTEGER';
 
@@ -101,14 +103,20 @@ END
       push @cust_pkgs, $cust_pkg[0];
       shift @cust_pkg;
     }
-    my $error = 
-      $cust_main->notify( 'impending_recur_template',
+    my $msgnum = $conf->config('impending_recur_msgnum',$cust_main->agentnum);
+    if ( $msgnum ) {
+      my $msg_template = qsearchs('msg_template', { msgnum => $msgnum });
+      $error = $msg_template->send($cust_main);
+    }
+    else {
+      $error = $cust_main->notify( 'impending_recur_template',
                           'extra_fields' => { 'packages'   => \@packages,
                                               'recurdates' => \@recurdates,
                                               'package'    => $packages[0],
                                               'recurdate'  => $recurdates[0],
                                             },
                         );
+    } #if $msgnum
     warn "Error notifying, custnum ". $cust_main->custnum. ": $error" if $error;
 
     unless ($error) {