X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=fs_selfservice%2FFS-SelfService%2Fcgi%2Fview_usage.html;h=07ccfedf1f2df82a03ab03998675697c03ab29b4;hp=c43f7d3dafb31899ce216dd024cc51a8ca5c8be3;hb=36245fa05ae5d9fb0ef893cdfe5ad98f88fd7e77;hpb=3a7f3a2e81cc7423ba9a08fd4b28b3b5f4f227a2 diff --git a/fs_selfservice/FS-SelfService/cgi/view_usage.html b/fs_selfservice/FS-SelfService/cgi/view_usage.html index c43f7d3da..07ccfedf1 100644 --- a/fs_selfservice/FS-SelfService/cgi/view_usage.html +++ b/fs_selfservice/FS-SelfService/cgi/view_usage.html @@ -1,85 +1,88 @@ <%= $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, $_; + @svc_pbx = (); + @bytes_svcs = (); # contains svc_acct and svc_broadband + @bytes_cols = qw(seconds_used seconds upbytes_used upbytes downbytes_used downbytes totalbytes_used totalbytes); + %bytes_show = map { $_ => 0 } @bytes_cols; + + foreach my $svc (@svcs) { + $by_pkg_label{ $svc->{pkg_label} } ||= []; + push @{ $by_pkg_label{ $svc->{pkg_label} } }, $svc; + + if (( $svc->{svcdb} eq 'svc_acct' ) || ( $svc->{svcdb} eq 'svc_broadband' )) { + foreach my $field (@bytes_cols) { + $bytes_show{$field} = 1 if length($svc->{$field}) or (($field !~ /_used$/) && $svc->{'recharge_'.$field}); + } + push @bytes_svcs, $svc; + } elsif ( $svc->{svcdb} eq 'svc_phone' ) { + push @svc_phone, $svc; + } elsif ( $svc->{svcdb} eq 'svc_port' ) { + push @svc_port, $svc; + } elsif ( $svc->{svcdb} eq 'svc_pbx' ) { + push @svc_pbx, $svc; } } ''; %> <%= include('header', 'Account usage') %> -<%= if( $hide_usage ){ $OUT .= '<' . '!--' } %> - <%= if ( $error ) { $OUT .= qq!$error

