4.x style
[freeside.git] / httemplate / edit / bulk-cust_main_county.html
1 <% include('/elements/header-popup.html', $title ) %>
2
3 <FORM ACTION="<% popurl(1)."process/bulk-cust_main_county.html" %>" METHOD="POST">
4
5 <INPUT TYPE="hidden" NAME="action" VALUE="<% $action %>">
6 <INPUT TYPE="hidden" NAME="rate_only" VALUE="<% $rate_only %>">
7 <INPUT TYPE="hidden" NAME="taxnum" VALUE="<% join(',', @taxnum) %>">
8
9 <TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
10
11 <% include('/elements/tr-td-label.html', 'label' => 'Country' ) %>
12   <TD BGCOLOR="#dddddd"><% $countries %>
13   </TD>
14 </TR>
15
16 <% include('/elements/tr-td-label.html', 'label' => 'State' ) %>
17   <TD BGCOLOR="#dddddd"><% $states %>
18   </TD>
19 </TR>
20
21 % if ( $counties ) {
22   <% include('/elements/tr-td-label.html', 'label' => 'County' ) %>
23     <TD BGCOLOR="#dddddd"><% $counties %>
24     </TD>
25   </TR>
26 % }
27
28 % if ( $cities ) {
29   <& /elements/tr-td-label.html, 'label' => 'City' &>
30     <TD BGCOLOR="#dddddd"><% $cities %>
31     </TD>
32   </TR>
33 % }
34
35 % if ( $districts ) {
36   <& /elements/tr-td-label.html, 'label' => 'District' &>
37     <TD BGCOLOR="#dddddd"><% $districts %>
38     </TD>
39   </TR>
40 % }
41
42 % if ( $conf->exists('enable_taxclasses') && $taxclasses ) {
43   <% include('/elements/tr-td-label.html', 'label' => 'Tax Class' ) %>
44     <TD BGCOLOR="#dddddd"><% $taxclasses %>
45     </TD>
46   </TR>
47 % }
48
49 % unless ($rate_only) {
50   <% include('/elements/tr-input-text.html',
51              'field' => 'taxname',
52              'label' => 'Tax name'
53           )
54   %>
55 % }
56
57 <% include('/elements/tr-input-percentage.html',
58              'field' => 'tax',
59              'label' => 'Tax rate',
60           )
61 %>
62
63 % unless ($rate_only) {
64   <% include('/elements/tablebreak-tr-title.html', value=>'Exemptions' ) %>
65
66   <% include('/elements/tr-checkbox.html',
67              'field' => 'setuptax',
68              'value' => 'Y',
69              'label' => 'This tax not applicable to setup fees',
70           )
71   %>
72
73   <% include('/elements/tr-checkbox.html',
74              'field' => 'recurtax',
75              'value' => 'Y',
76              'label' => 'This tax not applicable to recurring fees',
77           )
78   %>
79
80   <% include('/elements/tr-input-money.html',
81              'field' => 'exempt_amount',
82              'label' => 'Monthly exemption per customer ($25 "Texas tax")',
83           )
84   %>
85 % }
86
87 </TABLE>
88
89 <BR>
90
91 <INPUT TYPE="submit" VALUE="Bulk <% $action %> tax">
92
93 <%init>
94
95 my $conf = new FS::Conf;
96
97 die "access denied"
98   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
99
100 my @taxnum;
101 $cgi->param('taxnum') =~ /^([\d,]+)$/
102    or $m->comp('/elements/errorpage-popup.html', $cgi->param('error') || 'Nothing selected');
103 my @taxnum = split(',', $1);
104
105 $cgi->param('action') =~ /^(add|edit|edit_rate_only)$/ or die "unknown action";
106 my $action = $1;
107 my $rate_only;
108 if ($action eq "edit_rate_only") {
109   $action = "edit";
110   $rate_only = 1;
111 }
112 my $title = "Bulk $action tax rate";
113
114 my @cust_main_county =
115   map {
116         qsearchs('cust_main_county', { 'taxnum' => $_ })
117           or die "unknown taxnum $1";
118       }
119       @taxnum;
120
121 my %seen_country = {};
122 my @countries = map  FS::geocode_Mixin->code2country($_)."&nbsp;($_)",
123                 grep !$seen_country{$_}++,
124                 map  $_->country,
125                      @cust_main_county;
126 my $countries = join(', ', @countries);
127
128 my %seen_state = {};
129 my @states = map state_label($_->[0], $_->[1]),
130             grep !$seen_state{$_->[0]}++,
131              map [ $_->state, $_->country ],
132                  @cust_main_county;
133 my $states = join(', ', @states);
134
135 my %seen_county = {};
136 my @counties = grep !$seen_county{$_}++, map $_->county, @cust_main_county;
137 my $counties = join(', ', @counties);
138
139 my %seen_city = ( map { $_->city => 1 } @cust_main_county );
140 my @cities = grep $_, keys %seen_city;
141 my $cities = join(', ', @cities);
142
143 my @districts = grep $_, map { $_->district } @cust_main_county;
144 my $districts = join(', ', @districts);
145
146 my %seen_taxclass = {};
147 my @taxclasses = grep !$seen_taxclass{$_}++, map $_->taxclass, @cust_main_county;
148 my $taxclasses = join(', ', @taxclasses);
149
150 #my @fields = (
151 #  { field=>'country',  type=>'fixed-country', },
152 #  { field=>'state',    type=>'fixed-state', },
153 #  { field=>'county',   type=>'fixed', },
154 #);
155
156 #push @fields, { field=>'taxclass', type=>'fixed', }
157 #  if $conf->exists('enable_taxclasses');
158
159 </%init>