1 <% include('/elements/header-popup.html', 'Bulk Tax rate') %>
3 <FORM ACTION="<% popurl(1)."process/bulk-cust_main_county.html" %>" METHOD="POST">
5 <INPUT TYPE="hidden" NAME="taxnum" VALUE="<% join(',', @taxnum) %>">
7 <TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
9 <% include('/elements/tr-td-label.html', 'label' => 'Country' ) %>
10 <TD BGCOLOR="#dddddd"><% $countries %>
14 <% include('/elements/tr-td-label.html', 'label' => 'State' ) %>
15 <TD BGCOLOR="#dddddd"><% $states %>
20 <% include('/elements/tr-td-label.html', 'label' => 'County' ) %>
21 <TD BGCOLOR="#dddddd"><% $counties %>
26 % if ( $conf->exists('enable_taxclasses') && $taxclasses ) {
27 <% include('/elements/tr-td-label.html', 'label' => 'Tax Class' ) %>
28 <TD BGCOLOR="#dddddd"><% $taxclasses %>
33 <% include('/elements/tr-input-text.html',
39 <% include('/elements/tr-input-percentage.html',
41 'label' => 'Tax rate',
45 <% include('/elements/tablebreak-tr-title.html', value=>'Exemptions' ) %>
47 <% include('/elements/tr-checkbox.html',
48 'field' => 'setuptax',
50 'label' => 'This tax not applicable to setup fees',
54 <% include('/elements/tr-checkbox.html',
55 'field' => 'recurtax',
57 'label' => 'This tax not applicable to recurring fees',
61 <% include('/elements/tr-input-money.html',
62 'field' => 'exempt_amount',
63 'label' => 'Monthly exemption per customer ($25 "Texas tax")',
71 <INPUT TYPE="submit" VALUE="Bulk add tax">
75 my $conf = new FS::Conf;
78 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
81 if ( $cgi->param('error') ) {
82 $cgi->param('taxnum') =~ /^([\d,]+)$/
83 or die "no taxnum, but error: ". $cgi->param('error');
84 @taxnum = split(',', $1);
86 my($query) = $cgi->keywords;
87 $query =~ /^([\d,]+)$/
88 or die 'Nothing selected'; #XXX better error when nothing selected
89 @taxnum = split(',', $1);
92 my @cust_main_county =
94 qsearchs('cust_main_county', { 'taxnum' => $_ })
95 or die "unknown taxnum $1";
99 my %seen_country = {};
100 my @countries = map code2country($_)." ($_)",
101 grep !$seen_country{$_}++,
104 my $countries = join(', ', @countries);
107 my @states = map state_label($_->[0], $_->[1]),
108 grep !$seen_state{$_->[0]}++,
109 map [ $_->state, $_->country ],
111 my $states = join(', ', @states);
113 my %seen_county = {};
114 my @counties = grep !$seen_county{$_}++, map $_->county, @cust_main_county;
115 my $counties = join(', ', @counties);
117 my %seen_taxclass = {};
118 my @taxclasses = grep !$seen_taxclass{$_}++, map $_->taxclass, @cust_main_county;
119 my $taxclasses = join(', ', @taxclasses);
122 # { field=>'country', type=>'fixed-country', },
123 # { field=>'state', type=>'fixed-state', },
124 # { field=>'county', type=>'fixed', },
127 #push @fields, { field=>'taxclass', type=>'fixed', }
128 # if $conf->exists('enable_taxclasses');