From c2e126583354b58ef54ffa7f580b115b8eed1dd3 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Mon, 18 Mar 2013 19:33:34 -0700 Subject: multiple inventory classes for service columns, #21442 --- httemplate/elements/tr-select-inventory_item.html | 48 +++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 httemplate/elements/tr-select-inventory_item.html (limited to 'httemplate/elements') diff --git a/httemplate/elements/tr-select-inventory_item.html b/httemplate/elements/tr-select-inventory_item.html new file mode 100644 index 000000000..669e85f27 --- /dev/null +++ b/httemplate/elements/tr-select-inventory_item.html @@ -0,0 +1,48 @@ +% 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 &> + +<& select-tiered.html, + 'prefix' => $opt{'field'}.'_', + '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, +&> + + +% } +<%init> +my %opt = @_; +my @classnums; +if (ref($opt{'classnum'})) { + @classnums = @{ $opt{'classnum'} }; +} else { + @classnums = split(',', $opt{'classnum'}); +} +my $classnum_sql = 'classnum IN('.join(',', @classnums).')'; + -- cgit v1.2.1