This commit was generated by cvs2svn to compensate for changes in r8593,
[freeside.git] / httemplate / elements / tr-select-taxclass.html
1 % if ( ! $conf->exists('enable_taxclasses')
2 %      || scalar(@{ $opt{'taxclasses'} }) == 0
3 % ) { 
4
5   <INPUT TYPE="hidden" NAME="<% $opt{'element_name'} || $opt{'field'} || 'taxclass' %>" VALUE="<% $selected_taxclass %>">
6
7 % } else { 
8
9   <TR>
10     <TD ALIGN="right"><% $opt{'label'} || 'Tax class: ' %></TD>
11     <TD>
12       <% include( '/elements/select-taxclass.html',
13                     'curr_value' => $selected_taxclass,
14                     %opt
15                 )
16       %>
17     </TD>
18   </TR>
19
20 % } 
21 <%init>
22
23 my( %opt ) = @_;
24 my $conf = new FS::Conf;
25 my $selected_taxclass = $opt{'curr_value'}; # || $opt{'value'} necessary?
26
27 unless ( $opt{'taxclasses'} ) {
28
29   #my $sth = dbh->prepare('SELECT DISTINCT taxclass FROM cust_main_county')
30   my $sth = dbh->prepare("SELECT taxclass FROM part_pkg_taxclass WHERE disabled IS NULL OR disabled = '' OR taxclass = ?")
31     or die dbh->errstr;
32   $sth->execute($selected_taxclass) or die $sth->errstr;
33   my %taxclasses = map { $_->[0] => 1 } @{$sth->fetchall_arrayref};
34   @{ $opt{'taxclasses'} } = grep $_, keys %taxclasses;
35
36 }
37
38 </%init>