1 <& /elements/header-popup.html, mt($title) &>
3 <FORM ACTION="sqlradius_usage.html" METHOD="GET" TARGET="_top">
5 <& /elements/hidden.html,
9 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
11 % if ( scalar(@exports) == 1 ) {
13 <& /elements/hidden.html,
14 'field' => 'exportnum',
15 'value' => $exports[0]->exportnum,
19 <& /elements/tr-select-table.html,
20 'label' => 'Export', # kind of non-indicative...
21 'table' => 'part_export',
22 'name_col' => 'label',
23 'value_col' => 'exportnum',
24 'records' => \@exports,
29 <& /elements/tr-input-beginning_ending.html &>
31 <& /elements/tr-radio.html,
32 'field' => 'combine_svcs',
33 'options' => [ 0, 1 ],
35 'labels' => { 0 => 'Per service',
43 <INPUT TYPE="submit" VALUE="<% mt('Get Report') |h %>">
47 <& /elements/footer.html &>
50 my $curuser = $FS::CurrentUser::CurrentUser;
52 unless $curuser->access_right('Usage: RADIUS sessions');
55 my $title = 'Data Usage Report';
58 ($custnum) = $cgi->keywords;
60 $custnum = $cgi->param('custnum');
63 or die "illegal custnum $custnum";
64 my $cust_main = qsearchs( {
65 'table' => 'cust_main',
66 'hashref' => { 'custnum' => $custnum },
67 'extra_sql' => ' AND '. $curuser->agentnums_sql,
69 # get all exports that apply to this customer's services--should be fast, as
70 # everything here is indexed
71 my @exports = qsearch({
72 'table' => 'part_export',
73 'select' => 'DISTINCT part_export.*',
74 'addl_from' => ' JOIN export_svc USING (exportnum)
75 JOIN cust_svc USING (svcpart)
76 JOIN cust_pkg USING (pkgnum) ',
77 'extra_sql' => ' WHERE cust_pkg.custnum = '.$custnum,
79 @exports = grep { $_->can('usage_sessions') } @exports;