!; } ''; %> -<%= if ( @svc_acct ) { - $OUT.= ' - - - - - - - '; - } else { - $OUT .= ''; +<%= if ( @bytes_svcs ) { + $OUT .= '
AccountTime remainingUpload remainingDownload remainingTotal remaining
'; + $OUT .= ''; + $OUT .= '' if $bytes_show{'seconds_used'}; + $OUT .= '' if $bytes_show{'seconds'}; + $OUT .= '' if $bytes_show{'upbytes_used'}; + $OUT .= '' if $bytes_show{'upbytes'}; + $OUT .= '' if $bytes_show{'downbytes_used'}; + $OUT .= '' if $bytes_show{'downbytes'}; + $OUT .= '' if $bytes_show{'totalbytes_used'}; + $OUT .= '' if $bytes_show{'totalbytes'}; + $OUT .= ''; } %> -<%= foreach my $svc ( @svc_acct ) { - my $link = "${url}view_usage_details;". - "svcnum=$svc->{'svcnum'};beginning=0;ending=0"; +<%= foreach my $svc ( @bytes_svcs ) { + my $link = "${url}view_usage_details;". + "svcnum=$svc->{'svcnum'};beginning=0;ending=0"; my $username = $svc->{'value'}; $username =~ s/@.*?$//g if $view_usage_nodomain; - $OUT .= ''; + $OUT .= ''; + $OUT .= ''; + foreach my $field (@bytes_cols) { + $OUT .= '' if $bytes_show{$field}; + } if ( $svc->{'recharge_amount'} ) { my $link = "${url}process_order_recharge;". "svcnum=$svc->{'svcnum'}"; - $OUT .= ''; + $OUT .= ''; + foreach my $field ( qw(seconds upbytes downbytes totalbytes) ) { + $OUT .= '' if $bytes_show{$field.'_used'}; + if ($bytes_show{$field}) { + $OUT .= ''; + } + } + $OUT .= ''; } } %> -<%= scalar(@svc_acct) ? '
AccountTime usedTime remainingUpload usedUpload remainingDownload usedDownload remainingTotal usedTotal remaining
'; - $OUT .= qq!!. $svc->{'label'}. ': '. $username .''; - $OUT .= ''; - $OUT .= $svc->{'seconds'}; - $OUT .= ''; - $OUT .= $svc->{'upbytes'}; - $OUT .= ''; - $OUT .= $svc->{'downbytes'}; - $OUT .= ''; - $OUT .= $svc->{'totalbytes'}; - $OUT .= '
' . qq!!. $svc->{'label'}. ': '. $username .'' . $svc->{$field} . '
'; + $OUT .= '
'; $OUT .= qq!!.'Recharge for $'; $OUT .= $svc->{'recharge_amount'} . ' with'; - $OUT .= ''; - $OUT .= $svc->{'recharge_seconds'} if $svc->{'recharge_seconds'}; - $OUT .= ''; - $OUT .= $svc->{'recharge_upbytes'} if $svc->{'recharge_upbytes'}; - $OUT .= ''; - $OUT .= $svc->{'recharge_downbytes'} if $svc->{'recharge_downbytes'}; - $OUT .= ''; - $OUT .= $svc->{'recharge_totalbytes'} if $svc->{'recharge_totalbytes'}; - $OUT .= '
'; + $OUT .= $svc->{'recharge_'.$field} if $svc->{'recharge_'.$field}; + $OUT .= '


' : '' %> +<%= scalar(@bytes_svcs) ? '

' : '' %> -<%= if ( @svc_phone ) { +<%= if ( @svc_phone or @svc_pbx ) { %any = (); for my $dir (qw(outbound inbound)) { - $any{$dir} = grep { $_->{$dir} } @svc_phone; + $any{$dir} = grep { $_->{$dir} } (@svc_phone, @svc_pbx); } $OUT.= 'Call usage

@@ -99,21 +102,22 @@ } %> -<%= foreach my $svc_phone ( @svc_phone ) { - my $link = "${url}view_cdr_details;". - "svcnum=$svc_phone->{'svcnum'};beginning=0;ending=0"; - $OUT .= ''; # usage summary w/ links for my $dir (qw(outbound inbound)) { if ( $dir eq 'inbound' ) { $link .= ';inbound=1'; } - if ( $svc_phone->{$dir} ) { + if ( $svc_x->{$dir} ) { $OUT .= ''; } elsif ( $any{$dir} ) { @@ -156,7 +160,7 @@ ''; } } -if ( scalar(@svc_phone) or scalar(@usage_pools) ) { +if ( @svc_phone or @svc_pbx or @usage_pools ) { $OUT .= '
'. $svc_phone->{'label'}. ': '. $svc_phone->{'value'}; +<%= foreach my $svc_x ( @svc_phone, @svc_pbx ) { + my $link = $url . 'view_cdr_details;' . + 'svcnum='.$svc_x->{'svcnum'}. + ';beginning=0;ending=0'; + $OUT .= '
'. $svc_x->{'label'}. ': '. $svc_x->{'value'}; $OUT .= ''.qq!! . sprintf('%d calls (%.0f minutes)', - $svc_phone->{$dir}->{'count'}, - $svc_phone->{$dir}->{'duration'} / 60 + $svc_x->{$dir}->{'count'}, + $svc_x->{$dir}->{'duration'} / 60 ) . '* shared among all your phone plans


'; } ''; @@ -218,6 +222,5 @@ foreach my $svc_port ( @svc_port ) { -<%= if( $hide_usage ){ $OUT .= '--'. '>' } %> <%= include('footer') %>