5 #bad false laziness with search/cust_main.cgi (also needs fixing up for
8 0 < ( SELECT COUNT(*) FROM cust_pkg
9 WHERE cust_pkg.custnum = cust_main.custnum
10 AND ( cust_pkg.cancel IS NULL
11 OR cust_pkg.cancel = 0
14 OR 0 = ( SELECT COUNT(*) FROM cust_pkg
15 WHERE cust_pkg.custnum = cust_main.custnum
19 my $ncancelled_sth = dbh->prepare("SELECT COUNT(*) FROM cust_main
21 AND ( $ncancelled ) ")
24 my $total_sth = dbh->prepare("SELECT COUNT(*) FROM cust_main
30 <%= header('Agent Listing', menubar(
32 'Agent Types' => $p. 'browse/agent_type.cgi',
33 # 'Add new agent' => '../edit/agent.cgi'
35 Agents are resellers of your service. Agents may be limited to a subset of your
36 full offerings (via their type).<BR><BR>
37 <A HREF="<%= $p %>edit/agent.cgi"><I>Add a new agent</I></A><BR><BR>
41 <TH COLSPAN=2>Agent</TH>
44 <TH><FONT SIZE=-1>Freq.</FONT></TH>
45 <TH><FONT SIZE=-1>Prog.</FONT></TH>
48 # <TH><FONT SIZE=-1>Agent #</FONT></TH>
51 foreach my $agent ( sort {
52 #$a->getfield('agentnum') <=> $b->getfield('agentnum')
53 $a->getfield('agent') cmp $b->getfield('agent')
54 } qsearch('agent',{}) ) {
56 $ncancelled_sth->execute($agent->agentnum) or die $ncancelled_sth->errstr;
57 my $num_ncancelled = $ncancelled_sth->fetchrow_arrayref->[0];
59 $total_sth->execute($agent->agentnum) or die $total_sth->errstr;
60 my $num_total = $total_sth->fetchrow_arrayref->[0];
62 my $num_cancelled = $num_total - $num_ncancelled;
67 <TD><A HREF="<%=$p%>edit/agent.cgi?<%= $agent->agentnum %>">
68 <%= $agent->agentnum %></A></TD>
69 <TD><A HREF="<%=$p%>edit/agent.cgi?<%= $agent->agentnum %>">
70 <%= $agent->agent %></A></TD>
71 <TD><A HREF="<%=$p%>edit/agent_type.cgi?<%= $agent->typenum %>"><%= $agent->agent_type->atype %></A></TD>
73 <FONT COLOR="#00CC00"><B><%= $num_ncancelled %></B></FONT>
75 <BR><FONT COLOR="#FF0000"><B><%= $num_cancelled %></B></FONT>
78 <TD><%= $agent->freq %></TD>
79 <TD><%= $agent->prog %></TD>