X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FMyAccount.pm;h=7e131f9d0c16f7388c6dd48602a9950b77ce4870;hb=0876d107ce74a1c1e1abe9e40b5b6531df4d7b56;hp=fc9e12459d804026731bc1f0a7f24335517108fb;hpb=f95f2318fd9820f8989d18a387eb303858d6ce00;p=freeside.git diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index fc9e12459..7e131f9d0 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -44,13 +44,23 @@ $me = '[FS::ClientAPI::MyAccount]'; use vars qw( @cust_main_editable_fields ); @cust_main_editable_fields = qw( first last company address1 address2 city - county state zip country daytime night fax + county state zip country + daytime night fax mobile ship_first ship_last ship_company ship_address1 ship_address2 ship_city - ship_state ship_zip ship_country ship_daytime ship_night ship_fax + ship_state ship_zip ship_country + ship_daytime ship_night ship_fax ship_mobile + locale payby payinfo payname paystart_month paystart_year payissue payip ss paytype paystate stateid stateid_state ); +BEGIN { #preload to reduce time customer_info takes + if ( $FS::TicketSystem::system ) { + warn "$me: initializing ticket system\n" if $DEBUG; + FS::TicketSystem->init(); + } +} + sub _cache { $cache ||= new FS::ClientAPI_SessionCache( { 'namespace' => 'FS::ClientAPI::MyAccount', @@ -377,7 +387,8 @@ sub customer_info { ( $session->{'pkgnum'} ? 1 : 0 ), #nobalance ); - $return{name} = $cust_main->first. ' '. $cust_main->get('last'); + $return{name} = $cust_main->name; + $return{ship_name} = $cust_main->ship_name; for (@cust_main_editable_fields) { $return{$_} = $cust_main->get($_); @@ -443,6 +454,71 @@ sub customer_info { } +sub customer_info_short { + my $p = shift; + + my($context, $session, $custnum) = _custoragent_session_custnum($p); + return { 'error' => $session } if $context eq 'error'; + + my %return; + + my $conf = new FS::Conf; + + if ( $custnum ) { #customer record + + my $search = { 'custnum' => $custnum }; + $search->{'agentnum'} = $session->{'agentnum'} if $context eq 'agent'; + my $cust_main = qsearchs('cust_main', $search ) + or return { 'error' => "unknown custnum $custnum" }; + + $return{small_custview} = + small_custview( $cust_main, + scalar($conf->config('countrydefault')), + 1, ##nobalance + ); + + $return{name} = $cust_main->name; + $return{ship_name} = $cust_main->ship_name; + + $return{payby} = $cust_main->payby; + + #none of these are terribly expensive if we want 'em... + for (@cust_main_editable_fields) { + $return{$_} = $cust_main->get($_); + } + + if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) { + $return{payinfo} = $cust_main->paymask; + @return{'month', 'year'} = $cust_main->paydate_monthyear; + } + + $return{'invoicing_list'} = + join(', ', grep { $_ !~ /^(POST|FAX)$/ } $cust_main->invoicing_list ); + #$return{'postal_invoicing'} = + # 0 < ( grep { $_ eq 'POST' } $cust_main->invoicing_list ); + + if ( $session->{'svcnum'} ) { + my $cust_svc = qsearchs('cust_svc', { 'svcnum' => $session->{'svcnum'} }); + $return{'svc_label'} = ($cust_svc->label)[1] if $cust_svc; + } + + } elsif ( $session->{'svcnum'} ) { #no customer record + + #uuh, not supproted yet... die? + return { 'error' => 'customer_info_short not yet supported as agent' }; + + } else { + + return { 'error' => 'Expired session' }; #XXX redirect to login w/this err! + + } + + return { 'error' => '', + 'custnum' => $custnum, + %return, + }; +} + sub edit_info { my $p = shift; my $session = _cache->get($p->{'session_id'}) @@ -483,7 +559,7 @@ sub edit_info { $p->{'payinfo1'} =~ /^([\dx]+)$/ or return { 'error' => "illegal account number ". $p->{'payinfo1'} }; my $payinfo1 = $1; - $p->{'payinfo2'} =~ /^([\dx]+)$/ + $p->{'payinfo2'} =~ /^([\dx\.]+)$/ # . turned on by -require-bank-branch? or return { 'error' => "illegal ABA/routing number ". $p->{'payinfo2'} }; my $payinfo2 = $1; $payinfo = $payinfo1. '@'. $payinfo2;