harmless typo
[freeside.git] / htdocs / browse / agent_type.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: agent_type.cgi,v 1.6 1999-04-07 11:10:46 ivan Exp $
4 #
5 # ivan@sisd.com 97-dec-10
6 #
7 # Changes to allow page to work at a relative position in server
8 # Changes to make "Packages" display 2-wide in table (old way was too vertical)
9 #       bmccane@maxbaud.net 98-apr-3
10 #
11 # lose background, FS::CGI ivan@sisd.com 98-sep-2
12 #
13 # $Log: agent_type.cgi,v $
14 # Revision 1.6  1999-04-07 11:10:46  ivan
15 # harmless typo
16 #
17 # Revision 1.5  1999/01/19 05:13:25  ivan
18 # for mod_perl: no more top-level my() variables; use vars instead
19 # also the last s/create/new/;
20 #
21 # Revision 1.4  1999/01/18 09:41:15  ivan
22 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
23 # (good idea anyway)
24 #
25 # Revision 1.3  1998/12/17 05:25:17  ivan
26 # fix visual and other bugs
27 #
28 # Revision 1.2  1998/11/21 07:39:52  ivan
29 # visual
30 #
31
32 use strict;
33 use vars qw( $cgi $p $agent_type );
34 use CGI;
35 use CGI::Carp qw(fatalsToBrowser);
36 use FS::UID qw(cgisuidsetup swapuid);
37 use FS::Record qw(qsearch qsearchs);
38 use FS::CGI qw(header menubar popurl table);
39 use FS::agent_type;
40 use FS::type_pkgs;
41 use FS::part_pkg;
42
43 $cgi = new CGI;
44
45 &cgisuidsetup($cgi);
46
47 $p = popurl(2);
48 print $cgi->header( '-expires' => 'now' ), header("Agent Type Listing", menubar(
49   'Main Menu' => $p,
50 )), "Agent types define groups of packages that you can then assign to".
51     " particular agents.<BR><BR>", table, <<END;
52       <TR>
53         <TH COLSPAN=2>Agent Type</TH>
54         <TH COLSPAN="2">Packages</TH>
55       </TR>
56 END
57
58 foreach $agent_type ( sort { 
59   $a->getfield('typenum') <=> $b->getfield('typenum')
60 } qsearch('agent_type',{}) ) {
61   my($hashref)=$agent_type->hashref;
62   my(@type_pkgs)=qsearch('type_pkgs',{'typenum'=> $hashref->{typenum} });
63   my($rowspan)=scalar(@type_pkgs);
64   $rowspan = int($rowspan/2+0.5) ;
65   print <<END;
66       <TR>
67         <TD ROWSPAN=$rowspan><A HREF="${p}edit/agent_type.cgi?$hashref->{typenum}">
68           $hashref->{typenum}
69         </A></TD>
70         <TD ROWSPAN=$rowspan><A HREF="${p}edit/agent_type.cgi?$hashref->{typenum}">$hashref->{atype}</A></TD>
71 END
72
73   my($type_pkgs);
74   my($tdcount) = -1 ;
75   foreach $type_pkgs ( @type_pkgs ) {
76     my($pkgpart)=$type_pkgs->getfield('pkgpart');
77     my($part_pkg) = qsearchs('part_pkg',{'pkgpart'=> $pkgpart });
78     print qq!<TR>! if ($tdcount == 0) ;
79     $tdcount = 0 if ($tdcount == -1) ;
80     print qq!<TD><A HREF="${p}edit/part_pkg.cgi?$pkgpart">!,
81           $part_pkg->getfield('pkg'),"</A></TD>";
82     $tdcount ++ ;
83     if ($tdcount == 2)
84     {
85         print qq!</TR>\n! ;
86         $tdcount = 0 ;
87     }
88   }
89
90   print "</TR>";
91 }
92
93 print <<END;
94   <TR><TD COLSPAN=2><I><A HREF="${p}edit/agent_type.cgi">Add new agent type</A></I></TD></TR>
95     </TABLE>
96   </BODY>
97 </HTML>
98 END
99