X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FSignup.pm;h=4655b0984d79722d86b7570ff84265428bf8fff3;hb=35effa1bf4ac902547615c816960bbc8db8e7256;hp=92fc6361d0ec71d41cffd4217dae818ad1aaf5ae;hpb=f63c0e821610c885f9f49d301eeccf804e1ca6d3;p=freeside.git diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm index 92fc6361d..4655b0984 100644 --- a/FS/FS/ClientAPI/Signup.pm +++ b/FS/FS/ClientAPI/Signup.pm @@ -4,13 +4,16 @@ use strict; use Tie::RefHash; use FS::Conf; use FS::Record qw(qsearch qsearchs dbdef); +use FS::Msgcat qw(gettext); use FS::agent; use FS::cust_main_county; use FS::part_pkg; use FS::svc_acct_pop; use FS::cust_main; use FS::cust_pkg; -use FS::Msgcat qw(gettext); +use FS::svc_acct; +use FS::acct_snarf; +use FS::queue; use FS::ClientAPI; #hmm FS::ClientAPI->register_handlers( @@ -38,6 +41,16 @@ sub signup_info { ) ], + 'part_referral' => + [ + map { $_->hashref } + qsearch('part_referral', + dbdef->table('part_referral')->column('disabled') + ? { 'disabled' => '' } + : {} + ) + ], + 'agentnum2part_pkg' => { map { @@ -70,6 +83,8 @@ sub signup_info { 'countrydefault' => $conf->config('countrydefault') || 'US', + 'refnum' => $conf->config('signup_server-default_refnum'), + }; if ( @@ -155,18 +170,49 @@ sub new_customer { qw( username _password sec_phrase popnum ), } ); + my @acct_snarf; + my $snarfnum = 1; + while ( exists($packet->{"snarf_machine$snarfnum"}) + && length($packet->{"snarf_machine$snarfnum"}) ) { + my $acct_snarf = new FS::acct_snarf ( { + 'machine' => $packet->{"snarf_machine$snarfnum"}, + 'protocol' => $packet->{"snarf_protocol$snarfnum"}, + 'username' => $packet->{"snarf_username$snarfnum"}, + '_password' => $packet->{"snarf_password$snarfnum"}, + } ); + $snarfnum++; + push @acct_snarf, $acct_snarf; + } + $svc_acct->child_objects( \@acct_snarf ); + my $y = $svc_acct->setdefault; # arguably should be in new method return { 'error' => $y } if $y && !ref($y); $error = $svc_acct->check; return { 'error' => $error } if $error; + #setup a job dependancy to delay provisioning + my $placeholder = new FS::queue ( { + 'job' => 'FS::ClientAPI::Signup::__placeholder', + 'status' => 'locked', + } ); + $error = $placeholder->insert; + return { 'error' => $error } if $error; + use Tie::RefHash; tie my %hash, 'Tie::RefHash'; %hash = ( $cust_pkg => [ $svc_acct ] ); #msgcat - $error = $cust_main->insert( \%hash, \@invoicing_list, 'noexport' => 1 ); - return { 'error' => $error } if $error; + $error = $cust_main->insert( + \%hash, + \@invoicing_list, + 'depend_jobnum' => $placeholder->jobnum, + ); + if ( $error ) { + my $perror = $placeholder->delete; + $error .= " (Additionally, error removing placeholder: $perror)" if $perror; + return { 'error' => $error }; + } if ( $conf->exists('signup_server-realtime') ) { @@ -194,11 +240,20 @@ sub new_customer { local $FS::svc_Common::noexport_hack = 1; $cust_main->cancel('quiet'=>1); + my $perror = $placeholder->depended_delete; + warn "error removing provisioning jobs after decline: $perror" if $perror; + unless ( $perror ) { + $perror = $placeholder->delete; + warn "error removing placeholder after decline: $perror" if $perror; + } + return { 'error' => '_decline' }; } } - $cust_main->reexport; + + $error = $placeholder->delete; + return { 'error' => $error } if $error; return { error => '' };