+ if (length($columndef->columnvalue)) {
+
+ if ( $f->{'type'} =~ /^select-?(.*)/ ) {
+ # try to display this in a user-friendly manner
+ if ( $f->{'table'} ) { # find matching records
+ $f->{'value_col'} ||=
+ dbdef->table($f->{'table'})->primary_key;
+
+ my @values = split(',', $f->{'value'});
+ my @recs;
+ foreach (@values) {
+ push @recs, qsearchs( $f->{'table'},
+ { $f->{'value_col'} => $_ }
+ );
+ }
+ if ( @recs ) {
+ my $method = $f->{'name_col'};
+ if ( $f->{'multiple'} ) {
+ $f->{'formatted_value'} = [
+ map { $_->method } @recs
+ ];
+ } else { # there shouldn't be more than one...
+ $f->{'formatted_value'} = $recs[0]->$method;
+ }
+ } # if not, then just let tr-fixed display the
+ # values as-is
+
+ } # other select types probably don't matter
+ } # if it's a select
+
+ $f->{'type'} = 'fixed';
+
+ } else { # fixed, null
+ $f->{'type'} = 'hidden';
+ }
+
+ } elsif ( $flag eq 'A' ) { #auto assign from inventory
+ $f->{'type'} = 'hidden';
+
+ } elsif ( $flag eq 'M' ) { #manually assign from inventory
+ $f->{'type'} = 'select-inventory_item';
+ $f->{'empty_label'} = 'Select inventory item';
+ $f->{'extra_sql'} = 'WHERE ( svcnum IS NULL ' .
+ ($object->svcnum && ' OR svcnum = '.$object->svcnum) .
+ ')';
+ $f->{'classnum'} = $columndef->columnvalue;
+ $f->{'disable_empty'} = $object->svcnum ? 1 : 0;
+
+ } elsif ( $flag eq 'H' ) { #hardware
+ $f->{'type'} = 'select-hardware_type';
+ $f->{'hashref'} = {
+ 'classnum'=>$columndef->columnvalue
+ };
+
+ } elsif ( $flag eq 'S' #selectable choice
+ && $f->{type} !~ /^select-svc/ ) {
+ $f->{type} = 'select';
+ $f->{options} = [ split( /\s*,\s*/,
+ $columndef->columnvalue)
+ ];
+ } # shouldn't this be enforced for all 'S' fields?
+
+ if ( $f->{'type'} =~ /^select-svc/ )
+ {
+ $f->{'include_opt_callback'} =
+ sub { ( 'pkgnum' => $pkgnum,
+ 'svcpart' => $svcpart,
+ );
+ };
+ }
+
+ if ( $f->{'field'} eq 'custnum' && $pkgnum ) {
+ my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum});
+ $object->set('custnum', $cust_pkg->custnum);
+ }
+
+ if ( my $cb = $opt{'svc_field_callback'} ) {
+ &{ $cb }( $cgi, $object, $f);