summaryrefslogtreecommitdiff
path: root/httemplate/search/agent_commission.html
blob: 386452aebd7187f950cb5ff27b7c2771d869122a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
% if ( $agentnum ) {
<% $cgi->redirect($sales_link->[0] . $agentnum) %>
% } else {
<& elements/commission.html,
  'title'         => $title,
  'name_singular' => 'agent',
  'header'        => [ 'Agent' ],
  'fields'        => [ 'agent' ],
  'links'         => [ '' ],
  'align'         => 'l',
  'query'         => \%query,
  'count_query'   => $count_query,
  'disableable'   => 1,
  '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;

my %query = ( 'table' => 'agent' );
my $count_query = "SELECT COUNT(*) FROM agent";

my $agentnum = '';
if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
  $agentnum = $1;
} else {
  $cgi->delete('agentnum');
}

my $title = 'Agent commission';

my $sales_link = [ 'agent_pkg_class.html?agentnum=', 'agentnum' ];

my $commission_link = [ 'cust_credit.html?commission_agentnum=', 'agentnum' ];

</%init>