*** empty log message ***
[freeside.git] / htdocs / edit / agent_type.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: agent_type.cgi,v 1.6 1998-12-17 06:16:58 ivan Exp $
4 #
5 # agent_type.cgi: Add/Edit agent type (output form)
6 #
7 # ivan@sisd.com 97-dec-10
8 #
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
12 #
13 # use FS::CGI, added inline documentation ivan@sisd.com 98-jul-12
14 #
15 # $Log: agent_type.cgi,v $
16 # Revision 1.6  1998-12-17 06:16:58  ivan
17 # fix double // in relative URLs, s/CGI::Base/CGI/;
18 #
19 # Revision 1.5  1998/11/21 07:58:27  ivan
20 # package names link to them
21 #
22 # Revision 1.4  1998/11/21 07:45:19  ivan
23 # visual, use FS::table_name when doing qsearch('table_name')
24 #
25 # Revision 1.3  1998/11/15 11:20:12  ivan
26 # s/CGI-Base/CGI.pm/ causes s/QUERY_STRING/keywords/;
27 #
28 # Revision 1.2  1998/11/13 09:56:46  ivan
29 # change configuration file layout to support multiple distinct databases (with
30 # own set of config files, export, etc.)
31 #
32
33 use strict;
34 use CGI;
35 use CGI::Carp qw(fatalsToBrowser);
36 use FS::UID qw(cgisuidsetup);
37 use FS::Record qw(qsearch qsearchs);
38 use FS::agent_type;
39 use FS::CGI qw(header menubar popurl);
40 use FS::agent_type;
41 use FS::part_pkg;
42 use FS::type_pkgs;
43
44 my($cgi) = new CGI;
45
46 &cgisuidsetup($cgi);
47
48 my($agent_type,$action);
49 if ( $cgi->keywords =~ /^(\d+)$/ ) { #editing
50   $agent_type=qsearchs('agent_type',{'typenum'=>$1});
51   $action='Edit';
52 } else { #adding
53   $agent_type=create FS::agent_type {};
54   $action='Add';
55 }
56 my($hashref)=$agent_type->hashref;
57
58 my($p)=popurl(2);
59 print $cgi->header, header("$action Agent Type", menubar(
60   'Main Menu' => "$p",
61   'View all agent types' => "${p}browse/agent_type.cgi",
62 )), '<FORM ACTION="', popurl(1), 'process/agent_type.cgi" METHOD=POST>';
63
64 print qq!<INPUT TYPE="hidden" NAME="typenum" VALUE="$hashref->{typenum}">!,
65       "Agent Type #", $hashref->{typenum} ? $hashref->{typenum} : "(NEW)";
66
67 print <<END;
68 <BR><BR>Agent Type <INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="$hashref->{atype}">
69 <BR><BR>Select which packages agents of this type may sell to customers<BR>
70 END
71
72 my($part_pkg);
73 foreach $part_pkg ( qsearch('part_pkg',{}) ) {
74   print qq!<BR><INPUT TYPE="checkbox" NAME="pkgpart!,
75         $part_pkg->getfield('pkgpart'), qq!" !,
76        # ( 'CHECKED 'x scalar(
77         qsearchs('type_pkgs',{
78           'typenum' => $agent_type->getfield('typenum'),
79           'pkgpart'  => $part_pkg->getfield('pkgpart'),
80         })
81           ? 'CHECKED '
82           : '',
83         qq!"VALUE="ON"> !,
84     qq!<A HREF="${p}edit/part_pkg.cgi?!, $part_pkg->pkgpart, 
85     '">', $part_pkg->getfield('pkg'), '</A>',
86   ;
87 }
88
89 print qq!<BR><INPUT TYPE="submit" VALUE="!,
90       $hashref->{typenum} ? "Apply changes" : "Add agent type",
91       qq!">!;
92
93 print <<END;
94     </FORM>
95   </BODY>
96 </HTML>
97 END
98