summaryrefslogtreecommitdiff
path: root/httemplate/elements/tr-select-inventory_item.html
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-03-18 19:33:34 -0700
committerMark Wells <mark@freeside.biz>2013-03-18 19:33:34 -0700
commitc2e126583354b58ef54ffa7f580b115b8eed1dd3 (patch)
tree0e0c25a9e8ccff3085b6caf55408f8c383720471 /httemplate/elements/tr-select-inventory_item.html
parent04f99991071acf5c390ea4d52db37798543ff9d8 (diff)
multiple inventory classes for service columns, #21442
Diffstat (limited to 'httemplate/elements/tr-select-inventory_item.html')
-rw-r--r--httemplate/elements/tr-select-inventory_item.html48
1 files changed, 48 insertions, 0 deletions
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 &>
+<TD>
+<& 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,
+&>
+</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>