From b37cafd2acd4ab2c38b44bc4d8ebde76936ef6bb Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Thu, 16 Apr 2015 13:09:46 -0700 Subject: [PATCH] add E911 address to self-service provision_phone, document it, RT#34069 --- FS/FS/ClientAPI/MyAccount.pm | 37 +++++++---- fs_selfservice/FS-SelfService/SelfService.pm | 96 ++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+), 12 deletions(-) diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 471a09331..93f817de6 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -2665,11 +2665,12 @@ sub cancel_pkg { } sub provision_phone { - my $p = shift; - my @bulkdid; - @bulkdid = @{$p->{'bulkdid'}} if $p->{'bulkdid'}; + my $p = shift; + my @bulkdid; + @bulkdid = @{$p->{'bulkdid'}} if $p->{'bulkdid'}; - if($p->{'svcnum'} && $p->{'svcnum'} =~ /^\d+$/){ + #editing an existing phone number + if ( $p->{'svcnum'} && $p->{'svcnum'} =~ /^\d+$/ ) { my($context, $session, $custnum) = _custoragent_session_custnum($p); return { 'error' => $session } if $context eq 'error'; @@ -2686,8 +2687,8 @@ sub provision_phone { return { 'error' => $svc_phone->replace }; } -# single DID LNP - unless($p->{'lnp'}) { + # 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', @@ -2697,19 +2698,19 @@ sub provision_phone { $p, @_ ); - } + } -# single DID order - unless (scalar(@bulkdid)) { + # single DID order (the usual case) + unless (scalar(@bulkdid)) { return _provision( 'FS::svc_phone', [qw(phonenum countrycode)], [qw(phonenum countrycode)], $p, @_ ); - } + } -# bulk DID order case + # bulk DID order case my $error; foreach my $did ( @bulkdid ) { $did =~ s/[^0-9]//g; @@ -2801,9 +2802,21 @@ sub _provision { 'svcpart' => $p->{'svcpart'}, map { $_ => $p->{$_} } @$fields } ); + + my %insert_args = (); + #i shouldn't be a special case here (pass an option or something) + if ( $class eq 'FS::svc_phone' + && grep length($p->{$_}), @location_editable_fields + ) + { + $insert_args{'cust_location'} = new FS::cust_location { + map { $_ => $p->{$_} } @location_editable_fields + }; + } + warn "inserting $class record\n" if $DEBUG; - my $error = $svc_x->insert; + my $error = $svc_x->insert(%insert_args); unless ( $error ) { warn "finding inserted record for svcnum ". $svc_x->svcnum. "\n" diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index c4813728e..9d7e7ed17 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -1155,6 +1155,102 @@ pkgpart of package to cancel Returns a hash reference with a single key, B, empty on success, or an error message on errors. +=item provision_acct + +Provisions an account (svc_acct). + +Takes a hash references as parameter with the following keys: + +=over 4 + +=item session_id + +Session identifier + +=item pkgnum + +pkgnum of package into which this service is provisioned + +=item svcpart + +svcpart or service definition to provision + +=item username + +=item domsvc + +=item _password + +=back + +=item provision_phone + +Provisions a phone number (svc_phone). + +Takes a hash references as parameter with the following keys: + +=over 4 + +=item session_id + +Session identifier + +=item pkgnum + +pkgnum of package into which this service is provisioned + +=item svcpart + +svcpart or service definition to provision + +=item countrycode + +=item phonenum + +=item address1 + +=item address2 + +=item city + +=item county + +=item state + +=item zip + +=item country + +E911 Address (optional) + +=back + +=item provision_external + +Provisions an external service (svc_external). + +Takes a hash references as parameter with the following keys: + +=over 4 + +=item session_id + +Session identifier + +=item pkgnum + +pkgnum of package into which this service is provisioned + +=item svcpart + +svcpart or service definition to provision + +=item id + +=item title + +=back + =back =head1 SIGNUP FUNCTIONS -- 2.11.0