From: levinse Date: Sun, 26 Dec 2010 04:09:26 +0000 (+0000) Subject: added basic LNP capability to svc_phone including SS, RT10948 X-Git-Tag: TORRUS_1_0_9~3 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=7353f670ef61e617a9dfb6c258907eb70e0345f6 added basic LNP capability to svc_phone including SS, RT10948 --- 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; diff --git a/fs_selfservice/FS-SelfService/cgi/provision_svc_phone.html b/fs_selfservice/FS-SelfService/cgi/provision_svc_phone.html index 3ca7a1222..ab9827e93 100644 --- a/fs_selfservice/FS-SelfService/cgi/provision_svc_phone.html +++ b/fs_selfservice/FS-SelfService/cgi/provision_svc_phone.html @@ -1,6 +1,15 @@ -<%= $url = "$selfurl?session=$session_id;action="; ''; %> -<%= include('header', 'Setup phone number') %> +<%= $url = "$selfurl?session=$session_id;action="; + $heading2 = $lnp ? "Port-In Number" : "Setup phone number"; + ''; +%> +<%= include('header', $heading2) %> <%= + +sub lnp_textfield { + my ($name,$label) = (shift,shift); + qq!$label!; +} + if($error) { $OUT .= qq!
$error
!; } @@ -12,10 +21,21 @@ if($error) { -<%= didselector('field' => 'phonenum', +<%= +if($lnp) { + $OUT .= "" + . qq!! + . lnp_textfield(phonenum,"Phone Number") + . lnp_textfield("lnp_desired_due_date","Requested Port-In Date") + . lnp_textfield("lnp_other_provider","Current Provider") + . lnp_textfield("lnp_other_provider_account","Current Provider's Account #") + . "
"; +} else { + didselector('field' => 'phonenum', 'svcpart' => $svcpart, 'bulknum' => $numavail, ); +} %>

diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 0d3bed8f9..5b2d2980c 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -710,6 +710,7 @@ sub provision_svc { $action .= "_$1"; $result->{'numavail'} = $cgi->param('numavail'); + $result->{'lnp'} = $cgi->param('lnp'); $result; } @@ -717,13 +718,25 @@ sub provision_svc { sub process_svc_phone { my @bulkdid = $cgi->param('bulkdid'); my $phonenum = $cgi->param('phonenum'); - - my $result = provision_phone ( - 'session_id' => $session_id, - 'bulkdid' => [ @bulkdid ], - 'countrycode' => '1', - map { $_ => $cgi->param($_) } qw( pkgnum svcpart phonenum ) - ); + my $lnp = $cgi->param('lnp'); + + my $result; + if($lnp) { + $result = provision_phone ( + 'session_id' => $session_id, + 'countrycode' => '1', + map { $_ => $cgi->param($_) } qw( pkgnum svcpart phonenum + lnp_desired_due_date lnp_other_provider + lnp_other_provider_account ) + ); + } else { + $result = provision_phone ( + 'session_id' => $session_id, + 'bulkdid' => [ @bulkdid ], + 'countrycode' => '1', + map { $_ => $cgi->param($_) } qw( pkgnum svcpart phonenum ) + ); + } if ( exists $result->{'error'} && $result->{'error'} ) { $action = 'provision_svc_phone'; diff --git a/fs_selfservice/FS-SelfService/cgi/ws_list.html b/fs_selfservice/FS-SelfService/cgi/ws_list.html index 6b23b7dcb..2bdcd741d 100644 --- a/fs_selfservice/FS-SelfService/cgi/ws_list.html +++ b/fs_selfservice/FS-SelfService/cgi/ws_list.html @@ -57,6 +57,12 @@ if ( $pkgpart ) { . qq!$part_svc->{'svc'} ($part_svc->{'num_avail'}! . qq! available)

!; $OUT .= $link if $part_svc->{'can_get_dids'}; + + if($part_svc->{'svcdb'} eq 'svc_phone' && $lnp) { + $OUT .= qq!Port-In $part_svc->{'svc'}!; + } } $OUT .= ""; diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index 142d0c3ae..cab5167c6 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -356,6 +356,19 @@ Example: % %include_common, % %opt, % ); +% +% if ( $include eq 'tr-input-date-field' ) { +% # it's either hacking it here, or changing a lot more stuff +% @include = ( +% "/elements/$include.html", { +% 'name' => $field, +% 'value' => $opt{curr_value}, +% 'label' => $label, +% 'noinit' => $f->{noinit}, +% } +% ); +% } +% % @include; % }; % diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index d156ccd0a..437f7e850 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -334,6 +334,15 @@ that field. % 'multiple' => ($flag eq 'S'), % ); % +% } elsif ( $def->{type} eq 'select-lnp_status.html' ) { +% +% $html .= include('/elements/select-lnp_status.html', +% 'curr_value' => $value, +% 'element_name' => "${layer}__${field}", +% 'element_etc' => $disabled, +% 'multiple' => ($flag eq 'S'), +% ); +% % } elsif ( $def->{type} eq 'radius_usergroup_selector' ) { % % #XXX disable the RADIUS usergroup selector? ugh it sure does need diff --git a/httemplate/edit/process/svc_phone.html b/httemplate/edit/process/svc_phone.html index e02ec5ccc..ddc938216 100644 --- a/httemplate/edit/process/svc_phone.html +++ b/httemplate/edit/process/svc_phone.html @@ -1,6 +1,7 @@ <% include( 'elements/svc_Common.html', 'table' => 'svc_phone', 'args_callback' => $args_callback, + 'value_callback' => $value_callback, ) %> <%init> @@ -24,6 +25,9 @@ my $args_callback = sub { }; - +my $value_callback = sub { + my ($field, $value) = @_; + ($field =~ /_date$/) ? parse_datetime($value) : $value; +}; diff --git a/httemplate/edit/svc_phone.cgi b/httemplate/edit/svc_phone.cgi index b77d96233..6482165dc 100644 --- a/httemplate/edit/svc_phone.cgi +++ b/httemplate/edit/svc_phone.cgi @@ -1,17 +1,6 @@ <% include( 'elements/svc_Common.html', 'table' => 'svc_phone', 'fields' => \@fields, - 'labels' => { - 'svcnum' => 'Service', - 'countrycode' => 'Country code', - 'phonenum' => 'Phone number', - 'domsvc' => 'Domain', - 'sip_password' => 'SIP password', - 'pin' => 'Voicemail PIN', - 'phone_name' => 'Name', - 'pbxsvc' => 'PBX', - 'locationnum' => 'E911 location', - }, 'svc_new_callback' => sub { my( $cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt ) = @_; $svc_x->locationnum($cust_pkg->locationnum) if $cust_pkg; @@ -73,5 +62,29 @@ push @fields, { field => 'pbxsvc', { field => 'custnum', type=> 'hidden' }, #for new cust_locations ; +if ( $conf->exists('svc_phone-lnp') ) { + push @fields, + { value => 'Number Portability', + type => 'tablebreak-tr-title', + colspan => 7, + }, + { field => 'lnp_status', + type => 'select-lnp_status', + }, + { field => 'portable', + type => 'checkbox', + }, + 'lrn', + { field => 'lnp_desired_due_date', + type => 'input-date-field', + }, + { field => 'lnp_due_date', + type => 'input-date-field', + noinit => 1, + }, + 'lnp_other_provider', + 'lnp_other_provider_account', +; +} diff --git a/httemplate/elements/select-lnp_status.html b/httemplate/elements/select-lnp_status.html new file mode 100644 index 000000000..f4910e0b6 --- /dev/null +++ b/httemplate/elements/select-lnp_status.html @@ -0,0 +1,22 @@ + +<%init> + +my %opt = @_; + +my %seloptions = ( + 'native' => 'Native', + 'portedin' => 'Ported In', + 'portingin' => 'Porting In', + 'portingout' => 'Porting Out', + ); + diff --git a/httemplate/elements/tr-input-date-field.html b/httemplate/elements/tr-input-date-field.html index ff4996faf..5400fcb80 100644 --- a/httemplate/elements/tr-input-date-field.html +++ b/httemplate/elements/tr-input-date-field.html @@ -1,8 +1,9 @@ - +% unless ( $noinit ) { +% } <% $label %> @@ -23,7 +24,7 @@ <%init> -my($name, $value, $label, $format, $usedatetime); +my($name, $value, $label, $format, $usedatetime, $noinit); if ( ref($_[0]) ) { my $opt = shift; $name = $opt->{'name'}; @@ -31,6 +32,7 @@ if ( ref($_[0]) ) { $label = $opt->{'label'}; $format = $opt->{'format'}; $usedatetime = $opt->{'usedatetime'}; + $noinit = $opt->{'noinit'}; } else { ($name, $value, $label, $format, $usedatetime) = @_; } diff --git a/httemplate/elements/tr-select-lnp_status.html b/httemplate/elements/tr-select-lnp_status.html new file mode 100644 index 000000000..a71e94bfa --- /dev/null +++ b/httemplate/elements/tr-select-lnp_status.html @@ -0,0 +1,14 @@ + + <% $opt{'label'} || 'LNP Status' %> + + <% include('/elements/select-lnp_status.html', + 'curr_value' => $opt{'curr_value'}, + ) + %> + + +<%init> + +my %opt = @_; + + diff --git a/httemplate/view/svc_phone.cgi b/httemplate/view/svc_phone.cgi index 27d270c89..94948a78b 100644 --- a/httemplate/view/svc_phone.cgi +++ b/httemplate/view/svc_phone.cgi @@ -1,15 +1,7 @@ <% include('elements/svc_Common.html', 'table' => 'svc_phone', 'fields' => \@fields, - 'labels' => { - 'countrycode' => 'Country code', - 'phonenum' => 'Phone number', - 'domain' => 'Domain', - 'pbx_title' => 'PBX', - 'sip_password' => 'SIP password', - 'pin' => 'PIN', - 'phone_name' => 'Name', - }, + 'labels' => \%labels, 'html_foot' => $html_foot, ) %> @@ -18,10 +10,27 @@ my $conf = new FS::Conf; my $countrydefault = $conf->config('countrydefault') || 'US'; +my $fields = FS::svc_phone->table_info->{'fields'}; +my %labels = map { $_ => ( ref($fields->{$_}) + ? $fields->{$_}{'label'} + : $fields->{$_} + ); + } keys %$fields; + my @fields = qw( countrycode phonenum ); push @fields, 'domain' if $conf->exists('svc_phone-domain'); push @fields, qw( pbx_title sip_password pin phone_name ); +if ( $conf->exists('svc_phone-lnp') ) { +push @fields, 'lnp_status', + { field => 'portable', type => 'checkbox', }, + 'lrn', + { field => 'lnp_desired_due_date', type => 'date', }, + { field => 'lnp_due_date', type => 'date', }, + 'lnp_other_provider', + 'lnp_other_provider_account'; +} + my $html_foot = sub { my $svc_phone = shift;