1 <% include( 'elements/browse.html',
2 'title' => 'Tax Rates',
3 'name_singular' => 'tax rate',
4 'html_init' => $html_init,
5 'html_posttotal' => $html_posttotal,
7 'table' => 'cust_main_county',
10 'ORDER BY country, state, county, taxclass',
12 'count_query' => $count_query,
14 'header2' => \@header2,
18 'cell_style' => \@cell_style,
20 'link_onclicks' => \@link_onclicks,
24 % # <FONT SIZE=-1><A HREF="<% $p %>edit/process/cust_main_county-collapse.cgi?<% $hashref->{taxnum} %>">collapse state</A></FONT>
29 my $conf = new FS::Conf;
30 my $money_char = $conf->config('money_char') || '$';
32 my @manual_countries = ( 'US', 'CA', 'AU', 'NZ', 'GB' ); #some manual ordering
33 my @all_countries = ( @manual_countries,
34 grep { my $c = $_; ! grep { $c eq $_ } @manual_countries }
37 'select' => 'country',
38 'table' => 'cust_main_county',
40 'extra_sql' => 'GROUP BY country',
44 my $exempt_sub = sub {
45 my $cust_main_county = shift;
49 sprintf("$money_char%.2f per month", $cust_main_county->exempt_amount )
50 if $cust_main_county->exempt_amount > 0;
52 push @exempt, 'Setup fee'
53 if $cust_main_county->setuptax =~ /^Y$/i;
55 push @exempt, 'Recurring fee'
56 if $cust_main_county->recurtax =~ /^Y$/i;
58 [ map [ {'data'=>$_} ], @exempt ];
63 my $cell_style_sub = sub {
65 if ( $oldrow ne $row ) {
67 if ( $oldrow->country ne $row->country ) {
68 $cell_style = 'border-top:1px solid #000000';
69 } elsif ( $oldrow->state ne $row->state ) {
70 $cell_style = 'border-top:1px solid #cccccc'; #default?
71 } elsif ( $oldrow->state eq $row->state ) {
72 #$cell_style = 'border-top:dashed 1px dark gray';
73 $cell_style = 'border-top:1px dashed #cccccc';
81 #my $edit_link = [ "${p}edit/cust_main_county.html", 'taxnum' ];
82 my $edit_link = [ 'javascript:void(0);', sub { ''; } ];
84 my $edit_onclick = sub {
86 my $taxnum = $row->taxnum;
87 my $color = '#333399';
88 qq!overlib( OLiframeContent('${p}edit/cust_main_county.html?$taxnum', 540, 420, 'edit_cust_main_county_popup' ), CAPTION, 'Edit tax rate', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, BGCOLOR, '$color', CGCOLOR, '$color' ); return false;!;
92 my( $row, $desc, %opt ) = @_;
93 my $taxnum = $row->taxnum;
94 $taxnum = "taxclass$taxnum" if $opt{'taxclass'};
95 my $color = '#333399';
96 qq!<FONT SIZE="-1"><A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_main_county-expand.cgi?$taxnum', 540, 420, 'edit_cust_main_county_popup' ), CAPTION, '$desc', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, BGCOLOR, '$color', CGCOLOR, '$color' ); return false;">!;
103 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
105 #my $conf = new FS::Conf;
106 #my $money_char = $conf->config('money_char') || '$';
107 my $enable_taxclasses = $conf->exists('enable_taxclasses');
110 "Click on <u>add states</u> to specify a country's tax rates by state or province.
111 <BR>Click on <u>add counties</u> to specify a state's tax rates by county.";
112 $html_init .= "<BR>Click on <u>add taxclasses</u> to specify tax classes."
113 if $enable_taxclasses;
114 $html_init .= '<BR><BR>';
117 <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws.js"></SCRIPT>
118 <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws_iframe.js"></SCRIPT>
119 <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws_draggable.js"></SCRIPT>
120 <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/iframecontentmws.js"></SCRIPT>
123 my $filter_country = '';
124 if ( $cgi->param('filter_country') =~ /^(\w\w)$/ ) {
125 $filter_country = $1;
127 $cgi->delete('filter_country');
128 $cgi->param('dummy', 1);
130 my $country_filter_change =
131 "window.location = '".
132 $cgi->self_url. ";filter_country=' + this.options[this.selectedIndex].value;";
136 qq(<SELECT NAME="filter_country" onChange="$country_filter_change">).
137 qq(<OPTION VALUE="">(all)\n).
138 join("\n", map qq[<OPTION VALUE="$_"].
139 ( $_ eq $filter_country ? 'SELECTED' : '' ).
140 '>'. code2country($_). " ($_)",
146 my $count_query = 'SELECT COUNT(*) FROM cust_main_county';
147 if ( $filter_country ) {
148 $hashref->{'country'} = $filter_country;
149 $count_query .= " WHERE country = '$filter_country'";
154 my @header = ( 'Country', 'State/Province', 'County',);
155 my @header2 = ( '', '', '', );
156 my @links = ( '', '', '', );
157 my @link_onclicks = ( '', '', '', );
161 sub { my $country = shift->country;
162 code2country($country). " ($country)";
164 sub { state_label($_[0]->state, $_[0]->country).
167 : ' '. expand_link($_[0], 'Add States').
168 'add states</A></FONT>'
171 sub { $_[0]->county || '(all) '.
172 expand_link($_[0], 'Add Counties').
173 'add counties</A></FONT>'
179 sub { shift->state ? '000000' : '999999' },
180 sub { shift->county ? '000000' : '999999' },
183 if ( $conf->exists('enable_taxclasses') ) {
184 push @header, 'Tax class';
185 push @header2, '(per-package classification)';
186 push @fields, sub { $_[0]->taxclass || '(all) '.
187 expand_link($_[0], 'Add Taxclasses', 'taxclass'=>1).
188 'add taxclasses</A></FONT>'
190 push @color, sub { shift->taxclass ? '000000' : '999999' };
192 push @link_onclicks, '';
196 push @header, 'Tax name',
201 push @header2, '(printed on invoices)',
207 sub { shift->taxname || 'Tax' },
208 sub { shift->tax. '% <FONT SIZE="-1">(edit)</FONT>' },
213 sub { shift->taxname ? '000000' : '666666' },
214 sub { shift->tax ? '000000' : '666666' },
220 my @cell_style = map $cell_style_sub, (1..scalar(@header));
222 push @links, '', $edit_link, '';
223 push @link_onclicks, '', $edit_onclick, '';