Will things ever be the same again?
[freeside.git] / httemplate / elements / select-taxclass.html
1 %
2 %  my $conf = new FS::Conf;
3 %  my $selected_taxclass = scalar(@_) ? shift : '';
4 %
5 % if ( $conf->exists('enable_taxclasses') ) { 
6
7
8     <SELECT NAME="taxclass">
9 % if ( $conf->exists('require_taxclasses') ) { 
10
11
12         <OPTION VALUE="(select)">Select tax class
13 % } else { 
14
15
16         <OPTION VALUE="">
17 % } 
18 %
19 %        my $sth = dbh->prepare('SELECT DISTINCT taxclass FROM cust_main_county')
20 %          or die dbh->errstr;
21 %        $sth->execute or die $sth->errstr;
22 %        my %taxclasses = map { $_->[0] => 1 } @{$sth->fetchall_arrayref};
23 %        my @taxclasses = grep $_, keys %taxclasses;
24 %      
25 % foreach my $taxclass ( @taxclasses ) { 
26
27   
28           <OPTION VALUE="<% $taxclass %>"<% $taxclass eq $selected_taxclass ? ' SELECTED' : '' %>><% $taxclass %>
29 % } 
30
31
32     </SELECT>
33 % } else { 
34
35
36   <INPUT TYPE="hidden" NAME="taxclass" VALUE="<% $selected_taxclass %>">
37 % } 
38
39   
40