Added hide/show customer router link.
[freeside.git] / httemplate / browse / agent_type.cgi
index 30b8000..5473804 100755 (executable)
@@ -1,38 +1,27 @@
-<%
-#<!-- $Id: agent_type.cgi,v 1.4 2001-09-04 14:44:06 ivan Exp $ -->
-
-use strict;
-use vars qw( $cgi $p $agent_type );
-use CGI;
-use CGI::Carp qw(fatalsToBrowser);
-use FS::UID qw(cgisuidsetup);
-use FS::Record qw(qsearch qsearchs);
-use FS::CGI qw(header menubar popurl table);
-use FS::agent_type;
-use FS::type_pkgs;
-use FS::part_pkg;
-
-$cgi = new CGI;
-
-&cgisuidsetup($cgi);
-
-$p = popurl(2);
-print $cgi->header( '-expires' => 'now' ), header("Agent Type Listing", menubar(
+<!-- mason kludge -->
+<%= header("Agent Type Listing", menubar(
   'Main Menu' => $p,
-)), "Agent types define groups of packages that you can then assign to".
-    " particular agents.<BR><BR>", &table(), <<END;
-      <TR>
-        <TH COLSPAN=2>Agent Type</TH>
-        <TH COLSPAN="2">Packages</TH>
-      </TR>
-END
-
-foreach $agent_type ( sort { 
+  'Agents'    => $p. 'browse/agent.cgi',
+)) %>
+Agent types define groups of packages that you can then assign to particular
+agents.<BR><BR>
+<A HREF="<%= $p %>edit/agent_type.cgi"><I>Add a new agent type</I></A><BR><BR>
+
+<%= table() %>
+<TR>
+  <TH COLSPAN=2>Agent Type</TH>
+  <TH COLSPAN=2>Packages</TH>
+</TR>
+
+<% 
+foreach my $agent_type ( sort { 
   $a->getfield('typenum') <=> $b->getfield('typenum')
 } qsearch('agent_type',{}) ) {
-  my($hashref)=$agent_type->hashref;
-  my(@type_pkgs)=qsearch('type_pkgs',{'typenum'=> $hashref->{typenum} });
-  my($rowspan)=scalar(@type_pkgs);
+  my $hashref = $agent_type->hashref;
+  #more efficient to do this with SQL...
+  my @type_pkgs = grep { $_->part_pkg and ! $_->part_pkg->disabled }
+                       qsearch('type_pkgs',{'typenum'=> $hashref->{typenum} });
+  my $rowspan = scalar(@type_pkgs);
   $rowspan = int($rowspan/2+0.5) ;
   print <<END;
       <TR>
@@ -63,7 +52,6 @@ END
 }
 
 print <<END;
-  <TR><TD COLSPAN=2><I><A HREF="${p}edit/agent_type.cgi">Add a new agent type</A></I></TD></TR>
     </TABLE>
   </BODY>
 </HTML>