option to disable customer/package counts on agent browser, RT#29748
authorIvan Kohler <ivan@freeside.biz>
Mon, 23 Jun 2014 22:39:42 +0000 (15:39 -0700)
committerIvan Kohler <ivan@freeside.biz>
Mon, 23 Jun 2014 22:39:42 +0000 (15:39 -0700)
FS/FS/Conf.pm
FS/FS/agent.pm
FS/FS/cust_pkg.pm
httemplate/browse/agent.cgi

index 941417f..b38b0d7 100644 (file)
@@ -5741,6 +5741,13 @@ and customer address. Include units.',
     'type'        => 'checkbox',
   },
 
+  {
+    'key'         => 'agent-disable_counts',
+    'section'     => 'UI',
+    'description' => 'On the agent browse page, disable the customer and package counts.  Typically used for very large databases when this page takes too long to render.',
+    'type'        => 'checkbox',
+  },
+
   { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
index 1dd6796..e7fb3fb 100644 (file)
@@ -609,6 +609,28 @@ sub num_cancel_cust_pkg {
   shift->num_pkg_sql(FS::cust_pkg->cancel_sql);
 }
 
+=item num_on_hold_cust_pkg
+
+Returns the number of inactive customer packages (one-time packages otherwise
+unsuspended/uncancelled) for this agent.
+
+=cut
+
+sub num_on_hold_cust_pkg {
+  shift->num_pkg_sql(FS::cust_pkg->on_hold_sql);
+}
+
+=item num_not_yet_billed_cust_pkg
+
+Returns the number of inactive customer packages (one-time packages otherwise
+unsuspended/uncancelled) for this agent.
+
+=cut
+
+sub num_not_yet_billed_cust_pkg {
+  shift->num_pkg_sql(FS::cust_pkg->not_yet_billed_sql);
+}
+
 =item generate_reg_codes NUM PKGPART_ARRAYREF
 
 Generates the specified number of registration codes, allowing purchase of the
index 4a98b73..17505dd 100644 (file)
@@ -3182,7 +3182,7 @@ Class method that returns the list of possible status strings for packages
 tie my %statuscolor, 'Tie::IxHash', 
   'on hold'         => '7E0079', #purple!
   'not yet billed'  => '009999', #teal? cyan?
-  'one-time charge' => '000000',
+  'one-time charge' => '0000CC', #blue  #'000000',
   'active'          => '00CC00',
   'suspended'       => 'FF9900',
   'cancelled'       => 'FF0000',
@@ -3195,6 +3195,11 @@ sub statuses {
     keys %statuscolor;
 }
 
+sub statuscolors {
+  #my $self = shift;
+  \%statuscolor;
+}
+
 =item statuscolor
 
 Returns a hex triplet color string for this package's status.
index 8da37a2..ae8c618 100755 (executable)
@@ -62,10 +62,16 @@ full offerings (via their type).<BR><BR>
 
       <TR>
 
+%       ##
+%       # agentnum
+%       ##
         <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
           <A HREF="<%$p%>edit/agent.cgi?<% $agent->agentnum %>"><% $agent->agentnum %></A>
         </TD>
 
+%       ##
+%       # disabled
+%       ##
 %       if ( ! $cgi->param('showdisabled') ) { 
           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="center">
             <% $agent->disabled ? '<FONT COLOR="#FF0000"><B>DISABLED</B></FONT>'
@@ -74,14 +80,23 @@ full offerings (via their type).<BR><BR>
           </TD>
 %       } 
 
+%       ##
+%       # agent
+%       ##
         <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
           <A HREF="<%$p%>edit/agent.cgi?<% $agent->agentnum %>"><% $agent->agent %></A>
         </TD>
 
+%       ##
+%       # type
+%       ##
         <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
           <A HREF="<%$p%>edit/agent_type.cgi?<% $agent->typenum %>"><% $agent->agent_type->atype %></A>
         </TD>
 
+%       ##
+%       # master customer
+%       ##
         <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
 %         if ( $agent->agent_custnum ) {
             <& /elements/small_custview.html,
@@ -93,6 +108,10 @@ full offerings (via their type).<BR><BR>
 %         }
         </TD>
 
+%       ##
+%       # commissions
+%       ##
+
         <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
 
           <TABLE>
@@ -120,6 +139,9 @@ full offerings (via their type).<BR><BR>
 
         </TD>
 
+%       ##
+%       # access groups
+%       ##
         <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
 %         foreach my $access_group (
 %           map $_->access_group,
@@ -129,236 +151,127 @@ full offerings (via their type).<BR><BR>
 %         }
         </TD>
 
+%       ##
+%       # invoice template
+%       ##
         <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
           <% $agent->invoice_template || '(Default)' %>
         </TD>
 
+%       ##
+%       # customers
+%       ##
+
         <TD CLASS="inv" BGCOLOR="<% $bgcolor %>" VALIGN="bottom">
           <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
 
-            <TR>
-              <TH ALIGN="right" WIDTH="40%">
-                <FONT COLOR="#7e0079">
-                  <% my $num_prospect = $agent->num_prospect_cust_main %>&nbsp;
-                </FONT>
-              </TH>
-
-              <TD>
-% if ( $num_prospect ) { 
-
-                  <A HREF="<% $cust_main_link %>&prospect=1">
-% } 
-prospects
-% if ($num_prospect ) { 
-</A>
-% } 
-
-              <TD>
-            </TR>
-
-            <TR>
-              <TH ALIGN="right" WIDTH="40%">
-                <FONT COLOR="#0000CC">
-                  <% my $num_inactive = $agent->num_inactive_cust_main %>&nbsp;
-                </FONT>
-              </TH>
-
-              <TD>
-% if ( $num_inactive ) { 
-
-                  <A HREF="<% $cust_main_link %>&inactive=1">
-% } 
-inactive
-% if ( $num_inactive ) { 
-</A>
-% } 
-
-              </TD>
-            </TR>
-
-            <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>
-              </TH>
-
-              <TD>
-% if ( $num_active ) { 
+%           my @cust_status =
+%             qw( prospect inactive ordered active suspended cancelled );
+%           my %method = ( 'suspended' => 'susp',
+%                          'cancelled' => 'cancel'
+%                        );
+%           my %PL = ( 'prospect' => 'prospects', );
+%           my %link = ( 'cancelled' => 'showcancelledcustomers=1&cancelled' );
+%           my $statuscolor = FS::cust_main->statuscolors;
+%
+%           foreach my $status ( @cust_status ) {
+%             my $meth = exists($method{$status}) ? $method{$status} : $status;
+%             $meth = 'num_'. $meth. '_cust_main';
+%             my $link = exists($link{$status}) ? $link{$status} : $status;
 
-                  <A HREF="<% $cust_main_link %>&active=1">
+              <TR>
+%               my $num = 0;
+%               unless ( $disable_counts ) {
+                  <TH ALIGN="right" WIDTH="40%">
+                    <FONT COLOR="#<% $statuscolor->{$status} %>">
+                      <% $num = $agent->$meth() %>&nbsp;
+                    </FONT>
+                  </TH>
+%               }
+                <TD>
+% if ( $num || $disable_counts ) { 
+%                 
+
+                  <A HREF="<% $cust_main_link. "&$link=1" %>">
 % } 
-active
-% if ( $num_active ) { 
+<% exists($PL{$status}) ? $PL{$status} : $status %>
+% if ($num || $disable_counts ) {
 </A>
 % } 
 
-              </TD>
-            </TR>
-
-            <TR>
-              <TH ALIGN="right" WIDTH="40%">
-                <FONT COLOR="#FF9900">
-                  <% my $num_susp = $agent->num_susp_cust_main %>&nbsp;
-                </FONT>
-              </TH>
-
               <TD>
-% if ( $num_susp ) { 
-
-                  <A HREF="<% $cust_main_link %>&suspended=1">
-% } 
-suspended
-% if ( $num_susp ) { 
-</A>
-% } 
-
-              </TD>
             </TR>
 
-            <TR>
-              <TH ALIGN="right" WIDTH="40%">
-                <FONT COLOR="#FF0000">
-                  <% my $num_cancel = $agent->num_cancel_cust_main %>&nbsp;
-                </FONT>
-              </TH>
-
-              <TD>
-% if ( $num_cancel ) { 
-
-                  <A HREF="<% $cust_main_link %>&showcancelledcustomers=1&cancelled=1">
-% } 
-cancelled
-% if ( $num_cancel ) { 
-</A>
-% } 
-
-              </TD>
-            </TR>
+%           }
 
           </TABLE>
         </TD>
 
+%       ##
+%       # customer packages
+%       ##
+
         <TD CLASS="inv" BGCOLOR="<% $bgcolor %>" VALIGN="bottom">
           <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
 
-            <TR>
-              <TH ALIGN="right" WIDTH="40%">
-                <FONT COLOR="#0000CC">
-                  <% my $num_inactive_pkg = $agent->num_inactive_cust_pkg %>&nbsp;
-                </FONT>
-              </TH>
-
-              <TD>
-% if ( $num_inactive_pkg ) { 
-
-                  <A HREF="<% $cust_pkg_link %>&magic=inactive">
-% } 
-inactive
-% if ( $num_inactive_pkg ) { 
-</A>
-% } 
-
-              </TD>
-            </TR>
-
-            <!--ordered-->
-            <TR>
-              <TD>&nbsp;</TD>
-            </TR>
-
-            <TR>
-              <TH ALIGN="right" WIDTH="40%">
-                <FONT COLOR="#00CC00">
-                  <% my $num_active_pkg = $agent->num_active_cust_pkg %>&nbsp;
-                </FONT>
-              </TH>
-
-              <TD>
-% if ( $num_active_pkg ) { 
-
-                  <A HREF="<% $cust_pkg_link %>&magic=active">
-% } 
-active
-% if ( $num_active_pkg ) { 
-</A>
-% } 
-
-              </TD>
-            </TR>
+%           #my @pkg_status = FS::cust_pkg->statuses;
+%           my @pkg_status = ( 'on hold', 'one-time charge', 'not yet billed',
+%                              qw( active suspended cancelled ) );
+%           my %method = ( 'one-time charge' => 'inactive',
+%                          'suspended'       => 'susp',
+%                          'cancelled'       => 'cancel',
+%                        );
+%           my $statuscolor = FS::cust_pkg->statuscolors;
+%
+%           foreach my $status ( @pkg_status ) {
+%             my $magic = exists($method{$status}) ? $method{$status} : $status;
+%             $magic =~ s/ /_/g;
+%             my $meth = 'num_'. $magic. '_cust_pkg';
+%             ( my $label = $status ) =~ s/ /&nbsp;/g;
 
-            <TR>
-              <TH ALIGN="right" WIDTH="40%">
-                <FONT COLOR="#FF9900">
-                  <% my $num_susp_pkg = $agent->num_susp_cust_pkg %>&nbsp;
-                </FONT>
+              <TR>
+%               my $num = 0;
+%               unless ( $disable_counts ) {
+                  <TH ALIGN="right" WIDTH="40%">
+                    <FONT COLOR="#<% $statuscolor->{$status} %>">
+                      <% $num = $agent->$meth() %>&nbsp;
+                    </FONT>
+                  </TH>
+%               }
 
-              </TH>
               <TD>
-% if ( $num_susp_pkg ) { 
+% if ( $num || $disable_counts ) { 
 
-                  <A HREF="<% $cust_pkg_link %>&magic=suspended">
+                  <A HREF="<% $cust_pkg_link %>&magic=<% $magic %>">
 % } 
-suspended
-% if ( $num_susp_pkg ) { 
+<% $label %>
+% if ( $num || $disable_counts ) { 
 </A>
 % } 
 
               </TD>
             </TR>
-            
-            <TR>
-              <TH ALIGN="right" WIDTH="40%">
-                <FONT COLOR="#FF0000">
-                  <% my $num_cancel_pkg = $agent->num_cancel_cust_pkg %>&nbsp;
-                </FONT>
-              </TH>
-
-              <TD>
-% if ( $num_cancel_pkg ) { 
 
-                  <A HREF="<% $cust_pkg_link %>&magic=cancelled">
-% } 
-cancelled
-% if ( $num_cancel_pkg ) { 
-</A>
-% } 
-
-              </TD>
-            </TR>
+%           }
 
           </TABLE>
         </TD>
 
+%       ##
+%       # reports
+%       ##
         <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
           <A HREF="<% $p %>graph/report_cust_pkg.html?agentnum=<% $agent->agentnum %>">Package&nbsp;Churn</A>
           <BR><A HREF="<% $p %>search/report_cust_pay.html?agentnum=<% $agent->agentnum %>">Payments</A>
           <BR><A HREF="<% $p %>search/report_cust_credit.html?agentnum=<% $agent->agentnum %>">Credits</A>
           <BR><A HREF="<% $p %>search/report_receivables.cgi?agentnum=<% $agent->agentnum %>">A/R&nbsp;Aging</A>
           <!--<BR><A HREF="<% $p %>search/money_time.cgi?agentnum=<% $agent->agentnum %>">Sales/Credits/Receipts</A>-->
-
         </TD>
 
+%       ##
+%       # registration codes
+%       ##
+
         <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
           <% my $num_reg_code = $agent->num_reg_code %>
 % if ( $num_reg_code ) { 
@@ -373,6 +286,10 @@ Unused
           <BR><A HREF="<%$p%>edit/reg_code.cgi?agentnum=<% $agent->agentnum %>">Generate codes</A>
         </TD>
 
+%       ##
+%       # prepaid cards
+%       ##
+
         <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
           <% my $num_prepay_credit = $agent->num_prepay_credit %>
 % if ( $num_prepay_credit ) { 
@@ -386,19 +303,22 @@ Unused
 
           <BR><A HREF="<%$p%>edit/prepay_credit.cgi?agentnum=<% $agent->agentnum %>">Generate cards</A>
         </TD>
-% if ( $conf->config('ticket_system') ) { 
-
 
+%       ##
+%       # ticketing
+%       ##
+% if ( $conf->config('ticket_system') ) { 
           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
 % if ( $agent->ticketing_queueid ) { 
-
               Queue: <% $agent->ticketing_queueid %>: <% $agent->ticketing_queue %><BR>
 % } 
-
           </TD>
 % } 
 
 
+%       ##
+%       # payment gateway overrides
+%       ##
         <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
           <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
 % foreach my $override (
@@ -425,6 +345,10 @@ Unused
           </TABLE>
         </TD>
 
+%       ##
+%       # configuration overrides
+%       ##
+
         <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
           <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
 % foreach my $override (
@@ -474,5 +398,6 @@ if ( $cgi->param('showdisabled')
 }
 
 my $conf = new FS::Conf;
+my $disable_counts = $conf->exists('agent-disable_counts');
 
 </%init>