X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FSignup.pm;h=6dded4ccfbb7c569cc50fd39ceec8d6747c3b265;hb=7cdcb8d249f66efdbd5eb4efdd6e07f0f7948b49;hp=510d8f1ec20be941b22d7a38cbc5546936513cbf;hpb=f950e4da4b78949ae7a74e8127c0e3eab423178e;p=freeside.git diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm index 510d8f1ec..6dded4ccf 100644 --- a/FS/FS/ClientAPI/Signup.pm +++ b/FS/FS/ClientAPI/Signup.pm @@ -23,28 +23,21 @@ sub signup_info { my $conf = new FS::Conf; - use vars qw($signup_info); #cache for performance; - $signup_info ||= { + use vars qw($signup_info_cache); #cache for performance; + $signup_info_cache ||= { 'cust_main_county' => [ map { $_->hashref } qsearch('cust_main_county', {}) ], 'agent' => [ map { $_->hashref } - qsearch('agent', dbdef->table('agent')->column('disabled') - ? { 'disabled' => '' } - : {} - ) + qsearch('agent', { 'disabled' => '' } ) ], 'part_referral' => [ map { $_->hashref } - qsearch('part_referral', - dbdef->table('part_referral')->column('disabled') - ? { 'disabled' => '' } - : {} - ) + qsearch('part_referral', { 'disabled' => '' }) ], 'agentnum2part_pkg' => @@ -53,14 +46,15 @@ sub signup_info { my $href = $_->pkgpart_hashref; $_->agentnum => [ - map { { 'payby' => [ $_->payby ], %{$_->hashref} } } + map { { 'payby' => [ $_->payby ], + 'freq_pretty' => $_->freq_pretty, + 'options' => { $_->options }, + %{$_->hashref} + } } grep { $_->svcpart('svc_acct') && $href->{ $_->pkgpart } } qsearch( 'part_pkg', { 'disabled' => '' } ) ]; - } qsearch('agent', dbdef->table('agent')->column('disabled') - ? { 'disabled' => '' } - : {} - ) + } qsearch('agent', { 'disabled' => '' }) }, 'svc_acct_pop' => [ map { $_->hashref } qsearch('svc_acct_pop',{} ) ], @@ -73,14 +67,24 @@ sub signup_info { 'card_types' => card_types(), - 'cvv_enabled' => defined dbdef->table('cust_main')->column('paycvv'), + 'paytypes' => [ @FS::cust_main::paytypes ], + + 'cvv_enabled' => defined dbdef->table('cust_main')->column('paycvv'), # 1, + + 'stateid_enabled' => $conf->exists('show_stateid'), - 'ship_enabled' => defined dbdef->table('cust_main')->column('ship_last'), + 'paystate_enabled' => $conf->exists('show_bankstate'), + + 'ship_enabled' => defined dbdef->table('cust_main')->column('ship_last'),#1, 'msgcat' => { map { $_=>gettext($_) } qw( passwords_dont_match invalid_card unknown_card_type not_a empty_password illegal_or_empty_text ) }, + 'label' => { map { $_ => FS::Msgcat::_gettext($_) } qw( + stateid stateid_state + ) }, + 'statedefault' => $conf->config('statedefault') || 'CA', 'countrydefault' => $conf->config('countrydefault') || 'US', @@ -91,6 +95,8 @@ sub signup_info { }; + my $signup_info = { %$signup_info_cache }; + my @addl = qw( signup_server-classnum2 signup_server-classnum3 ); if ( grep { $conf->exists($_) } @addl ) { @@ -99,15 +105,25 @@ sub signup_info { foreach my $addl ( @addl ) { my $classnum = $conf->config($addl) or next; - my @pkgs = map { $_->hashref } + + my @pkgs = map { { + 'freq_pretty' => $_->freq_pretty, + 'options' => { $_->options }, + %{ $_->hashref } + }; + } qsearch( 'part_pkg', { classnum => $classnum } ); + push @{$signup_info->{optional_packages}}, \@pkgs; + } } my $agentnum = $packet->{'agentnum'} || $conf->config('signup_server-default_agentnum'); + $agentnum =~ /^(\d*)$/ or die "illegal agentnum"; + $agentnum = $1; my $session = ''; if ( exists $packet->{'session_id'} ) { @@ -139,7 +155,12 @@ sub signup_info { if ( $packet->{'reg_code'} ) { $signup_info->{'part_pkg'} = - [ map { { 'payby' => [ $_->payby ], %{$_->hashref} } } + [ map { { 'payby' => [ $_->payby ], + 'freq_pretty' => $_->freq_pretty, + 'options' => { $_->options }, + %{$_->hashref} + }; + } grep { $_->svcpart('svc_acct') } map { $_->part_pkg } qsearchs( 'reg_code', { 'code' => $packet->{'reg_code'}, @@ -153,7 +174,11 @@ sub signup_info { } elsif ( $packet->{'promo_code'} ) { $signup_info->{'part_pkg'} = - [ map { { 'payby' => [ $_->payby ], %{$_->hashref} } } + [ map { { 'payby' => [ $_->payby ], + 'freq_pretty' => $_->freq_pretty, + 'options' => { $_->options }, + %{$_->hashref} + } } grep { $_->svcpart('svc_acct') } qsearch( 'part_pkg', { 'promo_code' => { op=>'ILIKE', @@ -166,13 +191,31 @@ sub signup_info { unless @{ $signup_info->{'part_pkg'} }; } - if ( $agentnum && ! @{ $signup_info->{'part_pkg'} } ) { - $signup_info->{'part_pkg'} = $signup_info->{'agentnum2part_pkg'}{$agentnum}; + if ( $agentnum ) { + $signup_info->{'part_pkg'} = $signup_info->{'agentnum2part_pkg'}{$agentnum} + unless @{ $signup_info->{'part_pkg'} }; + + $signup_info->{'part_referral'} = + [ + map { $_->hashref } + qsearch( { + 'table' => 'part_referral', + 'hashref' => { 'disabled' => '' }, + 'extra_sql' => "AND ( agentnum = $agentnum ". + " OR agentnum IS NULL ) ", + }, + ) + ]; + } # else { # delete $signup_info->{'part_pkg'}; #} + $signup_info->{'part_pkg'} = [ sort { $a->{pkg} cmp $b->{pkg} } # case? + @{ $signup_info->{'part_pkg'} } + ]; + if ( exists $packet->{'session_id'} ) { my $agent_signup_info = { %$signup_info }; delete $agent_signup_info->{agentnum2part_pkg}; @@ -226,14 +269,14 @@ sub new_customer { last first ss company address1 address2 city county state zip country - daytime night fax + daytime night fax stateid stateid_state ship_last ship_first ship_ss ship_company ship_address1 ship_address2 ship_city ship_county ship_state ship_zip ship_country ship_daytime ship_night ship_fax payby - payinfo paycvv paydate payname + payinfo paycvv paydate payname paystate paytype paystart_month paystart_year payissue payip @@ -249,7 +292,9 @@ sub new_customer { $cust_main->payinfo($cust_main->daytime) if $cust_main->payby eq 'LECB' && ! $cust_main->payinfo; - my @invoicing_list = split( /\s*\,\s*/, $packet->{'invoicing_list'} ); + my @invoicing_list = $packet->{'invoicing_list'} + ? split( /\s*\,\s*/, $packet->{'invoicing_list'} ) + : (); $packet->{'pkgpart'} =~ /^(\d+)$/ or '' =~ /^()$/; my $pkgpart = $1; @@ -334,8 +379,7 @@ sub new_customer { #warn "[fs_signup_server] error billing new customer: $bill_error" # if $bill_error; - $cust_main->apply_payments; - $cust_main->apply_credits; + $cust_main->apply_payments_and_credits; $bill_error = $cust_main->collect('realtime' => 1); #warn "[fs_signup_server] error collecting from new customer: $bill_error"