stray closing /TABLE in the no-ticket case
[freeside.git] / httemplate / view / elements / svc_radius_usage.html
1 % if ( $part_svc->part_export_usage ) {
2 %
3 %  my $last_bill;
4 %  my %plandata;
5 %  if ( $cust_pkg ) {
6 %    #false laziness w/httemplate/edit/part_pkg... this stuff doesn't really
7 %    #belong in plan data
8 %    %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); }
9 %                    split("\n", $cust_pkg->part_pkg->plandata );
10 %
11 %    $last_bill = $cust_pkg->last_bill;
12 %  } else {
13 %    $last_bill = 0;
14 %    %plandata = ();
15 %  }
16 %
17 %  my $seconds = $svc->seconds_since_sqlradacct( $last_bill, time );
18 %  my $hour = int($seconds/3600);
19 %  my $min = int( ($seconds%3600) / 60 );
20 %  my $sec = $seconds%60;
21 %
22 %  my $input = $svc->attribute_since_sqlradacct(
23 %    $last_bill, time, 'AcctInputOctets'
24 %  ) / 1073741824;
25 %  my $output = $svc->attribute_since_sqlradacct(
26 %    $last_bill, time, 'AcctOutputOctets'
27 %  ) / 1073741824;
28 %
29 %  my $last_mac = $svc->attribute_last_sqlradacct( 'CallingStationId' );
30 %  if (     $last_mac =~ /^\s*(([\dA-F]{2}[\-:]){5}[\dA-F]{2})/i
31 %       and my $vendor = Net::MAC::Vendor::lookup($1)
32 %     )
33 %  {
34 %    $last_mac .= ' ('. $vendor->[0]. ')';
35 %  }
36
37
38   RADIUS session information<BR>
39   <% ntable('#cccccc',2) %>
40   <TR><TD BGCOLOR="#ffffff">
41 % if ( $seconds ) { 
42
43     Online <B><% $hour %></B>h <B><% $min %></B>m <B><% $sec %></B>s
44 % } else { 
45
46     Has not logged on
47 % } 
48 % if ( $cust_pkg ) { 
49
50     since last bill (<% time2str('%a %b %o %Y', $last_bill) %>)
51 % if ( length($plandata{recur_included_hours}) ) { 
52
53     - <% $plandata{recur_included_hours} %> total hours in plan
54 % } 
55
56     <BR>
57 % } else { 
58
59     (no billing cycle available for unaudited account)<BR>
60 % } 
61
62
63   Upload: <B><% sprintf("%.3f", $input) %></B> gigabytes<BR>
64   Download: <B><% sprintf("%.3f", $output) %></B> gigabytes<BR>
65 % if ( $svc->table eq 'svc_acct' ) {
66     Last Login: <B><% $svc->last_login_text %></B><BR>
67 % }
68 % if ( length($last_mac) ) {
69     Last Source or MAC: <B><% $last_mac %></B><BR>
70 % }
71 % my $href = qq!<A HREF="${p}search/sqlradius.cgi?svcnum=!. $svc->svcnum; 
72
73   View session detail:
74       <% $href %>;begin=<% $last_bill %>">this billing cycle</A>
75     | <% $href %>;begin=<% time-15552000 %>">past six months</A>
76     | <% $href %>">all sessions</A>
77
78   </TD></TR></TABLE><BR>
79 % } 
80 <%init>
81
82 my %opt = @_;
83
84 my $svc = $opt{'svc'};
85 my $part_svc = $opt{'part_svc'};
86 my $cust_pkg = $opt{'cust_pkg'};
87
88 </%init>