Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #1573: Extra columns for Contribution Detail report. #16458

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions CRM/Report/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2548,6 +2548,23 @@ protected function alterContactID($value, &$row, $fieldname) {
return $value;
}

/**
* @param $value
* @param $row
* @param $fieldname
*
* @return mixed
*/
protected function alterCommunicationtMethod($value, &$row, $fieldname) {
$communicationMethods = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');

// Explode padded values.
$values = CRM_utils_array::explodePadded($value);
// Flip values, compute intersection with $communicationMethods, and implode with commas.
$value = implode(', ', array_intersect_key($communicationMethods, array_flip($values)));
return $value;
}

/**
* @param $value
*
Expand Down Expand Up @@ -5463,6 +5480,15 @@ protected function getContactColumns($options = []) {
'is_group_bys' => TRUE,
'is_order_bys' => TRUE,
],
$options['prefix'] . 'preferred_communication_method' => [
'title' => $options['prefix_label'] . ts('Preferred Communication Method'),
'alter_display' => 'alterCommunicationtMethod',
'name' => 'preferred_communication_method',
'is_fields' => TRUE,
'is_filters' => FALSE,
'is_group_bys' => FALSE,
'is_order_bys' => FALSE,
],
];
foreach ([
'postal_greeting_display' => 'Postal Greeting',
Expand Down Expand Up @@ -5697,7 +5723,7 @@ protected function getAddressColumns($options = []) {
$options['prefix'] . 'postal_code' => [
'title' => $options['prefix_label'] . ts('Postal Code'),
'name' => 'postal_code',
'type' => 1,
'type' => 2,
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_group_bys' => TRUE,
Expand All @@ -5706,7 +5732,7 @@ protected function getAddressColumns($options = []) {
$options['prefix'] . 'postal_code_suffix' => [
'title' => $options['prefix_label'] . ts('Postal Code Suffix'),
'name' => 'postal_code_suffix',
'type' => 1,
'type' => 2,
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_group_bys' => TRUE,
Expand Down
11 changes: 8 additions & 3 deletions CRM/Report/Form/Contribute/Detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,16 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
*/
public function __construct() {
$this->_autoIncludeIndexedFieldsAsOrderBys = 1;
$this->_columns = array_merge($this->getColumns('Contact', [
$this->_columns = array_merge(
$this->getColumns('Contact', [
'order_bys_defaults' => ['sort_name' => 'ASC '],
'fields_defaults' => ['sort_name'],
'fields_excluded' => ['id'],
'fields_required' => ['id'],
'filters_defaults' => ['is_deleted' => 0],
'no_field_disambiguation' => TRUE,
]), [
]),
[
'civicrm_email' => [
'dao' => 'CRM_Core_DAO_Email',
'fields' => [
Expand Down Expand Up @@ -341,9 +343,12 @@ public function __construct() {
],
],
],
]) + $this->addAddressFields(FALSE);
],
$this->getColumns('Address')
);
// The tests test for this variation of the sort_name field. Don't argue with the tests :-).
$this->_columns['civicrm_contact']['fields']['sort_name']['title'] = ts('Donor Name');

$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
// If we have campaigns enabled, add those elements to both the fields, filters and sorting
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/CRM/Report/Form/Contribute/DetailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ public function postalCodeDataProvider() {
'first_name',
'email',
'total_amount',
'postal_code',
'address_postal_code',
],
'filters' => [
'postal_code_value' => 'B10 G56',
'postal_code_op' => 'has',
'address_postal_code_value' => 'B10 G56',
'address_postal_code_op' => 'has',
],
],
'fixtures/dataset-ascii.sql',
Expand Down