initial checkin of module files for proper perl installation
[freeside.git] / htdocs / browse / agent.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: agent.cgi,v 1.13 1999-04-09 04:22:34 ivan Exp $
4 #
5 # ivan@sisd.com 97-dec-12
6 #
7 # changes to allow pages to load from a relative location in the web tree.
8 #       bmccane@maxbaud.net     98-mar-25
9 #
10 # changed 'type' to 'atype' because type is reserved word in Pg6.3
11 #       bmccane@maxbaud.net     98-apr-3
12 #
13 # agent type was linking to wrong cgi ivan@sisd.com 98-jul-18
14 #
15 # lose background, FS::CGI ivan@sisd.com 98-sep-2
16 #
17 # $Log: agent.cgi,v $
18 # Revision 1.13  1999-04-09 04:22:34  ivan
19 # also table()
20 #
21 # Revision 1.12  1999/04/09 03:52:55  ivan
22 # explicit & for table/itable/ntable
23 #
24 # Revision 1.11  1999/01/20 09:43:16  ivan
25 # comment out future UI code (but look at it, it's neat!)
26 #
27 # Revision 1.10  1999/01/19 05:13:24  ivan
28 # for mod_perl: no more top-level my() variables; use vars instead
29 # also the last s/create/new/;
30 #
31 # Revision 1.9  1999/01/18 09:41:14  ivan
32 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
33 # (good idea anyway)
34 #
35 # Revision 1.8  1999/01/18 09:22:26  ivan
36 # changes to track email addresses for email invoicing
37 #
38 # Revision 1.7  1998/12/17 05:25:16  ivan
39 # fix visual and other bugs
40 #
41 # Revision 1.6  1998/11/23 05:29:46  ivan
42 # use CGI::Carp
43 #
44 # Revision 1.5  1998/11/23 05:27:31  ivan
45 # to eliminate warnings
46 #
47 # Revision 1.4  1998/11/20 08:50:36  ivan
48 # s/CGI::Base/CGI.pm, visual fixes
49 #
50 # Revision 1.3  1998/11/08 10:11:02  ivan
51 # CGI.pm
52 #
53 # Revision 1.2  1998/11/07 10:24:22  ivan
54 # don't use depriciated FS::Bill and FS::Invoice, other miscellania
55 #
56
57 use strict;
58 use vars qw( $ui $cgi $p $agent );
59 use CGI;
60 use CGI::Carp qw(fatalsToBrowser);
61 use FS::UID qw(cgisuidsetup swapuid);
62 use FS::Record qw(qsearch qsearchs);
63 use FS::CGI qw(header menubar table popurl);
64 use FS::agent;
65 use FS::agent_type;
66
67 #Begin silliness
68 #
69 #use FS::UI::CGI;
70 #use FS::UI::agent;
71 #
72 #$ui = new FS::UI::agent;
73 #$ui->browse;
74 #exit;
75 #__END__
76 #End silliness
77
78 $cgi = new CGI;
79
80 &cgisuidsetup($cgi);
81
82 $p = popurl(2);
83
84 print $cgi->header( '-expires' => 'now' ), header('Agent Listing', menubar(
85   'Main Menu'   => $p,
86   'Agent Types' => $p. 'browse/agent_type.cgi',
87 #  'Add new agent' => '../edit/agent.cgi'
88 )), <<END;
89 Agents are resellers of your service. Agents may be limited to a subset of your
90 full offerings (via their type).<BR><BR>
91 END
92 print &table(), <<END;
93       <TR>
94         <TH COLSPAN=2>Agent</TH>
95         <TH>Type</TH>
96         <TH><FONT SIZE=-1>Freq. (unimp.)</FONT></TH>
97         <TH><FONT SIZE=-1>Prog. (unimp.)</FONT></TH>
98       </TR>
99 END
100 #        <TH><FONT SIZE=-1>Agent #</FONT></TH>
101 #        <TH>Agent</TH>
102
103 foreach $agent ( sort { 
104   $a->getfield('agentnum') <=> $b->getfield('agentnum')
105 } qsearch('agent',{}) ) {
106   my($hashref)=$agent->hashref;
107   my($typenum)=$hashref->{typenum};
108   my($agent_type)=qsearchs('agent_type',{'typenum'=>$typenum});
109   my($atype)=$agent_type->getfield('atype');
110   print <<END;
111       <TR>
112         <TD><A HREF="${p}edit/agent.cgi?$hashref->{agentnum}">
113           $hashref->{agentnum}</A></TD>
114         <TD><A HREF="${p}edit/agent.cgi?$hashref->{agentnum}">
115           $hashref->{agent}</A></TD>
116         <TD><A HREF="${p}edit/agent_type.cgi?$typenum">$atype</A></TD>
117         <TD>$hashref->{freq}</TD>
118         <TD>$hashref->{prog}</TD>
119       </TR>
120 END
121
122 }
123
124 print <<END;
125       <TR>
126         <TD COLSPAN=2><A HREF="${p}edit/agent.cgi"><I>Add new agent</I></A></TD>
127         <TD><A HREF="${p}edit/agent_type.cgi"><I>Add new agent type</I></A></TD>
128       </TR>
129     </TABLE>
130
131   </BODY>
132 </HTML>
133 END
134