diff options
author | Mark Wells <mark@freeside.biz> | 2016-08-22 13:41:13 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2016-08-22 14:21:23 -0700 |
commit | 500e5a534592469550f36f8b830e5ece1341d05d (patch) | |
tree | 61d8db125836be1819a7d27cf5e7d067a25b85e4 /FS | |
parent | 3348a49e629d38a680b87d82a09babda1dfaf06f (diff) |
show data usage report link only for customers that might have data usage, #42310
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/cust_main/Packages.pm | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/FS/FS/cust_main/Packages.pm b/FS/FS/cust_main/Packages.pm index 745d547ff..ca6a9652e 100644 --- a/FS/FS/cust_main/Packages.pm +++ b/FS/FS/cust_main/Packages.pm @@ -764,6 +764,28 @@ sub num_pkgs { $sth->fetchrow_arrayref->[0]; } +=item num_usage_pkgs + +Returns the number of packages for this customer that have services that +can have RADIUS usage statistics. + +=cut + +sub num_usage_pkgs { + my $self = shift; + # have to enumerate exportnums but it's not bad + my @exportnums = map { $_->exportnum } + grep { $_->can('usage_sessions') } + qsearch('part_export'); + return 0 if !@exportnums; + my $in_exportnums = join(',', @exportnums); + my $sql = "SELECT COUNT(DISTINCT pkgnum) FROM cust_pkg + JOIN cust_svc USING (pkgnum) + JOIN export_svc USING (svcpart) + WHERE exportnum IN( $in_exportnums ) AND custnum = ?"; + FS::Record->scalar_sql($sql, $self->custnum); +} + =back =head1 BUGS |