3 # $Id: agent_type.cgi,v 1.4 1998-11-21 07:45:19 ivan Exp $
5 # agent_type.cgi: Add/Edit agent type (output form)
7 # ivan@sisd.com 97-dec-10
9 # Changes to allow page to work at a relative position in server
10 # Changed 'type' to 'atype' because Pg6.3 reserves the type word
11 # bmccane@maxbaud.net 98-apr-3
13 # use FS::CGI, added inline documentation ivan@sisd.com 98-jul-12
15 # $Log: agent_type.cgi,v $
16 # Revision 1.4 1998-11-21 07:45:19 ivan
17 # visual, use FS::table_name when doing qsearch('table_name')
19 # Revision 1.3 1998/11/15 11:20:12 ivan
20 # s/CGI-Base/CGI.pm/ causes s/QUERY_STRING/keywords/;
22 # Revision 1.2 1998/11/13 09:56:46 ivan
23 # change configuration file layout to support multiple distinct databases (with
24 # own set of config files, export, etc.)
29 use CGI::Carp qw(fatalsToBrowser);
30 use FS::UID qw(cgisuidsetup);
31 use FS::Record qw(qsearch qsearchs);
33 use FS::CGI qw(header menubar popurl);
42 my($agent_type,$action);
43 if ( $cgi->keywords =~ /^(\d+)$/ ) { #editing
44 $agent_type=qsearchs('agent_type',{'typenum'=>$1});
47 $agent_type=create FS::agent_type {};
50 my($hashref)=$agent_type->hashref;
53 print $cgi->header, header("$action Agent Type", menubar(
55 'View all agent types' => "$p/browse/agent_type.cgi",
56 )), '<FORM ACTION="', popurl(1), '/process/agent_type.cgi" METHOD=POST>';
58 print qq!<INPUT TYPE="hidden" NAME="typenum" VALUE="$hashref->{typenum}">!,
59 "Agent Type #", $hashref->{typenum} ? $hashref->{typenum} : "(NEW)";
62 <BR><BR>Agent Type <INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="$hashref->{atype}">
63 <BR><BR>Select which packages agents of this type may sell to customers<BR>
67 foreach $part_pkg ( qsearch('part_pkg',{}) ) {
68 print qq!<BR><INPUT TYPE="checkbox" NAME="pkgpart!,
69 $part_pkg->getfield('pkgpart'), qq!" !,
70 # ( 'CHECKED 'x scalar(
71 qsearchs('type_pkgs',{
72 'typenum' => $agent_type->getfield('typenum'),
73 'pkgpart' => $part_pkg->getfield('pkgpart'),
77 qq!"VALUE="ON"> !,$part_pkg->getfield('pkg')
81 print qq!<BR><INPUT TYPE="submit" VALUE="!,
82 $hashref->{typenum} ? "Apply changes" : "Add agent type",