RT#38217: Send email when logging conditions are met
[freeside.git] / httemplate / search / agent_pkg_class.html
1 <& elements/commission.html,
2   'title'         => $title,
3   'name_singular' => 'package class',
4   'header'        => [ 'Package class' ],
5   'fields'        => [ 'classname' ],
6   'links'         => [ '' ],
7   'align'         => 'l',
8   'query'         => \%query,
9   'count_query'   => $count_query,
10   'sales_detail_link'   => $sales_link,
11   'credit_detail_link'  => $commission_link,
12 &>
13 <%init>
14
15 die "access denied"
16   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
17
18 my $conf = new FS::Conf;
19
20 $cgi->param('agentnum') =~ /^(\d+)$/ or die 'illegal agentnum';
21 my $agentnum = $1;
22 my $agent = FS::agent->by_key($agentnum);
23
24 my $title = $agent->agent . ' commission';
25
26 my %query = ( 'table'     => 'agent_pkg_class',
27               'addl_from' => ' LEFT JOIN pkg_class USING (classnum)',
28               'hashref'   => { 'agentnum' => $agentnum },
29             );
30 my $count_query = "SELECT COUNT(*) FROM agent_pkg_class WHERE agentnum = $agentnum";
31
32 # cust_bill_pkg.cgi expects "classnum=0" for null classnum
33 my $sales_link = [ 'cust_bill_pkg.cgi?nottax=1;'.
34                    "agentnum=$agentnum;" .
35                    'classnum=',
36                    sub { shift->classnum || 0 },
37                  ];
38
39 my $commission_link = [ 'cust_credit.html?'.
40                         "commission_agentnum=$agentnum;" .
41                         'classnum=',
42                         'classnum'
43                       ];
44
45 </%init>