CRM-20275 Added credit card type field for contributions by organization report
authorEdsel <edsel.lopez@jmaconsulting.biz>
Mon, 13 Feb 2017 13:25:40 +0000 (18:55 +0530)
committerdeb.monish <monish.deb@jmaconsulting.biz>
Fri, 24 Mar 2017 06:47:28 +0000 (12:17 +0530)
CRM/Report/Form/Contribute/OrganizationSummary.php

index d4991a60d1db2b1cefea95c702d0191a1b369c56..64b97337feb7b37f14571993ac0b57096822f11d 100644 (file)
@@ -193,6 +193,24 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form {
         'fields' => array('email' => NULL),
         'grouping' => 'contact-fields',
       ),
+      '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,
+          ),
+        ),
+      ),
     );
 
     if ($campaignEnabled && !empty($this->activeCampaigns)) {
@@ -276,6 +294,9 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form {
                       {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
                       {$this->_aliases['civicrm_email']}.is_primary = 1\n ";
     }
+
+    // for credit card type
+    $this->addFinancialTrxnFromClause();
   }
 
   public function where() {
@@ -532,6 +553,11 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form {
         $entryFound = TRUE;
       }
 
+      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;
+      }
+
       // convert Individual display name to links
       if (array_key_exists('civicrm_contact_sort_name', $row) &&
         $rows[$rowNum]['civicrm_contact_sort_name'] &&