show last Calling-Station-Id on RADIUS summary, RT#29154
[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 %  ) / 1048576;
25 %  my $output = $svc->attribute_since_sqlradacct(
26 %    $last_bill, time, 'AcctOutputOctets'
27 %  ) / 1048576;
28 %
29 %  my $last_mac = $svc->attribute_last_sqlradacct( 'CallingStationId' );
30 %  if ( $last_mac =~ /^\s*(([\dA-F]{2}[\-:]){5}[\dA-F]{2})/i ) {
31 %    $last_mac .= ' ('. (Net::MAC::Vendor::lookup($1))->[0]. ')';
32 %  }
33
34
35   RADIUS session information<BR>
36   <% ntable('#cccccc',2) %>
37   <TR><TD BGCOLOR="#ffffff">
38 % if ( $seconds ) { 
39
40     Online <B><% $hour %></B>h <B><% $min %></B>m <B><% $sec %></B>s
41 % } else { 
42
43     Has not logged on
44 % } 
45 % if ( $cust_pkg ) { 
46
47     since last bill (<% time2str('%a %b %o %Y', $last_bill) %>)
48 % if ( length($plandata{recur_included_hours}) ) { 
49
50     - <% $plandata{recur_included_hours} %> total hours in plan
51 % } 
52
53     <BR>
54 % } else { 
55
56     (no billing cycle available for unaudited account)<BR>
57 % } 
58
59
60   Upload: <B><% sprintf("%.3f", $input) %></B> megabytes<BR>
61   Download: <B><% sprintf("%.3f", $output) %></B> megabytes<BR>
62 % if ( $svc->table eq 'svc_acct' ) {
63     Last Login: <B><% $svc->last_login_text %></B><BR>
64 % }
65 % if ( length($last_mac) ) {
66     Last Source or MAC: <B><% $last_mac %></B><BR>
67 % }
68 % my $href = qq!<A HREF="${p}search/sqlradius.cgi?svcnum=!. $svc->svcnum; 
69
70   View session detail:
71       <% $href %>;begin=<% $last_bill %>">this billing cycle</A>
72     | <% $href %>;begin=<% time-15552000 %>">past six months</A>
73     | <% $href %>">all sessions</A>
74
75   </TD></TR></TABLE><BR>
76 % } 
77 <%init>
78
79 my %opt = @_;
80
81 my $svc = $opt{'svc'};
82 my $part_svc = $opt{'part_svc'};
83 my $cust_pkg = $opt{'cust_pkg'};
84
85 </%init>