X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FMyAccount.pm;h=7d177f9fe2aa4d28755eaaa31b3fef82127322be;hb=1daea3b56a2a47dd74bc83ab61ab93edbc7dd847;hp=abb93e8ecffab4ff0640a5157079760ac7edfcc6;hpb=ee7abaf6cf68da08a8183e8d6aadb2e211f7be7d;p=freeside.git diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index abb93e8ec..7d177f9fe 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -121,7 +121,7 @@ sub skin_info { ) ), ( map { $_ => $conf->exists("selfservice-$_", $agentnum ) } - qw( menu_skipblanks menu_skipheadings menu_nounderline ) + qw( menu_skipblanks menu_skipheadings menu_nounderline no_logo ) ), ( map { $_ => scalar($conf->config_binary("selfservice-$_", $agentnum)) } qw( title_left_image title_right_image @@ -585,7 +585,7 @@ sub edit_info { $p->{'payinfo1'} =~ /^([\dx]+)$/ or return { 'error' => "illegal account number ". $p->{'payinfo1'} }; my $payinfo1 = $1; - $p->{'payinfo2'} =~ /^([\dx\.]+)$/ # . turned on by -require-bank-branch? + $p->{'payinfo2'} =~ /^([\dx\.]+)$/ # . turned on by echeck-country CA ? or return { 'error' => "illegal ABA/routing number ". $p->{'payinfo2'} }; my $payinfo2 = $1; $payinfo = $payinfo1. '@'. $payinfo2; @@ -790,7 +790,7 @@ sub validate_payment { $payinfo = $p->{'payinfo'}; - #more intelligent mathing will be needed here if you change + #more intelligent matching will be needed here if you change #card_masking_method and don't remove existing paymasks $payinfo = $cust_main->payinfo if $cust_main->paymask eq $payinfo; @@ -912,7 +912,7 @@ sub do_process_payment { if ( $validate->{'save'} ) { my $new = new FS::cust_main { $cust_main->hash }; - if ($validate->{'payby'} eq 'CARD' || $validate->{'payby'} eq 'DCRD') { + if ($payby eq 'CARD' || $payby eq 'DCRD') { $new->set( $_ => $validate->{$_} ) foreach qw( payname paystart_month paystart_year payissue payip address1 address2 city state zip country ); @@ -1422,6 +1422,9 @@ sub list_svcs { next if $pkgnum && $cust_pkg->pkgnum != $pkgnum; push @cust_svc, @{[ $cust_pkg->cust_svc ]}; #@{[ ]} to force array context } + + @cust_svc = grep { $_->part_svc->selfservice_access ne 'hidden' } @cust_svc; + if ( $p->{'svcdb'} ) { my $svcdb = ref($p->{'svcdb'}) eq 'HASH' ? $p->{'svcdb'} @@ -1445,7 +1448,8 @@ sub list_svcs { map { my $svc_x = $_->svc_x; my($label, $value) = $_->label; - my $svcdb = $_->part_svc->svcdb; + my $part_svc = $_->part_svc; + my $svcdb = $part_svc->svcdb; my $cust_pkg = $_->cust_pkg; my $part_pkg = $cust_pkg->part_pkg; @@ -1455,6 +1459,7 @@ sub list_svcs { 'label' => $label, 'value' => $value, 'pkg_status' => $cust_pkg->status, + 'readonly' => ( $part_svc->selfservice_access eq 'readonly' ), ); if ( $svcdb eq 'svc_acct' ) { @@ -1538,6 +1543,41 @@ sub svc_status_html { } +sub svc_status_hash { + my $p = shift; + + my($context, $session, $custnum) = _custoragent_session_custnum($p); + return { 'error' => $session } if $context eq 'error'; + + #XXX only svc_acct for now + my $svc_x = _customer_svc_x( $custnum, $p->{'svcnum'}, 'svc_acct') + or return { 'error' => "Service not found" }; + + my ( $html, $hashref ) = $svc_x->export_getstatus; + return $hashref; + +} + +sub set_svc_status_hash { + my $p = shift; + + my($context, $session, $custnum) = _custoragent_session_custnum($p); + return { 'error' => $session } if $context eq 'error'; + + #XXX only svc_acct for now + my $svc_x = _customer_svc_x( $custnum, $p->{'svcnum'}, 'svc_acct') + or return { 'error' => "Service not found" }; + + warn "set_svc_status_hash ". join(' / ', map "$_=>".$p->{$_}, keys %$p ) + if $DEBUG; + my $error = $svc_x->export_setstatus($p); #$p? returns error? + return { 'error' => $error } if $error; + + return {}; #? { 'error' => '' } + +} + + sub acct_forward_info { my $p = shift; @@ -1560,8 +1600,6 @@ sub acct_forward_info { sub process_acct_forward { my $p = shift; - warn Dumper($p); - my($context, $session, $custnum) = _custoragent_session_custnum($p); return { 'error' => $session } if $context eq 'error'; @@ -1569,7 +1607,6 @@ sub process_acct_forward { { 'srcsvc' => $p->{'svcnum'} }, 'svc_forward', ); - warn $old; if ( $p->{'dst'} eq '' ) { if ( $old ) { @@ -1593,10 +1630,13 @@ sub process_acct_forward { } else { my $conf = new FS::Conf; $new->svcpart($conf->config('selfservice-svc_forward_svcpart')); - $new->pkgnum($old->cust_svc->pkgnum); - warn Dumper($new); + + my $svc_acct = _customer_svc_x( $custnum, $p->{'svcnum'}, 'svc_acct' ) + or return { 'error' => 'No service' }; #how would we even get here? + + $new->pkgnum( $svc_acct->cust_svc->pkgnum ); + $error = $new->insert; - warn $error; } return { 'error' => $error }; @@ -1716,9 +1756,10 @@ sub list_support_usage { } sub _list_cdr_usage { - my($svc_phone, $begin, $end) = @_; - map [ $_->downstream_csv('format' => 'default', 'keeparray' => 1) ], #XXX config for format - $svc_phone->get_cdrs( 'begin'=>$begin, 'end'=>$end, ); + # XXX CDR type support... + my($svc_phone, $begin, $end, %opt) = @_; + map [ $_->downstream_csv(%opt, 'keeparray' => 1) ], + $svc_phone->get_cdrs( 'begin'=>$begin, 'end'=>$end, ); } sub list_cdr_usage { @@ -1743,12 +1784,26 @@ sub _usage_details { return { 'error' => 'No service selected in list_svc_usage' } unless $svc_x; - my $header = $svcdb eq 'svc_phone' - ? [ split(',', FS::cdr::invoice_header('default') ) ] #XXX - : []; - my $cust_pkg = $svc_x->cust_svc->cust_pkg; my $freq = $cust_pkg->part_pkg->freq; + my %callback_opt; + my $header = []; + if ( $svcdb eq 'svc_phone' ) { + my $format = $cust_pkg->part_pkg->option('output_format') || ''; + $format = '' if $format =~ /^sum_/; + # sensible default if there is no format or it's a summary format + if ( $cust_pkg->part_pkg->plan eq 'voip_inbound' ) { + $format ||= 'source_default'; + $callback_opt{inbound} = 1; + } + else { + $format ||= 'default'; + } + + $callback_opt{format} = $format; + $header = [ split(',', FS::cdr::invoice_header($format) ) ]; + } + my $start = $cust_pkg->setup; #my $end = $cust_pkg->bill; # or time? my $end = time; @@ -1758,7 +1813,9 @@ sub _usage_details { $p->{ending} = $end; } - my (@usage) = &$callback($svc_x, $p->{beginning}, $p->{ending}); + my (@usage) = &$callback($svc_x, $p->{beginning}, $p->{ending}, + %callback_opt + ); #kinda false laziness with FS::cust_main::bill, but perhaps #we should really change this bit to DateTime and DateTime::Duration