X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=fs_selfservice%2FFS-SelfService%2Fcgi%2Fview_usage.html;h=c43f7d3dafb31899ce216dd024cc51a8ca5c8be3;hp=b78f9975b3e29ffed5218d9e9c75b9d2c35323e4;hb=3a7f3a2e81cc7423ba9a08fd4b28b3b5f4f227a2;hpb=8e219ac3d60ba254c9bbc40adfeb2ebe40fd2b5f diff --git a/fs_selfservice/FS-SelfService/cgi/view_usage.html b/fs_selfservice/FS-SelfService/cgi/view_usage.html index b78f9975b..c43f7d3da 100644 --- a/fs_selfservice/FS-SelfService/cgi/view_usage.html +++ b/fs_selfservice/FS-SelfService/cgi/view_usage.html @@ -1,28 +1,51 @@ -MyAccount -MyAccount

-<%= $url = "$selfurl?session=$session_id;action="; ''; %> -<%= include('myaccount_menu') %> - +<%= $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 .= '<' . '!--' } %> -Service usage

<%= if ( $error ) { $OUT .= qq!$error

!; } ''; %> - - - - - - - - -<%= foreach my $svc ( @svcs ) { +<%= if ( @svc_acct ) { + $OUT.= '
AccountTime remainingUpload remainingDownload remainingTotal remaining
+ + + + + + + '; + } else { + $OUT .= ''; + } +%> + +<%= foreach my $svc ( @svc_acct ) { 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 .= ''; } - } %> + } +%> -
AccountTime remainingUpload remainingDownload remainingTotal remaining
'; - $OUT .= qq!!. $svc->{'label'}. ': '. $svc->{'value'}.''; + $OUT .= qq!!. $svc->{'label'}. ': '. $username .''; $OUT .= ''; $OUT .= $svc->{'seconds'}; $OUT .= ''; @@ -48,11 +71,153 @@ $OUT .= $svc->{'recharge_totalbytes'} if $svc->{'recharge_totalbytes'}; $OUT .= '
-
+<%= scalar(@svc_acct) ? '

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

+ + + '; + if ( $any{outbound} ) { + $OUT .= ' + '; + } + if ( $any{inbound} ) { + $OUT .= ' + '; + } + $OUT .= ''; + } else { + $OUT .= ''; + } +%> + +<%= 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} ) { + $OUT .= ''; + } elsif ( $any{$dir} ) { + $OUT .= ''; + } + } + $OUT .= ''; +} +''; +%> + +<%= if ( @usage_pools ) { + $OUT .= '
NumberDialedReceived
'. $svc_phone->{'label'}. ': '. $svc_phone->{'value'}; + $OUT .= ''.qq!! . + sprintf('%d calls (%.0f minutes)', + $svc_phone->{$dir}->{'count'}, + $svc_phone->{$dir}->{'duration'} / 60 + ) . + '
+ + + '; + 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! + + + + + !; + } + if ( $any_shared ) { + $OUT .= ''. + ''; + } +} +if ( scalar(@svc_phone) or scalar(@usage_pools) ) { + $OUT .= '
Remaining minutes
$description$remain / $total
* shared among all your phone plans


'; +} +''; +%> +<%= if ( @svc_port ) { + $OUT.= 'Bandwidth Graphs

+ + + + + + '; + } + $OUT .= ''; +%> + +<%= + +sub preset_range { + my($start,$end,$label,$date_format,$prefix) = (shift,shift,shift,shift,shift); + $start = Date::Format::time2str($date_format,$start); + $end = Date::Format::time2str($date_format,$end); + return ''.$label.''; +} + +foreach my $svc_port ( @svc_port ) { + $svcnum = $svc_port->{'svcnum'}; + $default_end = time; + $default_start = $default_end-86400; + + $OUT .= ''; + $OUT .= qq! '; +} +%> + +<%= scalar(@svc_port) ? '
Service +
'. $svc_port->{'label'}. ': '. $svc_port->{'value'}.'
+ + !; + $OUT .= preset_range($default_start,$default_end,'Last Day',$date_format,$svcnum) + .' | '.preset_range($default_end-86400*7,$default_end,'Last Week',$date_format,$svcnum) + .' | '.preset_range($default_end-86400*30,$default_end,'Last Month',$date_format,$svcnum) + .' | '.preset_range($default_end-86400*365,$default_end,'Last Year',$date_format,$svcnum); + + $OUT .= qq!
+ Start Date + End Date +
+ !; + + $OUT .= '


' : '' %> + + + +<%= if( $hide_usage ){ $OUT .= '--'. '>' } %> <%= include('footer') %> +