summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-09-06 11:47:02 -0700
committerMark Wells <mark@freeside.biz>2012-09-06 11:47:02 -0700
commitf8c8b9782ff5400790c2fb6dae017ce01790e56e (patch)
treeed4abe678b2ba0ebe5cc4289a2f76e0019943b40 /FS
parentb7ce9a95a6fa002d0d537c950f11f8a23d3dfc25 (diff)
separate all 477 reports by state, #18503
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/cust_pkg.pm37
1 files changed, 24 insertions, 13 deletions
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index ea29a2c68..c34eb43b5 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -3317,7 +3317,12 @@ specifies the user for agent virtualization
=item fcc_line
- boolean selects packages containing fcc form 477 telco lines
+boolean; if true, returns only packages with more than 0 FCC phone lines.
+
+=item state, country
+
+Limit to packages with a service location in the specified state and country.
+For FCC 477 reporting, mostly.
=back
@@ -3491,8 +3496,8 @@ sub search {
if ( exists($params->{'censustract'}) ) {
$params->{'censustract'} =~ /^([.\d]*)$/;
- my $censustract = "cust_main.censustract = '$1'";
- $censustract .= ' OR cust_main.censustract is NULL' unless $1;
+ my $censustract = "cust_location.censustract = '$1'";
+ $censustract .= ' OR cust_location.censustract is NULL' unless $1;
push @where, "( $censustract )";
}
@@ -3504,10 +3509,22 @@ sub search {
)
{
if ($1) {
- push @where, "cust_main.censustract LIKE '$1%'";
+ push @where, "cust_location.censustract LIKE '$1%'";
} else {
push @where,
- "( cust_main.censustract = '' OR cust_main.censustract IS NULL )";
+ "( cust_location.censustract = '' OR cust_location.censustract IS NULL )";
+ }
+ }
+
+ ###
+ # parse country/state
+ ###
+ for (qw(state country)) { # parsing rules are the same for these
+ if ( exists($params->{$_})
+ && uc($params->{$_}) =~ /^([A-Z]{2})$/ )
+ {
+ # XXX post-2.3 only--before that, state/country may be in cust_main
+ push @where, "cust_location.$_ = '$1'";
}
}
@@ -3635,7 +3652,8 @@ sub search {
my $addl_from = 'LEFT JOIN cust_main USING ( custnum ) '.
'LEFT JOIN part_pkg USING ( pkgpart ) '.
- 'LEFT JOIN pkg_class ON ( part_pkg.classnum = pkg_class.classnum ) ';
+ 'LEFT JOIN pkg_class ON ( part_pkg.classnum = pkg_class.classnum ) '.
+ 'LEFT JOIN cust_location USING ( locationnum ) ';
my $select;
my $count_query;
@@ -3644,13 +3662,6 @@ sub search {
$select = "DISTINCT substr($zip,1,5) as zip";
$orderby = "ORDER BY substr($zip,1,5)";
- $addl_from .= 'LEFT JOIN cust_location ON (
- cust_location.locationnum = COALESCE(
- cust_pkg.locationnum,
- cust_main.ship_locationnum,
- cust_main.bill_locationnum
- )
- )';
$count_query = "SELECT COUNT( DISTINCT substr($zip,1,5) )";
} else {
$select = join(', ',