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