reports with row grouping for payment/refund search, #25944
[freeside.git] / httemplate / elements / select.html
1 % unless ( $opt{'js_only'} ) {
2
3 <SELECT NAME          = "<% $opt{field} %>"
4         ID            = "<% $opt{id} %>"
5         previousValue = "<% $curr_value %>"
6         previousText  = "<% $labels->{$curr_value} || $curr_value %>"
7         <% $multiple %>
8         <% $size %>
9         <% $style %>
10         <% $opt{disabled} %>
11         <% $onchange %>
12 >
13
14 % if ( $opt{options} ) {
15 %
16 %   foreach my $option ( @{ $opt{options} } ) { #just arrayref for now
17
18       <OPTION VALUE="<% $option %>"
19               <% $opt{curr_value} eq $option ? 'SELECTED' : '' %>
20       >
21         <% $labels->{$option} || $option %>
22       </OPTION>
23
24 %   }
25 %
26 % } else { #deprecated weird value hashref used only by reason.html
27 %
28 %   my $aref = $opt{'value'}->{'values'};
29 %   my $vkey = $opt{'value'}->{'vcolumn'};
30 %   my $ckey = $opt{'value'}->{'ccolumn'};
31 %   foreach my $v (@$aref) {
32
33       <OPTION VALUE="<% $v->$vkey %>"
34               <% ($opt{curr_value} eq $v->$vkey) ? 'SELECTED' : '' %>
35       >
36         <% $v->$ckey %>
37       </OPTION>
38
39 %   }
40 %
41 % }
42
43 </SELECT>
44
45 % }
46 <%init>
47
48 my %opt = @_;
49
50 my $labels = $opt{'option_labels'} || $opt{'labels'};
51
52 my $curr_value = $opt{'curr_value'};
53
54 my $onchange = '';
55 if ( $opt{'onchange'} ) {
56   $onchange = $opt{'onchange'};
57   $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
58   $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack.  all onchange
59                                         #callbacks should act the same
60   $onchange = 'onChange="'. $onchange. '"' unless $onchange =~ /^onChange=/i;
61 }
62
63 $opt{'disabled'} = &{ $opt{'disabled'} }( \%opt )
64   if ref($opt{'disabled'}) eq 'CODE';
65 $opt{'disabled'} = 'DISABLED'
66   if $opt{'disabled'} && $opt{'disabled'} !~ /disabled/i; # uuh... yeah?
67
68 my @style = ref($opt{'style'})
69               ? @{ $opt{'style'} }
70               : $opt{'style'}
71                 ? ( $opt{'style'} )
72                 : ();
73
74 my $style = scalar(@style) ? 'STYLE="'. join(';', @style). '"' : '';
75
76 my $size = $opt{'size'} ? 'SIZE='.$opt{'size'} : '';
77
78 my $multiple = $opt{'multiple'} ? 'MULTIPLE' : '';
79
80 </%init>