From: Ivan Kohler Date: Fri, 10 Aug 2012 20:54:14 +0000 (-0700) Subject: add national id # handling for my, RT#18543 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=5a204201503f8e0db6087db6e53b84297cbc739a add national id # handling for my, RT#18543 --- 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"; + +% } + + <% 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 @@ <% $cust_main->signupdate ? time2str($date_format, $cust_main->signupdate) : '' %> +% 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}$/ ) { + <% mt('Old IC/Passport') |h %> +% } elsif ( $cust_main->national_id =~ /^\d{6}\-\d{2}\-\d{4}$/ ) { + <% mt('NRIC') |h %> +% } else { +% warn "unknown national_id format"; + +% } + <% $cust_main->national_id |h %> + +% } 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,