[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 2600a7158e2fe843f4ac21420a6e7b72bc9af541

Mark Wells mark at 420.am
Sat Mar 31 17:57:41 PDT 2012


The branch, FREESIDE_2_3_BRANCH has been updated
       via  2600a7158e2fe843f4ac21420a6e7b72bc9af541 (commit)
      from  180c20dc0b463cab61f9c8b31009e18a7be1b5c0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2600a7158e2fe843f4ac21420a6e7b72bc9af541
Author: Mark Wells <mark at freeside.biz>
Date:   Sat Mar 31 17:57:07 2012 -0700

    add customer referrals to signup graph, #17050

diff --git a/FS/FS/Report/Table.pm b/FS/FS/Report/Table.pm
index 3942543..b0e911f 100644
--- a/FS/FS/Report/Table.pm
+++ b/FS/FS/Report/Table.pm
@@ -32,21 +32,32 @@ options in %opt.
 
 =over 4
 
-=item signups: The number of customers signed up.
+=item signups: The number of customers signed up.  Options are "refnum" 
+(limit by advertising source) and "indirect" (boolean, tells us to limit 
+to customers that have a referral_custnum that matches the advertising source).
 
 =cut
 
 sub signups {
   my( $self, $speriod, $eperiod, $agentnum, %opt ) = @_;
-  my @where = (
-    $self->in_time_period_and_agent($speriod, $eperiod, $agentnum, 'signupdate')
+  my @where = ( $self->in_time_period_and_agent($speriod, $eperiod, $agentnum, 
+      'cust_main.signupdate')
   );
-  if ( $opt{'refnum'} ) {
+  my $join = '';
+  if ( $opt{'indirect'} ) {
+    $join = " JOIN cust_main AS referring_cust_main".
+            " ON (cust_main.referral_custnum = referring_cust_main.custnum)";
+
+    if ( $opt{'refnum'} ) {
+      push @where, "referring_cust_main.refnum = ".$opt{'refnum'};
+    }
+  }
+  elsif ( $opt{'refnum'} ) {
     push @where, "refnum = ".$opt{'refnum'};
   }
 
   $self->scalar_sql(
-    "SELECT COUNT(*) FROM cust_main WHERE ".join(' AND ', @where)
+    "SELECT COUNT(*) FROM cust_main $join WHERE ".join(' AND ', @where)
   );
 }
 
diff --git a/httemplate/graph/cust_signup.html b/httemplate/graph/cust_signup.html
index dd9100f..a3eb702 100644
--- a/httemplate/graph/cust_signup.html
+++ b/httemplate/graph/cust_signup.html
@@ -9,7 +9,7 @@
   'agentnum'        => $agentnum,
   'sprintf'         => '%u',
   'disable_money'   => 1,
-  'bottom_total'    => (scalar @items > 1 ? 1 : 0),
+  'bottom_total'    => (scalar @items > 1 && !$indirect ? 1 : 0),
   'bottom_link'     => $bottom_link,
   'link_fromparam'  => 'signupdate_begin',
   'link_toparam'    => 'signupdate_end',
@@ -59,25 +59,34 @@ elsif ( $cgi->param('refnum') =~ /^(\d*)$/ ) {
   }
 }
 
+my $indirect = ($cgi->param('indirect') eq 'Y' ? 1 : 0);
+
 my (@items, @labels, @colors, @params, @links);
 
 my $hue = 0;
-my $hue_increment = 125;
+my $hue_increment = 75;
 my @signup_colors;
 
 foreach my $referral (@referral) {
+  my %params = ('refnum' => $referral->refnum) unless $all_referral;
+
   push @items, 'signups';
   push @labels, ( $all_referral ? 'Signups' : $referral->referral );
-  push @params, ( $all_referral ? [] : [ 'refnum' => $referral->refnum ] );
+  push @params, [ %params ];
   push @links, $link . ($all_referral ? '' : "refnum=".$referral->refnum.';');
-  if ( !@signup_colors ) {
-    @signup_colors = Color::Scheme->new
-                        ->from_hue($hue)
-                        ->scheme('analogic')
-                        ->colors;
-    $hue += $hue_increment;
+  # rotate hue for each referral type
+  @signup_colors = Color::Scheme->new->from_hue($hue)->colors;
+  $hue += $hue_increment;
+  push @colors, $signup_colors[0];
+  if ( $indirect ) {
+    push @items, 'signups';
+    push @labels, $all_referral ?
+                  'Referrals' : 
+                  $referral->referral . ' referrals';
+    push @params, [ %params, 'indirect' => 1 ];
+    push @links, '';
+    push @colors, $signup_colors[1];
   }
-  push @colors, shift @signup_colors;
 }
 
 </%init>
diff --git a/httemplate/graph/report_cust_signup.html b/httemplate/graph/report_cust_signup.html
index 9d3f500..12dec8e 100644
--- a/httemplate/graph/report_cust_signup.html
+++ b/httemplate/graph/report_cust_signup.html
@@ -22,6 +22,12 @@
           )
 %>
 
+<& /elements/tr-td-label.html, label => 'Show customer referrals' &>
+<TD>
+  <INPUT TYPE="checkbox" NAME="indirect" VALUE="Y">
+</TD>
+</TR>
+
 </TABLE>
 
 <BR><INPUT TYPE="submit" VALUE="Display">

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Report/Table.pm                    |   21 ++++++++++++++++-----
 httemplate/graph/cust_signup.html        |   29 +++++++++++++++++++----------
 httemplate/graph/report_cust_signup.html |    6 ++++++
 3 files changed, 41 insertions(+), 15 deletions(-)




More information about the freeside-commits mailing list