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