From bdfeefa38cec93b3b825a6bc87c864450dba0c5a Mon Sep 17 00:00:00 2001 From: Edsel Date: Wed, 15 Feb 2017 16:07:48 +0530 Subject: [PATCH] CRM-20278 Added credit card type field to top donor report ---------------------------------------- * CRM-19997: Add Credit card type fields in contribution related reports https://issues.civicrm.org/jira/browse/CRM-19997 --- CRM/Report/Form/Contribute/TopDonor.php | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/CRM/Report/Form/Contribute/TopDonor.php b/CRM/Report/Form/Contribute/TopDonor.php index 2a33d66158..856807efb4 100644 --- a/CRM/Report/Form/Contribute/TopDonor.php +++ b/CRM/Report/Form/Contribute/TopDonor.php @@ -162,6 +162,24 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { ), ), ), + '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, + ), + ), + ), 'civicrm_email' => array( 'dao' => 'CRM_Core_DAO_Email', 'fields' => array( @@ -290,6 +308,10 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']} ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND {$this->_aliases['civicrm_phone']}.is_primary = 1"; + + // for credit card type + $this->addFinancialTrxnFromClause(); + $this->addAddressFromClause(); } @@ -494,6 +516,11 @@ ORDER BY civicrm_contribution_total_amount_sum DESC $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; + } + // skip looking further in rows, if first row itself doesn't // have the column we need if (!$entryFound) { -- 2.25.1