[freeside-commits] branch FREESIDE_2_3_BRANCH updated. a0d3f49b5c81e5dfd248000151f9ec5afd88f184

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


The branch, FREESIDE_2_3_BRANCH has been updated
       via  a0d3f49b5c81e5dfd248000151f9ec5afd88f184 (commit)
      from  0458f51a9f71d4c782effb86d6ad3c0d5a26b59f (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 a0d3f49b5c81e5dfd248000151f9ec5afd88f184
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Aug 10 13:54:29 2012 -0700

    add national id # handling for my, RT#18543

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 6efefce..e441a74 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1924,6 +1924,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 2f60462..09a87f9 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -844,6 +844,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 5ea8e18..e856e13 100644
--- a/httemplate/edit/cust_main/birthdate.html
+++ b/httemplate/edit/cust_main/birthdate.html
@@ -1,4 +1,36 @@
 <% ntable("#cccccc", 2) %>
+
+% 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 0e383af..90b55ca 100755
--- a/httemplate/edit/process/cust_main.cgi
+++ b/httemplate/edit/process/cust_main.cgi
@@ -91,6 +91,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 5872beb..7e8c3f4 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 |   32 ++++++++++++++++++++++++++++++
 httemplate/edit/process/cust_main.cgi    |   30 ++++++++++++++++++++++++++++
 httemplate/view/cust_main/misc.html      |   20 ++++++++++++++++++
 5 files changed, 91 insertions(+), 0 deletions(-)




More information about the freeside-commits mailing list