RT# 80138 - Added config option to display/edit customer option to send or not send...
authorChristopher Burger <burgerc@freeside.biz>
Thu, 15 Nov 2018 16:37:27 +0000 (11:37 -0500)
committerChristopher Burger <burgerc@freeside.biz>
Thu, 15 Nov 2018 16:37:27 +0000 (11:37 -0500)
FS/FS/Conf.pm
FS/FS/Schema.pm
FS/FS/cust_pay.pm
httemplate/edit/cust_main/billing.html
httemplate/view/cust_main/billing.html

index d5b72fa..5a74451 100644 (file)
@@ -1694,6 +1694,15 @@ and customer address. Include units.',
   },
 
   {
+    'key'         => 'allow_payment_receipt_noemail',
+    'section'     => 'notification',
+    'description' => 'Add option on customer edit/view page to disable emailing of payment receipts.  If this option is set to NO it will override customer specific option, so when set to NO system will not check for payment_receipt_noemail option at customer level.',
+    'type'        => 'checkbox',
+    'per_agent'   => 1,
+    'agent_bool'  => 1,
+  },
+
+  {
     'key'         => 'payment_receipt',
     'section'     => 'notification',
     'description' => 'Send payment receipts.',
index 6ea0609..169d22a 100644 (file)
@@ -1695,6 +1695,7 @@ sub tables_hashref {
         'invoice_attn', 'varchar', 'NULL', $char_d, '', '',
         'invoice_ship_address', 'char', 'NULL', 1, '', '',
         'postal_invoice', 'char', 'NULL', 1, '', '',
+        'paymentreceipt_noemail', 'char', 'NULL', 1, '', '',
       ],
       'primary_key'  => 'custnum',
       'unique'       => [ [ 'agentnum', 'agent_custid' ] ],
index 4c82d10..915cb33 100644 (file)
@@ -241,6 +241,8 @@ sub insert {
   local $FS::UID::AutoCommit = 0;
   my $dbh = dbh;
 
+  my $conf = new FS::Conf;
+
   my $cust_bill;
   if ( $self->invnum ) {
     $cust_bill = qsearchs('cust_bill', { 'invnum' => $self->invnum } )
@@ -650,6 +652,8 @@ sub send_receipt {
 
   return '' unless $conf->config_bool('payment_receipt', $cust_main->agentnum);
 
+  return '' if ($conf->config_bool('allow_payment_receipt_noemail', $cust_main->agentnum) && $cust_main->paymentreceipt_noemail);
+
   my @invoicing_list = $cust_main->invoicing_list_emailonly;
   return '' unless @invoicing_list;
 
index fa7abd2..618e191 100644 (file)
       box_first   => 1,
     &>
 
+% if ( $conf->config_bool('allow_payment_receipt_noemail', $cust_main->agentnum) ) {
+    <& /elements/tr-checkbox.html,
+      field       => 'paymentreceipt_noemail',
+      label       => emt('Do not send email payment receipts'),
+      value       => 'Y',
+      curr_value  => $cust_main->paymentreceipt_noemail,
+      box_first   => 1,
+    &>
+% }
+
     <& /elements/tr-checkbox.html,
       field       => 'message_noemail',
       label       => emt('Do not send other email notices'),
index 5935da9..29ed2c7 100644 (file)
@@ -167,6 +167,12 @@ set_display_recurring(<% encode_json({'display_recurring' => [ $cust_main->displ
   <TD><% $cust_main->invoice_noemail ? $refused : $allowed %></TD>
 % }
 </TR>
+% if ( $conf->config_bool('allow_payment_receipt_noemail', $cust_main->agentnum) ) {
+<TR>
+  <TH ALIGN="right"><% mt('Email payment receipts') |h %></TH>
+  <TD><% $cust_main->paymentreceipt_noemail ? $refused : $allowed %></TD>
+</TR>
+% }
 <TR>
   <TH ALIGN="right"><% mt('Other email notices') |h %></TH>
   <TD>