make sure the customers tables for each agent line up with each other, too
[freeside.git] / httemplate / browse / agent.cgi
1 <%
2
3   my %search;
4   if ( $cgi->param('showdisabled')
5        || !dbdef->table('agent')->column('disabled') ) {
6     %search = ();
7   } else {
8     %search = ( 'disabled' => '' );
9   }
10
11 %>
12 <%= header('Agent Listing', menubar(
13   'Main Menu'   => $p,
14   'Agent Types' => $p. 'browse/agent_type.cgi',
15 #  'Add new agent' => '../edit/agent.cgi'
16 )) %>
17 Agents are resellers of your service. Agents may be limited to a subset of your
18 full offerings (via their type).<BR><BR>
19 <A HREF="<%= $p %>edit/agent.cgi"><I>Add a new agent</I></A><BR><BR>
20
21 <% if ( dbdef->table('agent')->column('disabled') ) { %>
22   <%= $cgi->param('showdisabled')
23       ? do { $cgi->param('showdisabled', 0);
24              '( <a href="'. $cgi->self_url. '">hide disabled agents</a> )'; }
25       : do { $cgi->param('showdisabled', 1);
26              '( <a href="'. $cgi->self_url. '">show disabled agents</a> )'; }
27   %>
28 <% } %>
29
30 <%= table() %>
31 <TR>
32   <TH COLSPAN=<%= ( $cgi->param('showdisabled') || !dbdef->table('agent')->column('disabled') ) ? 2 : 3 %>>Agent</TH>
33   <TH>Type</TH>
34   <TH>Customers</TH>
35   <TH>Reports</TH>
36   <TH>Registration Codes</TH>
37   <TH>Prepaid cards</TH>
38   <TH><FONT SIZE=-1>Freq.</FONT></TH>
39   <TH><FONT SIZE=-1>Prog.</FONT></TH>
40 </TR>
41 <% 
42 #        <TH><FONT SIZE=-1>Agent #</FONT></TH>
43 #        <TH>Agent</TH>
44
45 foreach my $agent ( sort { 
46   #$a->getfield('agentnum') <=> $b->getfield('agentnum')
47   $a->getfield('agent') cmp $b->getfield('agent')
48 } qsearch('agent', \%search ) ) {
49
50   my $cust_main_link = $p. 'search/cust_main.cgi?agentnum_on=1&'.
51                        'agentnum='. $agent->agentnum;
52
53 %>
54
55       <TR>
56         <TD><A HREF="<%=$p%>edit/agent.cgi?<%= $agent->agentnum %>">
57           <%= $agent->agentnum %></A></TD>
58 <% if ( dbdef->table('agent')->column('disabled')
59         && !$cgi->param('showdisabled')           ) { %>
60         <TD><%= $agent->disabled ? 'DISABLED' : '' %></TD>
61 <% } %>
62
63         <TD><A HREF="<%=$p%>edit/agent.cgi?<%= $agent->agentnum %>">
64           <%= $agent->agent %></A></TD>
65         <TD><A HREF="<%=$p%>edit/agent_type.cgi?<%= $agent->typenum %>"><%= $agent->agent_type->atype %></A></TD>
66
67         <TD>
68
69           <TABLE CELLSPACING=0 CELLPADDING=0>
70             <TR>
71               <TH ALIGN="right" WIDTH="40%">
72                 <%= my $num_prospect = $agent->num_prospect_cust_main %>&nbsp;
73               </TH>
74               <TD>
75                 <% if ( $num_prospect ) { %>
76                   <A HREF="<%= $cust_main_link %>&prospect=1"><% } %>prospects<% if ($num_prospect ) { %></A><% } %>
77               <TD>
78             </TR>
79             <TR>
80               <TH ALIGN="right" WIDTH="40%">
81                 <FONT COLOR="#00CC00">
82                   <%= my $num_active = $agent->num_active_cust_main %>&nbsp;
83                 </FONT>
84               </TH>
85               <TD>
86                 <% if ( $num_active ) { %>
87                   <A HREF="<%= $cust_main_link %>&active=1"><% } %>active<% if ( $num_active ) { %></A><% } %>
88               </TD>
89             </TR>
90             <TR>
91               <TH ALIGN="right" WIDTH="40%">
92                 <FONT COLOR="#FF9900">
93                   <%= my $num_susp = $agent->num_susp_cust_main %>&nbsp;
94                 </FONT>
95               </TH>
96               <TD>
97                 <% if ( $num_susp ) { %>
98                   <A HREF="<%= $cust_main_link %>&suspended=1"><% } %>suspended<% if ( $num_susp ) { %></A><% } %>
99               </TD>
100             </TR>
101             <TR>
102               <TH ALIGN="right" WIDTH="40%">
103                 <FONT COLOR="#FF0000">
104                   <%= my $num_cancel = $agent->num_cancel_cust_main %>&nbsp;
105                 </FONT>
106               </TH>
107               <TD>
108                 <% if ( $num_cancel ) { %>
109                   <A HREF="<%= $cust_main_link %>&showcancelledcustomers=1&cancelled=1"><% } %>cancelled<% if ( $num_cancel ) { %></A><% } %>
110               </TD>
111             </TR>
112           </TABLE>
113         </TD>
114
115         <TD>
116           <A HREF="<%= $p %>search/report_cust_pay.html?agentnum=<%= $agent->agentnum %>">Payments</A>
117           <BR><A HREF="<%= $p %>search/report_cust_credit.html?agentnum=<%= $agent->agentnum %>">Credits</A>
118           <BR><A HREF="<%= $p %>search/report_receivables.cgi?agentnum=<%= $agent->agentnum %>">A/R Aging</A>
119           <!--<BR><A HREF="<%= $p %>search/money_time.cgi?agentnum=<%= $agent->agentnum %>">Sales/Credits/Receipts</A>-->
120
121         </TD>
122
123         <TD>
124           <%= my $num_reg_code = $agent->num_reg_code %>
125           <% if ( $num_reg_code ) { %>
126             <A HREF="<%=$p%>search/reg_code.html?agentnum=<%= $agent->agentnum %>"><% } %>Unused<% if ( $num_reg_code ) { %></A><% } %>
127           <BR><A HREF="<%=$p%>edit/reg_code.cgi?agentnum=<%= $agent->agentnum %>">Generate codes</A>
128         </TD>
129
130         <TD>
131           <%= my $num_prepay_credit = $agent->num_prepay_credit %>
132           <% if ( $num_prepay_credit ) { %>
133             <A HREF="<%=$p%>search/prepay_credit.html?agentnum=<%= $agent->agentnum %>"><% } %>Unused<% if ( $num_prepay_credit ) { %></A><% } %>
134           <BR><A HREF="<%=$p%>edit/prepay_credit.cgi?agentnum=<%= $agent->agentnum %>">Generate cards</A>
135         </TD>
136
137         <TD><%= $agent->freq %></TD>
138         <TD><%= $agent->prog %></TD>
139
140       </TR>
141
142 <% } %>
143
144     </TABLE>
145   </BODY>
146 </HTML>