CRM-13720 - Add address fields to TopDonor report. Using getAddressColumns() instead...
authorDave Greenberg <dave@civicrm.org>
Mon, 11 Nov 2013 20:11:28 +0000 (12:11 -0800)
committerDave Greenberg <dave@civicrm.org>
Mon, 11 Nov 2013 20:11:28 +0000 (12:11 -0800)
----------------------------------------
* CRM-13720: Add address fields to Top Donors report
  http://issues.civicrm.org/jira/browse/CRM-13720

CRM/Report/Form/Contribute/TopDonor.php

index 6d287134d1e4a0d2e9dc03d51df0c654000e7da4..cee3ad4f8fcc25a1f1e8ddc4a40ddf51ac323adc 100644 (file)
@@ -78,6 +78,9 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form {
           ),
         ),
       ),
+    )
+    + $this->getAddressColumns()
+    + array(
       'civicrm_contribution' =>
       array(
         'dao' => 'CRM_Contribute_DAO_Contribution',
@@ -227,13 +230,15 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form {
             }
             else {
               $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
-              $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'];
+              // $field['type'] is not always set. Use string type as default if not set.
+              $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = isset($field['type']) ? $field['type'] : 2;
               $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'];
             }
           }
         }
       }
     }
+    
     $this->_select = " SELECT * FROM ( SELECT " . implode(', ', $select) . " ";
   }
 
@@ -266,6 +271,7 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form {
                          ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
                             {$this->_aliases['civicrm_phone']}.is_primary = 1
        ";
+    $this->addAddressFromClause();
   }
 
   function where() {
@@ -438,6 +444,7 @@ ORDER BY civicrm_contribution_total_amount_sum DESC
           $rows[$rowNum]['civicrm_contact_display_name_link'] = $url;
           $entryFound = TRUE;
         }
+        $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s)') ? TRUE : $entryFound;
 
         // skip looking further in rows, if first row itself doesn't
         // have the column we need