[freeside-commits] freeside/httemplate/search part_pkg.html, 1.4, 1.5
Ivan,,,
ivan at wavetail.420.am
Tue Jun 28 22:19:05 PDT 2011
Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail.420.am:/tmp/cvs-serv28669
Modified Files:
part_pkg.html
Log Message:
optimize employee commission report, RT#13390
Index: part_pkg.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/part_pkg.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -d -r1.4 -r1.5
--- part_pkg.html 29 Jun 2011 04:31:18 -0000 1.4
+++ part_pkg.html 29 Jun 2011 05:19:03 -0000 1.5
@@ -45,8 +45,9 @@
if (1) { #employee commission reports
- $group_by = join(', ', ( map "access_user.$_", qw( usernum username ) ),
- ( map "part_pkg.$_", qw( pkgpart pkg comment ) ),
+ $group_by = join(', ',
+ ( map "access_user.$_", qw( usernum username ) ),
+ ( map "part_pkg.$_", qw( pkgpart pkg comment plan ) ),
);
$select = $group_by;
@@ -123,11 +124,9 @@
my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
- my $where = "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, " cust_bill_pkg.pkgnum > 0 ",
+ " cust_bill._date >= $beginning ",
+ " cust_bill._date <= $ending ";
push @header, '#'; # of sales';
push @links, ''; #link to detail report
@@ -148,7 +147,8 @@
" FROM cust_bill_pkg
LEFT JOIN cust_pkg USING ( pkgnum )
LEFT JOIN cust_bill USING ( invnum )
- $where AND pkgpart = ? AND ";
+ WHERE ". join(' AND ', @where).
+ " AND pkgpart = ? AND ";
my @arg = ($part_pkg->pkgpart);
if (1) { #employee commission reports
$sql .= 'usernum = ?';
@@ -208,6 +208,8 @@
$extra_sql .= "GROUP BY $group_by" if $group_by;
my $order_by = join(', ', @order_by);
-my $count_query = "SELECT COUNT(*) FROM part_pkg $addl_from $extra_sql";
+#XXX agent?
+my $count_query = "SELECT COUNT(*) FROM ( SELECT 1 FROM part_pkg $addl_from $extra_sql ) AS num";
+warn $count_query;
</%init>
More information about the freeside-commits
mailing list