[freeside-commits] branch master updated. 1e64160a779e96d84c5db648622dee4f88f34215

Jonathan Prykop jonathan at 420.am
Fri Jul 17 01:52:31 PDT 2015


The branch, master has been updated
       via  1e64160a779e96d84c5db648622dee4f88f34215 (commit)
      from  75158a0c8516d4344b9c3796de33710480961b21 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1e64160a779e96d84c5db648622dee4f88f34215
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Fri Jul 17 03:50:54 2015 -0500

    RT#37165: Print document when account is created

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 1d4a85a..90b5d29 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -2564,11 +2564,17 @@ and customer address. Include units.',
     'description' => 'Template to use for welcome messages when a svc_acct record is created.',
     %msg_template_options,
   },
-  
+
+  { 'key'         => 'svc_acct_welcome_letter',
+    'section'     => 'notification',
+    'description' => 'Optional LaTex template for a printed welcome letter when a svc_acct record is created.  Fields from the customer and svc_acct records are available for substitution.',
+    'type'        => 'textarea',
+  },
+
   {
     'key'         => 'svc_acct_welcome_exclude',
     'section'     => 'notification',
-    'description' => 'A list of svc_acct services for which no welcome email is to be sent.',
+    'description' => 'A list of svc_acct services for which no welcome email or letter is to be sent.',
     'type'        => 'select-part_svc',
     'multiple'    => 1,
   },
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index 0181b1e..a76d93d 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -57,6 +57,7 @@ use FS::svc_forward;
 use FS::svc_www;
 use FS::cdr;
 use FS::tower_sector;
+use FS::Misc;
 
 $DEBUG = 0;
 $me = '[FS::svc_acct]';
@@ -728,9 +729,11 @@ sub insert {
       $cust_main->invoicing_list(\@invoicing_list);
     }
 
-    #welcome email
+    #welcome email/letter
     my @welcome_exclude_svcparts = $conf->config('svc_acct_welcome_exclude');
     unless ( grep { $_ eq $self->svcpart } @welcome_exclude_svcparts ) {
+      #indent skips a level for some reason
+        #welcome email
         my $error = '';
         my $msgnum = $conf->config('welcome_msgnum', $agentnum);
         if ( $msgnum ) {
@@ -814,7 +817,21 @@ sub insert {
 
           } # if $welcome_template
         } # if !$msgnum
-    }
+        # print welcome letter
+        if ($conf->exists('svc_acct_welcome_letter')) {
+          my $queue = new FS::queue {
+            'job'     => 'FS::svc_acct::process_print_welcome_letter',
+          };
+          $error = $queue->insert(
+            'svcnum'  => $self->svcnum,
+            'template' => 'svc_acct_welcome_letter',
+          );
+          if ($error) {
+            warn "can't send welcome letter: $error";
+          }
+        }
+      #indent skipped a level for some reason
+    } # unless in @welcome_exclude_svcparts
   } # if $cust_pkg
 
   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
@@ -3019,6 +3036,26 @@ sub reached_threshold {
   }
 }
 
+sub process_print_welcome_letter {
+  my %opt = @_;
+
+  my $self = qsearchs('svc_acct', { 'svcnum' => $opt{'svcnum'} } )
+    or die "invalid svc_acct: " . $opt{'svcnum'};
+  my $cust_main = $self->cust_svc->cust_pkg->cust_main;
+
+  my $ps = $cust_main->print_ps('svc_acct_welcome_letter',
+    'extra_fields' => {
+      map { $_ => $self->$_ } $self->fields, # or maybe just username & password?
+    },
+  );
+  my $error = FS::Misc::do_print(
+    [ $ps ],
+    'agentnum' => $cust_main->agentnum,
+  );
+  die $error if $error;
+
+}
+
 =back
 
 =head1 BUGS

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm     |   10 ++++++++--
 FS/FS/svc_acct.pm |   41 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 47 insertions(+), 4 deletions(-)




More information about the freeside-commits mailing list