line up prospect/active/suspended/cancelled customers
[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>Reports</TH>
39   <TH>Registration Codes</TH>
40   <TH>Prepaid cards</TH>
41   <TH><FONT SIZE=-1>Freq.</FONT></TH>
42   <TH><FONT SIZE=-1>Prog.</FONT></TH>
43 </TR>
44 <% 
45 #        <TH><FONT SIZE=-1>Agent #</FONT></TH>
46 #        <TH>Agent</TH>
47
48 foreach my $agent ( sort { 
49   #$a->getfield('agentnum') <=> $b->getfield('agentnum')
50   $a->getfield('agent') cmp $b->getfield('agent')
51 } qsearch('agent', \%search ) ) {
52
53   my $cust_main_link = $p. 'search/cust_main.cgi?agentnum_on=1&'.
54                        'agentnum='. $agent->agentnum;
55
56 %>
57
58       <TR>
59         <TD><A HREF="<%=$p%>edit/agent.cgi?<%= $agent->agentnum %>">
60           <%= $agent->agentnum %></A></TD>
61 <% if ( dbdef->table('agent')->column('disabled')
62         && !$cgi->param('showdisabled')           ) { %>
63         <TD><%= $agent->disabled ? 'DISABLED' : '' %></TD>
64 <% } %>
65
66         <TD><A HREF="<%=$p%>edit/agent.cgi?<%= $agent->agentnum %>">
67           <%= $agent->agent %></A></TD>
68         <TD><A HREF="<%=$p%>edit/agent_type.cgi?<%= $agent->typenum %>"><%= $agent->agent_type->atype %></A></TD>
69
70         <TD>
71
72           <TABLE CELLSPACING=0 CELLPADDING=0>
73             <TR>
74               <TH ALIGN="right">
75                 <%= my $num_prospect = $agent->num_prospect_cust_main %>
76               </TH>
77               <TD>&nbsp;
78                 <% if ( $num_prospect ) { %>
79                   <A HREF="<%= $cust_main_link %>&prospect=1"><% } %>prospects<% if ($num_prospect ) { %></A><% } %>
80               <TD>
81             </TR>
82             <TR>
83               <TH ALIGN="right">
84                 <FONT COLOR="#00CC00">
85                   <%= my $num_active = $agent->num_active_cust_main %>
86                 </FONT>
87               </TH>
88               <TD>&nbsp;
89                 <% if ( $num_active ) { %>
90                   <A HREF="<%= $cust_main_link %>&active=1"><% } %>active<% if ( $num_active ) { %></A><% } %>
91               </TD>
92             </TR>
93             <TR>
94               <TH ALIGN="right">
95                 <FONT COLOR="#FF9900">
96                   <%= my $num_susp = $agent->num_susp_cust_main %>
97                 </FONT>
98               </TH>
99               <TD>&nbsp;
100                 <% if ( $num_susp ) { %>
101                   <A HREF="<%= $cust_main_link %>&suspended=1"><% } %>suspended<% if ( $num_susp ) { %></A><% } %>
102               </TD>
103             </TR>
104             <TR>
105               <TH ALIGN="right">
106                 <FONT COLOR="#FF0000">
107                   <%= my $num_cancel = $agent->num_cancel_cust_main %>
108                 </FONT>
109               </TH>
110               <TD>&nbsp;
111                 <% if ( $num_cancel ) { %>
112                   <A HREF="<%= $cust_main_link %>&showcancelledcustomers=1&cancelled=1"><% } %>cancelled<% if ( $num_cancel ) { %></A><% } %>
113               </TD>
114             </TR>
115           </TABLE>
116         </TD>
117
118         <TD>
119           <A HREF="<%= $p %>search/report_cust_pay.html?agentnum=<%= $agent->agentnum %>">Payments</A>
120           <BR><A HREF="<%= $p %>search/report_cust_credit.html?agentnum=<%= $agent->agentnum %>">Credits</A>
121           <BR><A HREF="<%= $p %>search/report_receivables.cgi?agentnum=<%= $agent->agentnum %>">A/R Aging</A>
122           <!--<BR><A HREF="<%= $p %>search/money_time.cgi?agentnum=<%= $agent->agentnum %>">Sales/Credits/Receipts</A>-->
123
124         </TD>
125
126         <TD>
127           <%= my $num_reg_code = $agent->num_reg_code %>
128           <% if ( $num_reg_code ) { %>
129             <A HREF="<%=$p%>search/reg_code.html?agentnum=<%= $agent->agentnum %>"><% } %>Unused<% if ( $num_reg_code ) { %></A><% } %>
130           <BR><A HREF="<%=$p%>edit/reg_code.cgi?agentnum=<%= $agent->agentnum %>">Generate codes</A>
131         </TD>
132
133         <TD>
134           <%= my $num_prepay_credit = $agent->num_prepay_credit %>
135           <% if ( $num_prepay_credit ) { %>
136             <A HREF="<%=$p%>search/prepay_credit.html?agentnum=<%= $agent->agentnum %>"><% } %>Unused<% if ( $num_prepay_credit ) { %></A><% } %>
137           <BR><A HREF="<%=$p%>edit/prepay_credit.cgi?agentnum=<%= $agent->agentnum %>">Generate cards</A>
138         </TD>
139
140         <TD><%= $agent->freq %></TD>
141         <TD><%= $agent->prog %></TD>
142
143       </TR>
144
145 <% } %>
146
147     </TABLE>
148   </BODY>
149 </HTML>