+
+#my $conf = new FS::Conf;
+#my $money_char = $conf->config('money_char') || '$';
+my $enable_taxclasses = $conf->exists('enable_taxclasses');
+
+my $html_init =
+ "Click on <u>add states</u> to specify a country's tax rates by state or province.
+ <BR>Click on <u>add counties</u> to specify a state's tax rates by county.";
+$html_init .= "<BR>Click on <u>add taxclasses</u> to specify tax classes."
+ if $enable_taxclasses;
+$html_init .= '<BR><BR>';
+
+$html_init .= qq(
+ <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws.js"></SCRIPT>
+ <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws_iframe.js"></SCRIPT>
+ <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws_draggable.js"></SCRIPT>
+ <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/iframecontentmws.js"></SCRIPT>
+);
+
+my $filter_country = '';
+if ( $cgi->param('filter_country') =~ /^(\w\w)$/ ) {
+ $filter_country = $1;
+}
+$cgi->delete('filter_country');
+$cgi->param('dummy', 1);
+
+my $country_filter_change =
+ "window.location = '".
+ $cgi->self_url. ";filter_country=' + this.options[this.selectedIndex].value;";
+
+my $html_posttotal =
+ '(show country: '.
+ qq(<SELECT NAME="filter_country" onChange="$country_filter_change">).
+ qq(<OPTION VALUE="">(all)\n).
+ join("\n", map qq[<OPTION VALUE="$_"].
+ ( $_ eq $filter_country ? 'SELECTED' : '' ).
+ '>'. code2country($_). " ($_)",
+ @all_countries
+ ).
+ '</SELECT>)';
+
+my $hashref = {};
+my $count_query = 'SELECT COUNT(*) FROM cust_main_county';
+if ( $filter_country ) {
+ $hashref->{'country'} = $filter_country;
+ $count_query .= " WHERE country = '$filter_country'";
+}
+
+$cell_style = '';
+
+my @header = ( 'Country', 'State/Province', 'County',);
+my @header2 = ( '', '', '', );
+my @links = ( '', '', '', );
+my @link_onclicks = ( '', '', '', );
+my $align = 'lll';
+
+my @fields = (
+ sub { my $country = shift->country;
+ code2country($country). " ($country)";
+ },
+ sub { state_label($_[0]->state, $_[0]->country).
+ ( $_[0]->state
+ ? ''
+ : ' '. expand_link($_[0], 'Add States').
+ 'add states</A></FONT>'
+ )
+ },
+ sub { $_[0]->county || '(all) '.
+ expand_link($_[0], 'Add Counties').
+ 'add counties</A></FONT>'
+ },
+);
+
+my @color = (
+ '000000',
+ sub { shift->state ? '000000' : '999999' },
+ sub { shift->county ? '000000' : '999999' },
+);
+
+if ( $conf->exists('enable_taxclasses') ) {
+ push @header, 'Tax class';
+ push @header2, '(per-package classification)';
+ push @fields, sub { $_[0]->taxclass || '(all) '.
+ expand_link($_[0], 'Add Taxclasses', 'taxclass'=>1).
+ 'add taxclasses</A></FONT>'
+ };
+ push @color, sub { shift->taxclass ? '000000' : '999999' };
+ push @links, '';
+ push @link_onclicks, '';
+ $align .= 'l';
+}
+
+push @header, 'Tax name',
+ 'Rate', #'Tax',
+ 'Exemptions',
+ ;
+
+push @header2, '(printed on invoices)',
+ '',
+ '',
+ ;
+
+push @fields,
+ sub { shift->taxname || 'Tax' },
+ sub { shift->tax. '% <FONT SIZE="-1">(edit)</FONT>' },
+ $exempt_sub,
+;
+
+push @color,
+ sub { shift->taxname ? '000000' : '666666' },
+ sub { shift->tax ? '000000' : '666666' },
+ '000000',
+;
+
+$align .= 'lrl';
+
+my @cell_style = map $cell_style_sub, (1..scalar(@header));
+
+push @links, '', $edit_link, '';
+push @link_onclicks, '', $edit_onclick, '';
+