-<% include( 'elements/search.html',
+<& elements/search.html,
'title' => $title,
'name_singular' => $name,
'header' => \@header,
'links' => \@links,
'align' => $align,
'sort_fields' => [],
- )
-%>
+
+&>
<%init>
#this is about reports about packages definitions (starting w/commission ones)
my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied"
- unless $curuser->access_right('Financial reports');
+ unless $curuser->access_right('Employees: Commission Report'); #that's all this does so far
my $conf = new FS::Conf;
my $money_char = $conf->config('money_char') || '$';
my $select = '';
my $addl_from = '';
my @where = ();
+my @top_where = ();
my @order_by = ();
my @header = ();
my @fields = ();
$title = $access_user->name;
- $match = 'cust_pkg.usernum = '. $access_user->usernum;
+ push @top_where, 'access_user.usernum = '. $access_user->usernum;
} else {
} elsif (0) { #agent commission reports
push @arg, 'XXXagent_custnum'; #$agent->agent_custnum
}
+ #warn $sql;
+ #warn join(',', @arg);
my $sth = dbh->prepare($sql) or die dbh->errstr;
$sth->execute(@arg) or die $sth->errstr;
$money_char. sprintf('%.2f', $sth->fetchrow_arrayref->[0] );
push @order_by, 'pkgpart'; #pkg?
$select ||= 'part_pkg.*';
-my $extra_sql = scalar(@where) ? 'WHERE ' . join(' AND ', @where) : '';
+push @top_where, @where;
+my $extra_sql = scalar(@top_where) ? 'WHERE ' . join(' AND ', @top_where) : '';
$extra_sql .= "GROUP BY $group_by" if $group_by;
my $order_by = join(', ', @order_by);
#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;
+#warn $count_query;
</%init>