From b2f5f42600f11ab24e5393353ed4c0de48816862 Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Thu, 11 Jun 2015 23:15:50 -0500 Subject: [PATCH] RT#29169: Show payment information in selfservice portal --- FS/FS/ClientAPI/MyAccount.pm | 1 + fs_selfservice/FS-SelfService/cgi/history.html | 39 ++++++++++++++++++++++ .../FS-SelfService/cgi/myaccount_menu.html | 4 +++ fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 6 ++++ 4 files changed, 50 insertions(+) create mode 100644 fs_selfservice/FS-SelfService/cgi/history.html diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index fa2b6ba8c..cb6ac02d8 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -740,6 +740,7 @@ sub billing_history { @history = sort { $b->{'date'} <=> $a->{'date'} } @history; $return{'history'} = \@history; + $return{'money_char'} = $conf->config("money_char") || '$', return \%return; diff --git a/fs_selfservice/FS-SelfService/cgi/history.html b/fs_selfservice/FS-SelfService/cgi/history.html new file mode 100644 index 000000000..00fdfa5ef --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/history.html @@ -0,0 +1,39 @@ +<%= include('header', 'Billing History') %> + +<%= +my $balance = 0; +my $style = 'text-align: left; margin: 0; padding: 0 1em 0 0;'; +my $moneystyle = 'text-align: right; margin: 0; padding: 0 1em 0 0;'; +my $col1 = "#ffffff"; +my $col2 = "#dddddd"; +my $col = $col1; +foreach my $item (@history) { + $balance += $$item{'amount'}; + $$item{'amount'} =~ s/^(-?)/$1$money_char/; + $out .= < + $$item{'date_pretty'} + $$item{'description'} + $$item{'amount'} + +EOF + $col = $col eq $col1 ? $col2 : $col1; +} +$balance = sprintf('%.2f',$balance); +$balance =~ s/^(-?)/$1$money_char/; +$out = <Balance: $balance

+ + + + + + +$out +
DateDescriptionAmount
+EOF +%> + + + +<%= include('footer') %> diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html b/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html index 999c62da0..6a28d804f 100644 --- a/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html +++ b/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html @@ -66,6 +66,10 @@ if ( ($balance || 0) > 0 ) { #XXXFIXME "enable selfservice prepay features" flag push @menu, { title=>' ' }; +push @menu, + { title=>'View Payment History', url=>'history', size=>'+1' }, +; + unless( $hide_usage ){ push @menu, { title=>'View my usage', url=>'view_usage', size=>'+1', } diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 0e60791ba..4c666cb14 100755 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -23,6 +23,7 @@ use FS::SelfService qw( mason_comp port_graph start_thirdparty finish_thirdparty reset_passwd check_reset_passwd process_reset_passwd + billing_history ); $template_dir = '.'; @@ -83,6 +84,7 @@ my @actions = ( qw( customer_suspend_pkg process_suspend_pkg switch_cust + history )); my @nologin_actions = (qw( @@ -353,6 +355,10 @@ sub invoices { list_invoices( 'session_id' => $session_id, ); } +sub history { + billing_history( 'session_id' => $session_id, ); +} + sub tktcreate { my $customer_info = customer_info( 'session_id' => $session_id ); return $customer_info if ( $customer_info->{'error'} ); -- 2.11.0