% my( $svcnum, $pkgnum, $svcpart, $part_svc, $svc_external ); if ( $cgi->param('error') ) { $svc_external = new FS::svc_external ( { map { $_, scalar($cgi->param($_)) } fields('svc_external') } ); $svcnum = $svc_external->svcnum; $pkgnum = $cgi->param('pkgnum'); $svcpart = $cgi->param('svcpart'); $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); die "No part_svc entry!" unless $part_svc; } else { my($query) = $cgi->keywords; if ( $query =~ /^(\d+)$/ ) { #editing $svcnum=$1; $svc_external=qsearchs('svc_external',{'svcnum'=>$svcnum}) or die "Unknown (svc_external) svcnum!"; my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) or die "Unknown (cust_svc) svcnum!"; $pkgnum=$cust_svc->pkgnum; $svcpart=$cust_svc->svcpart; $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); die "No part_svc entry!" unless $part_svc; } else { #adding foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart $pkgnum=$1 if /^pkgnum(\d+)$/; $svcpart=$1 if /^svcpart(\d+)$/; } $svc_external = new FS::svc_external { svcpart => $svcpart }; $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); die "No part_svc entry!" unless $part_svc; $svcnum=''; #set fixed and default fields from part_svc foreach my $part_svc_column ( grep { $_->columnflag } $part_svc->all_part_svc_column ) { $svc_external->setfield( $part_svc_column->columnname, $part_svc_column->columnvalue, ); } } } my $action = $svc_external->svcnum ? 'Edit' : 'Add'; my $p1 = popurl(1); print header("External service $action", ''); print qq!Error: !, $cgi->param('error'), "" if $cgi->param('error'); print qq!