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
15 use CGI::Carp qw(fatalsToBrowser);
16 use FS::UID qw(cgisuidsetup);
17 use FS::Record qw(qsearch qsearchs);
19 use FS::CGI qw(header menubar);
21 my($cgi) = new CGI::Base;
26 SendHeaders(); # one guess.
28 my($agent_type,$action);
29 if ( $cgi->var('QUERY_STRING') =~ /^(\d+)$/ ) { #editing
30 $agent_type=qsearchs('agent_type',{'typenum'=>$1});
33 $agent_type=create FS::agent_type {};
36 my($hashref)=$agent_type->hashref;
38 print header("$action Agent Type", menubar(
40 'View all agent types' => '../browse/agent_type.cgi',
41 )), '<FORM ACTION="process/agent_type.cgi" METHOD=POST>';
43 print qq!<INPUT TYPE="hidden" NAME="typenum" VALUE="$hashref->{typenum}">!,
44 "Agent Type #", $hashref->{typenum} ? $hashref->{typenum} : "(NEW)";
47 <BR>Type <INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="$hashref->{atype}">
48 <P>Select which packages agents of this type may sell to customers</P>
52 foreach $part_pkg ( qsearch('part_pkg',{}) ) {
53 print qq!<BR><INPUT TYPE="checkbox" NAME="pkgpart!,
54 $part_pkg->getfield('pkgpart'), qq!" !,
55 # ( 'CHECKED 'x scalar(
56 qsearchs('type_pkgs',{
57 'typenum' => $agent_type->getfield('typenum'),
58 'pkgpart' => $part_pkg->getfield('pkgpart'),
62 qq!"VALUE="ON"> !,$part_pkg->getfield('pkg')
66 print qq!<BR><INPUT TYPE="submit" VALUE="!,
67 $hashref->{typenum} ? "Apply changes" : "Add agent type",