X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Felements%2Fsvc_Common.html;h=e1c30908041424cbee226b4d091afbd10fd563c0;hp=64484eba0985694ee2ed28f6608150f8fff7da6c;hb=25efd7207d9ea9be4bea1093917c0d8dc4b1e87a;hpb=50c2e50db2999c61db1c1c72ae416482ef370d99 diff --git a/httemplate/edit/elements/svc_Common.html b/httemplate/edit/elements/svc_Common.html index 64484eba0..e1c309080 100644 --- a/httemplate/edit/elements/svc_Common.html +++ b/httemplate/edit/elements/svc_Common.html @@ -101,14 +101,52 @@ my $columndef = $part_svc->part_svc_column($f->{'field'}); my $flag = $columndef->columnflag; - if ( $flag eq 'F' ) { - $f->{'type'} = length($columndef->columnvalue) - ? 'fixed' - : 'hidden'; + + $f->{'required'} = 1 + if $columndef->required; + + if ( $flag eq 'F' ) { #fixed $f->{'value'} = $columndef->columnvalue; - } elsif ( $flag eq 'A' ) { + 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' ) { + + } 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 ' . @@ -116,21 +154,32 @@ ')'; $f->{'classnum'} = $columndef->columnvalue; $f->{'disable_empty'} = $object->svcnum ? 1 : 0; - } elsif ( $flag eq 'H' ) { + + } elsif ( $flag eq 'H' ) { #hardware $f->{'type'} = 'select-hardware_type'; $f->{'hashref'} = { 'classnum'=>$columndef->columnvalue }; - } elsif ( $flag eq 'S' ) { #selectable choice + + } elsif ( $flag eq 'S' #selectable choice + && $f->{type} !~ /^select-svc/ ) { $f->{type} = 'select'; $f->{options} = [ split( /\s*,\s*/, $columndef->columnvalue) ]; - } - - if ( $f->{'type'} eq 'select-svc_pbx' - || $f->{'type'} eq 'select-svc-domain' - ) + } # shouldn't this be enforced for all 'S' fields? + + elsif ( $flag eq 'P' ) { #form fcc_477 values + $f->{type} = 'fixed'; + my $cust_pkg = FS::Record::qsearchs({ + 'table' => 'cust_pkg', + 'hashref' => { 'pkgnum' => $object->{Hash}->{pkgnum} } + }); + my $fcc_record = $cust_pkg->fcc_477_record('broadband_'.$columndef->columnvalue.'stream') if $cust_pkg; + $f->{'value'} = $fcc_record->{Hash}->{optionvalue} ? $fcc_record->{Hash}->{optionvalue} * 1000 : ''; + } # end 477 values + + if ( $f->{'type'} =~ /^select-svc/ ) { $f->{'include_opt_callback'} = sub { ( 'pkgnum' => $pkgnum,