improved tax report, #23349
[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     },
34   &>
35 </TABLE>
36
37 <BR><INPUT TYPE="submit" VALUE="Get Report">
38
39 </FORM>
40
41 <% include('/elements/footer.html') %>
42 <%init>
43
44 die "access denied"
45   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
46
47 my $conf = new FS::Conf;
48
49 my $sth = dbh->prepare('SELECT DISTINCT(COALESCE(taxname, \'Tax\')) FROM cust_main_county');
50 $sth->execute or die $sth->errstr;
51 my @taxnames = map { $_->[0] } @{ $sth->fetchall_arrayref };
52
53 $sth = dbh->prepare('SELECT DISTINCT(country) FROM cust_location');
54 $sth->execute or die $sth->errstr;
55 my @countries = map { $_->[0] } @{ $sth->fetchall_arrayref };
56
57 my @breakdown;
58 if ( $conf->exists('enable_taxclasses') ) {
59   push @breakdown, 'taxclass';
60 }
61 if ( FS::pkg_class->count() > 0 ) {
62   push @breakdown, 'pkgclass';
63 }
64 if ( FS::cust_main_county->count("city is not null and city != ''") > 0 ) {
65   push @breakdown, 'city';
66 }
67
68 </%init>