combine ticket notification scrips, #15353
[freeside.git] / httemplate / search / cust_tax_adjustment.html
1 <% include( 'elements/search.html',
2               'title'         => $title,
3               'name_singular' => 'tax adjustment',
4               'query'         => $query,
5               'count_query'   => $count_query,
6               'header'        => [ 'Tax', 'Amount', 'Comment', 'Invoice' ],
7               'fields'        => [ 'taxname',
8                                    sub { $money_char. shift->amount },
9                                    'comment',
10                                    sub { my $l = shift->cust_bill_pkg;
11                                          $l ? '#'.$l->invnum : '';
12                                        },
13                                  ],
14               'links'         => [ '', '', '', $ilink ],
15           )
16 %>
17
18 <%init>
19
20 die "access denied"
21   unless $FS::CurrentUser::CurrentUser->access_right('Add customer tax adjustment');
22
23 my $conf = new FS::Conf;
24 my $money_char = $conf->config('money_char') || '$';
25
26 my $count_query = 'SELECT COUNT(*) FROM cust_tax_adjustment';
27
28 my $hashref = {};
29
30 my $custnum = '';
31 my $cust_main = '';
32 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
33   $custnum = $1;
34   $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
35   $hashref->{'custnum'} = $custnum;
36   $count_query .= " WHERE custnum = $custnum ";
37 }
38
39 my $title = 'Tax adjustments';
40 $title .= ' for '. $cust_main->name if $cust_main;
41
42 my $query = { 'table'   => 'cust_tax_adjustment',
43               'hashref' => $hashref,
44             };
45
46 my $ilink = [ $p.'view/cust_bill.cgi?', sub { my $l = shift->cust_bill_pkg;
47                                                $l ? $l->invnum : 'EXCEPTION';
48                                              }
49            ];
50
51 #XXX would be nice to list customer fields on the report too, if we ever need
52 # to link to here without a custnum (i'm sure we will, eventually...)
53
54 </%init>