always pass the "time" parameter to join_conditions_sql, related to #28978
[freeside.git] / httemplate / browse / agent.cgi
index b25b1fa..2552432 100755 (executable)
@@ -20,31 +20,34 @@ full offerings (via their type).<BR><BR>
 % my $bgcolor1 = '#eeeeee';
 %   my $bgcolor2 = '#ffffff';
 %   my $bgcolor = '';
-%
-
 
 <TR>
   <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<% ( $cgi->param('showdisabled') || !dbdef->table('agent')->column('disabled') ) ? 2 : 3 %>>Agent</TH>
   <TH CLASS="grid" BGCOLOR="#cccccc">Type</TH>
   <TH CLASS="grid" BGCOLOR="#cccccc">Master Customer</TH>
+  <TH CLASS="grid" BGCOLOR="#cccccc">Commissions</TH>
+  <TH CLASS="grid" BGCOLOR="#cccccc">Access Groups</TH>
   <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Invoice<BR>Template</FONT></TH>
   <TH CLASS="grid" BGCOLOR="#cccccc">Customers</TH>
   <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Customer<BR>packages</FONT></TH>
   <TH CLASS="grid" BGCOLOR="#cccccc">Reports</TH>
   <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Registration<BR>codes</FONT></TH>
   <TH CLASS="grid" BGCOLOR="#cccccc">Prepaid cards</TH>
