don't display a non-sensical duration for open sessions, RT#34966
[freeside.git] / fs_selfservice / FS-SelfService / cgi / view_usage_details.html
index 9067755..27afe12 100644 (file)
@@ -1,10 +1,10 @@
-<HTML><HEAD><TITLE>MyAccount</TITLE></HEAD>
-<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>MyAccount</FONT><BR><BR>
-<%= $url = "$selfurl?session=$session_id;action="; ''; %>
-<%= include('myaccount_menu') %>
-<TD VALIGN="top">
-
-<FONT SIZE=4>Service usage details</FONT><BR><BR>
+<%= $url = "$selfurl?;action="; ''; %>
+<%= include('header', 'Service usage details for '.
+                      Date::Format::time2str('%b&nbsp;%o&nbsp;%Y', $beginning).
+                      ' - '.
+                      Date::Format::time2str('%b&nbsp;%o&nbsp;%Y', $ending)
+           )
+%>
 
 <%= if ( $error ) {
   $OUT .= qq!<FONT SIZE="+1" COLOR="#ff0000">$error</FONT><BR><BR>!;
     <TH ALIGN="left">Account</TH>
     <TH ALIGN="right">Start Time</TH>
     <TH ALIGN="right">Duration</TH>
+    <TH ALIGN="right">Upload</TH>
+    <TH ALIGN="right">Download</TH>
   </TR>
 <%= my $total = 0;
+    my $utotal = 0;
+    my $dtotal = 0;
     foreach my $usage ( @usage ) {
   $OUT .= '<TR><TD>';
     $OUT .= $usage->{'username'};
     $OUT .= '</TD><TD ALIGN="right">';
     $OUT .= Date::Format::time2str('%T%P %a&nbsp;%b&nbsp;%o&nbsp;%Y', $usage->{'acctstarttime'});
     $OUT .= '</TD><TD ALIGN="right">';
-    my $duration =  $usage->{'acctstoptime'} - $usage->{'acctstarttime'};
+    my $duration = ( $usage->{'acctstoptime'} && $usage->{'acctstarttime'} )
+                     ? ( $usage->{'acctstoptime'} - $usage->{'acctstarttime'} )
+                     : 0;
     $total += $duration;
     my $h = int($duration/3600);
     my $m = sprintf("%02d", int(($duration % 3600) / 60));
     my $s = sprintf("%02d", $duration % 60);
     $OUT .=  "$h:$m:$s";
+    $OUT .= '</TD><TD ALIGN="right">';
+    $OUT .= Number::Format::format_bytes($usage->{'acctinputoctets'}, precision => 2);
+    $utotal += $usage->{'acctinputoctets'};
+    $OUT .= '</TD><TD ALIGN="right">';
+    $OUT .= Number::Format::format_bytes($usage->{'acctoutputoctets'}, precision => 2);
+    $dtotal += $usage->{'acctoutputoctets'};
   $OUT .= '</TD></TR>';
   }
   my $h = int($total/3600);
   my $m = sprintf("%02d", int(($total % 3600) / 60));
   my $s = sprintf("%02d", $total % 60);
-  $OUT .=  qq!<TR><TD></TD><TD></TD><TD ALIGN="right">========</TD></TR>!;
-  $OUT .=  qq!<TR><TD></TD><TD></TD><TD ALIGN="right">$h:$m:$s</TD></TR>!; %>
+  $OUT .=  qq!<TR><TD></TD><TD></TD>!;
+  $OUT .=  qq!<TD ALIGN="right"><HR></TD>! x 3;
+  $OUT .=  qq!</TR>!;
+  $OUT .=  qq!<TR><TD></TD><TD></TD><TD ALIGN="right">$h:$m:$s</TD>!;
+  $OUT .=  qq!<TD ALIGN="right">!;
+  $OUT .=  Number::Format::format_bytes($utotal, precision => 2). qq!</TD>!;
+  $OUT .=  qq!<TD ALIGN="right">!;
+  $OUT .=  Number::Format::format_bytes($dtotal, precision => 2). qq!</TD>!;
+  $OUT .=  qq!</TR>!; %>
 
 </TABLE>
 <BR>
 
-</TD></TR></TABLE>
-<HR>
-<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
-</BODY></HTML>
+<%= include('footer') %>