RT#29169: Show payment information in selfservice portal [merge for backport]
authorJonathan Prykop <jonathan@freeside.biz>
Fri, 12 Jun 2015 04:15:50 +0000 (23:15 -0500)
committerJonathan Prykop <jonathan@freeside.biz>
Tue, 16 Jun 2015 20:55:31 +0000 (15:55 -0500)
FS/FS/ClientAPI/MyAccount.pm
fs_selfservice/FS-SelfService/cgi/history.html [new file with mode: 0644]
fs_selfservice/FS-SelfService/cgi/myaccount_menu.html
fs_selfservice/FS-SelfService/cgi/selfservice.cgi

index b0ea736..4097ff8 100644 (file)
@@ -729,6 +729,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 (file)
index 0000000..00fdfa5
--- /dev/null
@@ -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 .= <<EOF;
+  <TR>
+    <TD style="$style background: $col;">$$item{'date_pretty'}</TD>
+    <TD style="$style background: $col;">$$item{'description'}</TD>
+    <TD style="$moneystyle background: $col;">$$item{'amount'}</TD>
+  </TR>
+EOF
+  $col = $col eq $col1 ? $col2 : $col1;
+}
+$balance = sprintf('%.2f',$balance);
+$balance =~ s/^(-?)/$1$money_char/;
+$out = <<EOF;
+<P>Balance: <B>$balance</B></P>
+<TABLE style="margin: 0;" CELLSPACING="0">
+  <TR>
+    <TH style="$style background: #ff9999;">Date</TH>
+    <TH style="$style background: #ff9999;">Description</TH>
+    <TH style="$moneystyle background: #ff9999;">Amount</TH>
+  </TR>
+$out
+</TABLE>
+EOF
+%>
+
+</TABLE>
+
+<%= include('footer') %>
index 999c62d..6a28d80 100644 (file)
@@ -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', }
index 1b728e2..2a8b2b6 100755 (executable)
@@ -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 = '.';
@@ -82,6 +83,7 @@ my @actions = ( qw(
   process_change_password
   customer_suspend_pkg
   process_suspend_pkg
+  history
 ));
 
 my @nologin_actions = (qw(
@@ -339,6 +341,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'} );