tax report improvements, #23449, #25935
[freeside.git] / httemplate / search / report_tax.html
1 <% include('/elements/header.html', 'Tax Report' ) %>
2
3 <FORM ACTION="report_tax.cgi" METHOD="GET">
4
5 <TABLE>
6
7   <& /elements/tr-select-agent.html, 'disable_empty'=>0 &>
8
9   <& /elements/tr-input-beginning_ending.html &>
10
11   <& /elements/tr-select.html,
12     'label'         => 'Country',
13     'field'         => 'country',
14     'options'       => \@countries,
15     'curr_value'    => ($conf->config('countrydefault') || 'US'),
16   &>
17
18   <& /elements/tr-select.html,
19     'label'         => 'For tax named ',
20     'field'         => 'taxname',
21     'options'       => \@taxnames,
22     'disable_empty' => 1,
23   &>
24
25   <& /elements/tr-checkbox-multiple.html,
26     'label'         => 'Break down by ',
27     'field'         => 'breakdown',
28     'options'       => \@breakdown,
29     'option_labels' => {
30       taxclass  => 'Tax class',
31       pkgclass  => 'Package class',
32       city      => 'City',
33       district  => 'District',
34     },
35   &>
36 </TABLE>
37
38 <BR><INPUT TYPE="submit" VALUE="Get Report">
39
40 </FORM>
41
42 <% include('/elements/footer.html') %>
43 <%init>
44
45 die "access denied"
46   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
47
48 my $conf = new FS::Conf;
49
50 my $sth = dbh->prepare('SELECT DISTINCT(COALESCE(taxname, \'Tax\')) FROM cust_main_county');
51 $sth->execute or die $sth->errstr;
52 my @taxnames = map { $_->[0] } @{ $sth->fetchall_arrayref };
53
54 $sth = dbh->prepare('SELECT DISTINCT(country) FROM cust_location');
55 $sth->execute or die $sth->errstr;
56 my @countries = map { $_->[0] } @{ $sth->fetchall_arrayref };
57
58 my @breakdown;
59 if ( $conf->exists('enable_taxclasses') ) {
60   push @breakdown, 'taxclass';
61 }
62 if ( FS::pkg_class->count() > 0 ) {
63   push @breakdown, 'pkgclass';
64 }
65 if ( FS::cust_main_county->count("city is not null and city != ''") > 0 ) {
66   push @breakdown, 'city';
67 }
68 if ( FS::cust_main_county->count("district is not null") > 0 ) {
69   push @breakdown, 'district';
70 }
71
72 </%init>