X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=fs_selfservice%2FFS-SelfService%2Fcgi%2Fview_usage.html;h=4099a57f514fcb8bb9a41e5d4d73ac07b55c01b2;hb=0592d8e1ad7c8cab286b43743765fd1435cfac84;hp=f7076684ecf2d0c541658e99ec6e050510b91eb1;hpb=db5e7f34b1e17ae6ce8909062537cc2fb98ca30d;p=freeside.git diff --git a/fs_selfservice/FS-SelfService/cgi/view_usage.html b/fs_selfservice/FS-SelfService/cgi/view_usage.html index f7076684e..4099a57f5 100644 --- a/fs_selfservice/FS-SelfService/cgi/view_usage.html +++ b/fs_selfservice/FS-SelfService/cgi/view_usage.html @@ -1,7 +1,23 @@ -<%= $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 = (); + @svc_pbx = (); + + 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, $_; + } elsif ( $_->{svcdb} eq 'svc_pbx' ) { + push @svc_pbx, $_; + } + } ''; %> <%= include('header', 'Account usage') %> @@ -61,13 +77,13 @@ <%= scalar(@svc_acct) ? '

' : '' %> -<%= 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

- +
'; if ( $any{outbound} ) { @@ -84,21 +100,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} ) { @@ -110,7 +127,42 @@ ''; %> -<%= scalar(@svc_phone) ? '
Number
'. $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 ) . '


' : '' %> +<%= if ( @usage_pools ) { + $OUT .= ' + + + '; + 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

@@ -148,8 +200,7 @@ foreach my $svc_port ( @svc_port ) { $OUT .= ''. $svc_port->{'label'}. ': '. $svc_port->{'value'}.''; $OUT .= qq!
- - !; + !; $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) @@ -170,3 +221,4 @@ foreach my $svc_port ( @svc_port ) { <%= include('footer') %> +