[freeside-commits] branch master updated. 0704f3f641deb525399521368f1e6ba9ff5b71cd

Mark Wells mark at 420.am
Wed Mar 6 15:05:01 PST 2013


The branch, master has been updated
       via  0704f3f641deb525399521368f1e6ba9ff5b71cd (commit)
      from  5fe75497ce60689c128d93a3f1c9339e7c5e4e49 (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 0704f3f641deb525399521368f1e6ba9ff5b71cd
Author: Mark Wells <mark at freeside.biz>
Date:   Wed Mar 6 15:04:14 2013 -0800

    customer location columns in more reports, #940

diff --git a/FS/FS/UI/Web.pm b/FS/FS/UI/Web.pm
index 91d2034..d6f183d 100644
--- a/FS/FS/UI/Web.pm
+++ b/FS/FS/UI/Web.pm
@@ -378,6 +378,9 @@ Otherwise, this function will assume the field is named "custnum".  If the
 argument isn't present at all, the join will just say "USING (custnum)", 
 which might work.
 
+As a special case, if TABLE is 'cust_main', only the joins to cust_location
+will be returned.
+
 LOCATION_TABLE is an optional table name to use for joining ship_location,
 in case your query also includes package information and you want the 
 "service address" columns to reflect package addresses.
@@ -392,11 +395,12 @@ sub join_cust_main {
   ($location_table, $locationnum) = split(/\./, $location_table);
   $locationnum ||= 'locationnum';
 
-  my $sql = ' LEFT JOIN cust_main ';
+  my $sql = '';
   if ( $cust_table ) {
-    $sql .= "ON (cust_main.custnum = $cust_table.$custnum)";
+    $sql = " LEFT JOIN cust_main ON (cust_main.custnum = $cust_table.$custnum)"
+      unless $cust_table eq 'cust_main';
   } else {
-    $sql .= "USING (custnum)";
+    $sql = " LEFT JOIN cust_main USING (custnum)";
   }
 
   if ( !@cust_fields or grep /^bill_/, @cust_fields ) {
diff --git a/httemplate/search/elements/cust_main_dayranges.html b/httemplate/search/elements/cust_main_dayranges.html
index eb75664..c9c71f2 100644
--- a/httemplate/search/elements/cust_main_dayranges.html
+++ b/httemplate/search/elements/cust_main_dayranges.html
@@ -172,10 +172,11 @@ my $count_sql = "select count(*) from cust_main $where";
 
 my $sql_query = {
   'table'     => 'cust_main',
+  'addl_from' => FS::UI::Web::join_cust_main('cust_main'),
   'hashref'   => {},
   'select'    => join(',',
                    #'cust_main.*',
-                   'custnum',
+                   'cust_main.custnum',
                    $range_cols,
                    $packages_cols,
                    FS::UI::Web::cust_sql_fields(),
diff --git a/httemplate/search/elements/cust_pay_or_refund.html b/httemplate/search/elements/cust_pay_or_refund.html
index b9da7ef..3dc54d9 100755
--- a/httemplate/search/elements/cust_pay_or_refund.html
+++ b/httemplate/search/elements/cust_pay_or_refund.html
@@ -424,7 +424,7 @@ if ( $cgi->param('magic') ) {
   #here is the agent virtualization
   push @search, $curuser->agentnums_sql;
 
-  my $addl_from = ' LEFT JOIN cust_main USING ( custnum ) ';
+  my $addl_from = FS::UI::Web::join_cust_main('cust_pay');
   my $group_by = '';
 
   if ( $cgi->param('tax_names') ) {

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

Summary of changes:
 FS/FS/UI/Web.pm                                    |   10 +++++++---
 .../search/elements/cust_main_dayranges.html       |    3 ++-
 httemplate/search/elements/cust_pay_or_refund.html |    2 +-
 3 files changed, 10 insertions(+), 5 deletions(-)




More information about the freeside-commits mailing list