6 if ( $cgi->param('showdisabled')
7 || !dbdef->table('agent')->column('disabled') ) {
10 %search = ( 'disabled' => '' );
13 #bad false laziness with search/cust_main.cgi (also needs fixing up for
16 0 < ( SELECT COUNT(*) FROM cust_pkg
17 WHERE cust_pkg.custnum = cust_main.custnum
18 AND ( cust_pkg.cancel IS NULL
19 OR cust_pkg.cancel = 0
22 OR 0 = ( SELECT COUNT(*) FROM cust_pkg
23 WHERE cust_pkg.custnum = cust_main.custnum
27 my $ncancelled_sth = dbh->prepare("SELECT COUNT(*) FROM cust_main
29 AND ( $ncancelled ) ")
32 my $total_sth = dbh->prepare("SELECT COUNT(*) FROM cust_main
38 <%= header('Agent Listing', menubar(
40 'Agent Types' => $p. 'browse/agent_type.cgi',
41 # 'Add new agent' => '../edit/agent.cgi'
43 Agents are resellers of your service. Agents may be limited to a subset of your
44 full offerings (via their type).<BR><BR>
45 <A HREF="<%= $p %>edit/agent.cgi"><I>Add a new agent</I></A><BR><BR>
47 <% if ( dbdef->table('agent')->column('disabled') ) { %>
48 <%= $cgi->param('showdisabled')
49 ? do { $cgi->param('showdisabled', 0);
50 '( <a href="'. $cgi->self_url. '">hide disabled agents</a> )'; }
51 : do { $cgi->param('showdisabled', 1);
52 '( <a href="'. $cgi->self_url. '">show disabled agents</a> )'; }
58 <TH COLSPAN=<%= $cgi->param('showdisabled') ? 2 : 3 %>>Agent</TH>
61 <TH><FONT SIZE=-1>Freq.</FONT></TH>
62 <TH><FONT SIZE=-1>Prog.</FONT></TH>
65 # <TH><FONT SIZE=-1>Agent #</FONT></TH>
68 foreach my $agent ( sort {
69 #$a->getfield('agentnum') <=> $b->getfield('agentnum')
70 $a->getfield('agent') cmp $b->getfield('agent')
71 } qsearch('agent', \%search ) ) {
73 $ncancelled_sth->execute($agent->agentnum) or die $ncancelled_sth->errstr;
74 my $num_ncancelled = $ncancelled_sth->fetchrow_arrayref->[0];
76 $total_sth->execute($agent->agentnum) or die $total_sth->errstr;
77 my $num_total = $total_sth->fetchrow_arrayref->[0];
79 my $num_cancelled = $num_total - $num_ncancelled;
81 my $cust_main_link = $p. 'search/cust_main.cgi?agentnum_on=1&'.
82 'agentnum='. $agent->agentnum;
87 <TD><A HREF="<%=$p%>edit/agent.cgi?<%= $agent->agentnum %>">
88 <%= $agent->agentnum %></A></TD>
89 <% if ( dbdef->table('agent')->column('disabled')
90 && !$cgi->param('showdisabled') ) { %>
91 <TD><%= $agent->disabled ? 'DISABLED' : '' %></TD>
94 <TD><A HREF="<%=$p%>edit/agent.cgi?<%= $agent->agentnum %>">
95 <%= $agent->agent %></A></TD>
96 <TD><A HREF="<%=$p%>edit/agent_type.cgi?<%= $agent->typenum %>"><%= $agent->agent_type->atype %></A></TD>
98 <FONT COLOR="#00CC00"><B><%= $num_ncancelled %></B></FONT>
99 <A HREF="<%= $cust_main_link %>&showcancelledcustomers=0">active</A>
100 <BR><FONT COLOR="#FF0000"><B><%= $num_cancelled %></B></FONT>
101 <A HREF="<%= $cust_main_link %>&showcancelledcustomers=1&cancelled=1">cancelled</A>
103 <TD><%= $agent->freq %></TD>
104 <TD><%= $agent->prog %></TD>