3 my $typenum = $cgi->param('typenum');
4 my $old = qsearchs('agent_type',{'typenum'=>$typenum}) if $typenum;
6 my $new = new FS::agent_type ( {
8 $_, scalar($cgi->param($_));
14 $error=$new->replace($old);
17 $typenum=$new->getfield('typenum');
21 $cgi->param('error', $error);
22 print $cgi->redirect(popurl(2). "agent_type.cgi?". $cgi->query_string );
25 #false laziness w/ edit/process/part_svc.cgi
26 foreach my $part_pkg (qsearch('part_pkg',{})) {
27 my($pkgpart)=$part_pkg->getfield('pkgpart');
29 my($type_pkgs)=qsearchs('type_pkgs',{
30 'typenum' => $typenum,
31 'pkgpart' => $pkgpart,
33 if ( $type_pkgs && ! $cgi->param("pkgpart$pkgpart") ) {
34 my($d_type_pkgs)=$type_pkgs; #need to save $type_pkgs for below.
35 $error=$d_type_pkgs->delete;
38 } elsif ( $cgi->param("pkgpart$pkgpart")
41 #ok to clobber it now (but bad form nonetheless?)
42 $type_pkgs=new FS::type_pkgs ({
43 'typenum' => $typenum,
44 'pkgpart' => $pkgpart,
46 $error= $type_pkgs->insert;
52 print $cgi->redirect(popurl(3). "browse/agent_type.cgi");