X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FMyAccount.pm;h=fe47acded21eb39cda9100c4af02e0cc8ac9d32d;hb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924;hp=71e47b56743398a53a01522111a4b90c46d3640a;hpb=cd7626282ab808893f3b1d06bd77d0a64300c3e5;p=freeside.git diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 71e47b567..fe47acded 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -27,6 +27,7 @@ use FS::TicketSystem; use FS::ClientAPI_SessionCache; use FS::cust_svc; use FS::svc_acct; +use FS::svc_forward; use FS::svc_domain; use FS::svc_phone; use FS::svc_external; @@ -120,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 @@ -1248,16 +1249,7 @@ sub list_invoices { my @legacy_cust_bill = $cust_main->legacy_cust_bill; - my @cust_bill = $cust_main->cust_bill; - - my $hide_taxclass = $conf->config('selfservice-hide_invoices-taxclass'); - if ( $hide_taxclass ) { - @cust_bill = grep { my @cust_bill_pkg = $_->cust_bill_pkg; - my @part_pkg= grep $_, map $_->part_pkg, @cust_bill_pkg; - grep { $_->taxclass ne $hide_taxclass } @part_pkg; - } - @cust_bill; - } + my @cust_bill = grep ! $_->hide, $cust_main->cust_bill; my $balance = 0; @@ -1430,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'} @@ -1453,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; @@ -1463,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' ) { @@ -1512,7 +1509,8 @@ sub list_svcs { } sub _customer_svc_x { - my($custnum, $svcnum, $table) = @_; + my($custnum, $svcnum, $table) = (shift, shift, shift); + my $hashref = ref($svcnum) ? $svcnum : { 'svcnum' => $svcnum }; $custnum =~ /^(\d+)$/ or die "illegal custnum"; my $search = " AND custnum = $1"; @@ -1523,7 +1521,7 @@ sub _customer_svc_x { 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum ) '. 'LEFT JOIN cust_pkg USING ( pkgnum ) ',#. #'LEFT JOIN cust_main USING ( custnum ) ', - 'hashref' => { 'svcnum' => $svcnum, }, + 'hashref' => $hashref, 'extra_sql' => $search, #important } ); @@ -1545,6 +1543,71 @@ sub svc_status_html { } +sub acct_forward_info { + my $p = shift; + + my($context, $session, $custnum) = _custoragent_session_custnum($p); + return { 'error' => $session } if $context eq 'error'; + + my $svc_forward = _customer_svc_x( $custnum, + { 'srcsvc' => $p->{'svcnum'} }, + 'svc_forward', + ) + or return { 'error' => '', + 'dst' => '', + }; + + return { 'error' => '', + 'dst' => $svc_forward->dst || $svc_forward->dstsvc_acct->email, + }; + +} + +sub process_acct_forward { + my $p = shift; + my($context, $session, $custnum) = _custoragent_session_custnum($p); + return { 'error' => $session } if $context eq 'error'; + + my $old = _customer_svc_x( $custnum, + { 'srcsvc' => $p->{'svcnum'} }, + 'svc_forward', + ); + + if ( $p->{'dst'} eq '' ) { + if ( $old ) { + my $error = $old->delete; + return { 'error' => $error }; + } + return { 'error' => '' }; + } + + my $new = new FS::svc_forward { 'srcsvc' => $p->{'svcnum'}, + 'dst' => $p->{'dst'}, + }; + + my $error; + if ( $old ) { + $new->svcnum($old->svcnum); + my $cust_svc = $old->cust_svc; + $new->svcpart($old->svcpart); + $new->pkgnuym($old->pkgnum); + $error = $new->replace($old); + } else { + my $conf = new FS::Conf; + $new->svcpart($conf->config('selfservice-svc_forward_svcpart')); + + 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; + } + + return { 'error' => $error }; + +} + sub list_dsl_devices { my $p = shift; @@ -1658,9 +1721,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 { @@ -1685,12 +1749,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; @@ -1700,7 +1778,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