& elements/commission.html,
'title' => $title,
'name_singular' => 'package class',
'header' => [ 'Package class' ],
'fields' => [ 'classname' ],
'links' => [ '' ],
'align' => 'l',
'query' => \%query,
'count_query' => $count_query,
'sales_detail_link' => $sales_link,
'credit_detail_link' => $commission_link,
&>
<%init>
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
my $conf = new FS::Conf;
$cgi->param('agentnum') =~ /^(\d+)$/ or die 'illegal agentnum';
my $agentnum = $1;
my $agent = FS::agent->by_key($agentnum);
my $title = $agent->agent . ' commission';
my %query = ( 'table' => 'agent_pkg_class',
'addl_from' => ' LEFT JOIN pkg_class USING (classnum)',
'hashref' => { 'agentnum' => $agentnum },
);
my $count_query = "SELECT COUNT(*) FROM agent_pkg_class WHERE agentnum = $agentnum";
# cust_bill_pkg.cgi expects "classnum=0" for null classnum
my $sales_link = [ 'cust_bill_pkg.cgi?nottax=1;'.
"agentnum=$agentnum;" .
'classnum=',
sub { shift->classnum || 0 },
];
my $commission_link = [ 'cust_credit.html?'.
"commission_agentnum=$agentnum;" .
'classnum=',
'classnum'
];
%init>