This commit was generated by cvs2svn to compensate for changes in r6255,
[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( $selected_taxclass, %opt ) = @_;
26 my $conf = new FS::Conf;
27
28 unless ( $opt{'taxclasses'} ) {
29
30   my $sth = dbh->prepare('SELECT DISTINCT taxclass FROM cust_main_county')
31      or die dbh->errstr;
32   $sth->execute or die $sth->errstr;
33   my %taxclasses = map { $_->[0] => 1 } @{$sth->fetchall_arrayref};
34   @{ $opt{'taxclasses'} } = grep $_, keys %taxclasses;
35
36 }
37
38 </%init>