X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_main%2FPackages.pm;h=e9134021bfa44e15074ad3bf1ddd1ef9f03c74c1;hp=ee5bddaca7a81205871a122c4ebed9ca692d1428;hb=2801b7c172cddcab51101d933e57a956d450ace2;hpb=c541cb0f1ab12a904252bd6b2658dba585860f28 diff --git a/FS/FS/cust_main/Packages.pm b/FS/FS/cust_main/Packages.pm index ee5bddaca..e9134021b 100644 --- a/FS/FS/cust_main/Packages.pm +++ b/FS/FS/cust_main/Packages.pm @@ -748,6 +748,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); +} + =item display_recurring Returns an array of hash references, one for each recurring freq