From b09f61d517dc01dd2eae04b3e03a5b9e5dab1a0f Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Fri, 29 Jul 2016 23:53:35 -0500 Subject: RT#42724: Data Usage Report - System Error on Column Sort --- httemplate/search/sqlradius_usage.html | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'httemplate/search/sqlradius_usage.html') diff --git a/httemplate/search/sqlradius_usage.html b/httemplate/search/sqlradius_usage.html index b5551ade6..08f9b6ba1 100644 --- a/httemplate/search/sqlradius_usage.html +++ b/httemplate/search/sqlradius_usage.html @@ -39,6 +39,7 @@ @svc_fields, @svc_usage, ], + 'order_by_sql' => $order_by_sql, 'links' => [ #( map { $_ ne 'Cust. Status' ? $link_cust : '' } # FS::UI::Web::cust_header() ), $link_cust, @@ -257,7 +258,23 @@ sub bytes_to_gb { $_[0] ? sprintf('%.3f', $_[0] / (1024*1024*1024.0)) : ''; } -warn Dumper \%usage_by_username; +my $conf = new FS::Conf; +my $order_by_sql = { + 'name' => "CASE WHEN cust_main.company IS NOT NULL + AND cust_main.company != '' + THEN CONCAT(cust_main.company,' (',cust_main.last,', ',cust_main.first,')') + ELSE CONCAT(cust_main.last,', ',cust_main.first) + END", + 'display_custnum' => $conf->exists('cust_main-default_agent_custid') + ? "CASE WHEN cust_main.agent_custid IS NOT NULL + AND cust_main.agent_custid != '' + AND cust_main.agent_custid ". regexp_sql. " '^[0-9]+\$' + THEN CAST(cust_main.agent_custid AS BIGINT) + ELSE cust_main.custnum + END" + : "custnum", +}; +#warn Dumper \%usage_by_username; -- cgit v1.2.1