summaryrefslogtreecommitdiff
path: root/httemplate/search/report_sqlradius_usage-custnum.html
blob: 276deaa0bb19ac41351d85e4d17e81a5ad928644 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<& /elements/header-popup.html, mt($title) &>

<FORM ACTION="sqlradius_usage.html" METHOD="GET" TARGET="_top">

<& /elements/hidden.html,
  'field' => 'custnum',
  'value' => $custnum,
&>
<TABLE BGCOLOR="#cccccc" CELLSPACING=0>

% if ( scalar(@exports) == 1 ) {
<tr><td>
<& /elements/hidden.html,
  'field'         => 'exportnum',
  'value'         => $exports[0]->exportnum,
&>
</td></tr>
% } else {
<& /elements/tr-select-table.html,
  'label'         => 'Export', # kind of non-indicative...
  'table'         => 'part_export',
  'name_col'      => 'label',
  'value_col'     => 'exportnum',
  'records'       => \@exports,
  'multiple'      => 1,
&>
% }

<& /elements/tr-input-beginning_ending.html &>

<& /elements/tr-radio.html,
  'field'         => 'combine_svcs',
  'options'       => [ 0, 1 ],
  'curr_value'    => 0,
  'labels'        => { 0 => 'Per service',
                       1 => 'Per package',
                     },
&>

</TABLE>

<BR>
<INPUT TYPE="submit" VALUE="<% mt('Get Report') |h %>">

</FORM>

<& /elements/footer.html &>
<%init>

my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied"
  unless $curuser->access_right('Usage: RADIUS sessions');
  # yes?

my $title = 'Data Usage Report';
my $custnum;
if ($cgi->keywords) {
  ($custnum) = $cgi->keywords;
} else {
  $custnum = $cgi->param('custnum');
}
$custnum =~ /^(\d+)$/
  or die "illegal custnum $custnum";
my $cust_main = qsearchs( {
  'table'     => 'cust_main',
  'hashref'   => { 'custnum' => $custnum },
  'extra_sql' => ' AND '. $curuser->agentnums_sql,
});
# get all exports that apply to this customer's services--should be fast, as
# everything here is indexed
my @exports = qsearch({
  'table'     => 'part_export',
  'select'    => 'DISTINCT part_export.*',
  'addl_from' => ' JOIN export_svc USING (exportnum)
                   JOIN cust_svc USING (svcpart)
                   JOIN cust_pkg USING (pkgnum) ',
  'extra_sql' => ' WHERE cust_pkg.custnum = '.$custnum,
});
@exports = grep { $_->can('usage_sessions') } @exports;

</%init>