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,
28 <& /elements/tr-input-beginning_ending.html &>
33 <INPUT TYPE="submit" VALUE="<% mt('Get Report') |h %>">
37 <& /elements/footer.html &>
40 my $curuser = $FS::CurrentUser::CurrentUser;
42 unless $curuser->access_right('Usage: RADIUS sessions');
45 my $title = 'Data Usage Report';
48 ($custnum) = $cgi->keywords;
50 $custnum = $cgi->param('custnum');
53 or die "illegal custnum $custnum";
54 my $cust_main = qsearchs( {
55 'table' => 'cust_main',
56 'hashref' => { 'custnum' => $custnum },
57 'extra_sql' => ' AND '. $curuser->agentnums_sql,
59 # get all exports that apply to this customer's services--should be fast, as
60 # everything here is indexed
61 my @exports = qsearch({
62 'table' => 'part_export',
63 'select' => 'DISTINCT part_export.*',
64 'addl_from' => ' JOIN export_svc USING (exportnum)
65 JOIN cust_svc USING (svcpart)
66 JOIN cust_pkg USING (pkgnum) ',
67 'extra_sql' => ' WHERE cust_pkg.custnum = '.$custnum,
69 @exports = grep { $_->can('usage_sessions') } @exports;