[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 0d4d7c6197ab31d3667c13a99cf2488cdbf4a23b
Ivan
ivan at 420.am
Thu Aug 16 01:31:17 PDT 2012
The branch, FREESIDE_2_3_BRANCH has been updated
via 0d4d7c6197ab31d3667c13a99cf2488cdbf4a23b (commit)
from 0ebd67ba94d633456c79afc2ca5902dd6245d365 (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 0d4d7c6197ab31d3667c13a99cf2488cdbf4a23b
Author: Ivan Kohler <ivan at freeside.biz>
Date: Thu Aug 16 01:31:16 2012 -0700
national IDs, RT#18543
diff --git a/FS/FS/cust_main/NationalID.pm b/FS/FS/cust_main/NationalID.pm
new file mode 100644
index 0000000..cc8d556
--- /dev/null
+++ b/FS/FS/cust_main/NationalID.pm
@@ -0,0 +1,60 @@
+package FS::cust_main::NationalID;
+
+use strict;
+use vars qw( $conf );
+use Date::Simple qw( days_in_month );
+use FS::UID;
+
+install_callback FS::UID sub {
+ $conf = new FS::Conf;
+};
+
+sub set_national_id_from_cgi {
+ my( $self, $cgi ) = @_;
+
+ my $error = '';
+
+ 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{2})(\d{2})(\d{2})\-?(\d{2})\-?(\d{4})$/ ) {
+ my( $y, $m, $d, $bp, $n ) = ( $1, $2, $3, $4, $5 );
+ $self->national_id( "$y$m$d-$bp-$n" );
+
+ my @lt = localtime(time);
+ my $year = ( $y <= substr( $lt[5]+1900, -2) ) ? 2000 + $y
+ : 1900 + $y;
+ $error ||= "Illegal NRIC: ". $cgi->param('national_id1')
+ if $m < 1 || $m > 12 || $d < 1 || $d > days_in_month($year, $m);
+ #$bp validation per http://en.wikipedia.org/wiki/National_Registration_Identity_Card_Number_%28Malaysia%29#Second_section:_Birthplace ? seems like a bad idea, some could be missing or get added
+ } 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}$/ ) {
+ $self->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') ) {
+ $self->national_id( $cgi->param('national_id0') );
+ }
+
+ $error;
+
+}
+
+1;
+
-----------------------------------------------------------------------
Summary of changes:
FS/FS/cust_main/NationalID.pm | 60 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
create mode 100644 FS/FS/cust_main/NationalID.pm
More information about the freeside-commits
mailing list