-<HTML>
- <HEAD>
- <TITLE>Tax Report Criteria</TITLE>
- </HEAD>
- <BODY BGCOLOR="#e8e8e8">
- <H1>Tax Report Criteria</H1>
- <FORM ACTION="report_tax.cgi" METHOD="GET">
- <TABLE>
- <%= include( '/elements/tr-select-agent.html' ) %>
- <%= include( '/elements/tr-input-beginning_ending.html' ) %>
- </TABLE>
-
- <BR><INPUT TYPE="submit" VALUE="Get Report">
-
- </FORM>
- </BODY>
-</HTML>
+<% include('/elements/header.html', 'Tax Report' ) %>
+<FORM ACTION="report_tax.cgi" METHOD="GET">
+
+<TABLE>
+
+ <& /elements/tr-select-agent.html, 'disable_empty'=>0 &>
+
+ <& /elements/tr-input-beginning_ending.html &>
+
+ <& /elements/tr-select.html,
+ 'label' => 'Country',
+ 'field' => 'country',
+ 'options' => \@countries,
+ 'curr_value' => ($conf->config('countrydefault') || 'US'),
+ &>
+
+ <& /elements/tr-select.html,
+ 'label' => 'For tax named ',
+ 'field' => 'taxname',
+ 'options' => \@taxnames,
+ 'disable_empty' => 1,
+ &>
+
+ <& /elements/tr-checkbox-multiple.html,
+ 'label' => 'Break down by ',
+ 'field' => 'breakdown',
+ 'options' => \@breakdown,
+ 'option_labels' => {
+ taxclass => 'Tax class',
+ pkgclass => 'Package class',
+ city => 'City',
+ },
+ &>
+</TABLE>
+
+<BR><INPUT TYPE="submit" VALUE="Get Report">
+
+</FORM>
+
+<% include('/elements/footer.html') %>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
+
+my $conf = new FS::Conf;
+
+my $sth = dbh->prepare('SELECT DISTINCT(COALESCE(taxname, \'Tax\')) FROM cust_main_county');
+$sth->execute or die $sth->errstr;
+my @taxnames = map { $_->[0] } @{ $sth->fetchall_arrayref };
+
+$sth = dbh->prepare('SELECT DISTINCT(country) FROM cust_location');
+$sth->execute or die $sth->errstr;
+my @countries = map { $_->[0] } @{ $sth->fetchall_arrayref };
+
+my @breakdown;
+if ( $conf->exists('enable_taxclasses') ) {
+ push @breakdown, 'taxclass';
+}
+if ( FS::pkg_class->count() > 0 ) {
+ push @breakdown, 'pkgclass';
+}
+if ( FS::cust_main_county->count("city is not null and city != ''") > 0 ) {
+ push @breakdown, 'city';
+}
+
+</%init>