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