From: ivan Date: Sat, 18 Feb 2012 04:32:28 +0000 (+0000) Subject: fix per-user commission reports to filter packages they didn't order, RT#15634 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=054d386242314b406e6bb2c69f2a62524c1a381b fix per-user commission reports to filter packages they didn't order, RT#15634 --- diff --git a/httemplate/search/part_pkg.html b/httemplate/search/part_pkg.html index 8d06ebd02..8a4419857 100644 --- a/httemplate/search/part_pkg.html +++ b/httemplate/search/part_pkg.html @@ -1,18 +1,19 @@ <% include( 'elements/search.html', - 'title' => $title, - 'name' => $name, - 'header' => \@header, - 'query' => { 'select' => $select, - 'table' => 'part_pkg', - 'addl_from' => $addl_from, - 'hashref' => {}, - 'extra_sql' => $extra_sql, - 'order_by' => "ORDER BY $order_by", - }, - 'count_query' => $count_query, - 'fields' => \@fields, - 'links' => \@links, - 'align' => $align, + 'title' => $title, + 'name_singular' => $name, + 'header' => \@header, + 'query' => { 'select' => $select, + 'table' => 'part_pkg', + 'addl_from' => $addl_from, + 'hashref' => {}, + 'extra_sql' => $extra_sql, + 'order_by' => "ORDER BY $order_by", + }, + 'count_query' => $count_query, + 'fields' => \@fields, + 'links' => \@links, + 'align' => $align, + 'sort_fields' => [], ) %> <%init> @@ -64,6 +65,8 @@ if (1) { #commission reports $title = $access_user->name; + $match = 'cust_pkg.usernum = '. $access_user->usernum; + } else { push @header, 'Employee'; @@ -187,7 +190,7 @@ if (1) { #commission reports my $access_user = qsearchs('access_user', { 'usernum' => $part_pkg->get('usernum'), }) or die "unknown usernum"; - return 0 unless $access_user->user_custnum; + return $money_char.'0.00' unless $access_user->user_custnum; push @arg, $access_user->user_custnum; } elsif (0) { #agent commission reports @@ -209,7 +212,9 @@ $extra_sql .= "GROUP BY $group_by" if $group_by; my $order_by = join(', ', @order_by); #XXX agent? -my $count_query = "SELECT COUNT(*) FROM ( SELECT 1 FROM part_pkg $addl_from $extra_sql ) AS num"; +#my $count_query = "SELECT COUNT(*) FROM ( SELECT 1 FROM part_pkg $addl_from $extra_sql ) AS num"; +#mysql? +my $count_query = "SELECT COUNT(*) FROM ( SELECT DISTINCT part_pkg.pkgpart FROM part_pkg $addl_from $extra_sql ) AS num"; warn $count_query;