fix unapplied payment report, RT#73048, fallout from #25944
[freeside.git] / httemplate / search / report_sqlradius_usage-custnum.html
1 <& /elements/header-popup.html, mt($title) &>
2
3 <FORM ACTION="sqlradius_usage.html" METHOD="GET" TARGET="_top">
4
5 <& /elements/hidden.html,
6   'field' => 'custnum',
7   'value' => $custnum,
8 &>
9 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
10
11 % if ( scalar(@exports) == 1 ) {
12 <tr><td>
13 <& /elements/hidden.html,
14   'field'         => 'exportnum',
15   'value'         => $exports[0]->exportnum,
16 &>
17 </td></tr>
18 % } else {
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,
25   'disable_empty' => 1,
26 &>
27 % }
28 <& /elements/tr-input-beginning_ending.html &>
29
30 </TABLE>
31
32 <BR>
33 <INPUT TYPE="submit" VALUE="<% mt('Get Report') |h %>">
34
35 </FORM>
36
37 <& /elements/footer.html &>
38 <%init>
39
40 my $curuser = $FS::CurrentUser::CurrentUser;
41 die "access denied"
42   unless $curuser->access_right('Usage: RADIUS sessions');
43   # yes?
44
45 my $title = 'Data Usage Report';
46 my $custnum;
47 if ($cgi->keywords) {
48   ($custnum) = $cgi->keywords;
49 } else {
50   $custnum = $cgi->param('custnum');
51 }
52 $custnum =~ /^(\d+)$/
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,
58 });
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,
68 });
69 @exports = grep { $_->can('usage_sessions') } @exports;
70
71 </%init>