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, INDEX USING HASH(contribution_id), contact_id int, INDEX USING HASH(contact_id),
546 membership_id int, INDEX USING HASH(membership_id), payment_id int, INDEX USING HASH(payment_id)) ENGINE=MEMORY';
547 CRM_Core_DAO
::executeQuery($sql);
550 INSERT INTO civireport_membership_contribution_detail (contribution_id, contact_id, membership_id)
551 SELECT contribution.id, {$this->_aliases['civicrm_contact']}.id, m.id
552 FROM civicrm_contribution contribution
553 INNER JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
554 ON {$this->_aliases['civicrm_contact']}.id = contribution.contact_id AND contribution.is_test = 0
556 LEFT JOIN civicrm_membership_payment mp
557 ON contribution.id = mp.contribution_id
558 LEFT JOIN civicrm_membership m
559 ON mp.membership_id = m.id AND m.is_test = 0 ";
561 CRM_Core_DAO
::executeQuery($fillTemp);
565 * @param bool $applyLimit
569 public function buildQuery($applyLimit = TRUE) {
571 //create temp table to be used as base table
574 $this->customDataFrom();
579 // order_by columns not selected for display need to be included in SELECT
580 $unselectedSectionColumns = $this->unselectedSectionColumns();
581 foreach ($unselectedSectionColumns as $alias => $section) {
582 $this->_select
.= ", {$section['dbAlias']} as {$alias}";
585 if ($applyLimit && empty($this->_params
['charts'])) {
589 $sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy} {$this->_having} {$this->_orderBy} {$this->_limit}";
593 public function groupBy() {
594 $this->_groupBy
= " GROUP BY {$this->_aliases['civicrm_contact']}.id, {$this->_aliases['civicrm_contribution']}.id ";
597 public function orderBy() {
598 $this->_orderBy
= " ORDER BY {$this->_aliases['civicrm_contact']}.sort_name, {$this->_aliases['civicrm_contact']}.id ";
599 if (!empty($this->_params
['fields']['first_donation_date']) ||
600 !empty($this->_params
['fields']['first_donation_amount'])
602 $this->_orderBy
.= ", {$this->_aliases['civicrm_contribution']}.receive_date";
611 public function statistics(&$rows) {
612 $statistics = parent
::statistics($rows);
614 $select = "SELECT DISTINCT {$this->_aliases['civicrm_contribution']}.id";
616 $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
617 FROM civicrm_contribution cc
618 WHERE cc.id IN ({$select} {$this->_from} {$this->_where})
619 GROUP BY cc.currency";
621 $dao = CRM_Core_DAO
::executeQuery($sql);
622 $totalAmount = $average = array();
623 while ($dao->fetch()) {
625 = CRM_Utils_Money
::format($dao->amount
, $dao->currency
) . "(" .
627 $average[] = CRM_Utils_Money
::format($dao->avg
, $dao->currency
);
629 $statistics['counts']['amount'] = array(
630 'title' => ts('Total Amount'),
631 'value' => implode(', ', $totalAmount),
632 'type' => CRM_Utils_Type
::T_STRING
,
635 $statistics['counts']['avg'] = array(
636 'title' => ts('Average'),
637 'value' => implode(', ', $average),
638 'type' => CRM_Utils_Type
::T_STRING
,
644 public function postProcess() {
645 // get the acl clauses built before we assemble the query
646 $this->buildACLClause($this->_aliases
['civicrm_contact']);
647 parent
::postProcess();
653 public function alterDisplay(&$rows) {
654 // custom code to alter rows
655 $checkList = array();
658 $contributionTypes = CRM_Contribute_PseudoConstant
::financialType();
659 $contributionStatus = CRM_Contribute_PseudoConstant
::contributionStatus();
660 $paymentInstruments = CRM_Contribute_PseudoConstant
::paymentInstrument();
662 //altering the csv display adding additional fields
663 if ($this->_outputMode
== 'csv') {
664 foreach ($this->_columns
as $tableName => $table) {
665 if (array_key_exists('fields', $table)) {
666 foreach ($table['fields'] as $fieldName => $field) {
667 if (!empty($field['csv_display']) && !empty($field['no_display'])) {
668 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
669 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
676 // allow repeat for first donation amount and date in csv
679 foreach ($rows as $rowNum => $row) {
680 if ($this->_outputMode
== 'csv') {
681 if (array_key_exists('civicrm_contact_id', $row)) {
682 if ($contactId = $row['civicrm_contact_id']) {
685 $fAmt = $row['first_donation_first_donation_amount'];
686 $fDate = $row['first_donation_first_donation_date'];
689 if ($pcid == $contactId) {
690 $rows[$rowNum]['first_donation_first_donation_amount'] = $fAmt;
691 $rows[$rowNum]['first_donation_first_donation_date'] = $fDate;
695 $fAmt = $row['first_donation_first_donation_amount'];
696 $fDate = $row['first_donation_first_donation_date'];
704 if (!empty($this->_noRepeats
) && $this->_outputMode
!= 'csv') {
705 $repeatFound = FALSE;
707 $display_flag = NULL;
708 if (array_key_exists('civicrm_contact_id', $row)) {
709 if ($cid = $row['civicrm_contact_id']) {
714 if ($prev_cid == $cid) {
725 foreach ($row as $colName => $colVal) {
726 if (in_array($colName, $this->_noRepeats
)) {
727 unset($rows[$rowNum][$colName]);
736 if (array_key_exists('civicrm_membership_membership_type_id', $row)) {
737 if ($value = $row['civicrm_membership_membership_type_id']) {
738 $rows[$rowNum]['civicrm_membership_membership_type_id'] = CRM_Member_PseudoConstant
::membershipType($value, FALSE);
743 if (array_key_exists('civicrm_batch_batch_id', $row)) {
744 if ($value = $row['civicrm_batch_batch_id']) {
745 $rows[$rowNum]['civicrm_batch_batch_id'] = CRM_Core_DAO
::getFieldValue('CRM_Batch_DAO_Batch', $value, 'title');
750 if (array_key_exists('civicrm_address_state_province_id', $row)) {
751 if ($value = $row['civicrm_address_state_province_id']) {
752 $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant
::stateProvince($value, FALSE);
757 if (array_key_exists('civicrm_address_country_id', $row)) {
758 if ($value = $row['civicrm_address_country_id']) {
759 $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant
::country($value, FALSE);
764 // convert donor sort name to link
765 if (array_key_exists('civicrm_contact_sort_name', $row) &&
766 !empty($rows[$rowNum]['civicrm_contact_sort_name']) &&
767 array_key_exists('civicrm_contact_id', $row)
769 $url = CRM_Utils_System
::url('civicrm/contact/view',
770 'reset=1&cid=' . $row['civicrm_contact_id'],
774 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
775 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts('View Contact Summary for this Contact.');
778 if ($value = CRM_Utils_Array
::value('civicrm_contribution_financial_type_id', $row)) {
779 $rows[$rowNum]['civicrm_contribution_financial_type_id'] = $contributionTypes[$value];
782 if ($value = CRM_Utils_Array
::value('civicrm_contribution_contribution_status_id', $row)) {
783 $rows[$rowNum]['civicrm_contribution_contribution_status_id'] = $contributionStatus[$value];
786 if ($value = CRM_Utils_Array
::value('civicrm_contribution_payment_instrument_id', $row)) {
787 $rows[$rowNum]['civicrm_contribution_payment_instrument_id'] = $paymentInstruments[$value];
790 if (($value = CRM_Utils_Array
::value('civicrm_contribution_total_amount_sum', $row)) &&
791 CRM_Core_Permission
::check('access CiviContribute')
793 $url = CRM_Utils_System
::url('civicrm/contact/view/contribution',
794 'reset=1&id=' . $row['civicrm_contribution_contribution_id'] .
795 '&cid=' . $row['civicrm_contact_id'] .
796 '&action=view&context=contribution&selectedChild=contribute',
799 $rows[$rowNum]['civicrm_contribution_total_amount_sum_link'] = $url;
800 $rows[$rowNum]['civicrm_contribution_total_amount_sum_hover'] = ts('View Details of this Contribution.');
804 // convert campaign_id to campaign title
805 if (array_key_exists('civicrm_contribution_campaign_id', $row)) {
806 if ($value = $row['civicrm_contribution_campaign_id']) {
807 $rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->activeCampaigns
[$value];
812 $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'member/contributionDetail', 'List all contribution(s) for this ') ?
TRUE : $entryFound;
814 // skip looking further in rows, if first row itself doesn't
815 // have the column we need