[freeside-commits] branch FREESIDE_3_BRANCH updated. c6067e5ce005117ee3239eb00de0adc58efa4ee5
Ivan
ivan at 420.am
Thu Apr 27 13:42:02 PDT 2017
The branch, FREESIDE_3_BRANCH has been updated
via c6067e5ce005117ee3239eb00de0adc58efa4ee5 (commit)
from 6d922e31555a5888a1c070ea403e5d80608d357c (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 c6067e5ce005117ee3239eb00de0adc58efa4ee5
Author: Ivan Kohler <ivan at freeside.biz>
Date: Thu Apr 27 13:42:01 2017 -0700
customer referral report, RT#75757
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index 5c21a8e..04d97bd 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -878,6 +878,15 @@ sub search {
if $params->{'no_tax'};
##
+ # with referrals
+ ##
+ if ( $params->{'with_referrals'} ) {
+ push @where,
+ ' EXISTS ( SELECT 1 FROM cust_main AS referred_cust_main
+ WHERE cust_main.custnum = referred_cust_main.referral_custnum )';
+ }
+
+ ##
# dates
##
@@ -1147,6 +1156,20 @@ sub search {
}
+ if ( $params->{'with_referrals'} ) {
+
+ #XXX next: num for each customer status
+
+ push @select,
+ '( SELECT COUNT(*) FROM cust_main AS referred_cust_main
+ WHERE cust_main.custnum = referred_cust_main.referral_custnum
+ ) AS num_referrals';
+
+ unshift @extra_headers, 'Referrals';
+ unshift @extra_fields, 'num_referrals';
+
+ }
+
my $select = join(', ', @select);
my $sql_query = {
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index 07dc699..3386777 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -129,6 +129,7 @@ $report_customers_lists{'by active trouble tickets'} = [ $fsurl. 'search/cust_ma
if $conf->config('ticket_system');
$report_customers_lists{'with USPS-unvalidated addresses'} = [ $fsurl. 'search/cust_main.cgi?browse=uspsunvalid', '' ]
if $conf->config('usps_webtools-userid') && $conf->config('usps_webtools-password');
+$report_customers_lists{'with referrals'} = [ $fsurl. 'search/cust_main.html?with_referrals=1' ];
tie my %report_customers, 'Tie::IxHash';
$report_customers{'List customers'} = [ \%report_customers_lists, 'List customers' ]
diff --git a/httemplate/search/cust_main.html b/httemplate/search/cust_main.html
index 040d6c3..0743829 100755
--- a/httemplate/search/cust_main.html
+++ b/httemplate/search/cust_main.html
@@ -27,7 +27,11 @@
$cgi->param('cust_fields')
)
),
- map '', @extra_fields
+ map { $_ eq 'num_referrals'
+ ? $referral_link
+ : ''
+ }
+ @extra_fields
],
&>
<%init>
@@ -51,6 +55,7 @@ my @scalars = qw (
all_tags
all_pkg_classnums
any_pkg_status
+ with_referrals
);
for my $param ( @scalars ) {
@@ -104,6 +109,8 @@ my @extra_fields = @{ delete($sql_query->{'extra_fields'}) };
my $link = [ "${p}view/cust_main.cgi?", 'custnum' ];
+my $referral_link = [ "${p}search/cust_main.cgi?referral_custnum=", 'custnum' ];
+
###
# email links
###
-----------------------------------------------------------------------
Summary of changes:
FS/FS/cust_main/Search.pm | 23 +++++++++++++++++++++++
httemplate/elements/menu.html | 1 +
httemplate/search/cust_main.html | 9 ++++++++-
3 files changed, 32 insertions(+), 1 deletion(-)
More information about the freeside-commits
mailing list