X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=fs_selfservice%2FFS-SelfService%2Fcgi%2Fview_usage.html;h=c43f7d3dafb31899ce216dd024cc51a8ca5c8be3;hb=d353c1f9bbfee93e96219851af27a78f56837c50;hp=fd5426a75251e70351e79e19aaa24477a2b56520;hpb=158103c8701d8cd87148c579dc101979c808b8c2;p=freeside.git
diff --git a/fs_selfservice/FS-SelfService/cgi/view_usage.html b/fs_selfservice/FS-SelfService/cgi/view_usage.html
index fd5426a75..c43f7d3da 100644
--- a/fs_selfservice/FS-SelfService/cgi/view_usage.html
+++ b/fs_selfservice/FS-SelfService/cgi/view_usage.html
@@ -1,10 +1,25 @@
-<%= $url = "$selfurl?session=$session_id;action=";
- @svc_acct = grep { $_->{svcdb} eq 'svc_acct' } @svcs;
- @svc_phone = grep { $_->{svcdb} eq 'svc_phone' } @svcs;
- @svc_port = grep { $_->{svcdb} eq 'svc_port' } @svcs;
+<%= $url = "$selfurl?action=";
+ %by_pkg_label = (); # not used yet, but I'm sure it will be...
+ @svc_acct = ();
+ @svc_phone = ();
+ @svc_port = ();
+
+ foreach (@svcs) {
+ $by_pkg_label{ $_->{pkg_label} } ||= [];
+ push @{ $by_pkg_label{ $_->{pkg_label} } }, $_;
+ if ( $_->{svcdb} eq 'svc_acct' ) {
+ push @svc_acct, $_;
+ } elsif ( $_->{svcdb} eq 'svc_phone' ) {
+ push @svc_phone, $_;
+ } elsif ( $_->{svcdb} eq 'svc_port' ) {
+ push @svc_port, $_;
+ }
+ }
'';
%>
<%= include('header', 'Account usage') %>
+<%= if( $hide_usage ){ $OUT .= '<' . '!--' } %>
+
<%= if ( $error ) {
$OUT .= qq!$error
!;
@@ -62,11 +77,22 @@
<%= scalar(@svc_acct) ? '
' : '' %>
<%= if ( @svc_phone ) {
+ %any = ();
+ for my $dir (qw(outbound inbound)) {
+ $any{$dir} = grep { $_->{$dir} } @svc_phone;
+ }
$OUT.= 'Call usage
-
+
- Number | '; #"Account" ?
- #what else?
+ Number | ';
+ if ( $any{outbound} ) {
+ $OUT .= '
+ Dialed | ';
+ }
+ if ( $any{inbound} ) {
+ $OUT .= '
+ Received | ';
+ }
$OUT .= '
';
} else {
$OUT .= '';
@@ -76,13 +102,65 @@
<%= foreach my $svc_phone ( @svc_phone ) {
my $link = "${url}view_cdr_details;".
"svcnum=$svc_phone->{'svcnum'};beginning=0;ending=0";
- $OUT .= '';
- $OUT .= qq!!. $svc_phone->{'label'}. ': '. $svc_phone->{'value'}.'';
- $OUT .= ' |
';
+ $OUT .= ''. $svc_phone->{'label'}. ': '. $svc_phone->{'value'};
+ $OUT .= ' | ';
+ # usage summary w/ links
+ for my $dir (qw(outbound inbound)) {
+ if ( $dir eq 'inbound' ) {
+ $link .= ';inbound=1';
+ }
+ if ( $svc_phone->{$dir} ) {
+ $OUT .= ''.qq!! .
+ sprintf('%d calls (%.0f minutes)',
+ $svc_phone->{$dir}->{'count'},
+ $svc_phone->{$dir}->{'duration'} / 60
+ ) .
+ ' | ';
+ } elsif ( $any{$dir} ) {
+ $OUT .= ' | ';
+ }
}
+ $OUT .= '
';
+}
+'';
%>
-<%= scalar(@svc_phone) ? '
' : '' %>
+<%= if ( @usage_pools ) {
+ $OUT .= '
+
+ Remaining minutes |
+ ';
+ my $any_shared = 0;
+ foreach my $usage (@usage_pools) {
+ # false laziness with the back office side
+ my ($description, $remain, $total, $shared) = @$usage;
+ if ( $shared ) {
+ $any_shared = 1;
+ $description .= '*';
+ }
+ my $ratio = 255 * ($remain/$total);
+ $ratio = 255 if $color > 255;
+ my $color =
+ sprintf('STYLE="font-weight: bold; color: #%02x%02x00"',
+ 255 - $ratio, $ratio);
+ $OUT .=
+ qq!
+ $description |
+ $remain |
+ / |
+ $total |
+
!;
+ }
+ if ( $any_shared ) {
+ $OUT .= ''.
+ '* shared among all your phone plans |
';
+ }
+}
+if ( scalar(@svc_phone) or scalar(@usage_pools) ) {
+ $OUT .= '
';
+}
+'';
+%>
<%= if ( @svc_port ) {
$OUT.= 'Bandwidth Graphs
@@ -120,8 +198,7 @@ foreach my $svc_port ( @svc_port ) {
$OUT .= ''. $svc_port->{'label'}. ': '. $svc_port->{'value'}.' | ';
$OUT .= qq! |
+<%= if( $hide_usage ){ $OUT .= '--'. '>' } %>
<%= include('footer') %>
+