fix inventory vs. hardware type selection, RT#33425
[freeside.git] / httemplate / elements / tr-select-reason.html
index 2dce9ef..8b43dd3 100755 (executable)
@@ -70,8 +70,7 @@ Example:
   'id'              => $id,
   'table'           => 'reason',
   'records'         => \@reasons,
-  'label_callback'  => sub { my $reason = shift;
-                             $reason->type . ' : ' .  $reason->reason },
+  'name_col'        => 'label',
   'disable_empty'   => 1,
   'pre_options'     => [ 0 => 'Select reason...' ],
   'post_options'    => \@post_options,
@@ -175,13 +174,18 @@ if ($class eq 'C') {
   die "illegal class: $class";
 }
 
+my $select = join(',',
+  'reason.*',
+  FS::Record::concat_sql([ 'type', "' : '", 'reason' ]) . ' AS label',
+);
+
 my @reasons = qsearch({
   'table'           => 'reason',
+  'select'          => $select,
   'addl_from'       => ' LEFT JOIN reason_type'.
                        ' ON (reason.reason_type = reason_type.typenum)',
   'hashref'         => { disabled => '' },
   'extra_sql'       => " AND reason_type.class = '$class'",
-  'order_by'        => ' ORDER BY type, reason',
 });
 
 my %all_hints;