per-agent notification options, RT#10797
authormark <mark>
Tue, 7 Dec 2010 22:26:17 +0000 (22:26 +0000)
committermark <mark>
Tue, 7 Dec 2010 22:26:17 +0000 (22:26 +0000)
FS/FS/Conf.pm
FS/FS/cust_main/Billing_Realtime.pm
FS/FS/cust_pay.pm
FS/FS/cust_pkg.pm

index f5b2451..bcebdf6 100644 (file)
@@ -568,16 +568,20 @@ logo.eps
 
 my %msg_template_options = (
   'type'        => 'select-sub',
-  'options_sub' => sub { require FS::Record;
-                         require FS::agent;
-                         require FS::msg_template;
-                         map { $_->msgnum, $_->msgname } 
-                            qsearch('msg_template', { disabled => '' });
-                       },
-  'option_sub'  => sub { require FS::msg_template;
+  'options_sub' => sub { 
+    my @templates = qsearch({
+        'table' => 'msg_template', 
+        'hashref' => { 'disabled' => '' },
+        'extra_sql' => ' AND '. 
+          $FS::CurrentUser::CurrentUser->agentnums_sql(null => 1),
+        });
+    map { $_->msgnum, $_->msgname } @templates;
+  },
+  'option_sub'  => sub { 
                          my $msg_template = FS::msg_template->by_key(shift);
                          $msg_template ? $msg_template->msgname : ''
                        },
+  'per_agent' => 1,
 );
 
 
@@ -1246,6 +1250,7 @@ and customer address. Include units.',
     'section'     => 'notification',
     'description' => 'Send payment receipts.',
     'type'        => 'checkbox',
+    'per_agent'   => 1,
   },
 
   {
@@ -1271,6 +1276,7 @@ and customer address. Include units.',
                        'cust_pay'          => 'When payment is made.',
                        'cust_bill_pay_pkg' => 'When payment is applied.',
                      ],
+    'per_agent'   => 1,
   },
 
   {
@@ -1874,6 +1880,7 @@ and customer address. Include units.',
     'section'     => 'notification',
     'description' => 'Enable emailing of credit card and electronic check decline notices.',
     'type'        => 'checkbox',
+    'per_agent'   => 1,
   },
 
   {
@@ -1881,6 +1888,7 @@ and customer address. Include units.',
     'section'     => 'notification',
     'description' => 'List of error messages that should not trigger email decline notices, one per line.',
     'type'        => 'textarea',
+    'per_agent'   => 1,
   },
 
   {
@@ -1909,6 +1917,7 @@ and customer address. Include units.',
     'section'     => 'notification',
     'description' => 'Enable emailing of cancellation notices.  Make sure to select the template in the cancel_msgnum option.',
     'type'        => 'checkbox',
+    'per_agent'   => 1,
   },
 
   {
@@ -2930,6 +2939,13 @@ and customer address. Include units.',
     'type'        => 'textarea',
   },
 
+#  {
+#    'key'         => 'batch-manual_approval',
+#    'section'     => 'billing',
+#    'description' => 'Allow manual batch closure, which will approve all payments that do not yet have a status.  This is dangerous, but may be needed if your processor does not provide a list of approved payments.',
+#    'type'        => 'checkbox',
+#  },
+#
   {
     'key'         => 'payment_history-years',
     'section'     => 'UI',
index 2124075..ba1e9c8 100644 (file)
@@ -902,10 +902,10 @@ sub _realtime_bop_result {
     }
 
     if ( !$options{'quiet'} && !$realtime_bop_decline_quiet
-         && $conf->exists('emaildecline')
+         && $conf->exists('emaildecline', $self->agentnum)
          && grep { $_ ne 'POST' } $self->invoicing_list
          && ! grep { $transaction->error_message =~ /$_/ }
-                   $conf->config('emaildecline-exclude')
+                   $conf->config('emaildecline-exclude', $self->agentnum)
     ) {
 
       # Send a decline alert to the customer.
index 014affe..71bc707 100644 (file)
@@ -297,7 +297,8 @@ sub insert {
   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
 
   #payment receipt
-  my $trigger = $conf->config('payment_receipt-trigger') || 'cust_pay';
+  my $trigger = $conf->config('payment_receipt-trigger', 
+                              $self->cust_main->agentnum) || 'cust_pay';
   if ( $trigger eq 'cust_pay' ) {
     my $error = $self->send_receipt(
       'manual'    => $options{'manual'},
@@ -533,7 +534,7 @@ sub send_receipt {
 
   my $conf = new FS::Conf;
 
-  return '' unless $conf->exists('payment_receipt');
+  return '' unless $conf->exists('payment_receipt', $cust_main->agentnum);
 
   my @invoicing_list = $cust_main->invoicing_list_emailonly;
   return '' unless @invoicing_list;
@@ -547,13 +548,9 @@ sub send_receipt {
        || ! $cust_bill
      )
   {
-
-    if ( $conf->exists('payment_receipt_msgnum')
-         && $conf->config('payment_receipt_msgnum')
-       )
-    {
-      my $msg_template = 
-          FS::msg_template->by_key($conf->config('payment_receipt_msgnum'));
+    my $msgnum = $conf->config('payment_receipt_msgnum', $cust_main->agentnum);
+    if ( $msgnum ) {
+      my $msg_template = FS::msg_template->by_key($msgnum);
       $error = $msg_template->send('cust_main'=> $cust_main, 'object'=> $self);
 
     } elsif ( $conf->exists('payment_receipt_email') ) {
index 66d8bae..a946de4 100644 (file)
@@ -707,7 +707,9 @@ sub cancel {
   return '' if $date; #no errors
 
   my @invoicing_list = grep { $_ !~ /^(POST|FAX)$/ } $self->cust_main->invoicing_list;
-  if ( !$options{'quiet'} && $conf->exists('emailcancel') && @invoicing_list ) {
+  if ( !$options{'quiet'} && 
+        $conf->exists('emailcancel', $self->cust_main->agentnum) && 
+        @invoicing_list ) {
     my $msgnum = $conf->config('cancel_msgnum', $self->cust_main->agentnum);
     my $error = '';
     if ( $msgnum ) {