oops, last bit for reg codes
[freeside.git] / httemplate / browse / agent.cgi
1 <!-- mason kludge -->
2
3 <%
4
5   my %search;
6   if ( $cgi->param('showdisabled')
7        || !dbdef->table('agent')->column('disabled') ) {
8     %search = ();
9   } else {
10     %search = ( 'disabled' => '' );
11   }
12
13 %>
14
15 <%= header('Agent Listing', menubar(
16   'Main Menu'   => $p,
17   'Agent Types' => $p. 'browse/agent_type.cgi',
18 #  'Add new agent' => '../edit/agent.cgi'
19 )) %>
20 Agents are resellers of your service. Agents may be limited to a subset of your
21 full offerings (via their type).<BR><BR>
22 <A HREF="<%= $p %>edit/agent.cgi"><I>Add a new agent</I></A><BR><BR>
23
24 <% if ( dbdef->table('agent')->column('disabled') ) { %>
25   <%= $cgi->param('showdisabled')
26       ? do { $cgi->param('showdisabled', 0);
27              '( <a href="'. $cgi->self_url. '">hide disabled agents</a> )'; }
28       : do { $cgi->param('showdisabled', 1);
29              '( <a href="'. $cgi->self_url. '">show disabled agents</a> )'; }
30   %>
31 <% } %>
32
33 <%= table() %>
34 <TR>
35   <TH COLSPAN=<%= ( $cgi->param('showdisabled') || !dbdef->table('agent')->column('disabled') ) ? 2 : 3 %>>Agent</TH>
36   <TH>Type</TH>
37   <TH>Customers</TH>
38   <TH>Registration Codes</TH>
39   <TH><FONT SIZE=-1>Freq.</FONT></TH>
40   <TH><FONT SIZE=-1>Prog.</FONT></TH>
41 </TR>
42 <% 
43 #        <TH><FONT SIZE=-1>Agent #</FONT></TH>
44 #        <TH>Agent</TH>
45
46 foreach my $agent ( sort { 
47   #$a->getfield('agentnum') <=> $b->getfield('agentnum')
48   $a->getfield('agent') cmp $b->getfield('agent')
49 } qsearch('agent', \%search ) ) {
50
51   my $cust_main_link = $p. 'search/cust_main.cgi?agentnum_on=1&'.
52                        'agentnum='. $agent->agentnum;
53
54 %>
55
56       <TR>
57         <TD><A HREF="<%=$p%>edit/agent.cgi?<%= $agent->agentnum %>">
58           <%= $agent->agentnum %></A></TD>
59 <% if ( dbdef->table('agent')->column('disabled')
60         && !$cgi->param('showdisabled')           ) { %>
61         <TD><%= $agent->disabled ? 'DISABLED' : '' %></TD>
62 <% } %>
63
64         <TD><A HREF="<%=$p%>edit/agent.cgi?<%= $agent->agentnum %>">
65           <%= $agent->agent %></A></TD>
66         <TD><A HREF="<%=$p%>edit/agent_type.cgi?<%= $agent->typenum %>"><%= $agent->agent_type->atype %></A></TD>
67         <TD>
68
69           <B>
70             <%= my $num_prospect = $agent->num_prospect_cust_main %>
71           </B>
72           <% if ( $num_prospect ) { %>
73             <A HREF="<%= $cust_main_link %>&prospect=1"><% } %>prospects<% if ($num_prospect ) { %></A><% } %>
74
75           <BR><FONT COLOR="#00CC00"><B>
76             <%= my $num_active = $agent->num_active_cust_main %>
77           </B></FONT>
78           <% if ( $num_active ) { %>
79             <A HREF="<%= $cust_main_link %>&active=1"><% } %>active<% if ( $num_active ) { %></A><% } %>
80
81           <BR><FONT COLOR="#FF9900"><B>
82             <%= my $num_susp = $agent->num_susp_cust_main %>
83           </B></FONT>
84           <% if ( $num_susp ) { %>
85             <A HREF="<%= $cust_main_link %>&suspended=1"><% } %>suspended<% if ( $num_susp ) { %></A><% } %>
86
87           <BR><FONT COLOR="#FF0000"><B>
88             <%= my $num_cancel = $agent->num_cancel_cust_main %>
89           </B></FONT>
90           <% if ( $num_cancel ) { %>
91             <A HREF="<%= $cust_main_link %>&showcancelledcustomers=1&cancelled=1"><% } %>cancelled<% if ( $num_cancel ) { %></A><% } %>
92         </TD>
93         <TD>
94           <%= my $num_reg_code = $agent->num_reg_code %>
95           <% if ( $num_reg_code ) { %>
96             <A HREF="<%=$p%>search/reg_code.html?agentnum=<%= $agent->agentnum %>"><% } %>Unused<% if ( $num_reg_code ) { %></A><% } %>
97           <BR><A HREF="<%=$p%>edit/reg_code.cgi?agentnum=<%= $agent->agentnum %>">Generate codes</A>
98         </TD>
99         <TD><%= $agent->freq %></TD>
100         <TD><%= $agent->prog %></TD>
101       </TR>
102
103 <% } %>
104
105     </TABLE>
106   </BODY>
107 </HTML>