From 7353f670ef61e617a9dfb6c258907eb70e0345f6 Mon Sep 17 00:00:00 2001 From: levinse Date: Sun, 26 Dec 2010 04:09:26 +0000 Subject: added basic LNP capability to svc_phone including SS, RT10948 --- FS/FS/ClientAPI/MyAccount.pm | 22 ++++++++++++++++++++-- FS/FS/Conf.pm | 7 +++++++ FS/FS/Record.pm | 14 ++++++++++++++ FS/FS/Schema.pm | 7 +++++++ FS/FS/svc_phone.pm | 28 ++++++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 2 deletions(-) (limited to 'FS') diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 9a20285d7..d619e8493 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -18,6 +18,7 @@ use FS::Conf; use FS::Record qw(qsearch qsearchs dbh); use FS::Msgcat qw(gettext); use FS::Misc qw(card_types); +use FS::Misc::DateTime qw(parse_datetime); use FS::ClientAPI_SessionCache; use FS::svc_acct; use FS::svc_domain; @@ -978,6 +979,7 @@ sub list_pkgs { 'wholesale_view' => 1, 'login_svcpart' => [ $conf->config('selfservice_server-login_svcpart') ], 'date_format' => $conf->config('date_format') || '%m/%d/%Y', + 'lnp' => $conf->exists('svc_phone-lnp'), }; } @@ -1568,7 +1570,23 @@ sub cancel_pkg { sub provision_phone { my $p = shift; - my @bulkdid = @{$p->{'bulkdid'}}; + my @bulkdid; + @bulkdid = @{$p->{'bulkdid'}} if $p->{'bulkdid'}; + +# single DID LNP + unless($p->{'lnp'}) { + $p->{'lnp_desired_due_date'} = parse_datetime($p->{'lnp_desired_due_date'}); + $p->{'lnp_status'} = "portingin"; + return _provision( 'FS::svc_phone', + [qw(lnp_desired_due_date lnp_other_provider + lnp_other_provider_account phonenum countrycode lnp_status)], + [qw(phonenum countrycode)], + $p, + @_ + ); + } + +# single DID order unless (scalar(@bulkdid)) { return _provision( 'FS::svc_phone', [qw(phonenum countrycode)], @@ -1578,7 +1596,7 @@ sub provision_phone { ); } -# bulk case +# bulk DID order case my $error; foreach my $did ( @bulkdid ) { $did =~ s/[^0-9]//g; diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 132ee47d7..fbf18cbbc 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -3789,6 +3789,13 @@ and customer address. Include units.', 'description' => 'Maximum length of the phone service "Name" field (svc_phone.phone_name). Sometimes useful to limit this (to 15?) when exporting as Caller ID data.', 'type' => 'text', }, + + { + 'key' => 'svc_phone-lnp', + 'section' => '', + 'description' => 'Enables Number Portability features for svc_phone', + 'type' => 'checkbox', + }, { 'key' => 'default_phone_countrycode', diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 16520f409..2e2612e35 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -2589,6 +2589,20 @@ sub ut_enum { return "Illegal (enum) field $field: ". $self->getfield($field); } +=item ut_enumn COLUMN CHOICES_ARRAYREF + +Like ut_enum, except the null value is also allowed. + +=cut + +sub ut_enumn { + my( $self, $field, $choices ) = @_; + $self->getfield($field) + ? $self->ut_enum($field, $choices) + : ''; +} + + =item ut_foreign_key COLUMN FOREIGN_TABLE FOREIGN_COLUMN Check/untaint a foreign column key. Call a regular ut_ method (like ut_number) diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 253eb6602..72243413a 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -2873,6 +2873,13 @@ sub tables_hashref { 'pbxsvc', 'int', 'NULL', '', '', '', 'domsvc', 'int', 'NULL', '', '', '', 'locationnum', 'int', 'NULL', '', '', '', + 'lnp_status', 'varchar', 'NULL', $char_d, '', '', + 'portable', 'char', 'NULL', 1, '', '', + 'lrn', 'char', 'NULL', 10, '', '', + 'lnp_desired_due_date', 'int', 'NULL', '', '', '', + 'lnp_due_date', 'int', 'NULL', '', '', '', + 'lnp_other_provider', 'varchar', 'NULL', $char_d, '', '', + 'lnp_other_provider_account', 'varchar', 'NULL', $char_d, '', '', ], 'primary_key' => 'svcnum', 'unique' => [], diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm index adf7a6c56..be6e2f7c2 100644 --- a/FS/FS/svc_phone.pm +++ b/FS/FS/svc_phone.pm @@ -97,6 +97,7 @@ points to. You can ask the object for a copy with the I method. # the new method can be inherited from FS::Record, if a table method is defined # sub table_info { + my %dis2 = ( disable_inventory=>1, disable_select=>1 ); { 'name' => 'Phone number', 'sorts' => 'phonenum', @@ -134,6 +135,26 @@ sub table_info { disable_inventory => 1, disable_select => 1, }, + 'lnp_status' => { label => 'LNP Status', + type => 'select-lnp_status.html', + %dis2, + }, + 'portable' => { label => 'Portable?', %dis2, }, + 'lrn' => { label => 'LRN', + disable_inventory => 1, + }, + 'lnp_desired_due_date' => + { label => 'LNP Desired Due Date', %dis2 }, + 'lnp_due_date' => + { label => 'LNP Due Date', %dis2 }, + 'lnp_other_provider' => + { label => 'LNP Other Provider', + disable_inventory => 1, + }, + 'lnp_other_provider_account' => + { label => 'LNP Other Provider Account #', + %dis2 + }, }, }; } @@ -392,6 +413,13 @@ sub check { || $self->ut_foreign_keyn('pbxsvc', 'svc_pbx', 'svcnum' ) || $self->ut_foreign_keyn('domsvc', 'svc_domain', 'svcnum' ) || $self->ut_foreign_keyn('locationnum', 'cust_location', 'locationnum') + || $self->ut_numbern('lrn') + || $self->ut_numbern('lnp_desired_due_date') + || $self->ut_numbern('lnp_due_date') + || $self->ut_textn('lnp_other_provider') + || $self->ut_textn('lnp_other_provider_account') + || $self->ut_enumn('lnp_status', ['','portingin','portingout','portedin','native']) + || $self->ut_enumn('portable', ['','Y']) ; return $error if $error; -- cgit v1.2.1