This commit was generated by cvs2svn to compensate for changes in r4407,
[freeside.git] / httemplate / browse / agent_type.cgi
1 <!-- mason kludge -->
2 <%= header("Agent Type Listing", menubar(
3   'Main Menu' => $p,
4   'Agents'    => $p. 'browse/agent.cgi',
5 )) %>
6 Agent types define groups of packages that you can then assign to particular
7 agents.<BR><BR>
8 <A HREF="<%= $p %>edit/agent_type.cgi"><I>Add a new agent type</I></A><BR><BR>
9
10 <%= table() %>
11 <TR>
12   <TH COLSPAN=2>Agent Type</TH>
13   <TH COLSPAN=2>Packages</TH>
14 </TR>
15
16 <% 
17 foreach my $agent_type ( sort { 
18   $a->getfield('typenum') <=> $b->getfield('typenum')
19 } qsearch('agent_type',{}) ) {
20   my $hashref = $agent_type->hashref;
21   #more efficient to do this with SQL...
22   my @type_pkgs = grep { $_->part_pkg and ! $_->part_pkg->disabled }
23                        qsearch('type_pkgs',{'typenum'=> $hashref->{typenum} });
24   my $rowspan = scalar(@type_pkgs);
25   $rowspan = int($rowspan/2+0.5) ;
26   print <<END;
27       <TR>
28         <TD ROWSPAN=$rowspan><A HREF="${p}edit/agent_type.cgi?$hashref->{typenum}">
29           $hashref->{typenum}
30         </A></TD>
31         <TD ROWSPAN=$rowspan><A HREF="${p}edit/agent_type.cgi?$hashref->{typenum}">$hashref->{atype}</A></TD>
32 END
33
34   my($type_pkgs);
35   my($tdcount) = -1 ;
36   foreach $type_pkgs ( @type_pkgs ) {
37     my($pkgpart)=$type_pkgs->getfield('pkgpart');
38     my($part_pkg) = qsearchs('part_pkg',{'pkgpart'=> $pkgpart });
39     print qq!<TR>! if ($tdcount == 0) ;
40     $tdcount = 0 if ($tdcount == -1) ;
41     print qq!<TD><A HREF="${p}edit/part_pkg.cgi?$pkgpart">!,
42           $part_pkg->getfield('pkg'),"</A></TD>";
43     $tdcount ++ ;
44     if ($tdcount == 2)
45     {
46         print qq!</TR>\n! ;
47         $tdcount = 0 ;
48     }
49   }
50
51   print "</TR>";
52 }
53
54 print <<END;
55     </TABLE>
56   </BODY>
57 </HTML>
58 END
59
60 %>