9d51a37e691468c66f0fed34e3aa48c27f171c9f
[freeside.git] / httemplate / browse / agent_type.cgi
1 <%
2 #
3 # $Id: agent_type.cgi,v 1.1 2001-07-30 07:36:03 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.1  2001-07-30 07:36:03  ivan
15 # templates!!!
16 #
17 # Revision 1.8  1999/04/09 04:22:34  ivan
18 # also table()
19 #
20 # Revision 1.7  1999/04/09 03:52:55  ivan
21 # explicit & for table/itable/ntable
22 #
23 # Revision 1.6  1999/04/07 11:10:46  ivan
24 # harmless typo
25 #
26 # Revision 1.5  1999/01/19 05:13:25  ivan
27 # for mod_perl: no more top-level my() variables; use vars instead
28 # also the last s/create/new/;
29 #
30 # Revision 1.4  1999/01/18 09:41:15  ivan
31 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
32 # (good idea anyway)
33 #
34 # Revision 1.3  1998/12/17 05:25:17  ivan
35 # fix visual and other bugs
36 #
37 # Revision 1.2  1998/11/21 07:39:52  ivan
38 # visual
39 #
40
41 use strict;
42 use vars qw( $cgi $p $agent_type );
43 use CGI;
44 use CGI::Carp qw(fatalsToBrowser);
45 use FS::UID qw(cgisuidsetup swapuid);
46 use FS::Record qw(qsearch qsearchs);
47 use FS::CGI qw(header menubar popurl table);
48 use FS::agent_type;
49 use FS::type_pkgs;
50 use FS::part_pkg;
51
52 $cgi = new CGI;
53
54 &cgisuidsetup($cgi);
55
56 $p = popurl(2);
57 print $cgi->header( '-expires' => 'now' ), header("Agent Type Listing", menubar(
58   'Main Menu' => $p,
59 )), "Agent types define groups of packages that you can then assign to".
60     " particular agents.<BR><BR>", &table(), <<END;
61       <TR>
62         <TH COLSPAN=2>Agent Type</TH>
63         <TH COLSPAN="2">Packages</TH>
64       </TR>
65 END
66
67 foreach $agent_type ( sort { 
68   $a->getfield('typenum') <=> $b->getfield('typenum')
69 } qsearch('agent_type',{}) ) {
70   my($hashref)=$agent_type->hashref;
71   my(@type_pkgs)=qsearch('type_pkgs',{'typenum'=> $hashref->{typenum} });
72   my($rowspan)=scalar(@type_pkgs);
73   $rowspan = int($rowspan/2+0.5) ;
74   print <<END;
75       <TR>
76         <TD ROWSPAN=$rowspan><A HREF="${p}edit/agent_type.cgi?$hashref->{typenum}">
77           $hashref->{typenum}
78         </A></TD>
79         <TD ROWSPAN=$rowspan><A HREF="${p}edit/agent_type.cgi?$hashref->{typenum}">$hashref->{atype}</A></TD>
80 END
81
82   my($type_pkgs);
83   my($tdcount) = -1 ;
84   foreach $type_pkgs ( @type_pkgs ) {
85     my($pkgpart)=$type_pkgs->getfield('pkgpart');
86     my($part_pkg) = qsearchs('part_pkg',{'pkgpart'=> $pkgpart });
87     print qq!<TR>! if ($tdcount == 0) ;
88     $tdcount = 0 if ($tdcount == -1) ;
89     print qq!<TD><A HREF="${p}edit/part_pkg.cgi?$pkgpart">!,
90           $part_pkg->getfield('pkg'),"</A></TD>";
91     $tdcount ++ ;
92     if ($tdcount == 2)
93     {
94         print qq!</TR>\n! ;
95         $tdcount = 0 ;
96     }
97   }
98
99   print "</TR>";
100 }
101
102 print <<END;
103   <TR><TD COLSPAN=2><I><A HREF="${p}edit/agent_type.cgi">Add new agent type</A></I></TD></TR>
104     </TABLE>
105   </BODY>
106 </HTML>
107 END
108
109 %>