X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Freport_tax.html;h=8d8d1084c4eb12f1f73b26a74d16ef0f17cd3527;hb=11df448ba461eed4d33fded0f21ed15c155a7896;hp=2ab0e0b2e37988e16fa76c267f26965a6ec47d55;hpb=624b2d44625f69d71175c3348cae635d580c890b;p=freeside.git
diff --git a/httemplate/search/report_tax.html b/httemplate/search/report_tax.html
index 2ab0e0b2e..8d8d1084c 100755
--- a/httemplate/search/report_tax.html
+++ b/httemplate/search/report_tax.html
@@ -4,56 +4,45 @@
-% if ( $conf->config('tax-report_groups') ) {
-% my @lines = $conf->config('tax-report_groups');
-
+ <& /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',
+ district => 'District',
+ },
+ &>
- Tax group |
-
- |
-% }
-
- <% include( '/elements/tr-select-agent.html', 'disable_empty'=>0 ) %>
-
- <% include( '/elements/tr-input-beginning_ending.html' ) %>
-
-% if ( $city ) {
-
- |
- Show cities |
-
-% }
-
-% if ( $conf->exists('enable_taxclasses') ) {
-
- |
- Show tax classes |
-
-% }
-
-% my @pkg_class = qsearch('pkg_class', {});
-% if ( @pkg_class ) {
-
- |
- Show package classes |
-
-% }
-
@@ -68,12 +57,26 @@ die "access denied"
my $conf = new FS::Conf;
-my $city_sql = "SELECT COUNT(*) FROM cust_main_county
- WHERE city != '' AND city IS NOT NULL
- LIMIT 1";
-
-my $city_sth = dbh->prepare($city_sql) or die dbh->errstr;
-$city_sth->execute or die $city_sth->errstr;
-my $city = $city_sth->fetchrow_arrayref->[0];
+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';
+}
+if ( FS::cust_main_county->count("district is not null") > 0 ) {
+ push @breakdown, 'district';
+}
%init>