CRM-20284 Added credit card type field to contribute aggregate by relationship report
authorEdsel <edsel.lopez@jmaconsulting.biz>
Wed, 15 Feb 2017 11:29:55 +0000 (16:59 +0530)
committerdeb.monish <monish.deb@jmaconsulting.biz>
Fri, 24 Mar 2017 05:01:11 +0000 (10:31 +0530)
----------------------------------------
* CRM-19997: Add Credit card type fields in contribution related reports
  https://issues.civicrm.org/jira/browse/CRM-19997

----------------------------------------
* CRM-20284:
  https://issues.civicrm.org/jira/browse/CRM-20284

CRM-20284 Added credit card type field for Contribution Aggregate by relationship report

----------------------------------------
* CRM-20284: Add credit card type field for Contribution Aggregate by Relationship report
  https://issues.civicrm.org/jira/browse/CRM-20284

CRM-20284 Fixed report to read from card type rather than credit card type

----------------------------------------
* CRM-20284: Add credit card type field for Contribution Aggregate by Relationship report
  https://issues.civicrm.org/jira/browse/CRM-20284

CRM-20284 Removed line break

----------------------------------------
* CRM-20284:
  https://issues.civicrm.org/jira/browse/CRM-20284

CRM/Report/Form/Contribute/History.php

index aaf303905814a1be04a0908c8d65fee5101c36e5..d70e4847a0e676bd15e44944129eb2be0c5efa6d 100644 (file)
@@ -269,6 +269,26 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form {
         ),
       ),
     );
+    $this->_columns += array(
+      'civicrm_financial_trxn' => array(
+        'dao' => 'CRM_Financial_DAO_FinancialTrxn',
+        'fields' => array(
+          'card_type' => array(
+            'title' => ts('Credit Card Type'),
+            'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type SEPARATOR ",")',
+          ),
+        ),
+        'filters' => array(
+          'card_type' => array(
+            'title' => ts('Credit Card Type'),
+            'operatorType' => CRM_Report_Form::OP_MULTISELECT,
+            'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type'),
+            'default' => NULL,
+            'type' => CRM_Utils_Type::T_STRING,
+          ),
+        ),
+      ),
+    );
 
     $this->_columns['civicrm_contribution']['fields']['civicrm_upto_' .
     $this->_yearStatisticsFrom] = array(
@@ -394,13 +414,10 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form {
     $this->_relationshipFrom = " INNER JOIN civicrm_relationship {$this->_aliases['civicrm_relationship']}
                      ON (({$this->_aliases['civicrm_relationship']}.contact_id_a = {$relContacAlias}.id OR {$this->_aliases['civicrm_relationship']}.contact_id_b = {$relContacAlias}.id ) AND {$this->_aliases['civicrm_relationship']}.is_active = 1) ";
 
-    if ($this->_addressField) {
-      $this->_from .= "
-                  LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
-                         ON {$this->_aliases['civicrm_contact']}.id =
-                            {$this->_aliases['civicrm_address']}.contact_id AND
-                            {$this->_aliases['civicrm_address']}.is_primary = 1\n";
-    }
+    $this->addAddressFromClause();
+
+    // for credit card type
+    $this->addFinancialTrxnFromClause();
   }
 
   public function where() {
@@ -859,6 +876,11 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form {
         $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contribution Details for this Contact.");
       }
 
+      if (!empty($row['civicrm_financial_trxn_card_type'])) {
+        $rows[$rowNum]['civicrm_financial_trxn_card_type'] = $this->getLabels($row['civicrm_financial_trxn_card_type'], 'CRM_Financial_DAO_FinancialTrxn', 'card_type');
+        $entryFound = TRUE;
+      }
+
       // display birthday in the configured custom format
       if (array_key_exists('civicrm_contact_birth_date', $row)) {
         $birthDate = $row['civicrm_contact_birth_date'];