-% if ( $conf->config('ticket_system') ) { 
 
+% if ( $conf->config('ticket_system') ) { 
     <TH CLASS="grid" BGCOLOR="#cccccc">Ticketing</TH>
 % } 
 
+% if ( $conf->config('currencies') ) { 
+    <TH CLASS="grid" BGCOLOR="#cccccc">Currencies</TH>
+% } 
+
   <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Payment Gateway Overrides</FONT></TH>
   <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Configuration Overrides</FONT></TH>
 </TR>
-% 
+
 %#        <TH><FONT SIZE=-1>Agent #</FONT></TH>
 %#        <TH>Agent</TH>
-%
 %foreach my $agent ( sort { 
 %  #$a->getfield('agentnum') <=> $b->getfield('agentnum')
 %  $a->getfield('agent') cmp $b->getfield('agent')
@@ -60,9 +63,6 @@ full offerings (via their type).<BR><BR>
 %  } else {
 %    $bgcolor = $bgcolor1;
 %  }
-%
-%
-
 
       <TR>
 
@@ -70,10 +70,11 @@ full offerings (via their type).<BR><BR>
           <A HREF="<%$p%>edit/agent.cgi?<% $agent->agentnum %>"><% $agent->agentnum %></A>
         </TD>
 
-%       if ( dbdef->table('agent')->column('disabled')
-%            && !$cgi->param('showdisabled')           ) { 
-          <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
-            <% $agent->disabled ? 'DISABLED' : '' %>
+%       if ( ! $cgi->param('showdisabled') ) { 
+          <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="center">
+            <% $agent->disabled ? '<FONT COLOR="#FF0000"><B>DISABLED</B></FONT>'
+                                : '<FONT COLOR="#00CC00"><B>Active</B></FONT>'
+            %>
           </TD>
 %       } 
 
@@ -87,12 +88,48 @@ full offerings (via their type).<BR><BR>
 
         <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
 %         if ( $agent->agent_custnum ) {
-            <% include('/elements/small_custview.html',
-                         $agent->agent_custnum,
-                         scalar($conf->config('countrydefault')),
-                         1, #show balance
-                      )
-            %>
+            <& /elements/small_custview.html,
+                 $agent->agent_custnum,
+                 scalar($conf->config('countrydefault')),
+                 1, #show balance
+                 $p.'view/cust_main.cgi',
+            &>
+%         }
+        </TD>
+
+        <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+
+          <TABLE>
+
+%           #surprising amount of false laziness w/ edit/process/agent.cgi
+%           my @pkg_class = qsearch('pkg_class', { 'disabled'=>'' });
+%           foreach my $pkg_class ( '', @pkg_class ) {
+%             my %agent_pkg_class = ( 'agentnum' => $agent->agentnum,
+%                                     'classnum' => $pkg_class ? $pkg_class->classnum : ''
+%                                   );
+%             my $agent_pkg_class =
+%               qsearchs( 'agent_pkg_class', \%agent_pkg_class )
+%               || new FS::agent_pkg_class   \%agent_pkg_class;
+%             my $param = 'classnum'. $agent_pkg_class{classnum};
+
+              <TR>
+                <TD><% $agent_pkg_class->commission_percent || 0 %>%</TD>
+                <TD><% $pkg_class ? $pkg_class->classname : mt('(no package class)') |h %>
+                </TD>
+              </TR>
+
+%           }
+
+          </TABLE>
+
+        </TD>
+
+        <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+%         foreach my $access_group (
+%           map $_->access_group,
+%               qsearch('access_groupagent', { 'agentnum' => $agent->agentnum })
+%         ) {
+            <A HREF="<%$p%>edit/access_group.html?<% $access_group->groupnum %>"><% $access_group->groupname |h %><BR>
 %         }
         </TD>
 
@@ -145,6 +182,26 @@ inactive
 
             <TR>
               <TH ALIGN="right" WIDTH="40%">
+                <FONT COLOR="#009999">
+                  <% my $num_ordered = $agent->num_ordered_cust_main %>&nbsp;
+                </FONT>
+              </TH>
+
+              <TD>
+% if ( $num_ordered ) { 
+
+                  <A HREF="<% $cust_main_link %>&ordered=1">
+% } 
+ordered
+% if ($num_ordered ) { 
+</A>
+% } 
+
+              <TD>
+            </TR>
+
+            <TR>
+              <TH ALIGN="right" WIDTH="40%">
                 <FONT COLOR="#00CC00">
                   <% my $num_active = $agent->num_active_cust_main %>&nbsp;
                 </FONT>
@@ -229,6 +286,11 @@ inactive
               </TD>
             </TR>
 
+            <!--ordered-->
+            <TR>
+              <TD>&nbsp;</TD>
+            </TR>
+
             <TR>
               <TH ALIGN="right" WIDTH="40%">
                 <FONT COLOR="#00CC00">
@@ -328,19 +390,23 @@ Unused
 
           <BR><A HREF="<%$p%>edit/prepay_credit.cgi?agentnum=<% $agent->agentnum %>">Generate cards</A>
         </TD>
-% if ( $conf->config('ticket_system') ) { 
-
 
+% if ( $conf->config('ticket_system') ) { 
           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
-% if ( $agent->ticketing_queueid ) { 
-
-              Queue: <% $agent->ticketing_queueid %>: <% $agent->ticketing_queue %><BR>
+%         if ( $agent->ticketing_queueid ) { 
+              Queue: <% $agent->ticketing_queueid %>:
+                     <% $agent->ticketing_queue %>
+              <BR>
+%         } 
+          </TD>
 % } 
 
+% if ( $conf->config('currencies') ) { 
+          <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+            <% join('<BR>', sort keys %{ $agent->agent_currency_hashref } ) %>
           </TD>
 % } 
 
-
         <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
           <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
 % foreach my $override (
@@ -356,7 +422,7 @@ Unused
                         ? ' for '. $override->taxclass. ' only'
                         : ''
                   %>
-                  <FONT SIZE=-1><A HREF="<%$p%>misc/delete-agent_payment_gateway.cgi?<% $override->agentgatewaynum %>">(delete)</A></FONT>
+                  <FONT SIZE=-1><A HREF="javascript:areyousure('delete this payment gateway override', '<%$p%>misc/delete-agent_payment_gateway.cgi?<% $override->agentgatewaynum %>')">(delete)</A></FONT>
                 </TD>
               </TR>
 % } 
@@ -376,14 +442,13 @@ Unused
 
               <TR>
                 <TD> 
-                  <% $override->name %>
-                  <FONT SIZE=-1><A HREF="<%$p%>config/config-delete.cgi?<% $override->confnum %>">(delete)</A></FONT>
+                  <% $override->name %>&nbsp;<FONT SIZE=-1><A HREF="javascript:areyousure('delete this configuration override', '<%$p%>config/config-delete.cgi?confnum=<% $override->confnum %>')">(delete)</A></FONT>
                 </TD>
               </TR>
 % } 
 
             <TR>
-              <TD><FONT SIZE=-1><A HREF="<%$p%>config/config-view.cgi?agentnum=<% $agent->agentnum %>">(add override)</A></FONT></TD>
+              <TD><FONT SIZE=-1><A HREF="<%$p%>config/config-view.cgi?agentnum=<% $agent->agentnum %>">(view/add/edit overrides)</A></FONT></TD>
             </TR>
           </TABLE>
         </TD>
@@ -393,6 +458,14 @@ Unused
 
 
     </TABLE>
+
+<SCRIPT TYPE="text/javascript">
+  function areyousure(what, href) {
+    if ( confirm("Are you sure you want to " + what + "?") == true )
+      window.location.href = href;
+  }
+</SCRIPT>
+
   </BODY>
 </HTML>
 <%init>