[freeside-commits] branch master updated. 5a204201503f8e0db6087db6e53b84297cbc739a

Ivan ivan at 420.am
Fri Aug 10 13:54:20 PDT 2012


The branch, master has been updated
       via  5a204201503f8e0db6087db6e53b84297cbc739a (commit)
      from  d32459cf059ff29a5ddc4b83ca2bf50a7828454b (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 5a204201503f8e0db6087db6e53b84297cbc739a
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Aug 10 13:54:14 2012 -0700

    add national id # handling for my, RT#18543

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 39b59cf..43d5611 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1985,6 +1985,14 @@ and customer address. Include units.',
   },
 
   {
+    'key'         => 'national_id-country',
+    'section'     => 'UI',
+    'description' => 'Track a national identification number, for specific countries.',
+    'type'        => 'select',
+    'select_enum' => [ '', 'MY' ],
+  },
+
+  {
     'key'         => 'show_bankstate',
     'section'     => 'UI',
     'description' => "Turns on display/collection of state for bank accounts in the web interface.  Sometimes required by electronic check (ACH) processors.",
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 72f8c30..6b32d71 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -980,6 +980,7 @@ sub tables_hashref {
         'ss',       'varchar', 'NULL', 11, '', '', 
         'stateid', 'varchar', 'NULL', $char_d, '', '', 
         'stateid_state', 'varchar', 'NULL', $char_d, '', '', 
+        'national_id', 'varchar', 'NULL', $char_d, '', '',
         'birthdate' , at date_type, '', '', 
         'spouse_birthdate' , at date_type, '', '', 
         'anniversary_date' , at date_type, '', '', 
diff --git a/httemplate/edit/cust_main/birthdate.html b/httemplate/edit/cust_main/birthdate.html
index 5447a3a..5af819b 100644
--- a/httemplate/edit/cust_main/birthdate.html
+++ b/httemplate/edit/cust_main/birthdate.html
@@ -2,6 +2,37 @@
 
 % # maybe put after the contact names?
 
+% my $id_country = $conf->config('national_id-country');
+%  if ( $id_country ) {
+%   if ( $id_country eq 'MY' ) {
+%     my($old, $nric) = ( '', '');
+%     if ( $cust_main->national_id =~ /^\w\d{9}$/ ) {
+%       $old = $cust_main->national_id;
+%     } elsif ( $cust_main->national_id =~ /^\d{6}\-\d{2}\-\d{4}$/ ) {
+%       $nric = $cust_main->national_id;
+%     } else {
+%       warn "unknown national_id format";
+        <INPUT TYPE="hidden" NAME="national_id0" VALUE="<% $cust_main->national_id |h %>">
+%     }
+
+      <% include( '/elements/tr-input-text.html',
+                    'field' => 'national_id1',
+                    'value' => $nric,
+                    'label' => 'NRIC',
+                )
+      %>
+      <% include( '/elements/tr-input-text.html',
+                    'field' => 'national_id2',
+                    'value' => $old,
+                    'label' => 'Old IC/Passport',
+                )
+      %>
+
+%   } else {
+%     warn "unknown national_id-country $id_country";
+%   }
+% }
+
 % if ( $conf->exists('cust_main-enable_birthdate') ) {
   <% include( '/elements/tr-input-date-field.html', {
                 'name'        => 'birthdate',
diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi
index 866452d..622dd87 100755
--- a/httemplate/edit/process/cust_main.cgi
+++ b/httemplate/edit/process/cust_main.cgi
@@ -110,6 +110,36 @@ if ( $cgi->param('no_credit_limit') ) {
 
 $new->tagnum( [ $cgi->param('tagnum') ] );
 
+if ( my $id_country = $conf->config('national_id-country') ) {
+  if ( $id_country eq 'MY' ) {
+
+    if ( $cgi->param('national_id1') =~ /\S/ ) {
+      my $nric = $cgi->param('national_id1');
+      $nric =~ s/\s//g;
+      if ( $nric =~ /^(\d{6})\-?(\d{2})\-?(\d{4})$/ ) {
+        $new->national_id( "$1-$2-$3" );
+      } else {
+        $error ||= "Illegal NRIC: ". $cgi->param('national_id1');
+      }
+    } elsif ( $cgi->param('national_id2') =~ /\S/ ) {
+      my $oldic = $cgi->param('national_id2');
+      $oldic =~ s/\s//g;
+      if ( $oldic =~ /^\w\d{9}$/ ) {
+        $new->national_id($oldic);
+      } else {
+        $error ||= "Illegal Old IC/Passport: ". $cgi->param('national_id2');
+      }
+    } else {
+      $error ||= 'Either NRIC or Old IC/Passport is required';
+    }
+    
+  } else {
+    warn "unknown national_id-country $id_country";
+  }
+} elsif ( $cgi->param('national_id0') ) {
+  $new->national_id( $cgi->param('national_id0') );
+}
+
 my %usedatetime = ( 'birthdate'        => 1,
                     'spouse_birthdate' => 1,
                     'anniversary_date' => 1,
diff --git a/httemplate/view/cust_main/misc.html b/httemplate/view/cust_main/misc.html
index dc6da53..9713b24 100644
--- a/httemplate/view/cust_main/misc.html
+++ b/httemplate/view/cust_main/misc.html
@@ -102,6 +102,26 @@
     <TD BGCOLOR="#ffffff"><% $cust_main->signupdate ? time2str($date_format, $cust_main->signupdate) : '' %></TD>
   </TR>
 
+% my $id_country = $conf->config('national_id-country');
+%  if ( $id_country ) {
+%   if ( $id_country eq 'MY' ) {
+      <TR>
+%     my($old, $nric) = ( '', '');
+%     if ( $cust_main->national_id =~ /^\w\d{9}$/ ) {
+          <TD ALIGN="right"><% mt('Old IC/Passport') |h %></TD>
+%     } elsif ( $cust_main->national_id =~ /^\d{6}\-\d{2}\-\d{4}$/ ) {
+          <TD ALIGN="right"><% mt('NRIC') |h %></TD>
+%     } else {
+%       warn "unknown national_id format";
+          <TD ALIGN="right"></TD>
+%     }
+        <TD BGCOLOR="#ffffff"><% $cust_main->national_id |h %></TD>
+      </TR>
+%   } else {
+%     warn "unknown national_id-country $id_country";
+%   }
+% }
+
 % if ( $conf->exists('cust_main-enable_birthdate') ) {
 %   my $dt = $cust_main->birthdate ne ''
 %              ? DateTime->from_epoch( 'epoch'     => $cust_main->birthdate,

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

Summary of changes:
 FS/FS/Conf.pm                            |    8 +++++++
 FS/FS/Schema.pm                          |    1 +
 httemplate/edit/cust_main/birthdate.html |   31 ++++++++++++++++++++++++++++++
 httemplate/edit/process/cust_main.cgi    |   30 +++++++++++++++++++++++++++++
 httemplate/view/cust_main/misc.html      |   20 +++++++++++++++++++
 5 files changed, 90 insertions(+), 0 deletions(-)




More information about the freeside-commits mailing list