X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=fs_selfservice%2FFS-SelfService%2Fcgi%2Fview_usage.html;h=2b9eb8bc2c58faf889c7f4adec1efe522f0ef10c;hb=877a4eb85cb847bd314d6a9192fedb1dc35c5d02;hp=b78f9975b3e29ffed5218d9e9c75b9d2c35323e4;hpb=8e219ac3d60ba254c9bbc40adfeb2ebe40fd2b5f;p=freeside.git diff --git a/fs_selfservice/FS-SelfService/cgi/view_usage.html b/fs_selfservice/FS-SelfService/cgi/view_usage.html index b78f9975b..2b9eb8bc2 100644 --- a/fs_selfservice/FS-SelfService/cgi/view_usage.html +++ b/fs_selfservice/FS-SelfService/cgi/view_usage.html @@ -1,58 +1,238 @@ -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_phone = (); + @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; -Service usage

+ 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 ( $error ) { $OUT .= qq!$error

!; } ''; %> - - - - - - - - -<%= foreach my $svc ( @svcs ) { - my $link = "${url}view_usage_details;". - "svcnum=$svc->{'svcnum'};beginning=0;ending=0"; - $OUT .= ''; +<%= if ( @bytes_svcs ) { + $OUT .= '
AccountTime remainingUpload remainingDownload remainingTotal remaining
'; - $OUT .= qq!!. $svc->{'label'}. ': '. $svc->{'value'}.''; - $OUT .= ''; - $OUT .= $svc->{'seconds'}; - $OUT .= ''; - $OUT .= $svc->{'upbytes'}; - $OUT .= ''; - $OUT .= $svc->{'downbytes'}; - $OUT .= ''; - $OUT .= $svc->{'totalbytes'}; - $OUT .= '
'; + $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 ( @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 .= ''; + 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 .= ''; + } + } + if ((@bytes_svcs > 1) and (grep { $bytes_show{$_.'_used'} } qw(seconds upbytes downbytes totalbytes) )) { + $OUT .= ''; + $OUT .= ''; + foreach my $field (@bytes_cols) { + if ($bytes_show{$field}) { + $OUT .= ''; + } } - } %> + $OUT .= ''; + } +%> -
AccountTime usedTime remainingUpload usedUpload remainingDownload usedDownload remainingTotal usedTotal remaining
' . 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 .= '
Total Used'; + $OUT .= $bytes_used_total{$field} || '0' if $field =~ /_used$/; + $OUT .= '
-
+<%= scalar(@bytes_svcs) ? '

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

+ + + '; + if ( $any{outbound} ) { + $OUT .= ' + '; + } + if ( $any{inbound} ) { + $OUT .= ' + '; + } + $OUT .= ''; + } else { + $OUT .= ''; + } +%> + +<%= foreach my $svc_x ( @svc_phone, @svc_pbx ) { + my $link = $url . 'view_cdr_details;' . + 'svcnum='.$svc_x->{'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_x->{$dir} ) { + $OUT .= ''; + } elsif ( $any{$dir} ) { + $OUT .= ''; + } + } + $OUT .= ''; +} +''; +%> +<%= if ( @usage_pools ) { + $OUT .= '
NumberDialedReceived
'. $svc_x->{'label'}. ': '. $svc_x->{'value'}; + $OUT .= ''.qq!! . + sprintf('%d calls (%.0f minutes)', + $svc_x->{$dir}->{'count'}, + $svc_x->{$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 ( @svc_phone or @svc_pbx or @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 .= '


' : '' %> + + + <%= include('footer') %> +