summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2012-08-10 13:54:14 -0700
committerIvan Kohler <ivan@freeside.biz>2012-08-10 13:54:14 -0700
commit5a204201503f8e0db6087db6e53b84297cbc739a (patch)
tree6f17419140a68f9a0c783d2bc4e4b2029a79574c
parentd32459cf059ff29a5ddc4b83ca2bf50a7828454b (diff)
add national id # handling for my, RT#18543
-rw-r--r--FS/FS/Conf.pm8
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--httemplate/edit/cust_main/birthdate.html31
-rwxr-xr-xhttemplate/edit/process/cust_main.cgi30
-rw-r--r--httemplate/view/cust_main/misc.html20
5 files changed, 90 insertions, 0 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 39b59cf37..43d561168 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 72f8c3027..6b32d7153 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' ,@date_type, '', '',
'spouse_birthdate' ,@date_type, '', '',
'anniversary_date' ,@date_type, '', '',
diff --git a/httemplate/edit/cust_main/birthdate.html b/httemplate/edit/cust_main/birthdate.html
index 5447a3ad0..5af819bdc 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 866452de1..622dd87c5 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 dc6da53f1..9713b2469 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,