3 # $Id: agent_type.cgi,v 1.2 1998-11-21 07:49:20 ivan Exp $
5 # ivan@sisd.com 97-dec-11
7 # Changes to allow page to work at a relative position in server
8 # bmccane@maxbaud.net 98-apr-3
10 # lose background, FS::CGI ivan@sisd.com 98-sep-2
12 # $Log: agent_type.cgi,v $
13 # Revision 1.2 1998-11-21 07:49:20 ivan
14 # s/CGI::Request/CGI.pm/
19 use CGI::Carp qw(fatalsToBrowser);
20 use FS::CGI qw(idiot popurl);
21 use FS::UID qw(cgisuidsetup);
22 use FS::Record qw(qsearch qsearchs);
23 use FS::agent_type qw(fields);
30 my($typenum)=$cgi->param('typenum');
31 my($old)=qsearchs('agent_type',{'typenum'=>$typenum}) if $typenum;
33 my($new)=create FS::agent_type ( {
35 $_, scalar($cgi->param($_));
36 } fields('agent_type')
41 $error=$new->replace($old);
44 $typenum=$new->getfield('typenum');
53 foreach $part_pkg (qsearch('part_pkg',{})) {
54 my($pkgpart)=$part_pkg->getfield('pkgpart');
56 my($type_pkgs)=qsearchs('type_pkgs',{
57 'typenum' => $typenum,
58 'pkgpart' => $pkgpart,
60 if ( $type_pkgs && ! $cgi->param("pkgpart$pkgpart") ) {
61 my($d_type_pkgs)=$type_pkgs; #need to save $type_pkgs for below.
62 $error=$d_type_pkgs->del; #FS::Record not FS::type_pkgs,
63 #so ->del not ->delete. hmm. hmm.
69 } elsif ( $cgi->param("pkgpart$pkgpart")
72 #ok to clobber it now (but bad form nonetheless?)
73 $type_pkgs=create FS::type_pkgs ({
74 'typenum' => $typenum,
75 'pkgpart' => $pkgpart,
77 $error= $type_pkgs->insert;
86 #$req->cgi->redirect("../../view/agent_type.cgi?$typenum");
87 #$req->cgi->redirect("../../edit/agent_type.cgi?$typenum");
88 print $cgi->redirect(popurl(3). "/browse/agent_type.cgi");