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