comment out future UI code (but look at it, it's neat!)
[freeside.git] / htdocs / edit / agent_type.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: agent_type.cgi,v 1.9 1999-01-19 05:13:32 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.9  1999-01-19 05:13:32  ivan
17 # for mod_perl: no more top-level my() variables; use vars instead
18 # also the last s/create/new/;
19 #
20 # Revision 1.8  1999/01/18 09:41:22  ivan
21 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
22 # (good idea anyway)
23 #
24 # Revision 1.7  1999/01/18 09:22:29  ivan
25 # changes to track email addresses for email invoicing
26 #
27 # Revision 1.6  1998/12/17 06:16:58  ivan
28 # fix double // in relative URLs, s/CGI::Base/CGI/;
29 #
30 # Revision 1.5  1998/11/21 07:58:27  ivan
31 # package names link to them
32 #
33 # Revision 1.4  1998/11/21 07:45:19  ivan
34 # visual, use FS::table_name when doing qsearch('table_name')
35 #
36 # Revision 1.3  1998/11/15 11:20:12  ivan
37 # s/CGI-Base/CGI.pm/ causes s/QUERY_STRING/keywords/;
38 #
39 # Revision 1.2  1998/11/13 09:56:46  ivan
40 # change configuration file layout to support multiple distinct databases (with
41 # own set of config files, export, etc.)
42 #
43
44 use strict;
45 use vars qw( $cgi $agent_type $action $hashref $p $part_pkg );
46 use CGI;
47 use CGI::Carp qw(fatalsToBrowser);
48 use FS::UID qw(cgisuidsetup);
49 use FS::Record qw(qsearch qsearchs);
50 use FS::agent_type;
51 use FS::CGI qw(header menubar popurl);
52 use FS::agent_type;
53 use FS::part_pkg;
54 use FS::type_pkgs;
55
56 $cgi = new CGI;
57
58 &cgisuidsetup($cgi);
59
60 if ( $cgi->keywords ) { #editing
61   my( $query ) = $cgi->keywords;
62   $query =~ /^(\d+)$/;
63   $agent_type=qsearchs('agent_type',{'typenum'=>$1});
64   $action='Edit';
65 } else { #adding
66   $agent_type = new FS::agent_type {};
67   $action='Add';
68 }
69 $hashref = $agent_type->hashref;
70
71 $p = popurl(2);
72 print $cgi->header( '-expires' => 'now' ), header("$action Agent Type", menubar(
73   'Main Menu' => "$p",
74   'View all agent types' => "${p}browse/agent_type.cgi",
75 )), '<FORM ACTION="', popurl(1), 'process/agent_type.cgi" METHOD=POST>';
76
77 print qq!<INPUT TYPE="hidden" NAME="typenum" VALUE="$hashref->{typenum}">!,
78       "Agent Type #", $hashref->{typenum} ? $hashref->{typenum} : "(NEW)";
79
80 print <<END;
81 <BR><BR>Agent Type <INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="$hashref->{atype}">
82 <BR><BR>Select which packages agents of this type may sell to customers<BR>
83 END
84
85 foreach $part_pkg ( qsearch('part_pkg',{}) ) {
86   print qq!<BR><INPUT TYPE="checkbox" NAME="pkgpart!,
87         $part_pkg->getfield('pkgpart'), qq!" !,
88        # ( 'CHECKED 'x scalar(
89         qsearchs('type_pkgs',{
90           'typenum' => $agent_type->getfield('typenum'),
91           'pkgpart'  => $part_pkg->getfield('pkgpart'),
92         })
93           ? 'CHECKED '
94           : '',
95         qq!"VALUE="ON"> !,
96     qq!<A HREF="${p}edit/part_pkg.cgi?!, $part_pkg->pkgpart, 
97     '">', $part_pkg->getfield('pkg'), '</A>',
98   ;
99 }
100
101 print qq!<BR><INPUT TYPE="submit" VALUE="!,
102       $hashref->{typenum} ? "Apply changes" : "Add agent type",
103       qq!">!;
104
105 print <<END;
106     </FORM>
107   </BODY>
108 </HTML>
109 END
110