X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_bill_pkg_discount.html;h=b472366bea4bc0dd9a9ac06f6b736bf350434671;hb=9b05a3660eabd3215bdebf9429eb490b41570436;hp=088b29115cc2082e8e06be083b093d385f60ed9c;hpb=624b2d44625f69d71175c3348cae635d580c890b;p=freeside.git diff --git a/httemplate/search/cust_bill_pkg_discount.html b/httemplate/search/cust_bill_pkg_discount.html index 088b29115..b472366be 100644 --- a/httemplate/search/cust_bill_pkg_discount.html +++ b/httemplate/search/cust_bill_pkg_discount.html @@ -85,6 +85,11 @@ if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { push @where, "cust_main.agentnum = $1"; } +#usernum +if ( $cgi->param('usernum') =~ /^(\d+)$/ ) { + push @where, "cust_pkg_discount.usernum = $1"; +} + # #classnum # # not specified: all classes # # 0: empty class @@ -110,18 +115,25 @@ if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { my $count_query = "SELECT COUNT(*), SUM(amount)"; -my $join_cust = ' JOIN cust_bill_pkg USING ( billpkgnum ) - JOIN cust_bill USING ( invnum ) - LEFT JOIN cust_main USING ( custnum ) '; +my $join_cust_pkg_discount = + 'LEFT JOIN cust_pkg_discount USING (pkgdiscountnum)'; + +my $join_cust = + ' JOIN cust_bill_pkg USING ( billpkgnum ) + JOIN cust_bill USING ( invnum ) + LEFT JOIN cust_main USING ( custnum ) '; -my $join_pkg = ' LEFT JOIN cust_pkg USING ( pkgnum ) - LEFT JOIN part_pkg USING ( pkgpart ) '; - #LEFT JOIN part_pkg AS override - # ON pkgpart_override = override.pkgpart '; +my $join_pkg = + ' LEFT JOIN cust_pkg ON ( cust_bill_pkg.pkgnum = cust_pkg.pkgnum ) + LEFT JOIN part_pkg USING ( pkgpart ) '; + #LEFT JOIN part_pkg AS override + # ON pkgpart_override = override.pkgpart '; my $where = ' WHERE '. join(' AND ', @where); -$count_query .= " FROM cust_bill_pkg_discount $join_cust $join_pkg $where"; +$count_query .= + " FROM cust_bill_pkg_discount $join_cust_pkg_discount $join_cust $join_pkg ". + $where; my @select = ( 'cust_bill_pkg_discount.*', @@ -135,7 +147,7 @@ push @select, 'cust_main.custnum', my $query = { 'table' => 'cust_bill_pkg_discount', - 'addl_from' => "$join_cust $join_pkg", + 'addl_from' => "$join_cust_pkg_discount $join_cust $join_pkg", 'hashref' => {}, 'select' => join(', ', @select ), 'extra_sql' => $where,