2 #<!-- $Id: agent_type.cgi,v 1.2 2001-08-21 02:31:56 ivan Exp $ -->
5 use vars qw( $cgi $agent_type $action $hashref $p $part_pkg );
7 use CGI::Carp qw(fatalsToBrowser);
8 use FS::UID qw(cgisuidsetup);
9 use FS::Record qw(qsearch qsearchs fields);
11 use FS::CGI qw(header menubar popurl);
20 if ( $cgi->param('error') ) {
21 $agent_type = new FS::agent_type ( {
22 map { $_, scalar($cgi->param($_)) } fields('agent')
24 } elsif ( $cgi->keywords ) { #editing
25 my( $query ) = $cgi->keywords;
27 $agent_type=qsearchs('agent_type',{'typenum'=>$1});
29 $agent_type = new FS::agent_type {};
31 $action = $agent_type->typenum ? 'Edit' : 'Add';
32 $hashref = $agent_type->hashref;
35 print $cgi->header( '-expires' => 'now' ), header("$action Agent Type", menubar(
37 'View all agent types' => "${p}browse/agent_type.cgi",
40 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
42 if $cgi->param('error');
44 print '<FORM ACTION="', popurl(1), 'process/agent_type.cgi" METHOD=POST>',
45 qq!<INPUT TYPE="hidden" NAME="typenum" VALUE="$hashref->{typenum}">!,
46 "Agent Type #", $hashref->{typenum} ? $hashref->{typenum} : "(NEW)";
49 <BR><BR>Agent Type <INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="$hashref->{atype}">
50 <BR><BR>Select which packages agents of this type may sell to customers<BR>
53 foreach $part_pkg ( qsearch('part_pkg',{}) ) {
54 print qq!<BR><INPUT TYPE="checkbox" NAME="pkgpart!,
55 $part_pkg->getfield('pkgpart'), qq!" !,
56 # ( 'CHECKED 'x scalar(
57 qsearchs('type_pkgs',{
58 'typenum' => $agent_type->getfield('typenum'),
59 'pkgpart' => $part_pkg->getfield('pkgpart'),
64 qq!<A HREF="${p}edit/part_pkg.cgi?!, $part_pkg->pkgpart,
65 '">', $part_pkg->getfield('pkg'), '</A>',
69 print qq!<BR><INPUT TYPE="submit" VALUE="!,
70 $hashref->{typenum} ? "Apply changes" : "Add agent type",