[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 47a5a10d363c2ff97b060916f735f2debc840ce8
Ivan
ivan at 420.am
Fri Feb 24 00:08:36 PST 2012
The branch, FREESIDE_2_3_BRANCH has been updated
via 47a5a10d363c2ff97b060916f735f2debc840ce8 (commit)
from 229b67b82cbd4f1b70cad07c0da33d12f2a114c0 (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 47a5a10d363c2ff97b060916f735f2debc840ce8
Author: Ivan Kohler <ivan at freeside.biz>
Date: Fri Feb 24 00:08:33 2012 -0800
fix advanced customer report w/"add package columns" under mysql, RT#16214
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index 04e4d24..4da516b 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -736,7 +736,7 @@ sub search {
my $extra_sql = scalar(@where) ? ' WHERE '. join(' AND ', @where) : '';
- my $pkg_join = 'LEFT JOIN cust_pkg USING ( custnum ) ';
+ my $addl_from = '';
my $count_query = "SELECT COUNT(*) FROM cust_main $extra_sql";
@@ -750,19 +750,22 @@ sub search {
if ($params->{'flattened_pkgs'}) {
+ my $pkg_join = '';
+
if ($dbh->{Driver}->{Name} eq 'Pg') {
push @select, "array_to_string(array(select pkg from cust_pkg left join part_pkg using ( pkgpart ) where cust_main.custnum = cust_pkg.custnum $pkgwhere),'|') as magic";
- }elsif ($dbh->{Driver}->{Name} =~ /^mysql/i) {
+ } elsif ($dbh->{Driver}->{Name} =~ /^mysql/i) {
push @select, "GROUP_CONCAT(part_pkg.pkg SEPARATOR '|') as magic";
- $pkg_join .= " LEFT JOIN part_pkg using ( pkgpart )";
- }else{
+ $addl_from .= ' LEFT JOIN cust_pkg USING ( custnum ) '; #Pg too w/flatpkg?
+ $pkg_join .= ' LEFT JOIN part_pkg USING ( pkgpart ) ';
+ } else {
warn "warning: unknown database type ". $dbh->{Driver}->{Name}.
"omitting packing information from report.";
}
- my $header_query = "SELECT COUNT(cust_pkg.custnum = cust_main.custnum) AS count FROM cust_main $pkg_join $extra_sql $pkgwhere group by cust_main.custnum order by count desc limit 1";
+ my $header_query = "SELECT COUNT(cust_pkg.custnum = cust_main.custnum) AS count FROM cust_main $addl_from $pkg_join $extra_sql $pkgwhere group by cust_main.custnum order by count desc limit 1";
my $sth = dbh->prepare($header_query) or die dbh->errstr;
$sth->execute() or die $sth->errstr;
@@ -797,6 +800,7 @@ sub search {
my $sql_query = {
'table' => 'cust_main',
'select' => $select,
+ 'addl_from' => $addl_from,
'hashref' => {},
'extra_sql' => $extra_sql,
'order_by' => $orderby,
-----------------------------------------------------------------------
Summary of changes:
FS/FS/cust_main/Search.pm | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
More information about the freeside-commits
mailing list