blob: 516594573f5ac0fb2673f2c57a171fc4cb0f3dd9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
<%
my $typenum = $cgi->param('typenum');
my $old = qsearchs('agent_type',{'typenum'=>$typenum}) if $typenum;
my $new = new FS::agent_type ( {
map {
$_, scalar($cgi->param($_));
} fields('agent_type')
} );
my $error;
if ( $typenum ) {
$error=$new->replace($old);
} else {
$error=$new->insert;
$typenum=$new->getfield('typenum');
}
if ( $error ) {
$cgi->param('error', $error);
print $cgi->redirect(popurl(2). "agent_type.cgi?". $cgi->query_string );
} else {
#false laziness w/ edit/process/part_svc.cgi
foreach my $part_pkg (qsearch('part_pkg',{})) {
my($pkgpart)=$part_pkg->getfield('pkgpart');
my($type_pkgs)=qsearchs('type_pkgs',{
'typenum' => $typenum,
'pkgpart' => $pkgpart,
});
if ( $type_pkgs && ! $cgi->param("pkgpart$pkgpart") ) {
my($d_type_pkgs)=$type_pkgs; #need to save $type_pkgs for below.
$error=$d_type_pkgs->delete;
die $error if $error;
} elsif ( $cgi->param("pkgpart$pkgpart")
&& ! $type_pkgs
) {
#ok to clobber it now (but bad form nonetheless?)
$type_pkgs=new FS::type_pkgs ({
'typenum' => $typenum,
'pkgpart' => $pkgpart,
});
$error= $type_pkgs->insert;
die $error if $error;
}
}
print $cgi->redirect(popurl(3). "browse/agent_type.cgi");
}
%>
|