-<% include( 'elements/search.html',
+<& elements/search.html,
'title' => $title,
'name' => 'net credits',
'query' => $sql_query,
'',
FS::UI::Web::cust_styles(),
],
- )
-%>
+
+&>
<%init>
die "access denied"
my @search = ();
if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) {
- push @search, "agentnum = $1";
+ push @search, "cust_main.agentnum = $1";
my $agent = qsearchs('agent', { 'agentnum' => $1 } );
die "unknown agentnum $1" unless $agent;
$title = $agent->agent. " $title";
}
if ( $cgi->param('refnum') && $cgi->param('refnum') =~ /^(\d+)$/ ) {
- push @search, "refnum = $1";
+ push @search, "cust_main.refnum = $1";
my $part_referral = qsearchs('part_referral', { 'refnum' => $1 } );
die "unknown refnum $1" unless $part_referral;
$title = $part_referral->referral. " $title";
#
my $count_query = 'SELECT COUNT(*), SUM(amount)
FROM cust_credit_bill
- LEFT JOIN cust_bill USING ( invnum )
- LEFT JOIN cust_main USING ( custnum ) '.
+ LEFT JOIN cust_bill USING ( invnum ) '.
+ FS::UI::Web::join_cust_main('cust_bill') .
$where;
my $sql_query = {
'hashref' => {},
'extra_sql' => $where,
'addl_from' => 'LEFT JOIN cust_bill USING ( invnum )
- LEFT JOIN cust_credit USING ( crednum )
- LEFT JOIN cust_main ON ( cust_bill.custnum = cust_main.custnum )',
+ LEFT JOIN cust_credit USING ( crednum )'.
+ FS::UI::Web::join_cust_main('cust_bill')
};
my $cust_bill_link = sub {