X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Felements%2Fsvc_Common.html;h=36950b2c98762dc5bfd4d1f7e36bbc12fed71bcb;hb=fa6176ab2df85c4b66026e9fe2a7242293d20ce5;hp=31d4739bfdc74f8832b440700aadbc9c246c209a;hpb=9ad4f8407cc106ef5815e65bce2ee873cd0896c2;p=freeside.git diff --git a/httemplate/edit/elements/svc_Common.html b/httemplate/edit/elements/svc_Common.html index 31d4739bf..36950b2c9 100644 --- a/httemplate/edit/elements/svc_Common.html +++ b/httemplate/edit/elements/svc_Common.html @@ -34,12 +34,14 @@ 'new_hashref_callback' => sub { #my( $cgi, $svc_x ) = @_; - { svcpart => $svcpart }; + { pkgnum => $pkgnum, + svcpart => $svcpart, + }; }, 'new_callback' => sub { - my( $cgi, $svc_x, $fields, $opt ) = @_;; + my( $cgi, $svc_x, $fields, $opt ) = @_; $part_svc = qsearchs( 'part_svc', { svcpart=>$svcpart }); die "No part_svc entry!" unless $part_svc; @@ -48,6 +50,13 @@ #$svcnum=''; + if ( my $cb = $opt{'svc_new_callback'} ) { + my $cust_pkg = $pkgnum + ? qsearchs('cust_pkg', {pkgnum=>$pkgnum}) + : ''; #? + &{ $cb }( $cgi,$svc_x, $part_svc,$cust_pkg, $fields,$opt); + } + $svc_x->set_default_and_fixed; }, @@ -62,9 +71,29 @@ ? 'fixed' : 'hidden'; $f->{'value'} = $columndef->columnvalue; + } elsif ( $flag eq 'A' ) { + $f->{'type'} = 'hidden'; + } elsif ( $flag eq 'M' ) { + $f->{'empty_label'} = 'Select inventory item'; + $f->{'type'} = 'select-table'; + $f->{'table'} = 'inventory_item'; + $f->{'name_col'} = 'item'; + $f->{'value_col'} = 'item'; + $f->{'hashref'} = { + 'classnum'=>$columndef->columnvalue, + #'svcnum' => '', + }; + $f->{'extra_sql'} = 'AND ( svcnum IS NULL '; + $f->{'extra_sql'} .= ' OR svcnum = '. $object->svcnum + if $object->svcnum; + $f->{'extra_sql'} .= ' ) '; + $f->{'disable_empty'} = $object->svcnum ? 1 : 0, } - if ( $f->{'type'} eq 'select-svc_pbx' ) { + if ( $f->{'type'} eq 'select-svc_pbx' + || $f->{'type'} eq 'select-svc-domain' + ) + { $f->{'include_opt_callback'} = sub { ( 'pkgnum' => $pkgnum, 'svcpart' => $svcpart, @@ -72,6 +101,11 @@ }; } + if ( $f->{'field'} eq 'custnum' && $pkgnum ) { + my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum}); + $object->set('custnum', $cust_pkg->custnum); + } + }, 'html_init' => sub { @@ -121,12 +155,33 @@ sub label_fixup { my( $part_svc, $opt ) = @_; + $opt->{'name'} ||= $part_svc->svc; + + my $svcdb = $part_svc->svcdb; + require "FS/$svcdb.pm"; + + if ( UNIVERSAL::can("FS::$svcdb", 'table_info') ) { + #$opt->{'name'} ||= "FS::$svcdb"->table_info->{'name'}; + + my $fields = "FS::$svcdb"->table_info->{'fields'}; + $opt->{'fields'} ||= [ grep { $_ ne 'svcnum' } keys %$fields ]; + + $opt->{labels} ||= { + map { $_ => ( ref($fields->{$_}) + ? $fields->{$_}{'label'} + : $fields->{$_} + ); + } + keys %$fields + }; + } + #false laziness w/view/svc_Common.html #override default labels with service-definition labels if applicable my $labels = $opt->{labels}; # with -> here - foreach my $field ( keys %$labels ) { + foreach my $field ( keys %{ $opt->{labels} } ) { my $col = $part_svc->part_svc_column($field); - $labels->{$field} = $col->columnlabel if $col->columnlabel !~ /^\S*$/; + $labels->{$field} = $col->columnlabel if $col->columnlabel !~ /^\s*$/; } }