3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
35 class CRM_Report_Form_Member_ContributionDetail
extends CRM_Report_Form
{
36 protected $_addressField = FALSE;
38 protected $_emailField = FALSE;
40 protected $_summary = NULL;
41 protected $_allBatches = NULL;
43 protected $_customGroupExtends = array(
52 public function __construct() {
53 $config = CRM_Core_Config
::singleton();
54 $campaignEnabled = in_array('CiviCampaign', $config->enableComponents
);
55 if ($campaignEnabled) {
56 $getCampaigns = CRM_Campaign_BAO_Campaign
::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
57 $this->activeCampaigns
= $getCampaigns['campaigns'];
58 asort($this->activeCampaigns
);
60 $this->_columns
= array(
61 'civicrm_contact' => array(
62 'dao' => 'CRM_Contact_DAO_Contact',
65 'title' => ts('Donor Name'),
69 'first_name' => array(
70 'title' => ts('First Name'),
74 'title' => ts('Last Name'),
77 'contact_type' => array(
78 'title' => ts('Contact Type'),
81 'contact_sub_type' => array(
82 'title' => ts('Contact Subtype'),
85 'do_not_email' => array(
86 'title' => ts('Do Not Email'),
89 'is_opt_out' => array(
90 'title' => ts('No Bulk Email(Is Opt Out)'),
96 'csv_display' => TRUE,
97 'title' => ts('Contact ID'),
101 'sort_name' => array(
102 'title' => ts('Donor Name'),
103 'operator' => 'like',
106 'title' => ts('Contact ID'),
107 'no_display' => TRUE,
110 'grouping' => 'contact-fields',
112 'civicrm_email' => array(
113 'dao' => 'CRM_Core_DAO_Email',
116 'title' => ts('Donor Email'),
121 'grouping' => 'contact-fields',
123 'civicrm_phone' => array(
124 'dao' => 'CRM_Core_DAO_Phone',
127 'title' => ts('Donor Phone'),
132 'grouping' => 'contact-fields',
134 'first_donation' => array(
135 'dao' => 'CRM_Contribute_DAO_Contribution',
137 'first_donation_date' => array(
138 'title' => ts('First Contribution Date'),
139 'base_field' => 'receive_date',
142 'first_donation_amount' => array(
143 'title' => ts('First Contribution Amount'),
144 'base_field' => 'total_amount',
149 'civicrm_contribution' => array(
150 'dao' => 'CRM_Contribute_DAO_Contribution',
152 'contribution_id' => array(
154 'no_display' => TRUE,
156 'csv_display' => TRUE,
157 'title' => ts('Contribution ID'),
159 'financial_type_id' => array(
160 'title' => ts('Financial Type'),
163 'contribution_recur_id' => array(
164 'title' => ts('Recurring Contribution Id'),
165 'name' => 'contribution_recur_id',
167 'no_display' => TRUE,
168 'csv_display' => TRUE,
170 'contribution_status_id' => array(
171 'title' => ts('Contribution Status'),
173 'payment_instrument_id' => array(
174 'title' => ts('Payment Type'),
176 'contribution_source' => array(
178 'title' => ts('Contribution Source'),
182 'no_display' => TRUE,
185 'receive_date' => array('default' => TRUE),
186 'receipt_date' => NULL,
187 'fee_amount' => NULL,
188 'net_amount' => NULL,
189 'total_amount' => array(
190 'title' => ts('Amount'),
195 'receive_date' => array('operatorType' => CRM_Report_Form
::OP_DATE
),
196 'financial_type_id' => array(
197 'title' => ts('Financial Type'),
198 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
199 'options' => CRM_Contribute_PseudoConstant
::financialType(),
202 'title' => 'Currency',
203 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
204 'options' => CRM_Core_OptionGroup
::values('currencies_enabled'),
206 'type' => CRM_Utils_Type
::T_STRING
,
208 'payment_instrument_id' => array(
209 'title' => ts('Payment Type'),
210 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
211 'options' => CRM_Contribute_PseudoConstant
::paymentInstrument(),
213 'contribution_status_id' => array(
214 'title' => ts('Contribution Status'),
215 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
216 'options' => CRM_Contribute_PseudoConstant
::contributionStatus(),
217 'default' => array(1),
219 'total_amount' => array('title' => ts('Contribution Amount')),
221 'grouping' => 'contri-fields',
223 'civicrm_product' => array(
224 'dao' => 'CRM_Contribute_DAO_Product',
226 'product_name' => array(
228 'title' => ts('Premium'),
232 'civicrm_contribution_product' => array(
233 'dao' => 'CRM_Contribute_DAO_ContributionProduct',
235 'product_id' => array(
236 'no_display' => TRUE,
238 'product_option' => array(
239 'title' => ts('Premium Option'),
241 'fulfilled_date' => array(
242 'title' => ts('Premium Fulfilled Date'),
244 'contribution_id' => array(
245 'no_display' => TRUE,
249 'civicrm_contribution_ordinality' => array(
250 'dao' => 'CRM_Contribute_DAO_Contribution',
251 'alias' => 'cordinality',
253 'ordinality' => array(
254 'title' => ts('Contribution Ordinality'),
255 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
257 0 => 'First by Contributor',
258 1 => 'Second or Later by Contributor',
263 'civicrm_membership' => array(
264 'dao' => 'CRM_Member_DAO_Membership',
266 'membership_type_id' => array(
267 'title' => ts('Membership Type'),
271 'membership_start_date' => array(
272 'title' => ts('Start Date'),
275 'membership_end_date' => array(
276 'title' => ts('End Date'),
279 'join_date' => array(
280 'title' => ts('Join Date'),
283 'source' => array('title' => ts('Membership Source')),
286 'join_date' => array('operatorType' => CRM_Report_Form
::OP_DATE
),
287 'membership_start_date' => array('operatorType' => CRM_Report_Form
::OP_DATE
),
288 'membership_end_date' => array('operatorType' => CRM_Report_Form
::OP_DATE
),
289 'owner_membership_id' => array(
290 'title' => ts('Membership Owner ID'),
291 'operatorType' => CRM_Report_Form
::OP_INT
,
294 'name' => 'membership_type_id',
295 'title' => ts('Membership Types'),
296 'type' => CRM_Utils_Type
::T_INT
,
297 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
298 'options' => CRM_Member_PseudoConstant
::membershipType(),
301 'grouping' => 'member-fields',
303 'civicrm_membership_status' => array(
304 'dao' => 'CRM_Member_DAO_MembershipStatus',
305 'alias' => 'mem_status',
307 'membership_status_name' => array(
309 'title' => ts('Membership Status'),
316 'title' => ts('Membership Status'),
317 'type' => CRM_Utils_Type
::T_INT
,
318 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
319 'options' => CRM_Member_PseudoConstant
::membershipStatus(NULL, NULL, 'label'),
322 'grouping' => 'member-fields',
324 'civicrm_note' => array(
325 'dao' => 'CRM_Core_DAO_Note',
327 'contribution_note' => array(
329 'title' => ts('Contribution Note'),
335 'title' => ts('Contribution Note'),
336 'operator' => 'like',
337 'type' => CRM_Utils_Type
::T_STRING
,
341 ) +
$this->addAddressFields(FALSE);
343 $this->_groupFilter
= TRUE;
344 $this->_tagFilter
= TRUE;
346 // Don't show Batch display column and filter unless batches are being used
347 $this->_allBatches
= CRM_Batch_BAO_Batch
::getBatches();
348 if (!empty($this->_allBatches
)) {
349 $this->_columns
['civicrm_batch']['dao'] = 'CRM_Batch_DAO_Batch';
350 $this->_columns
['civicrm_batch']['fields']['batch_id'] = array(
352 'title' => ts('Batch Name'),
354 $this->_columns
['civicrm_batch']['filters']['bid'] = array(
356 'title' => ts('Batch Name'),
357 'type' => CRM_Utils_Type
::T_INT
,
358 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
359 'options' => $this->_allBatches
,
361 $this->_columns
['civicrm_entity_batch']['dao'] = 'CRM_Batch_DAO_EntityBatch';
362 $this->_columns
['civicrm_entity_batch']['fields']['entity_batch_id'] = array(
363 'name' => 'batch_id',
365 'no_display' => TRUE,
369 if ($campaignEnabled && !empty($this->activeCampaigns
)) {
370 $this->_columns
['civicrm_contribution']['fields']['campaign_id'] = array(
371 'title' => ts('Campaign'),
372 'default' => 'false',
374 $this->_columns
['civicrm_contribution']['filters']['campaign_id'] = array(
375 'title' => ts('Campaign'),
376 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
377 'options' => $this->activeCampaigns
,
379 $this->_columns
['civicrm_contribution']['order_bys']['campaign_id'] = array('title' => ts('Campaign'));
382 $this->_currencyColumn
= 'civicrm_contribution_currency';
383 parent
::__construct();
386 public function preProcess() {
387 parent
::preProcess();
390 public function select() {
393 $this->_columnHeaders
= array();
394 foreach ($this->_columns
as $tableName => $table) {
395 if (array_key_exists('fields', $table)) {
396 foreach ($table['fields'] as $fieldName => $field) {
397 if (!empty($field['required']) ||
398 !empty($this->_params
['fields'][$fieldName])
400 if ($tableName == 'civicrm_address') {
401 $this->_addressField
= TRUE;
403 if ($tableName == 'civicrm_email') {
404 $this->_emailField
= TRUE;
407 // only include statistics columns if set
408 if (!empty($field['statistics'])) {
409 foreach ($field['statistics'] as $stat => $label) {
410 switch (strtolower($stat)) {
412 $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}";
413 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
414 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = $field['type'];
415 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
419 $select[] = "COUNT({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}";
420 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
421 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
425 $select[] = "ROUND(AVG({$field['dbAlias']}),2) as {$tableName}_{$fieldName}_{$stat}";
426 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = $field['type'];
427 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
428 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
433 elseif ($fieldName == 'first_donation_date' ||
434 $fieldName == 'first_donation_amount'
436 $baseField = CRM_Utils_Array
::value('base_field', $field);
437 $select[] = "{$this->_aliases['civicrm_contribution']}.{$baseField} as {$tableName}_{$fieldName}";
438 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
439 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
442 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
443 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
444 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
451 $this->_select
= 'SELECT ' . implode(', ', $select) . ' ';
454 public function from() {
456 FROM civireport_membership_contribution_detail
457 INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
458 ON (civireport_membership_contribution_detail.contribution_id = {$this->_aliases['civicrm_contribution']}.id)
459 LEFT JOIN civicrm_membership {$this->_aliases['civicrm_membership']}
460 ON (civireport_membership_contribution_detail.membership_id = {$this->_aliases['civicrm_membership']}.id)
461 INNER JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
462 ON (civireport_membership_contribution_detail.contact_id = {$this->_aliases['civicrm_contact']}.id)
463 LEFT JOIN civicrm_membership_status {$this->_aliases['civicrm_membership_status']}
464 ON {$this->_aliases['civicrm_membership_status']}.id =
465 {$this->_aliases['civicrm_membership']}.status_id
470 if (!empty($this->_params
['fields']['product_name']) ||
471 !empty($this->_params
['fields']['product_option']) ||
472 !empty($this->_params
['fields']['fulfilled_date'])
475 LEFT JOIN civicrm_contribution_product {$this->_aliases['civicrm_contribution_product']}
476 ON ({$this->_aliases['civicrm_contribution_product']}.contribution_id = {$this->_aliases['civicrm_contribution']}.id)
477 LEFT JOIN civicrm_product {$this->_aliases['civicrm_product']} ON ({$this->_aliases['civicrm_product']}.id = {$this->_aliases['civicrm_contribution_product']}.product_id)";
480 if (!empty($this->_params
['ordinality_value'])) {
482 INNER JOIN (SELECT c.id, IF(COUNT(oc.id) = 0, 0, 1) AS ordinality FROM civicrm_contribution c LEFT JOIN civicrm_contribution oc ON c.contact_id = oc.contact_id AND oc.receive_date < c.receive_date GROUP BY c.id) {$this->_aliases['civicrm_contribution_ordinality']}
483 ON {$this->_aliases['civicrm_contribution_ordinality']}.id = {$this->_aliases['civicrm_contribution']}.id";
486 // include contribution note
487 if (!empty($this->_params
['fields']['contribution_note']) ||
488 !empty($this->_params
['note_value'])
491 LEFT JOIN civicrm_note {$this->_aliases['civicrm_note']}
492 ON ( {$this->_aliases['civicrm_note']}.entity_table = 'civicrm_contribution' AND
493 {$this->_aliases['civicrm_contribution']}.id = {$this->_aliases['civicrm_note']}.entity_id )";
497 if (!empty($this->_params
['fields']['phone'])) {
499 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
500 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
501 {$this->_aliases['civicrm_phone']}.is_primary = 1)";
503 //for contribution batches
504 if ($this->_allBatches
&&
505 (!empty($this->_params
['fields']['batch_id']) ||
506 !empty($this->_params
['bid_value']))
509 LEFT JOIN civicrm_entity_financial_trxn tx ON (tx.entity_id = {$this->_aliases['civicrm_contribution']}.id AND
510 tx.entity_table = 'civicrm_contribution')
511 LEFT JOIN civicrm_entity_batch {$this->_aliases['civicrm_entity_batch']}
512 ON ({$this->_aliases['civicrm_entity_batch']}.entity_id = tx.financial_trxn_id AND
513 {$this->_aliases['civicrm_entity_batch']}.entity_table = 'civicrm_financial_trxn')
514 LEFT JOIN civicrm_batch {$this->_aliases['civicrm_batch']}
515 ON {$this->_aliases['civicrm_batch']}.id = {$this->_aliases['civicrm_entity_batch']}.batch_id";
518 if ($this->_addressField
OR
519 (!empty($this->_params
['state_province_id_value']) OR
520 !empty($this->_params
['country_id_value']))
523 LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
524 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND
525 {$this->_aliases['civicrm_address']}.is_primary = 1\n";
528 if ($this->_emailField
) {
530 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
531 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
532 {$this->_aliases['civicrm_email']}.is_primary = 1\n";
537 * @param bool $applyLimit
539 public function tempTable($applyLimit = TRUE) {
540 // create temp table with contact ids,contribtuion id,membership id
541 $dropTempTable = 'DROP TEMPORARY TABLE IF EXISTS civireport_membership_contribution_detail';
542 CRM_Core_DAO
::executeQuery($dropTempTable);
544 $sql = 'CREATE TEMPORARY TABLE civireport_membership_contribution_detail
545 (contribution_id int, contact_id int, membership_id int, payment_id int) ENGINE=HEAP';
546 CRM_Core_DAO
::executeQuery($sql);
549 INSERT INTO civireport_membership_contribution_detail (contribution_id, contact_id, membership_id)
550 SELECT contribution.id, {$this->_aliases['civicrm_contact']}.id, m.id
551 FROM civicrm_contribution contribution
552 INNER JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
553 ON {$this->_aliases['civicrm_contact']}.id = contribution.contact_id AND contribution.is_test = 0
555 LEFT JOIN civicrm_membership_payment mp
556 ON contribution.id = mp.contribution_id
557 LEFT JOIN civicrm_membership m
558 ON mp.membership_id = m.id AND m.is_test = 0 ";
560 CRM_Core_DAO
::executeQuery($fillTemp);
564 * @param bool $applyLimit
568 public function buildQuery($applyLimit = TRUE) {
570 //create temp table to be used as base table
573 $this->customDataFrom();
578 // order_by columns not selected for display need to be included in SELECT
579 $unselectedSectionColumns = $this->unselectedSectionColumns();
580 foreach ($unselectedSectionColumns as $alias => $section) {
581 $this->_select
.= ", {$section['dbAlias']} as {$alias}";
584 if ($applyLimit && empty($this->_params
['charts'])) {
588 $sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy} {$this->_having} {$this->_orderBy} {$this->_limit}";
592 public function groupBy() {
593 $this->_groupBy
= " GROUP BY {$this->_aliases['civicrm_contact']}.id, {$this->_aliases['civicrm_contribution']}.id ";
596 public function orderBy() {
597 $this->_orderBy
= " ORDER BY {$this->_aliases['civicrm_contact']}.sort_name, {$this->_aliases['civicrm_contact']}.id ";
598 if (!empty($this->_params
['fields']['first_donation_date']) ||
599 !empty($this->_params
['fields']['first_donation_amount'])
601 $this->_orderBy
.= ", {$this->_aliases['civicrm_contribution']}.receive_date";
610 public function statistics(&$rows) {
611 $statistics = parent
::statistics($rows);
613 $select = "SELECT DISTINCT {$this->_aliases['civicrm_contribution']}.id";
615 $sql = "SELECT COUNT(cc.id) as count, SUM(cc.total_amount) as amount, ROUND(AVG(cc.total_amount), 2) as avg, cc.currency as currency
616 FROM civicrm_contribution cc
617 WHERE cc.id IN ({$select} {$this->_from} {$this->_where})
618 GROUP BY cc.currency";
620 $dao = CRM_Core_DAO
::executeQuery($sql);
621 $totalAmount = $average = array();
622 while ($dao->fetch()) {
624 = CRM_Utils_Money
::format($dao->amount
, $dao->currency
) . "(" .
626 $average[] = CRM_Utils_Money
::format($dao->avg
, $dao->currency
);
628 $statistics['counts']['amount'] = array(
629 'title' => ts('Total Amount'),
630 'value' => implode(', ', $totalAmount),
631 'type' => CRM_Utils_Type
::T_STRING
,
634 $statistics['counts']['avg'] = array(
635 'title' => ts('Average'),
636 'value' => implode(', ', $average),
637 'type' => CRM_Utils_Type
::T_STRING
,
643 public function postProcess() {
644 // get the acl clauses built before we assemble the query
645 $this->buildACLClause($this->_aliases
['civicrm_contact']);
646 parent
::postProcess();
652 public function alterDisplay(&$rows) {
653 // custom code to alter rows
654 $checkList = array();
657 $contributionTypes = CRM_Contribute_PseudoConstant
::financialType();
658 $contributionStatus = CRM_Contribute_PseudoConstant
::contributionStatus();
659 $paymentInstruments = CRM_Contribute_PseudoConstant
::paymentInstrument();
661 //altering the csv display adding additional fields
662 if ($this->_outputMode
== 'csv') {
663 foreach ($this->_columns
as $tableName => $table) {
664 if (array_key_exists('fields', $table)) {
665 foreach ($table['fields'] as $fieldName => $field) {
666 if (!empty($field['csv_display']) && !empty($field['no_display'])) {
667 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
668 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
675 // allow repeat for first donation amount and date in csv
678 foreach ($rows as $rowNum => $row) {
679 if ($this->_outputMode
== 'csv') {
680 if (array_key_exists('civicrm_contact_id', $row)) {
681 if ($contactId = $row['civicrm_contact_id']) {
684 $fAmt = $row['first_donation_first_donation_amount'];
685 $fDate = $row['first_donation_first_donation_date'];
688 if ($pcid == $contactId) {
689 $rows[$rowNum]['first_donation_first_donation_amount'] = $fAmt;
690 $rows[$rowNum]['first_donation_first_donation_date'] = $fDate;
694 $fAmt = $row['first_donation_first_donation_amount'];
695 $fDate = $row['first_donation_first_donation_date'];
703 if (!empty($this->_noRepeats
) && $this->_outputMode
!= 'csv') {
704 $repeatFound = FALSE;
706 $display_flag = NULL;
707 if (array_key_exists('civicrm_contact_id', $row)) {
708 if ($cid = $row['civicrm_contact_id']) {
713 if ($prev_cid == $cid) {
724 foreach ($row as $colName => $colVal) {
725 if (in_array($colName, $this->_noRepeats
)) {
726 unset($rows[$rowNum][$colName]);
735 if (array_key_exists('civicrm_membership_membership_type_id', $row)) {
736 if ($value = $row['civicrm_membership_membership_type_id']) {
737 $rows[$rowNum]['civicrm_membership_membership_type_id'] = CRM_Member_PseudoConstant
::membershipType($value, FALSE);
742 if (array_key_exists('civicrm_batch_batch_id', $row)) {
743 if ($value = $row['civicrm_batch_batch_id']) {
744 $rows[$rowNum]['civicrm_batch_batch_id'] = CRM_Core_DAO
::getFieldValue('CRM_Batch_DAO_Batch', $value, 'title');
749 if (array_key_exists('civicrm_address_state_province_id', $row)) {
750 if ($value = $row['civicrm_address_state_province_id']) {
751 $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant
::stateProvince($value, FALSE);
756 if (array_key_exists('civicrm_address_country_id', $row)) {
757 if ($value = $row['civicrm_address_country_id']) {
758 $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant
::country($value, FALSE);
763 // convert donor sort name to link
764 if (array_key_exists('civicrm_contact_sort_name', $row) &&
765 !empty($rows[$rowNum]['civicrm_contact_sort_name']) &&
766 array_key_exists('civicrm_contact_id', $row)
768 $url = CRM_Utils_System
::url('civicrm/contact/view',
769 'reset=1&cid=' . $row['civicrm_contact_id'],
773 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
774 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts('View Contact Summary for this Contact.');
777 if ($value = CRM_Utils_Array
::value('civicrm_contribution_financial_type_id', $row)) {
778 $rows[$rowNum]['civicrm_contribution_financial_type_id'] = $contributionTypes[$value];
781 if ($value = CRM_Utils_Array
::value('civicrm_contribution_contribution_status_id', $row)) {
782 $rows[$rowNum]['civicrm_contribution_contribution_status_id'] = $contributionStatus[$value];
785 if ($value = CRM_Utils_Array
::value('civicrm_contribution_payment_instrument_id', $row)) {
786 $rows[$rowNum]['civicrm_contribution_payment_instrument_id'] = $paymentInstruments[$value];
789 if (($value = CRM_Utils_Array
::value('civicrm_contribution_total_amount_sum', $row)) &&
790 CRM_Core_Permission
::check('access CiviContribute')
792 $url = CRM_Utils_System
::url('civicrm/contact/view/contribution',
793 'reset=1&id=' . $row['civicrm_contribution_contribution_id'] .
794 '&cid=' . $row['civicrm_contact_id'] .
795 '&action=view&context=contribution&selectedChild=contribute',
798 $rows[$rowNum]['civicrm_contribution_total_amount_sum_link'] = $url;
799 $rows[$rowNum]['civicrm_contribution_total_amount_sum_hover'] = ts('View Details of this Contribution.');
803 // convert campaign_id to campaign title
804 if (array_key_exists('civicrm_contribution_campaign_id', $row)) {
805 if ($value = $row['civicrm_contribution_campaign_id']) {
806 $rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->activeCampaigns
[$value];
811 $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'member/contributionDetail', 'List all contribution(s) for this ') ?
TRUE : $entryFound;
813 // skip looking further in rows, if first row itself doesn't
814 // have the column we need