Revert "RT# 39340 - configured the minimal selfservice to get mac address from radius...
[freeside.git] / httemplate / search / sales_commission.html
1 % if ( $salesnum ) {
2 %   my $url = 'sales_pkg_class.html?' . $cgi->query_string;
3 <% $cgi->redirect($url) %>
4 % } else {
5 <& elements/commission.html,
6   'title'         => $title,
7   'name_singular' => 'sales person',
8   'header'        => [ 'Sales person' ],
9   'fields'        => [ 'salesperson' ],
10   'links'         => [ '' ],
11   'align'         => 'l',
12   'query'         => \%query,
13   'count_query'   => $count_query,
14   'disableable'   => 1,
15   'sales_detail_link'   => $sales_link,
16   'credit_detail_link'  => $commission_link,
17 &>
18 % }
19 <%init>
20
21 die "access denied"
22   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
23
24 my $conf = new FS::Conf;
25
26 my %query = ( 'table' => 'sales' );
27 my $count_query = "SELECT COUNT(*) FROM sales";
28
29 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
30   $query{hashref}->{agentnum} = $1;
31   $count_query .= " WHERE agentnum = $1";
32 }
33
34 my $salesnum = '';
35 if ( $cgi->param('salesnum') =~ /^(\d+)$/ ) {
36   $salesnum = $1;
37 } else {
38   $cgi->delete('salesnum');
39 }
40
41 my $title = 'Sales person commission';
42
43 my $cust_main_sales = $cgi->param('cust_main_sales') eq 'Y' ? 'Y' : '';
44 $query{'cust_main_sales'} = $cust_main_sales;
45
46 my $sales_link = [ 'sales_pkg_class.html?'.
47                    "cust_main_sales=$cust_main_sales;salesnum=",
48                    'salesnum'
49                  ];
50
51 my $commission_link = [ 'cust_credit.html?'.
52                         "cust_main_sales=$cust_main_sales;commission_salesnum=",
53                         'salesnum'
54                       ];
55
56 </%init>