CRM-20273 Fixed report to read from card type rather than credit card type
authorEdsel <edsel.lopez@jmaconsulting.biz>
Wed, 15 Mar 2017 12:10:02 +0000 (17:40 +0530)
committerdeb.monish <monish.deb@jmaconsulting.biz>
Tue, 28 Mar 2017 09:33:05 +0000 (15:03 +0530)
CRM/Report/Form/Contribute/Detail.php

index ac3c5852ab44d024651bd3ff663d10433191baed..3c3d536fab4d4c2e6aac0425acbef53bc6629333 100644 (file)
@@ -292,24 +292,21 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
       'civicrm_financial_trxn' => array(
         'dao' => 'CRM_Financial_DAO_FinancialTrxn',
         'fields' => array(
-          'credit_card_type' => array(
+          'card_type' => array(
             'title' => ts('Credit Card Type'),
-            'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.credit_card_type SEPARATOR ",")',
+            'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type SEPARATOR ",")',
           ),
         ),
         'filters' => array(
-          'credit_card_type' => array(
+          'card_type' => array(
             'title' => ts('Credit Card Type'),
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-            'options' => CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialTrxn', 'credit_card_type'),
+            'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type'),
             'default' => NULL,
             'type' => CRM_Utils_Type::T_STRING,
           ),
         ),
       ),
-      'civicrm_entity_financial_trxn' => array(
-        'dao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
-      ),
       'civicrm_batch' => array(
         'dao' => 'CRM_Batch_DAO_EntityBatch',
         'grouping' => 'contri-fields',
@@ -768,8 +765,8 @@ UNION ALL
         $rows[$rowNum]['civicrm_batch_batch_id'] = CRM_Utils_Array::value($row['civicrm_batch_batch_id'], $batches);
         $entryFound = TRUE;
       }
-      if (!empty($row['civicrm_financial_trxn_credit_card_type'])) {
-        $rows[$rowNum]['civicrm_financial_trxn_credit_card_type'] = $this->getGroupCreditCardType($row['civicrm_financial_trxn_credit_card_type']);
+      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;
       }
 
@@ -1026,13 +1023,7 @@ WHERE  civicrm_contribution_contribution_id={$row['civicrm_contribution_contribu
           AND {$this->_aliases['civicrm_batch']}.entity_table = 'civicrm_financial_trxn')";
     }
     // for credit card type
-    if ($this->isTableSelected('civicrm_financial_trxn')) {
-      $this->_from .= "\n LEFT JOIN civicrm_entity_financial_trxn {$this->_aliases['civicrm_entity_financial_trxn']}
-                    ON ({$this->_aliases['civicrm_contribution']}.id = {$this->_aliases['civicrm_entity_financial_trxn']}.entity_id AND
-                        {$this->_aliases['civicrm_entity_financial_trxn']}.entity_table = 'civicrm_contribution')
-              LEFT JOIN civicrm_financial_trxn {$this->_aliases['civicrm_financial_trxn']}
-                    ON {$this->_aliases['civicrm_financial_trxn']}.id = {$this->_aliases['civicrm_entity_financial_trxn']}.financial_trxn_id";
-    }
+    $this->addFinancialTrxnFromClause();
   }
 
 }