4 if ( $cgi->param('error') ) {
5 $agent_type = new FS::agent_type ( {
6 map { $_, scalar($cgi->param($_)) } fields('agent')
8 } elsif ( $cgi->keywords ) { #editing
9 my( $query ) = $cgi->keywords;
11 $agent_type=qsearchs('agent_type',{'typenum'=>$1});
13 $agent_type = new FS::agent_type {};
15 my $action = $agent_type->typenum ? 'Edit' : 'Add';
16 my $hashref = $agent_type->hashref;
18 print header("$action Agent Type", menubar(
20 'View all agent types' => "${p}browse/agent_type.cgi",
23 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
25 if $cgi->param('error');
27 print '<FORM ACTION="', popurl(1), 'process/agent_type.cgi" METHOD=POST>',
28 qq!<INPUT TYPE="hidden" NAME="typenum" VALUE="$hashref->{typenum}">!,
29 "Agent Type #", $hashref->{typenum} ? $hashref->{typenum} : "(NEW)";
32 <BR><BR>Agent Type <INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="$hashref->{atype}">
33 <BR><BR>Select which packages agents of this type may sell to customers<BR>
36 foreach my $part_pkg ( qsearch('part_pkg',{ 'disabled' => '' }) ) {
37 print qq!<BR><INPUT TYPE="checkbox" NAME="pkgpart!,
38 $part_pkg->getfield('pkgpart'), qq!" !,
39 # ( 'CHECKED 'x scalar(
40 qsearchs('type_pkgs',{
41 'typenum' => $agent_type->getfield('typenum'),
42 'pkgpart' => $part_pkg->getfield('pkgpart'),
47 qq!<A HREF="${p}edit/part_pkg.cgi?!, $part_pkg->pkgpart,
48 '">', $part_pkg->getfield('pkg'), '</A>',
52 print qq!<BR><BR><INPUT TYPE="submit" VALUE="!,
53 $hashref->{typenum} ? "Apply changes" : "Add agent type",