X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FMyAccount.pm;h=cbc3dba90f8806a1b7826ef0e3c0df0c68cfc0b2;hb=08ba9f8e8d5c7dc641817d3fa7580faf3a38b50a;hp=587c8276b6357f83c2a1f68c89b5f3d6d974428e;hpb=82c1277c1ad43936672c6919c3a186e821b22b70;p=freeside.git diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 587c8276b..cbc3dba90 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -55,6 +55,20 @@ sub _cache { } ); } +sub login_info { + my $p = shift; + + my $conf = new FS::Conf; + + my %info = ( + 'phone_login' => $conf->exists('selfservice_server-phone_login'), + 'single_domain'=> scalar($conf->config('selfservice_server-single_domain')), + ); + + return \%info; + +} + #false laziness w/FS::ClientAPI::passwd::passwd sub login { my $p = shift; @@ -94,9 +108,10 @@ sub login { # if $conf->exists('selfservice_server-primary_only') # && ( ! $pkg_svc || $pkg_svc->primary_svc ne 'Y' ); my $cust_svc = $svc_acct->cust_svc; + my $part_pkg = $cust_svc->cust_pkg->part_pkg; return { error => 'Only primary user may log in.' } if $conf->exists('selfservice_server-primary_only') - && $cust_svc->svcpart != $cust_svc->cust_pkg->svcpart('svc_acct'); + && $cust_svc->svcpart != $part_pkg->svcpart('svc_acct'); return { error => 'Incorrect password.' } unless $svc_acct->check_password($p->{'password'}); @@ -525,6 +540,15 @@ sub process_payment_order_pkg { order_pkg($p); } +sub process_payment_order_renew { + my $p = shift; + + my $hr = process_payment($p); + return $hr if $hr->{'error'}; + + order_renew($p); +} + sub process_prepay { my $p = shift; @@ -1081,6 +1105,64 @@ sub _do_bop_realtime { ''; } +sub renew_info { + my $p = shift; + + my($context, $session, $custnum) = _custoragent_session_custnum($p); + return { 'error' => $session } if $context eq 'error'; + + my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) + or return { 'error' => "unknown custnum $custnum" }; + + my @cust_pkg = sort { $a->bill <=> $b->bill } + grep { $_->part_pkg->freq ne '0' } + $cust_main->ncancelled_pkgs; + + #return { 'error' => 'No active packages to renew.' } unless @cust_pkg; + + my $total = 0; + + my @array = map { + $total += $_->part_pkg->base_recur; + my $renew_date = $_->part_pkg->add_freq($_->bill); + { + 'bill_date' => $_->bill, + 'bill_date_pretty' => time2str('%x', $_->bill), + 'renew_date' => $renew_date, + 'renew_date_pretty' => time2str('%x', $renew_date), + 'amount' => sprintf('.%2f', $total), + }; + } + @cust_pkg; + + return { 'dates' => \@array }; + +} + +sub order_renew { + my $p = shift; + + my($context, $session, $custnum) = _custoragent_session_custnum($p); + return { 'error' => $session } if $context eq 'error'; + + my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) + or return { 'error' => "unknown custnum $custnum" }; + + my $date = $p->{'date'}; + + my $now = time; + + #freeside-daily -n -d $date fs_daily $custnum + $cust_main->bill_and_collect( 'time' => $date, + 'invoice_time' => $now, + 'actual_time' => $now, + 'check_freq' => '1d', + ); + + return { 'error' => '' }; + +} + sub cancel_pkg { my $p = shift; my $session = _cache->get($p->{'session_id'})