RT# 73421 Add allow messages flag message_dest to contact_email
authorMitch Jackson <mitch@freeside.biz>
Sun, 28 Jan 2018 03:21:59 +0000 (21:21 -0600)
committerMitch Jackson <mitch@freeside.biz>
Sun, 28 Jan 2018 03:21:59 +0000 (21:21 -0600)
FS/FS/Schema.pm
FS/FS/contact.pm
FS/FS/cust_contact.pm
httemplate/edit/process/cust_main-contacts.html
httemplate/elements/contact.html
httemplate/view/cust_main/contacts_new.html

index f7ac973..65eadad 100644 (file)
@@ -1793,7 +1793,8 @@ sub tables_hashref {
         'classnum',              'int', 'NULL',  '', '', '',
         'comment',           'varchar', 'NULL', 255, '', '',
         'selfservice_access',   'char', 'NULL',   1, '', '',
-        'invoice_dest',         'char', 'NULL',       1, '', '',
+        'invoice_dest',         'char', 'NULL',   1, '', '', # Y or NULL
+        'message_dest',         'char', 'NULL',   1, '', '', # Y or NULL
       ],
       'primary_key'  => 'custcontactnum',
       'unique'       => [ [ 'custnum', 'contactnum' ], ],
index 44c5388..fa047f5 100644 (file)
@@ -155,7 +155,7 @@ sub insert {
   $self->custnum('');
 
   my %link_hash = ();
-  for (qw( classnum comment selfservice_access invoice_dest )) {
+  for (qw( classnum comment selfservice_access invoice_dest message_dest)) {
     $link_hash{$_} = $self->get($_);
     $self->$_('');
   }
@@ -430,7 +430,7 @@ sub replace {
   $self->custnum('');
 
   my %link_hash = ();
-  for (qw( classnum comment selfservice_access invoice_dest )) {
+  for (qw( classnum comment selfservice_access invoice_dest message_dest )) {
     $link_hash{$_} = $self->get($_);
     $self->$_('');
   }
@@ -955,7 +955,7 @@ sub cgi_contact_fields {
 
   my @contact_fields = qw(
     classnum first last title comment emailaddress selfservice_access
-    invoice_dest password
+    invoice_dest message_dest password
   );
 
   push @contact_fields, 'phonetypenum'. $_->phonetypenum
@@ -1028,4 +1028,3 @@ L<FS::Record>, schema.html from the base documentation.
 =cut
 
 1;
-
index 118a9e0..adad46e 100644 (file)
@@ -59,6 +59,11 @@ empty or Y
 
 'Y' if the customer should get invoices sent to this address, null if not
 
+=item message_dest
+
+'Y' if contact should get non-invoice email messages sent to this address,
+NULL if not
+
 =back
 
 =head1 METHODS
@@ -119,6 +124,7 @@ sub check {
     || $self->ut_textn('comment')
     || $self->ut_enum('selfservice_access', [ '', 'Y' ])
     || $self->ut_flag('invoice_dest')
+    || $self->ut_flag('message_dest')
   ;
   return $error if $error;
 
@@ -148,4 +154,3 @@ L<FS::contact>, L<FS::cust_main>, L<FS::Record>
 =cut
 
 1;
-
index 2a7185b..5b8319f 100644 (file)
@@ -1,3 +1,11 @@
+<%doc>
+
+  This form works indirectly with the tables contact_email and
+  contact_phone.  The columns are updated against an FS::contact
+  object.  The insert/update methods of FS::contact will make the
+  necessary inserts/updates to contact_email and contact_phone.
+
+</%doc>
 <% include('elements/process.html',
      'table'          => 'cust_main',
      'error_redirect' => popurl(3). 'edit/cust_main-contacts.html?',
index faee7ea..43e5201 100644 (file)
@@ -42,7 +42,8 @@
 %         $value = join(', ', map $_->emailaddress, $contact->contact_email);
 %       } elsif ( $field eq 'selfservice_access'
 %              or $field eq 'comment'
-%              or $field eq 'invoice_dest' ) {
+%              or $field eq 'invoice_dest'
+%              or $field eq 'message_dest' ) {
 %         $value = $X_contact->get($field);
 %       } else {
 %         $value = $contact->get($field);
@@ -78,7 +79,7 @@
                       return false
                     }
             </SCRIPT>
-%         } elsif ( $field eq 'invoice_dest' ) {
+%         } elsif ( $field eq 'invoice_dest' || $field eq 'message_dest' ) {
 %           my $curr_value = $cgi->param($name . '_' . $field);
 %           $curr_value = $value if !defined($curr_value);
             <& select.html,
@@ -168,6 +169,7 @@ tie my %label, 'Tie::IxHash',
 
 unless ($opt{'for_prospect'}) {
   $label{'invoice_dest'} = 'Send&nbsp;invoices';
+  $label{'message_dest'} = 'Send&nbsp;messages';
   $label{'selfservice_access'} = 'Self-service';
 }
 
index 9448867..a28b449 100644 (file)
@@ -11,6 +11,7 @@
   <%$th%>Email</TH>
   <%$th%>Send invoices</TH>
   <%$th%>Self-service</TH>
+  <%$th%>Send messages</TH>
 % foreach my $phone_type (@phone_type) {
     <%$th%><% $phone_type->typename |h %></TH>
 % }
@@ -32,6 +33,7 @@
 %       my @contact_email = $contact->contact_email;
         <%$td%><% join(', ', map $_->emailaddress, @contact_email) %></TD>
         <%$td%><% $cust_contact->invoice_dest eq 'Y' ? 'Yes' : 'No' %></TD>
+        <%$td%><% $cust_contact->message_dest eq 'Y' ? 'Yes' : 'No' %></TD>
         <%$td%>
 %         if ( $cust_contact->selfservice_access ) {
             Enabled