From 4e7b6a04a4df66c42f82f0c06c35df266a5fc87a Mon Sep 17 00:00:00 2001 From: yashodha Date: Tue, 10 Sep 2019 16:45:59 +0530 Subject: [PATCH] CRM-21677 - report clean up for contribution reports --- CRM/Report/Form/Contribute/History.php | 19 +------------------ CRM/Report/Form/Contribute/SoftCredit.php | 20 ++------------------ CRM/Report/Form/Contribute/TopDonor.php | 20 ++------------------ 3 files changed, 5 insertions(+), 54 deletions(-) diff --git a/CRM/Report/Form/Contribute/History.php b/CRM/Report/Form/Contribute/History.php index 2e8c9be10c..a46611a554 100644 --- a/CRM/Report/Form/Contribute/History.php +++ b/CRM/Report/Form/Contribute/History.php @@ -810,15 +810,6 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $last_primary = NULL; foreach ($rows as $rowNum => $row) { - //handle gender - if (array_key_exists('civicrm_contact_gender_id', $row)) { - if ($value = $row['civicrm_contact_gender_id']) { - $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); - $row['civicrm_contact_gender_id'] = $rows[$rowNum]['civicrm_contact_gender_id'] = $gender[$value]; - } - $entryFound = TRUE; - } - // Highlight primary contact and amount row if (is_numeric($rowNum) || ($last_primary && ($rowNum == "{$last_primary}_total")) @@ -860,15 +851,7 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $entryFound = TRUE; } - // display birthday in the configured custom format - if (array_key_exists('civicrm_contact_birth_date', $row)) { - $birthDate = $row['civicrm_contact_birth_date']; - if ($birthDate) { - $rows[$rowNum]['civicrm_contact_birth_date'] = CRM_Utils_Date::customFormat($birthDate, '%Y%m%d'); - } - $entryFound = TRUE; - } - + $entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, NULL, NULL) ? TRUE : $entryFound; $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, NULL, NULL) ? TRUE : $entryFound; } diff --git a/CRM/Report/Form/Contribute/SoftCredit.php b/CRM/Report/Form/Contribute/SoftCredit.php index 31d50193cd..3f8fdd54f0 100644 --- a/CRM/Report/Form/Contribute/SoftCredit.php +++ b/CRM/Report/Form/Contribute/SoftCredit.php @@ -613,29 +613,13 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency ); } - //handle gender - if (array_key_exists('civicrm_contact_gender_id', $row)) { - if ($value = $row['civicrm_contact_gender_id']) { - $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); - $rows[$rowNum]['civicrm_contact_gender_id'] = $gender[$value]; - } - $entryFound = TRUE; - } - - // display birthday in the configured custom format - if (array_key_exists('civicrm_contact_birth_date', $row)) { - $birthDate = $row['civicrm_contact_birth_date']; - if ($birthDate) { - $rows[$rowNum]['civicrm_contact_birth_date'] = CRM_Utils_Date::customFormat($birthDate, '%Y%m%d'); - } - $entryFound = TRUE; - } - if (!empty($row['civicrm_financial_trxn_card_type_id']) && !in_array('Subtotal', $rows[$rowNum])) { $rows[$rowNum]['civicrm_financial_trxn_card_type_id'] = $this->getLabels($row['civicrm_financial_trxn_card_type_id'], 'CRM_Financial_DAO_FinancialTrxn', 'card_type_id'); $entryFound = TRUE; } + $entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, NULL, NULL) ? TRUE : $entryFound; + // skip looking further in rows, if first row itself doesn't // have the column we need if (!$entryFound) { diff --git a/CRM/Report/Form/Contribute/TopDonor.php b/CRM/Report/Form/Contribute/TopDonor.php index 9b613bef3c..b6479c14aa 100644 --- a/CRM/Report/Form/Contribute/TopDonor.php +++ b/CRM/Report/Form/Contribute/TopDonor.php @@ -410,29 +410,13 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { } $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s)') ? TRUE : $entryFound; - //handle gender - if (array_key_exists('civicrm_contact_gender_id', $row)) { - if ($value = $row['civicrm_contact_gender_id']) { - $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); - $rows[$rowNum]['civicrm_contact_gender_id'] = $gender[$value]; - } - $entryFound = TRUE; - } - - // display birthday in the configured custom format - if (array_key_exists('civicrm_contact_birth_date', $row)) { - $birthDate = $row['civicrm_contact_birth_date']; - if ($birthDate) { - $rows[$rowNum]['civicrm_contact_birth_date'] = CRM_Utils_Date::customFormat($birthDate, '%Y%m%d'); - } - $entryFound = TRUE; - } - if (!empty($row['civicrm_financial_trxn_card_type_id'])) { $rows[$rowNum]['civicrm_financial_trxn_card_type_id'] = $this->getLabels($row['civicrm_financial_trxn_card_type_id'], 'CRM_Financial_DAO_FinancialTrxn', 'card_type_id'); $entryFound = TRUE; } + $entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, NULL, NULL) ? TRUE : $entryFound; + // skip looking further in rows, if first row itself doesn't // have the column we need if (!$entryFound) { -- 2.25.1