- my $match = '';
- if (1) { #employee commission reports
- $match = 'cust_pkg.usernum = access_user.usernum';
- } elsif (0) { #agent commission reports
- $match = 'cust_main.agentnum = agent.agentnum';
- }
-
- my $from_cust_bill_pkg_where = "FROM cust_bill_pkg
- LEFT JOIN ( cust_bill ) USING ( invnum )
- LEFT JOIN ( cust_pkg ) USING ( pkgnum )
- WHERE cust_bill_pkg.pkgnum > 0
- AND cust_bill._date >= $beginning
- AND cust_bill._date <= $ending ";
- my $and = " AND $match
- AND cust_pkg.pkgpart = part_pkg.pkgpart";
-
- push @where, "EXISTS( SELECT 1 $from_cust_bill_pkg_where $and )";
+ push @where, " cust_bill_pkg.pkgnum > 0 ",
+ " cust_bill._date >= $beginning ",
+ " cust_bill._date <= $ending ";