default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / httemplate / elements / select-taxclass.html
1 % if ( $conf->exists('enable_taxclasses') ) { 
2
3     <SELECT NAME="<% $opt{'element_name'} || $opt{'field'} || '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="<% $opt{'element_name'} || $opt{'field'} || '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   my $sth = dbh->prepare("SELECT taxclass FROM part_pkg_taxclass WHERE disabled IS NULL OR disabled = '' OR taxclass = ?")
34     or die dbh->errstr;
35   $sth->execute($selected_taxclass) or die $sth->errstr;
36   my %taxclasses = map { $_->[0] => 1 } @{$sth->fetchall_arrayref};
37   @{ $opt{'taxclasses'} } = grep $_, keys %taxclasses;
38
39 }
40
41 </%init>