X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_bill_pkg_discount.html;h=bb8038a44120dc35b8d98bc45bb721e0f540d5fd;hb=c4b71bc4459cb7d403cbebede470aeb2c6292a6e;hp=088b29115cc2082e8e06be083b093d385f60ed9c;hpb=942c8b05b17b119a3dad84d7035c76b481dc5b99;p=freeside.git diff --git a/httemplate/search/cust_bill_pkg_discount.html b/httemplate/search/cust_bill_pkg_discount.html index 088b29115..bb8038a44 100644 --- a/httemplate/search/cust_bill_pkg_discount.html +++ b/httemplate/search/cust_bill_pkg_discount.html @@ -26,6 +26,14 @@ sub { time2str('%b %d %Y', shift->_date ) }, \&FS::UI::Web::cust_fields, ], + 'sort_fields' => [ + '', + 'amount', + 'months', + 'pkg', + 'invnum', + '_date', + ], 'links' => [ #'', '', #link to customer discount??? @@ -85,6 +93,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 +123,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 +155,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,