X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=fs_signup%2Ffs_signup_server;h=b0d28be8c89c1b917fc92dcc2f92711d0250b85f;hb=0bb8360049c3ec543889d98a8d4ca27051139d68;hp=56d616b534664040349fd2b3e3ee3ad50ccc0ef3;hpb=5e39e2d7963d6f8304e5afb5d8b5f50aa6eaaf14;p=freeside.git diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server index 56d616b53..b0d28be8c 100755 --- a/fs_signup/fs_signup_server +++ b/fs_signup/fs_signup_server @@ -5,7 +5,8 @@ use strict; use IO::Handle; -use FS::SSH qw(sshopen2); +use Tie::RefHash; +use Net::SSH qw(sshopen2); use FS::UID qw(adminsuidsetup); use FS::Record qw( qsearch qsearchs ); use FS::cust_main_county; @@ -15,7 +16,7 @@ use vars qw( $opt $Debug ); $Debug = 0; -my @payby = qw(CARD); +my @payby = qw(CARD PREPAY); my $user = shift or die &usage; &adminsuidsetup( $user ); @@ -28,7 +29,8 @@ my $pkgpart = $agent->pkgpart_hashref; my $refnum = shift or die &usage; -$SIG{CHLD} = sub { wait() }; +#causing trouble for some folks +#$SIG{CHLD} = sub { wait() }; my($fs_signupd)="/usr/local/sbin/fs_signupd"; @@ -55,7 +57,7 @@ while (1) { warn "[fs_signup_server] Sending package definitions...\n" if $Debug; my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } } - qsearch( 'part_pkg', {} ); + qsearch( 'part_pkg', { 'disabled' => '' } ); print $writer $data = join("\n", ( scalar(@part_pkg) || die "no usable package definitions, agent $agentnum" ), map { @@ -86,9 +88,9 @@ while (1) { chop( my( $first, $last, $ss, $company, $address1, $address2, $city, $county, $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, - $paydate, $payname, $invoicing_list, $pkgpart, $username, $password, - $popnum, - ) = map { scalar(<$reader>) } ( 1 .. 23 ) ); + $paydate, $payname, $invoicing_list, $referral_custnum, + $pkgpart, $username, $password, $popnum, + ) = map { scalar(<$reader>) } ( 1 .. 24 ) ); warn "[fs_signup_server] Processing signup...\n" if $Debug; @@ -97,38 +99,37 @@ while (1) { #shares some stuff with htdocs/edit/process/cust_main.cgi... take any # common that are still here and library them. my $cust_main = new FS::cust_main ( { - 'custnum' => '', - 'agentnum' => $agentnum, - 'refnum' => $refnum, - 'last' => $last, - 'first' => $first, - 'ss' => $ss, - 'company' => $company, - 'address1' => $address1, - 'address2' => $address2, - 'city' => $city, - 'county' => $county, - 'state' => $state, - 'zip' => $zip, - 'country' => $country, - 'daytime' => $daytime, - 'night' => $night, - 'fax' => $fax, - 'payby' => $payby, - 'payinfo' => $payinfo, - 'paydate' => $paydate, - 'payname' => $payname, + 'custnum' => '', + 'agentnum' => $agentnum, + 'refnum' => $refnum, + 'last' => $last, + 'first' => $first, + 'ss' => $ss, + 'company' => $company, + 'address1' => $address1, + 'address2' => $address2, + 'city' => $city, + 'county' => $county, + 'state' => $state, + 'zip' => $zip, + 'country' => $country, + 'daytime' => $daytime, + 'night' => $night, + 'fax' => $fax, + 'payby' => $payby, + 'payinfo' => $payinfo, + 'paydate' => $paydate, + 'payname' => $payname, + 'referral_custnum' => $referral_custnum, } ); $error = "Illegal payment type" unless grep { $_ eq $payby } @payby; my @invoicing_list = split( /\s*\,\s*/, $invoicing_list ); - $error ||= $cust_main->check_invoicing_list( \@invoicing_list ); - my $part_pkg = qsearchs( 'part_pkg', { 'pkgpart' => $pkgpart } ) or $error ||= "WARNING: unknown pkgpart $pkgpart"; - my $svcpart = $part_pkg->svcpart; + my $svcpart = $part_pkg->svcpart unless $error; # this should wind up in FS::cust_pkg! my $agent = qsearchs( 'agent', { 'agentnum' => $agentnum } ); @@ -159,22 +160,14 @@ while (1) { $error ||= $svc_acct->check; - $error ||= $cust_main->insert; - if ( $cust_pkg && ! $error ) { #in this case, $cust_pkg should always - #be definied, but.... - $cust_pkg->custnum( $cust_main->custnum ); - $error ||= $cust_pkg->insert; - warn "WARNING: $error on pre-checked cust_pkg record!" if $error; - $svc_acct->pkgnum( $cust_pkg->pkgnum ); - $error ||= $svc_acct->insert; - warn "WARNING: $error on pre-checked svc_acct record!" if $error; - } + use Tie::RefHash; + tie my %hash, 'Tie::RefHash'; + %hash = ( $cust_pkg => [ $svc_acct ] ); + $error ||= $cust_main->insert( \%hash, \@invoicing_list ); warn "[fs_signup_server] Sending results...\n" if $Debug; print $writer $error, "\n"; - $cust_main->invoicing_list( \@invoicing_list ) unless $error; - } close $writer; close $reader;