fix visual and other bugs
[freeside.git] / htdocs / browse / agent_type.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: agent_type.cgi,v 1.3 1998-12-17 05:25:17 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.3  1998-12-17 05:25:17  ivan
15 # fix visual and other bugs
16 #
17 # Revision 1.2  1998/11/21 07:39:52  ivan
18 # visual
19 #
20
21 use strict;
22 use CGI;
23 use CGI::Carp qw(fatalsToBrowser);
24 use FS::UID qw(cgisuidsetup swapuid);
25 use FS::Record qw(qsearch qsearchs);
26 use FS::CGI qw(header menubar popurl table);
27 use FS::agent_type;
28 use FS::type_pkgs;
29 use FS::part_pkg;
30
31 my($cgi) = new CGI;
32
33 &cgisuidsetup($cgi);
34
35 my($p)=popurl(2);
36 print $cgi->header, header("Agent Type Listing", menubar(
37   'Main Menu' => $p,
38 )), "Agent types define groups of packages that you can then assign to".
39     " particular agents.<BR><BR>", table, <<END;
40       <TR>
41         <TH COLSPAN=2>Agent Type</TH>
42         <TH COLSPAN="2">Packages</TH>
43       </TR>
44 END
45
46 my($agent_type);
47 foreach $agent_type ( sort { 
48   $a->getfield('typenum') <=> $b->getfield('typenum')
49 } qsearch('agent_type',{}) ) {
50   my($hashref)=$agent_type->hashref;
51   my(@type_pkgs)=qsearch('type_pkgs',{'typenum'=> $hashref->{typenum} });
52   my($rowspan)=scalar(@type_pkgs);
53   $rowspan = int($rowspan/2+0.5) ;
54   print <<END;
55       <TR>
56         <TD ROWSPAN=$rowspan><A HREF="${p}edit/agent_type.cgi?$hashref->{typenum}">
57           $hashref->{typenum}
58         </A></TD>
59         <TD ROWSPAN=$rowspan><A HREF="${p}/edit/agent_type.cgi?$hashref->{typenum}">$hashref->{atype}</A></TD>
60 END
61
62   my($type_pkgs);
63   my($tdcount) = -1 ;
64   foreach $type_pkgs ( @type_pkgs ) {
65     my($pkgpart)=$type_pkgs->getfield('pkgpart');
66     my($part_pkg) = qsearchs('part_pkg',{'pkgpart'=> $pkgpart });
67     print qq!<TR>! if ($tdcount == 0) ;
68     $tdcount = 0 if ($tdcount == -1) ;
69     print qq!<TD><A HREF="${p}edit/part_pkg.cgi?$pkgpart">!,
70           $part_pkg->getfield('pkg'),"</A></TD>";
71     $tdcount ++ ;
72     if ($tdcount == 2)
73     {
74         print qq!</TR>\n! ;
75         $tdcount = 0 ;
76     }
77   }
78
79   print "</TR>";
80 }
81
82 print <<END;
83   <TR><TD COLSPAN=2><I><A HREF="${p}edit/agent_type.cgi">Add new agent type</A></I></TD></TR>
84     </TABLE>
85   </BODY>
86 </HTML>
87 END
88