4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.4 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2013 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
32 * @copyright CiviCRM LLC (c) 2004-2013
36 class CRM_Report_Form_Member_ContributionDetail
extends CRM_Report_Form
{
37 protected $_addressField = FALSE;
39 protected $_emailField = FALSE;
40 protected $_emailFieldHonor = FALSE;
42 protected $_nameFieldHonor = FALSE;
44 protected $_summary = NULL;
46 protected $_customGroupExtends = array(
47 'Contribution', 'Membership');
49 function __construct() {
50 $config = CRM_Core_Config
::singleton();
51 $campaignEnabled = in_array('CiviCampaign', $config->enableComponents
);
52 if ($campaignEnabled) {
53 $getCampaigns = CRM_Campaign_BAO_Campaign
::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
54 $this->activeCampaigns
= $getCampaigns['campaigns'];
55 asort($this->activeCampaigns
);
57 $this->_columns
= array(
60 'dao' => 'CRM_Contact_DAO_Contact',
64 array('title' => ts('Donor Name'),
69 array('title' => ts('First Name'),
73 array('title' => ts('Last Name'),
77 array('title' => ts('Contact Type'),
82 'title' => ts('Contact SubType'),
86 array('title' => ts('Do Not Email'),
90 array('title' => ts('No Bulk Email(Is Opt Out)'),
97 'csv_display' => TRUE,
98 'title' => ts('Contact ID'),
104 array('title' => ts('Donor Name'),
105 'operator' => 'like',
108 array('title' => ts('Contact ID'),
109 'no_display' => TRUE,
112 'grouping' => 'contact-fields',
116 'dao' => 'CRM_Core_DAO_Email',
120 array('title' => ts('Donor Email'),
125 'grouping' => 'contact-fields',
129 'dao' => 'CRM_Core_DAO_Phone',
133 array('title' => ts('Donor Phone'),
138 'grouping' => 'contact-fields',
140 'civicrm_contact_honor' =>
142 'dao' => 'CRM_Contact_DAO_Contact',
146 array('title' => ts('Honoree Name'),
147 'name' => 'sort_name',
148 'alias' => 'contacthonor',
154 'no_display' => TRUE,
155 'title' => ts('Honoree ID'),
157 'alias' => 'contacthonor',
162 'civicrm_email_honor' =>
164 'dao' => 'CRM_Core_DAO_Email',
168 array('title' => ts('Honoree Email'),
170 'alias' => 'emailhonor',
175 'grouping' => 'contact-fields',
177 'first_donation' => array(
178 'dao' => 'CRM_Contribute_DAO_Contribution',
181 'first_donation_date' => array(
182 'title' => ts('First Contribution Date'),
183 'base_field' => 'receive_date',
186 'first_donation_amount' => array(
187 'title' => ts('First Contribution Amount'),
188 'base_field' => 'total_amount',
193 'civicrm_contribution' =>
195 'dao' => 'CRM_Contribute_DAO_Contribution',
198 'contribution_id' => array(
200 'no_display' => TRUE,
202 'csv_display' => TRUE,
203 'title' => ts('Contribution ID'),
205 'financial_type_id' => array('title' => ts('Financial Type'),
208 'contribution_recur_id' => array('title' => ts('Recurring Contribution Id'),
209 'name' => 'contribution_recur_id',
211 'no_display' => TRUE,
212 'csv_display' => TRUE,
214 'contribution_status_id' => array('title' => ts('Contribution Status'),
216 'payment_instrument_id' => array('title' => ts('Payment Type'),
218 'contribution_source' => array(
220 'title' => ts('Contribution Source'),
224 'no_display' => TRUE,
227 'receive_date' => array('default' => TRUE),
228 'receipt_date' => NULL,
229 'honor_type_id' => array('title' => ts('Honor Type'),
232 'fee_amount' => NULL,
233 'net_amount' => NULL,
234 'total_amount' => array('title' => ts('Amount'),
241 array('operatorType' => CRM_Report_Form
::OP_DATE
),
242 'financial_type_id' =>
243 array('title' => ts('Financial Type'),
244 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
245 'options' => CRM_Contribute_PseudoConstant
::financialType(),
248 array('title' => 'Currency',
249 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
250 'options' => CRM_Core_OptionGroup
::values('currencies_enabled'),
252 'type' => CRM_Utils_Type
::T_STRING
,
254 'payment_instrument_id' =>
255 array('title' => ts('Payment Type'),
256 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
257 'options' => CRM_Contribute_PseudoConstant
::paymentInstrument(),
259 'contribution_status_id' =>
260 array('title' => ts('Contribution Status'),
261 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
262 'options' => CRM_Contribute_PseudoConstant
::contributionStatus(),
263 'default' => array(1),
266 array('title' => ts('Contribution Amount')),
268 'grouping' => 'contri-fields',
272 'dao' => 'CRM_Contribute_DAO_Product',
275 'product_name' => array(
277 'title' => ts('Premium'),
281 'civicrm_contribution_product' =>
283 'dao' => 'CRM_Contribute_DAO_ContributionProduct',
286 'product_id' => array(
287 'no_display' => TRUE,
289 'product_option' => array(
290 'title' => ts('Premium Option'),
292 'contribution_id' => array(
293 'no_display' => TRUE,
299 'dao' => 'CRM_Contact_DAO_GroupContact',
305 'name' => 'group_id',
306 'title' => ts('Group'),
307 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
309 'options' => CRM_Core_PseudoConstant
::group(),
313 'civicrm_contribution_ordinality' =>
315 'dao' => 'CRM_Contribute_DAO_Contribution',
316 'alias' => 'cordinality',
320 array('title' => ts('Contribution Ordinality'),
321 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
323 0 => 'First by Contributor',
324 1 => 'Second or Later by Contributor',
329 'civicrm_membership' =>
331 'dao' => 'CRM_Member_DAO_Membership',
334 'membership_type_id' => array('title' => ts('Membership Type'),
338 'membership_start_date' => array('title' => ts('Start Date'),
341 'membership_end_date' => array('title' => ts('End Date'),
344 'join_date' => array('title' => ts('Join Date'),
347 'source' => array('title' => ts('Membership Source')),
351 array('operatorType' => CRM_Report_Form
::OP_DATE
),
352 'membership_start_date' =>
353 array('operatorType' => CRM_Report_Form
::OP_DATE
),
354 'membership_end_date' =>
355 array('operatorType' => CRM_Report_Form
::OP_DATE
),
356 'owner_membership_id' =>
357 array('title' => ts('Membership Owner ID'),
358 'operatorType' => CRM_Report_Form
::OP_INT
,
362 'name' => 'membership_type_id',
363 'title' => ts('Membership Types'),
364 'type' => CRM_Utils_Type
::T_INT
,
365 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
366 'options' => CRM_Member_PseudoConstant
::membershipType(),
369 'grouping' => 'member-fields',
371 'civicrm_membership_status' =>
373 'dao' => 'CRM_Member_DAO_MembershipStatus',
374 'alias' => 'mem_status',
377 'membership_status_name' =>
380 'title' => ts('Membership Status'),
388 'title' => ts('Membership Status'),
389 'type' => CRM_Utils_Type
::T_INT
,
390 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
391 'options' => CRM_Member_PseudoConstant
::membershipStatus(NULL, NULL, 'label'),
394 'grouping' => 'member-fields',
398 'dao' => 'CRM_Core_DAO_Note',
401 'contribution_note' =>
404 'title' => ts('Contribution Note'),
412 'title' => ts('Contribution Note'),
413 'operator' => 'like',
414 'type' => CRM_Utils_Type
::T_STRING
,
418 ) +
$this->addAddressFields(FALSE);
420 $this->_tagFilter
= TRUE;
422 // Don't show Batch display column and filter unless batches are being used
423 $this->_closedBatches
= CRM_Batch_BAO_Batch
::getBatches();
424 if (!empty($this->_closedBatches
)) {
425 $this->_columns
['civicrm_batch']['dao'] = 'CRM_Batch_DAO_Batch';
426 $this->_columns
['civicrm_batch']['fields']['batch_id'] = array(
428 'title' => ts('Batch Name'),
430 $this->_columns
['civicrm_batch']['filters']['bid'] = array(
432 'title' => ts('Batch Name'),
433 'type' => CRM_Utils_Type
::T_INT
,
434 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
435 'options' => $this->_closedBatches
,
437 $this->_columns
['civicrm_entity_batch']['dao'] = 'CRM_Batch_DAO_EntityBatch';
438 $this->_columns
['civicrm_entity_batch']['fields']['entity_batch_id'] = array(
439 'name' => 'batch_id',
441 'no_display' => TRUE,
445 if ($campaignEnabled && !empty($this->activeCampaigns
)) {
446 $this->_columns
['civicrm_contribution']['fields']['campaign_id'] = array(
447 'title' => ts('Campaign'),
448 'default' => 'false',
450 $this->_columns
['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'),
451 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
452 'options' => $this->activeCampaigns
,
454 $this->_columns
['civicrm_contribution']['order_bys']['campaign_id'] = array('title' => ts('Campaign'));
457 $this->_currencyColumn
= 'civicrm_contribution_currency';
458 parent
::__construct();
461 function preProcess() {
462 parent
::preProcess();
468 $this->_columnHeaders
= array();
469 foreach ($this->_columns
as $tableName => $table) {
470 if (array_key_exists('fields', $table)) {
471 foreach ($table['fields'] as $fieldName => $field) {
472 if (CRM_Utils_Array
::value('required', $field) ||
473 CRM_Utils_Array
::value($fieldName, $this->_params
['fields'])
475 if ($tableName == 'civicrm_address') {
476 $this->_addressField
= TRUE;
478 if ($tableName == 'civicrm_email') {
479 $this->_emailField
= TRUE;
481 elseif ($tableName == 'civicrm_email_honor') {
482 $this->_emailFieldHonor
= TRUE;
485 if ($tableName == 'civicrm_contact_honor') {
486 $this->_nameFieldHonor
= TRUE;
489 // only include statistics columns if set
490 if (CRM_Utils_Array
::value('statistics', $field)) {
491 foreach ($field['statistics'] as $stat => $label) {
492 switch (strtolower($stat)) {
494 $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}";
495 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
496 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = $field['type'];
497 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
501 $select[] = "COUNT({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}";
502 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
503 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
507 $select[] = "ROUND(AVG({$field['dbAlias']}),2) as {$tableName}_{$fieldName}_{$stat}";
508 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = $field['type'];
509 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
510 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
515 elseif ($fieldName == 'first_donation_date' ||
$fieldName == 'first_donation_amount') {
516 $baseField = CRM_Utils_Array
::value('base_field', $field);
517 $select[] = "{$this->_aliases['civicrm_contribution']}.{$baseField} as {$tableName}_{$fieldName}";
518 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
519 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
522 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
523 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
524 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
531 $this->_select
= 'SELECT ' . implode(', ', $select) . ' ';
536 FROM civireport_membership_contribution_detail
537 INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
538 ON (civireport_membership_contribution_detail.contribution_id = {$this->_aliases['civicrm_contribution']}.id)
539 LEFT JOIN civicrm_membership {$this->_aliases['civicrm_membership']}
540 ON (civireport_membership_contribution_detail.membership_id = {$this->_aliases['civicrm_membership']}.id)
541 INNER JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
542 ON (civireport_membership_contribution_detail.contact_id = {$this->_aliases['civicrm_contact']}.id)
543 LEFT JOIN civicrm_membership_status {$this->_aliases['civicrm_membership_status']}
544 ON {$this->_aliases['civicrm_membership_status']}.id =
545 {$this->_aliases['civicrm_membership']}.status_id
549 if (CRM_Utils_Array
::value('product_name', $this->_params
['fields']) || CRM_Utils_Array
::value('product_option', $this->_params
['fields'])) {
551 LEFT JOIN civicrm_contribution_product {$this->_aliases['civicrm_contribution_product']}
552 ON ({$this->_aliases['civicrm_contribution_product']}.contribution_id = {$this->_aliases['civicrm_contribution']}.id)
553 LEFT JOIN civicrm_product {$this->_aliases['civicrm_product']} ON ({$this->_aliases['civicrm_product']}.id = {$this->_aliases['civicrm_contribution_product']}.product_id)";
556 if (!empty($this->_params
['ordinality_value'])) {
558 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']}
559 ON {$this->_aliases['civicrm_contribution_ordinality']}.id = {$this->_aliases['civicrm_contribution']}.id";
562 // include contribution note
563 if (CRM_Utils_Array
::value('contribution_note', $this->_params
['fields']) ||
!empty($this->_params
['note_value'])) {
565 LEFT JOIN civicrm_note {$this->_aliases['civicrm_note']}
566 ON ( {$this->_aliases['civicrm_note']}.entity_table = 'civicrm_contribution' AND
567 {$this->_aliases['civicrm_contribution']}.id = {$this->_aliases['civicrm_note']}.entity_id )";
571 if (CRM_Utils_Array
::value('phone', $this->_params
['fields'])) {
573 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
574 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
575 {$this->_aliases['civicrm_phone']}.is_primary = 1)";
577 //for contribution batches
578 if ($this->_closedBatches
&&
579 (CRM_Utils_Array
::value('batch_id', $this->_params
['fields']) ||
!empty($this->_params
['bid_value']))) {
581 LEFT JOIN civicrm_entity_batch {$this->_aliases['civicrm_entity_batch']}
582 ON ({$this->_aliases['civicrm_entity_batch']}.entity_id = {$this->_aliases['civicrm_contribution']}.id AND
583 {$this->_aliases['civicrm_entity_batch']}.entity_table = 'civicrm_contribution')
584 LEFT JOIN civicrm_batch {$this->_aliases['civicrm_batch']}
585 ON {$this->_aliases['civicrm_batch']}.id = {$this->_aliases['civicrm_entity_batch']}.batch_id";
588 if ($this->_addressField
OR (!empty($this->_params
['state_province_id_value']) OR !empty($this->_params
['country_id_value']))) {
590 LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
591 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND
592 {$this->_aliases['civicrm_address']}.is_primary = 1\n";
595 if ($this->_emailField
) {
597 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
598 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
599 {$this->_aliases['civicrm_email']}.is_primary = 1\n";
602 // include Honor name field
603 if ($this->_nameFieldHonor
) {
605 LEFT JOIN civicrm_contact contacthonor
606 ON contacthonor.id = {$this->_aliases['civicrm_contribution']}.honor_contact_id";
609 // include Honor email field
610 if ($this->_emailFieldHonor
) {
612 LEFT JOIN civicrm_email emailhonor
613 ON emailhonor.contact_id = {$this->_aliases['civicrm_contribution']}.honor_contact_id
614 AND emailhonor.is_primary = 1\n";
618 function tempTable($applyLimit = TRUE) {
619 // create temp table with contact ids,contribtuion id,membership id
620 $dropTempTable = 'DROP TABLE IF EXISTS civireport_membership_contribution_detail';
621 CRM_Core_DAO
::executeQuery($dropTempTable);
623 $sql = 'CREATE TEMPORARY TABLE civireport_membership_contribution_detail
624 (contribution_id int, contact_id int, membership_id int, payment_id int) ENGINE=HEAP';
625 CRM_Core_DAO
::executeQuery($sql);
628 INSERT INTO civireport_membership_contribution_detail (contribution_id, contact_id, membership_id)
629 SELECT contribution.id, contact.id, m.id
630 FROM civicrm_contribution contribution
631 INNER JOIN civicrm_contact contact {$this->_aclFrom}
632 ON contact.id = contribution.contact_id AND contribution.is_test = 0
633 LEFT JOIN civicrm_membership_payment mp
634 ON contribution.id = mp.contribution_id
635 LEFT JOIN civicrm_membership m
636 ON mp.membership_id = m.id AND m.is_test = 0 ";
638 CRM_Core_DAO
::executeQuery($fillTemp);
641 function buildQuery($applyLimit = TRUE) {
643 //create temp table to be used as base table
646 $this->customDataFrom();
651 // order_by columns not selected for display need to be included in SELECT
652 $unselectedSectionColumns = $this->unselectedSectionColumns();
653 foreach ($unselectedSectionColumns as $alias => $section) {
654 $this->_select
.= ", {$section['dbAlias']} as {$alias}";
657 if ($applyLimit && !CRM_Utils_Array
::value('charts', $this->_params
)) {
661 $sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy} {$this->_having} {$this->_orderBy} {$this->_limit}";
666 $this->_groupBy
= " GROUP BY {$this->_aliases['civicrm_contact']}.id, {$this->_aliases['civicrm_contribution']}.id ";
670 $this->_orderBy
= " ORDER BY {$this->_aliases['civicrm_contact']}.sort_name, {$this->_aliases['civicrm_contact']}.id ";
671 if (CRM_Utils_Array
::value('first_donation_date', $this->_params
['fields'])
672 || CRM_Utils_Array
::value('first_donation_amount', $this->_params
['fields'])) {
673 $this->_orderBy
.= ", {$this->_aliases['civicrm_contribution']}.receive_date";
677 function statistics(&$rows) {
678 $statistics = parent
::statistics($rows);
680 $select = " SELECT COUNT({$this->_aliases['civicrm_contribution']}.total_amount ) as count, SUM( {$this->_aliases['civicrm_contribution']}.total_amount ) as amount, ROUND(AVG({$this->_aliases['civicrm_contribution']}.total_amount), 2) as avg, {$this->_aliases['civicrm_contribution']}.currency as currency ";
682 $group = "\nGROUP BY {$this->_aliases['civicrm_contribution']}.currency";
683 $sql = "{$select} {$this->_from} {$this->_where} {$group}";
685 $dao = CRM_Core_DAO
::executeQuery($sql);
686 while ($dao->fetch()) {
687 $totalAmount[] = CRM_Utils_Money
::format($dao->amount
, $dao->currency
)."(".$dao->count
.")";
688 $average[] = CRM_Utils_Money
::format($dao->avg
, $dao->currency
);
690 $statistics['counts']['amount'] = array(
691 'title' => ts('Total Amount'),
692 'value' => implode(', ', $totalAmount),
693 'type' => CRM_Utils_Type
::T_STRING
,
696 $statistics['counts']['avg'] = array(
697 'title' => ts('Average'),
698 'value' => implode(', ', $average),
699 'type' => CRM_Utils_Type
::T_STRING
,
705 function postProcess() {
706 // get the acl clauses built before we assemble the query
707 $this->buildACLClause($this->_aliases
['civicrm_contact']);
708 parent
::postProcess();
711 function alterDisplay(&$rows) {
712 // custom code to alter rows
713 $checkList = array();
716 $contributionTypes = CRM_Contribute_PseudoConstant
::financialType();
717 $contributionStatus = CRM_Contribute_PseudoConstant
::contributionStatus();
718 $paymentInstruments = CRM_Contribute_PseudoConstant
::paymentInstrument();
719 $honorTypes = CRM_Core_OptionGroup
::values('honor_type', FALSE, FALSE, FALSE, NULL, 'label');
721 //altering the csv display adding additional fields
722 if ($this->_outputMode
== 'csv') {
723 foreach ($this->_columns
as $tableName => $table) {
724 if (array_key_exists('fields', $table)) {
725 foreach ($table['fields'] as $fieldName => $field) {
726 if (CRM_Utils_Array
::value('csv_display', $field) && CRM_Utils_Array
::value('no_display', $field)) {
727 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
728 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
735 // allow repeat for first donation amount and date in csv
738 foreach ($rows as $rowNum => $row) {
739 if ($this->_outputMode
== 'csv') {
740 if (array_key_exists('civicrm_contact_id', $row)) {
741 if ($contactId = $row['civicrm_contact_id']) {
744 $fAmt = $row['first_donation_first_donation_amount'];
745 $fDate = $row['first_donation_first_donation_date'];
748 if ($pcid == $contactId) {
749 $rows[$rowNum]['first_donation_first_donation_amount'] = $fAmt;
750 $rows[$rowNum]['first_donation_first_donation_date'] = $fDate;
754 $fAmt = $row['first_donation_first_donation_amount'];
755 $fDate = $row['first_donation_first_donation_date'];
763 if (!empty($this->_noRepeats
) && $this->_outputMode
!= 'csv') {
764 $repeatFound = FALSE;
767 $display_flag = NULL;
768 if (array_key_exists('civicrm_contact_id', $row)) {
769 if ($cid = $row['civicrm_contact_id']) {
774 if ($prev_cid == $cid) {
785 foreach ($row as $colName => $colVal) {
786 if (in_array($colName, $this->_noRepeats
)) {
787 unset($rows[$rowNum][$colName]);
797 if (array_key_exists('civicrm_membership_membership_type_id', $row)) {
798 if ($value = $row['civicrm_membership_membership_type_id']) {
799 $rows[$rowNum]['civicrm_membership_membership_type_id'] = CRM_Member_PseudoConstant
::membershipType($value, FALSE);
804 if (array_key_exists('civicrm_batch_batch_id', $row)) {
805 if ($value = $row['civicrm_batch_batch_id']) {
806 $rows[$rowNum]['civicrm_batch_batch_id'] = CRM_Core_DAO
::getFieldValue('CRM_Batch_DAO_Batch', $value, 'title');
811 if (array_key_exists('civicrm_address_state_province_id', $row)) {
812 if ($value = $row['civicrm_address_state_province_id']) {
813 $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant
::stateProvince($value, FALSE);
818 if (array_key_exists('civicrm_address_country_id', $row)) {
819 if ($value = $row['civicrm_address_country_id']) {
820 $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant
::country($value, FALSE);
825 // convert donor sort name to link
826 if (array_key_exists('civicrm_contact_sort_name', $row) &&
827 CRM_Utils_Array
::value('civicrm_contact_sort_name', $rows[$rowNum]) &&
828 array_key_exists('civicrm_contact_id', $row)
830 $url = CRM_Utils_System
::url('civicrm/contact/view',
831 'reset=1&cid=' . $row['civicrm_contact_id'],
835 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
836 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts('View Contact Summary for this Contact.');
839 // convert honoree sort name to link
840 if (array_key_exists('civicrm_contact_honor_sort_name_honor', $row) &&
841 CRM_Utils_Array
::value('civicrm_contact_honor_sort_name_honor', $rows[$rowNum]) &&
842 array_key_exists('civicrm_contact_honor_id_honor', $row)
845 $url = CRM_Utils_System
::url('civicrm/contact/view',
846 'reset=1&cid=' . $row['civicrm_contact_honor_id_honor'],
849 $rows[$rowNum]['civicrm_contact_honor_sort_name_honor_link'] = $url;
850 $rows[$rowNum]['civicrm_contact_honor_sort_name_honor_hover'] = ts('View Contact Summary for Honoree.');
853 if ($value = CRM_Utils_Array
::value('civicrm_contribution_financial_type_id', $row)) {
854 $rows[$rowNum]['civicrm_contribution_financial_type_id'] = $contributionTypes[$value];
857 if ($value = CRM_Utils_Array
::value('civicrm_contribution_contribution_status_id', $row)) {
858 $rows[$rowNum]['civicrm_contribution_contribution_status_id'] = $contributionStatus[$value];
861 if ($value = CRM_Utils_Array
::value('civicrm_contribution_payment_instrument_id', $row)) {
862 $rows[$rowNum]['civicrm_contribution_payment_instrument_id'] = $paymentInstruments[$value];
865 if ($value = CRM_Utils_Array
::value('civicrm_contribution_honor_type_id', $row)) {
866 $rows[$rowNum]['civicrm_contribution_honor_type_id'] = $honorTypes[$value];
869 if (($value = CRM_Utils_Array
::value('civicrm_contribution_total_amount_sum', $row)) &&
870 CRM_Core_Permission
::check('access CiviContribute')
872 $url = CRM_Utils_System
::url('civicrm/contact/view/contribution',
873 'reset=1&id=' . $row['civicrm_contribution_contribution_id'] . '&cid=' . $row['civicrm_contact_id'] . '&action=view&context=contribution&selectedChild=contribute',
876 $rows[$rowNum]['civicrm_contribution_total_amount_sum_link'] = $url;
877 $rows[$rowNum]['civicrm_contribution_total_amount_sum_hover'] = ts('View Details of this Contribution.');
881 // convert campaign_id to campaign title
882 if (array_key_exists('civicrm_contribution_campaign_id', $row)) {
883 if ($value = $row['civicrm_contribution_campaign_id']) {
884 $rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->activeCampaigns
[$value];
889 $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'member/contributionDetail', 'List all contribution(s) for this ') ?
TRUE : $entryFound;
891 // skip looking further in rows, if first row itself doesn't
892 // have the column we need