3 # $Id: agent_type.cgi,v 1.10 1999-01-25 12:09:51 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.10 1999-01-25 12:09:51 ivan
17 # yet more mod_perl stuff
19 # Revision 1.9 1999/01/19 05:13:32 ivan
20 # for mod_perl: no more top-level my() variables; use vars instead
21 # also the last s/create/new/;
23 # Revision 1.8 1999/01/18 09:41:22 ivan
24 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
27 # Revision 1.7 1999/01/18 09:22:29 ivan
28 # changes to track email addresses for email invoicing
30 # Revision 1.6 1998/12/17 06:16:58 ivan
31 # fix double // in relative URLs, s/CGI::Base/CGI/;
33 # Revision 1.5 1998/11/21 07:58:27 ivan
34 # package names link to them
36 # Revision 1.4 1998/11/21 07:45:19 ivan
37 # visual, use FS::table_name when doing qsearch('table_name')
39 # Revision 1.3 1998/11/15 11:20:12 ivan
40 # s/CGI-Base/CGI.pm/ causes s/QUERY_STRING/keywords/;
42 # Revision 1.2 1998/11/13 09:56:46 ivan
43 # change configuration file layout to support multiple distinct databases (with
44 # own set of config files, export, etc.)
48 use vars qw( $cgi $agent_type $action $hashref $p $part_pkg );
50 use CGI::Carp qw(fatalsToBrowser);
51 use FS::UID qw(cgisuidsetup);
52 use FS::Record qw(qsearch qsearchs fields);
54 use FS::CGI qw(header menubar popurl);
63 if ( $cgi->param('error') ) {
64 $agent_type = new FS::agent_type ( {
65 map { $_, scalar($cgi->param($_)) } fields('agent')
67 } elsif ( $cgi->keywords ) { #editing
68 my( $query ) = $cgi->keywords;
70 $agent_type=qsearchs('agent_type',{'typenum'=>$1});
72 $agent_type = new FS::agent_type {};
74 $action = $agent_type->typenum ? 'Edit' : 'Add';
75 $hashref = $agent_type->hashref;
78 print $cgi->header( '-expires' => 'now' ), header("$action Agent Type", menubar(
80 'View all agent types' => "${p}browse/agent_type.cgi",
83 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
85 if $cgi->param('error');
87 print '<FORM ACTION="', popurl(1), 'process/agent_type.cgi" METHOD=POST>',
88 qq!<INPUT TYPE="hidden" NAME="typenum" VALUE="$hashref->{typenum}">!,
89 "Agent Type #", $hashref->{typenum} ? $hashref->{typenum} : "(NEW)";
92 <BR><BR>Agent Type <INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="$hashref->{atype}">
93 <BR><BR>Select which packages agents of this type may sell to customers<BR>
96 foreach $part_pkg ( qsearch('part_pkg',{}) ) {
97 print qq!<BR><INPUT TYPE="checkbox" NAME="pkgpart!,
98 $part_pkg->getfield('pkgpart'), qq!" !,
99 # ( 'CHECKED 'x scalar(
100 qsearchs('type_pkgs',{
101 'typenum' => $agent_type->getfield('typenum'),
102 'pkgpart' => $part_pkg->getfield('pkgpart'),
107 qq!<A HREF="${p}edit/part_pkg.cgi?!, $part_pkg->pkgpart,
108 '">', $part_pkg->getfield('pkg'), '</A>',
112 print qq!<BR><INPUT TYPE="submit" VALUE="!,
113 $hashref->{typenum} ? "Apply changes" : "Add agent type",