v4 style
[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   <tr>
12     <td></td>
13     <td colspan=2 style="font-weight: bold">
14       <& /elements/radio.html,
15         'field' => 'all',
16         'value' => 1,
17         'curr_value' => 1,
18       &> All taxes
19       <& /elements/radio.html,
20         'field' => 'all',
21         'value' => 0,
22       &> A specific tax
23     </td>
24   </tr>
25   <& /elements/tr-select.html,
26     'label'         => 'Country',
27     'field'         => 'country',
28     'options'       => \@countries,
29     'curr_value'    => ($conf->config('countrydefault') || 'US'),
30   &>
31
32   <& /elements/tr-select.html,
33     'label'         => 'For tax named ',
34     'field'         => 'taxname',
35     'options'       => \@taxnames,
36     'disable_empty' => 1,
37   &>
38
39   <& /elements/tr-checkbox-multiple.html,
40     'label'         => 'Break down by ',
41     'field'         => 'breakdown',
42     'options'       => \@breakdown,
43     'option_labels' => {
44       taxclass  => 'Tax class',
45       pkgclass  => 'Package class',
46       city      => 'City',
47       district  => 'District',
48     },
49   &>
50   <TR>
51     <TD></TD>
52     <TD>Deduct credited tax if it was 
53       <SELECT NAME="credit_date">
54         <OPTION VALUE="cust_bill" SELECTED>invoiced in this period</OPTION>
55         <OPTION VALUE="cust_credit_bill">credited in this period</OPTION>
56       </SELECT>
57     </TD>
58   </TR>
59
60 </TABLE>
61
62 <BR><INPUT TYPE="submit" VALUE="Get Report">
63
64 </FORM>
65
66 <script>
67 $(document).ready(function() {
68   $('[name=all]').on('change', function(ev) {
69     // disable country/taxname/breakdown if 'all' = 1
70     if (this.checked) {
71       var disabled = (this.value == 1);
72       $('[name=country').prop('disabled', disabled);
73       $('[name=taxname').prop('disabled', disabled);
74       $('[name=breakdown').prop('disabled', disabled);
75     }
76   });
77   $('[name=all]').change();
78 });
79 </script>
80
81 <% include('/elements/footer.html') %>
82 <%init>
83
84 die "access denied"
85   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
86
87 my $conf = new FS::Conf;
88
89 my $sth = dbh->prepare('SELECT DISTINCT(COALESCE(taxname, \'Tax\')) FROM cust_main_county');
90 $sth->execute or die $sth->errstr;
91 my @taxnames = map { $_->[0] } @{ $sth->fetchall_arrayref };
92
93 $sth = dbh->prepare('SELECT DISTINCT(country) FROM cust_location');
94 $sth->execute or die $sth->errstr;
95 my @countries = map { $_->[0] } @{ $sth->fetchall_arrayref };
96
97 my @breakdown;
98 if ( $conf->exists('enable_taxclasses') ) {
99   push @breakdown, 'taxclass';
100 }
101 if ( FS::pkg_class->count() > 0 ) {
102   push @breakdown, 'pkgclass';
103 }
104 if ( FS::cust_main_county->count("city is not null and city != ''") > 0 ) {
105   push @breakdown, 'city';
106 }
107 if ( FS::cust_main_county->count("district is not null") > 0 ) {
108   push @breakdown, 'district';
109 }
110
111 </%init>