[freeside-commits] branch master updated. c66b912fd7f13f5fb0f2cc433f22b78d3ec5b56b

Jonathan Prykop jonathan at 420.am
Thu Jun 9 21:51:10 PDT 2016


The branch, master has been updated
       via  c66b912fd7f13f5fb0f2cc433f22b78d3ec5b56b (commit)
      from  7ff5165def7e86bd475d76e9d7c12e33516311e4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c66b912fd7f13f5fb0f2cc433f22b78d3ec5b56b
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Thu Jun 9 23:50:43 2016 -0500

    RT#42297: Show total usage on Selfservice View my usage page

diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 9863065..531b2e2 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -1835,6 +1835,7 @@ sub list_svcs {
   #              @svc_x;
 
   my @svcs; # stuff to return to the client
+  my %bytes_used_total; # for _used columns only
   foreach my $cust_svc (@cust_svc) {
     my $svc_x = $cust_svc->svc_x;
     my($label, $value) = $cust_svc->label;
@@ -1868,6 +1869,10 @@ sub list_svcs {
         'downbytes_used'  => display_bytecount($down_used),
         'totalbytes_used' => display_bytecount($up_used + $down_used)
       );
+      $bytes_used_total{'seconds_used'} += $hash{'seconds_used'};
+      $bytes_used_total{'upbytes_used'} += $up_used;
+      $bytes_used_total{'downbytes_used'} += $down_used;
+      $bytes_used_total{'totalbytes_used'} += $up_used + $down_used;
     }
 
     if ( $svcdb eq 'svc_acct' ) {
@@ -1942,12 +1947,19 @@ sub list_svcs {
     push @svcs, \%hash;
   } # foreach $cust_svc
 
+  foreach my $field (keys %bytes_used_total) {
+    if ($field =~ /bytes/) {
+      $bytes_used_total{$field} = display_bytecount($bytes_used_total{$field});
+    }
+  }
+
   return { 
     'svcnum'   => $session->{'svcnum'},
     'custnum'  => $custnum,
     'date_format' => $conf->config('date_format') || '%m/%d/%Y',
     'view_usage_nodomain' => $conf->exists('selfservice-view_usage_nodomain'),
     'svcs'     => \@svcs,
+    'bytes_used_total' => \%bytes_used_total,
     'usage_pools' => [
       map { $usage_pools{$_} }
       sort { $a cmp $b }
diff --git a/fs_selfservice/FS-SelfService/cgi/view_usage.html b/fs_selfservice/FS-SelfService/cgi/view_usage.html
index 07ccfed..2b9eb8b 100644
--- a/fs_selfservice/FS-SelfService/cgi/view_usage.html
+++ b/fs_selfservice/FS-SelfService/cgi/view_usage.html
@@ -75,6 +75,18 @@
       $OUT .= '</TR>';
     }
   }
+  if ((@bytes_svcs > 1) and (grep { $bytes_show{$_.'_used'} } qw(seconds upbytes downbytes totalbytes) )) {
+    $OUT .= '<TR>';
+    $OUT .= '<TH align="left">Total Used</TH>';
+    foreach my $field (@bytes_cols) {
+      if ($bytes_show{$field}) {
+        $OUT .= '<TD ALIGN="right">';
+        $OUT .= $bytes_used_total{$field} || '0' if $field =~ /_used$/;
+        $OUT .= '</TD>';
+      }
+    }
+    $OUT .= '</TR>';
+  }    
 %>
 
 <%= scalar(@bytes_svcs) ? '</TABLE><BR><BR>' : '' %>

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/ClientAPI/MyAccount.pm                      |   12 ++++++++++++
 fs_selfservice/FS-SelfService/cgi/view_usage.html |   12 ++++++++++++
 2 files changed, 24 insertions(+)




More information about the freeside-commits mailing list