From 4e2e2afe2b9d54e971f433350f215df156e64f60 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Tue, 26 Jul 2016 11:49:18 -0700 Subject: per-customer RADIUS data usage report, #42310 --- .../search/report_sqlradius_usage-custnum.html | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 httemplate/search/report_sqlradius_usage-custnum.html (limited to 'httemplate/search/report_sqlradius_usage-custnum.html') diff --git a/httemplate/search/report_sqlradius_usage-custnum.html b/httemplate/search/report_sqlradius_usage-custnum.html new file mode 100644 index 000000000..a71012dd4 --- /dev/null +++ b/httemplate/search/report_sqlradius_usage-custnum.html @@ -0,0 +1,71 @@ +<& /elements/header-popup.html, mt($title) &> + +
+ +<& /elements/hidden.html, + 'field' => 'custnum', + 'value' => $custnum, +&> + + +% if ( scalar(@exports) == 1 ) { + +% } else { +<& /elements/tr-select-table.html, + 'label' => 'Export', # kind of non-indicative... + 'table' => 'part_export', + 'name_col' => 'label', + 'value_col' => 'exportnum', + 'records' => \@exports, + 'disable_empty' => 1, +&> +% } +<& /elements/tr-input-beginning_ending.html &> + +
+<& /elements/hidden.html, + 'field' => 'exportnum', + 'value' => $exports[0]->exportnum, +&> +
+ +
+ + +
+ +<& /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; + + -- cgit v1.2.1