3 # agent_type.cgi: Add/Edit agent type (output form)
5 # ivan@sisd.com 97-dec-10
7 # Changes to allow page to work at a relative position in server
8 # Changed 'type' to 'atype' because Pg6.3 reserves the type word
9 # bmccane@maxbaud.net 98-apr-3
11 # use FS::CGI, added inline documentation ivan@sisd.com 98-jul-12
13 # $Log: agent_type.cgi,v $
14 # Revision 1.2 1998-11-13 09:56:46 ivan
15 # change configuration file layout to support multiple distinct databases (with
16 # own set of config files, export, etc.)
21 use CGI::Carp qw(fatalsToBrowser);
22 use FS::UID qw(cgisuidsetup);
23 use FS::Record qw(qsearch qsearchs);
25 use FS::CGI qw(header menubar);
31 my($agent_type,$action);
32 if ( $cgi->var('QUERY_STRING') =~ /^(\d+)$/ ) { #editing
33 $agent_type=qsearchs('agent_type',{'typenum'=>$1});
36 $agent_type=create FS::agent_type {};
39 my($hashref)=$agent_type->hashref;
41 print $cgi->header, header("$action Agent Type", menubar(
43 'View all agent types' => '../browse/agent_type.cgi',
44 )), '<FORM ACTION="process/agent_type.cgi" METHOD=POST>';
46 print qq!<INPUT TYPE="hidden" NAME="typenum" VALUE="$hashref->{typenum}">!,
47 "Agent Type #", $hashref->{typenum} ? $hashref->{typenum} : "(NEW)";
50 <BR>Type <INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="$hashref->{atype}">
51 <P>Select which packages agents of this type may sell to customers</P>
55 foreach $part_pkg ( qsearch('part_pkg',{}) ) {
56 print qq!<BR><INPUT TYPE="checkbox" NAME="pkgpart!,
57 $part_pkg->getfield('pkgpart'), qq!" !,
58 # ( 'CHECKED 'x scalar(
59 qsearchs('type_pkgs',{
60 'typenum' => $agent_type->getfield('typenum'),
61 'pkgpart' => $part_pkg->getfield('pkgpart'),
65 qq!"VALUE="ON"> !,$part_pkg->getfield('pkg')
69 print qq!<BR><INPUT TYPE="submit" VALUE="!,
70 $hashref->{typenum} ? "Apply changes" : "Add agent type",