From d2a1da5271b61c79d21fb7201d93a9340a7c644c Mon Sep 17 00:00:00 2001 From: Edsel Roque Lopez Date: Fri, 24 Mar 2017 03:14:37 +0530 Subject: [PATCH] CRM-20283 Added credit card type field for PCP report (#9996) * CRM-20283 Added credit card type field to PCP report ---------------------------------------- * CRM-19997: Add Credit card type fields in contribution related reports https://issues.civicrm.org/jira/browse/CRM-19997 ---------------------------------------- * CRM-20283: https://issues.civicrm.org/jira/browse/CRM-20283 CRM-20283 Added credit card type field for PCP report ---------------------------------------- * CRM-20283: Add credit card type field for PCP report https://issues.civicrm.org/jira/browse/CRM-20283 CRM-20283 Bug fixes ---------------------------------------- * CRM-20283: Add credit card type field for PCP report https://issues.civicrm.org/jira/browse/CRM-20283 CRM-20283 Fixed report to read from card type rather than credit card type ---------------------------------------- * CRM-20283: Add credit card type field for PCP report https://issues.civicrm.org/jira/browse/CRM-20283 CRM-20283 Removed line break ---------------------------------------- * CRM-20283: https://issues.civicrm.org/jira/browse/CRM-20283 * QA fixes --- CRM/Report/Form.php | 17 +++++++++++++++-- CRM/Report/Form/Contribute/PCP.php | 26 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 62000041db..a8d4a1f7cd 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -4335,8 +4335,7 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a */ public function addPhoneFromClause() { // include address field if address column is to be included - if ($this->isTableSelected('civicrm_phone') - ) { + if ($this->isTableSelected('civicrm_phone')) { $this->_from .= " LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']} ON ({$this->_aliases['civicrm_contact']}.id = @@ -4345,6 +4344,20 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a } } + /** + * Add Financial Transaction into From Table if required. + */ + public function addFinancialTrxnFromClause() { + if ($this->isTableSelected('civicrm_financial_trxn')) { + $this->_from .= " + LEFT JOIN civicrm_entity_financial_trxn eftcc + ON ({$this->_aliases['civicrm_contribution']}.id = eftcc.entity_id AND + eftcc.entity_table = 'civicrm_contribution') + LEFT JOIN civicrm_financial_trxn {$this->_aliases['civicrm_financial_trxn']} + ON {$this->_aliases['civicrm_financial_trxn']}.id = eftcc.financial_trxn_id \n"; + } + } + /** * Get phone columns to add to array. * diff --git a/CRM/Report/Form/Contribute/PCP.php b/CRM/Report/Form/Contribute/PCP.php index c43c5b1bab..6a137a1b15 100644 --- a/CRM/Report/Form/Contribute/PCP.php +++ b/CRM/Report/Form/Contribute/PCP.php @@ -166,6 +166,24 @@ class CRM_Report_Form_Contribute_PCP extends CRM_Report_Form { ), 'grouping' => 'pcp-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, + ), + ), + ), ); parent::__construct(); @@ -190,6 +208,9 @@ LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']} LEFT JOIN civicrm_contribution_page {$this->_aliases['civicrm_contribution_page']} ON {$this->_aliases['civicrm_pcp']}.page_id = {$this->_aliases['civicrm_contribution_page']}.id"; + + // for credit card type + $this->addFinancialTrxnFromClause(); } public function groupBy() { @@ -355,6 +376,11 @@ LEFT JOIN civicrm_contribution_page {$this->_aliases['civicrm_contribution_page' $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; + } + if (!$entryFound) { break; } -- 2.25.1