add spouse name to customer records, #24919
authorMark Wells <mark@freeside.biz>
Fri, 14 Mar 2014 23:59:38 +0000 (16:59 -0700)
committerMark Wells <mark@freeside.biz>
Fri, 14 Mar 2014 23:59:38 +0000 (16:59 -0700)
FS/FS/Conf.pm
FS/FS/Schema.pm
FS/FS/Upgrade.pm
FS/FS/cust_main.pm
httemplate/edit/cust_main.cgi
httemplate/edit/cust_main/birthdate.html
httemplate/edit/cust_main/name.html
httemplate/edit/cust_main/top_misc.html
httemplate/elements/freeside.css
httemplate/view/cust_main/contacts.html
httemplate/view/cust_main/misc.html

index 34254c6..13d0704 100644 (file)
@@ -3854,9 +3854,9 @@ and customer address. Include units.',
   },
 
   {
-    'key'         => 'cust_main-enable_spouse_birthdate',
+    'key'         => 'cust_main-enable_spouse',
     'section'     => 'UI',
-    'description' => 'Enable tracking of a spouse birth date with each customer record',
+    'description' => 'Enable tracking of a spouse\'s name and date of birth with each customer record',
     'type'        => 'checkbox',
   },
 
index bf756d1..4f54772 100644 (file)
@@ -466,7 +466,7 @@ sub tables_hashref {
   my $char_d = 80; #default maxlength for text fields
 
   #my(@date_type)  = ( 'timestamp', '', ''     );
-  my @date_type  = ( 'int', 'NULL', ''     );
+  my @date_type = ( 'int', 'NULL', ''     );
   my @perl_type = ( 'text', 'NULL', ''  ); 
   my @money_type = ( 'decimal',   '', '10,2' );
   my @money_typen = ( 'decimal',   'NULL', '10,2' );
@@ -1521,8 +1521,10 @@ sub tables_hashref {
         'stateid_state', 'varchar', 'NULL', $char_d, '', '', 
         'national_id', 'varchar', 'NULL', $char_d, '', '',
         'birthdate' ,@date_type, '', '', 
-        'spouse_birthdate' ,@date_type, '', '', 
-        'anniversary_date' ,@date_type, '', '', 
+        'spouse_last',  'varchar', 'NULL', 2*$char_d, '', '',
+        'spouse_first', 'varchar', 'NULL', $char_d, '', '',
+        'spouse_birthdate', @date_type, '', '', 
+        'anniversary_date', @date_type, '', '', 
         'signupdate',@date_type, '', '', 
         'dundate',   @date_type, '', '', 
         'company',  'varchar', 'NULL', $char_d, '', '', 
index a7fe99f..bf3e2ad 100644 (file)
@@ -91,6 +91,11 @@ sub upgrade_config {
     && length($conf->config('usps_webtools-userid')) > 0
     && ! $conf->exists('address_standardize_method');
 
+  # this option has been renamed/expanded
+  if ( $conf->exists('cust_main-enable_spouse_birthdate') ) {
+    $conf->touch('cust_main-enable_spouse');
+    $conf->delete('cust_main-enable_spouse_birthdate');
+  }
 }
 
 sub upgrade_overlimit_groups {
index b37b0da..9f382ac 100644 (file)
@@ -1744,6 +1744,8 @@ sub check {
     || $self->ut_name('first')
     || $self->ut_snumbern('signupdate')
     || $self->ut_snumbern('birthdate')
+    || $self->ut_namen('spouse_last')
+    || $self->ut_namen('spouse_first')
     || $self->ut_snumbern('spouse_birthdate')
     || $self->ut_snumbern('anniversary_date')
     || $self->ut_textn('company')
index 629c808..ddb61fa 100755 (executable)
@@ -30,7 +30,6 @@
 %# birthdate
 % if (    $conf->config('national_id-country')
 %      || $conf->exists('cust_main-enable_birthdate')
-%      || $conf->exists('cust_main-enable_spouse_birthdate')
 %      || $conf->exists('cust_main-enable_anniversary_date')
 %    )
 % {
index e1adbd3..ecf591f 100644 (file)
 % }
 
 % if ( $conf->exists('cust_main-enable_birthdate') ) {
-  <% include( '/elements/tr-input-date-field.html', {
-                'name'        => 'birthdate',
-                'value'       => $cust_main->birthdate,
-                'label'       => 'Date of Birth',
-                'format'      => ( $conf->config('date_format') || "%m/%d/%Y" ),
-                'usedatetime' => 1,
-                'noinit'      => $noinit++,
-            })
-  %>
-% }
+  <& /elements/tr-input-date-field.html, {
+        'name'        => 'birthdate',
+        'value'       => $cust_main->birthdate,
+        'label'       => 'Date of Birth',
+        'format'      => ( $conf->config('date_format') || "%m/%d/%Y" ),
+        'usedatetime' => 1,
+        'noinit'      => $noinit++,
+     }
+  &>
 
-% if ( $conf->exists('cust_main-enable_spouse_birthdate') ) {
-  <% include( '/elements/tr-input-date-field.html', {
-                'name'        => 'spouse_birthdate',
-                'value'       => $cust_main->spouse_birthdate,
-                'label'       => 'Spouse Date of Birth',
-                'format'      => ( $conf->config('date_format') || "%m/%d/%Y" ),
-                'usedatetime' => 1,
-                'noinit'      => $noinit++,
-            })
-  %>
-% }
+%   if ( $conf->exists('cust_main-enable_spouse') ) {
+  <& /elements/tr-input-date-field.html, {
+        'name'        => 'spouse_birthdate',
+        'value'       => $cust_main->spouse_birthdate,
+        'label'       => 'Spouse Date of Birth',
+        'format'      => ( $conf->config('date_format') || "%m/%d/%Y" ),
+        'usedatetime' => 1,
+        'noinit'      => $noinit++,
+      }
+  &>
+%   } # if enable_spouse
+% } # if enable_birthdate 
 
 % if ( $conf->exists('cust_main-enable_anniversary_date') ) {
   <% include( '/elements/tr-input-date-field.html', {
index 2641ec9..fbb0a91 100644 (file)
@@ -1,36 +1,40 @@
 <%def .namepart>
 % my ($field, $value, $label, $extra) = @_;
-<TD>
+<DIV STYLE="display: inline-block">
   <INPUT TYPE="text" NAME="<% $field %>" VALUE="<% $value |h %>" <%$extra%>>
   <BR><FONT SIZE=-1><% mt($label) %></FONT>
-</TD>
+</DIV>
 </%def>
 
 <TR>
-  <TH VALIGN="top" ALIGN="right"><%$r%><% mt('Contact name') |h %></TH>
-  <TD COLSPAN=6>
-    <TABLE CELLSPACING=0 CELLPADDING=0>
-      <TR>
-        <& .namepart, 'last', $cust_main->last, 'Last' &>
-        <TD VALIGN="top"> , </TD>
+  <TD CLASS="required label"><% mt('Contact name') |h %></TD>
+  <TD COLSPAN=6 STYLE="vertical-align:top">
+        <& .namepart, 'last', $cust_main->last, 'Last', ',' &>
         <& .namepart, 'first', $cust_main->first, 'First' &>
 % if ( $conf->exists('show_ss') ) {
-        <TD>&nbsp;</TD>
+        &nbsp;
         <& .namepart, 'ss', $ss, 'SS#', "SIZE=11" &>
 % } else  {
         <INPUT TYPE="hidden" NAME="ss" VALUE="<% $ss %>">
 % }
-      </TR>
-    </TABLE>
   </TD>
 </TR>
+% if ( $conf->exists('cust_main-enable_spouse') ) {
+<TR ID="spouse_row">
+  <TD CLASS="label"><% mt('Spouse\'s name') |h %></TD>
+  <TD COLSPAN=6>
+        <& .namepart, 'spouse_last', $cust_main->spouse_last, 'Last', ',' &>
+        <& .namepart, 'spouse_first', $cust_main->spouse_first, 'First' &>
+  </TD>
+</TR>
+% }
 
 % if ( $conf->exists('cust-email-high-visibility') ) {
 <TR>
-  <TD ALIGN="right">
+  <TD ALIGN="right" CLASS="
     <% $conf->exists('cust_main-require_invoicing_list_email', $agentnum)
-        ? $r
-        : '' %>Email address(es)
+        ? 'required label'
+        : 'label' %>">Email address(es)
   </TD>
   <TD BGCOLOR="#FFFF00">
     <INPUT TYPE="text" NAME="invoicing_list" 
@@ -42,7 +46,6 @@
 my $cust_main = shift;
 my $agentnum = $cust_main->agentnum if $cust_main->custnum;
 my $conf = FS::Conf->new;
-my $r = '<font color="#ff0000">*</font>&nbsp;';
 my $ss;
 
 if ( $cgi->param('error') or $conf->exists('unmask_ss') ) {
index e25506f..f3fde53 100644 (file)
     if ( what.checked == (what.value == 'Commercial' ) ) {
       document.getElementById('company_row').style.display = '';
       document.getElementById('contacts_div').style.display = '';
+      document.getElementById('spouse_row').style.display = 'none';
     } else {
       if ( document.getElementById('company').value.length == 0 ) {
         document.getElementById('company_row').style.display = 'none';
       }
       document.getElementById('contacts_div').style.display = 'none';
+      document.getElementById('spouse_row').style.display = '';
     }
   }
 
index 3933e9d..4ba0f3f 100644 (file)
@@ -282,3 +282,17 @@ table.inv { border: none }
 th.inv { border: none }
 td.inv { border: none }
 
+td.label {
+  text-align: right;
+}
+
+.required {
+  font-weight: bold;
+}
+
+.required::before {
+  content: "* ";
+  color: #ff0000;
+}
+
+
index 4444535..739cd58 100644 (file)
                               : $cust_main->masked('ss') || '&nbsp;' %></TD>
 %   }
   </TR>
+%   if ( $conf->exists('cust_main-enable_spouse') and
+%        ($cust_main->spouse_last or $cust_main->spouse_first) ) {
+  <TR>
+    <TD ALIGN="right"><% mt('Spouse') |h %></TD>
+    <TD COLSPAN=5 BGCOLOR="#ffffff">
+      <% join(', ', grep $_, 
+                    $cust_main->spouse_last, $cust_main->spouse_first) %>
+    </TD>
+  </TR>
+% }
 %   if ( $conf->exists('cust-email-high-visibility') ) {
   <TR>
     <TD ALIGN="right"><% mt('Email address(es)') |h %></TD>
index 7915195..0d011f6 100644 (file)
     <TD BGCOLOR="#ffffff"><% $dt ? $dt->strftime($date_format) : '' %></TD>
   </TR>
 
-% }
-
-% if ( $conf->exists('cust_main-enable_spouse_birthdate') ) {
-%   my $dt = $cust_main->spouse_birthdate ne ''
-%              ? DateTime->from_epoch( 'epoch'  => $cust_main->spouse_birthdate,
-%                                      'time_zone' =>'floating',
-%                                    )
-%              : '';
+%   if ( $conf->exists('cust_main-enable_spouse') 
+%        and $cust_main->spouse_birthdate ) {
+%     my $dt = DateTime->from_epoch(
+%                   'epoch'  => $cust_main->spouse_birthdate,
+%                   'time_zone' =>'floating'
+%              );
 
   <TR>
     <TD ALIGN="right"><% mt('Spouse Date of Birth') |h %></TD>
     <TD BGCOLOR="#ffffff"><% $dt ? $dt->strftime($date_format) : '' %></TD>
   </TR>
 
-% }
+%   }
+% } # enable_birthdate
 
 % if ( $conf->exists('cust_main-enable_anniversary_date') ) {
 %   my $dt = $cust_main->anniversary_date ne ''