1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
% if ( scalar(@classnums) == 0 ) {
<& tr-fixed.html, %opt &>
% } elsif ( scalar(@classnums) == 1 ) {
% $opt{'extra_sql'} .= ' AND '.$classnum_sql;
<& tr-select-table.html,
'table' => 'inventory_item',
'name_col' => 'item',
'value_col' => 'item',
%opt
&>
% } else {
<& tr-td-label.html, %opt &>
<TD>
<& select-tiered.html,
'tiers' => [
{
field => $opt{'field'}.'_classnum',
table => 'inventory_class',
extra_sql => "WHERE $classnum_sql",
name_col => 'classname',
empty_label => '(all)',
},
{
field => $opt{'field'},
table => 'inventory_item',
name_col => 'item',
value_col => 'item',
link_col => 'classnum',
extra_sql => delete($opt{'extra_sql'}),
disable_empty => 1,
},
],
%opt,
'prefix' => $opt{'prefix'}. $opt{'field'}. '_', #after %opt so it overrides
&>
</TD>
</TR>
% }
<%init>
my %opt = @_;
my @classnums;
if (ref($opt{'classnum'})) {
@classnums = @{ $opt{'classnum'} };
} else {
@classnums = split(',', $opt{'classnum'});
}
my $classnum_sql = 'classnum IN('.join(',', @classnums).')';
</%init>
|