3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
35 class CRM_Report_Form_Contact_Detail
extends CRM_Report_Form
{
36 CONST ROW_COUNT_LIMIT
= 10;
38 protected $_summary = NULL;
40 protected $_customGroupExtends = array(
41 'Contact', 'Individual', 'Household', 'Organization');
43 function __construct() {
44 $this->_autoIncludeIndexedFieldsAsOrderBys
= 1;
45 $this->_columns
= array(
48 'dao' => 'CRM_Contact_DAO_Contact',
52 array('title' => ts('Contact Name'),
56 'first_name' => array('title' => ts('First Name'),
58 'last_name' => array('title' => ts('Last Name'),
69 array('title' => ts('Contact ID'),
73 array('title' => ts('Contact Name'),
76 'grouping' => 'contact-fields',
80 array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'),
85 'dao' => 'CRM_Core_DAO_Address',
86 'grouping' => 'contact-fields',
89 'street_address' => NULL,
91 'postal_code' => NULL,
92 'state_province_id' =>
93 array('title' => ts('State/Province'),
97 array('state_province_id' => array('title' => 'State/Province'),
98 'city' => array('title' => 'City'),
99 'postal_code' => array('title' => 'Postal Code'),
104 'dao' => 'CRM_Core_DAO_Country',
108 array('title' => 'Country', 'default' => TRUE),
113 array('title' => 'Country'),
115 'grouping' => 'contact-fields',
119 'dao' => 'CRM_Core_DAO_Email',
123 array('title' => ts('Email'),
127 'grouping' => 'contact-fields',
131 array('title' => ts('Email'),
135 'civicrm_contribution' =>
137 'dao' => 'CRM_Contribute_DAO_Contribution',
142 'no_display' => TRUE,
146 array('title' => ts('Contribution'),
150 'total_amount' => array('default' => TRUE),
151 'financial_type_id' => array('title' => ts('Financial Type'),
155 'receive_date' => array('default' => TRUE),
156 'receipt_date' => NULL,
157 'contribution_status_id' => array('title' => ts('Contribution Status'),
160 'contribution_source' => NULL,
163 'civicrm_membership' =>
165 'dao' => 'CRM_Member_DAO_Membership',
170 'no_display' => TRUE,
174 array('title' => ts('Membership'),
178 'membership_type_id' => array('title' => ts('Membership Type'),
182 'membership_start_date' => array('title' => ts('Start Date'),
185 'membership_end_date' => array('title' => ts('End Date'),
188 'membership_status_id' => array(
189 'name' => 'status_id',
190 'title' => ts('Membership Status'),
193 'source' => array('title' => 'Membership Source'),
196 'civicrm_participant' =>
198 'dao' => 'CRM_Event_DAO_Participant',
203 'no_display' => TRUE,
207 array('title' => ts('Participant'),
211 'event_id' => array('default' => TRUE),
212 'participant_status_id' => array(
213 'name' => 'status_id',
214 'title' => ts('Participant Status'),
217 'role_id' => array('title' => ts('Role'),
220 'participant_register_date' => array('title' => ts('Register Date'),
223 'fee_level' => array('title' => ts('Fee Level'),
226 'fee_amount' => array('title' => ts('Fee Amount'),
231 'civicrm_relationship' =>
233 'dao' => 'CRM_Contact_DAO_Relationship',
239 'title' => ts('Relationship'),
243 'relationship_type_id' =>
244 array('title' => ts('Relationship Type'),
248 array('title' => ts('Relationship With'),
253 'title' => 'Start Date ',
254 'type' => CRM_Report_Form
::OP_DATE
,
258 'title' => 'End Date ',
259 'type' => CRM_Report_Form
::OP_DATE
,
263 'civicrm_activity' =>
265 'dao' => 'CRM_Activity_DAO_Activity',
269 array('title' => ts('Activity'),
273 'activity_type_id' =>
274 array('title' => ts('Activity Type'),
278 array('title' => ts('Subject'),
281 'source_contact_id' =>
282 array('title' => ts('Added By'),
285 'activity_date_time' =>
286 array('title' => ts('Activity Date'),
289 'activity_status_id' =>
291 'name' => 'status_id',
292 'title' => ts('Activity Status'),
296 'grouping' => 'activity-fields',
298 'civicrm_activity_target' =>
300 'dao' => 'CRM_Activity_DAO_ActivityContact',
304 array('title' => ts('With Contact'),
308 'grouping' => 'activity-fields',
310 'civicrm_activity_assignment' =>
312 'dao' => 'CRM_Activity_DAO_ActivityContact',
316 array('title' => ts('Assigned To'),
320 'grouping' => 'activity-fields',
324 'dao' => 'CRM_Contact_DAO_Group',
330 'name' => 'group_id',
331 'title' => ts('Group'),
332 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
334 'options' => CRM_Core_PseudoConstant
::group(),
340 'dao' => 'CRM_Core_DAO_Phone',
342 array('phone' => NULL),
343 'grouping' => 'contact-fields',
347 $this->_tagFilter
= TRUE;
348 parent
::__construct();
351 function preProcess() {
352 $this->_csvSupported
= FALSE;
353 parent
::preProcess();
358 $this->_columnHeaders
= array();
359 $this->_component
= array('contribution_civireport', 'membership_civireport', 'participant_civireport', 'relationship_civireport', 'activity_civireport');
360 foreach ($this->_columns
as $tableName => $table) {
361 if (array_key_exists('fields', $table)) {
362 foreach ($table['fields'] as $fieldName => $field) {
363 if (CRM_Utils_Array
::value('required', $field) ||
364 CRM_Utils_Array
::value($fieldName, $this->_params
['fields'])
366 //isolate the select clause compoenent wise
367 if (in_array($table['alias'], $this->_component
)) {
368 $select[$table['alias']][] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
369 $this->_columnHeadersComponent
[$table['alias']]["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
370 $this->_columnHeadersComponent
[$table['alias']]["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
372 elseif ($table['alias'] == $this->_aliases
['civicrm_activity_target'] ||
373 $table['alias'] == $this->_aliases
['civicrm_activity_assignment']
375 if ($table['alias'] == $this->_aliases
['civicrm_activity_target']) {
376 $addContactId = 'civicrm_activity_target.contact_id';
379 $addContactId = 'civicrm_activity_assignment.contact_id';
382 $tableName = $table['alias'];
383 $select['activity_civireport'][] = "$tableName.display_name as {$tableName}_{$fieldName}, $addContactId ";
384 $this->_columnHeadersComponent
['activity_civireport']["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
385 $this->_columnHeadersComponent
['activity_civireport']["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
388 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
389 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
390 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = $field['title'];
397 foreach ($this->_component
as $val) {
398 if (CRM_Utils_Array
::value($val, $select)) {
399 $this->_selectComponent
[$val] = "SELECT " . implode(', ', $select[$val]) . " ";
400 unset($select[$val]);
404 $this->_select
= "SELECT " . implode(', ', $select) . " ";
407 static function formRule($fields, $files, $self) {
415 FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom}";
417 if ($this->isTableSelected('civicrm_country') ||
$this->isTableSelected('civicrm_address')) {
419 LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
420 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND
421 {$this->_aliases['civicrm_address']}.is_primary = 1 ) ";
424 if ($this->isTableSelected('civicrm_email')) {
426 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
427 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
428 {$this->_aliases['civicrm_email']}.is_primary = 1) ";
431 if ($this->isTableSelected('civicrm_phone')) {
433 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
434 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
435 {$this->_aliases['civicrm_phone']}.is_primary = 1 ";
438 if ($this->isTableSelected('civicrm_country')) {
440 LEFT JOIN civicrm_country {$this->_aliases['civicrm_country']}
441 ON {$this->_aliases['civicrm_address']}.country_id = {$this->_aliases['civicrm_country']}.id AND
442 {$this->_aliases['civicrm_address']}.is_primary = 1 ";
445 $this->_from
.= "{$group}";
447 foreach ($this->_component
as $val) {
448 if (CRM_Utils_Array
::value('contribution_civireport', $this->_selectComponent
)) {
449 $this->_formComponent
['contribution_civireport'] = " FROM
450 civicrm_contact {$this->_aliases['civicrm_contact']}
451 INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
452 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id
456 if (CRM_Utils_Array
::value('membership_civireport', $this->_selectComponent
)) {
457 $this->_formComponent
['membership_civireport'] = " FROM
458 civicrm_contact {$this->_aliases['civicrm_contact']}
459 INNER JOIN civicrm_membership {$this->_aliases['civicrm_membership']}
460 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_membership']}.contact_id
463 if (CRM_Utils_Array
::value('participant_civireport', $this->_selectComponent
)) {
464 $this->_formComponent
['participant_civireport'] = " FROM
465 civicrm_contact {$this->_aliases['civicrm_contact']}
466 INNER JOIN civicrm_participant {$this->_aliases['civicrm_participant']}
467 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_participant']}.contact_id
471 if (CRM_Utils_Array
::value('activity_civireport', $this->_selectComponent
)) {
472 $activityContacts = CRM_Core_OptionGroup
::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
473 $assigneeID = CRM_Utils_Array
::key('Activity Assignees', $activityContacts);
474 $targetID = CRM_Utils_Array
::key('Activity Targets', $activityContacts);
476 $this->_formComponent
['activity_civireport'] = "FROM
477 civicrm_activity {$this->_aliases['civicrm_activity']}
478 LEFT JOIN civicrm_activity_contact civicrm_activity_target ON
479 {$this->_aliases['civicrm_activity']}.id = civicrm_activity_target.activity_id AND
480 civicrm_activity_target.record_type_id = {$targetID}
481 LEFT JOIN civicrm_activity_contact civicrm_activity_assignment ON
482 {$this->_aliases['civicrm_activity']}.id = civicrm_activity_assignment.activity_id AND civicrm_activity_assignment.record_type_id = {$assigneeID}
483 LEFT JOIN civicrm_contact sourceContact ON
484 {$this->_aliases['civicrm_activity']}.source_contact_id = sourceContact.id
485 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_target']} ON
486 civicrm_activity_target.contact_id = {$this->_aliases['civicrm_activity_target']}.id
488 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_assignment']} ON
489 civicrm_activity_assignment.contact_id = {$this->_aliases['civicrm_activity_assignment']}.id
490 LEFT JOIN civicrm_option_value ON
491 ( {$this->_aliases['civicrm_activity']}.activity_type_id = civicrm_option_value.value )
492 LEFT JOIN civicrm_option_group ON
493 civicrm_option_group.id = civicrm_option_value.option_group_id
494 LEFT JOIN civicrm_case_activity ON
495 civicrm_case_activity.activity_id = {$this->_aliases['civicrm_activity']}.id
496 LEFT JOIN civicrm_case ON
497 civicrm_case_activity.case_id = civicrm_case.id
498 LEFT JOIN civicrm_case_contact ON
499 civicrm_case_contact.case_id = civicrm_case.id ";
502 if (CRM_Utils_Array
::value('relationship_civireport', $this->_selectComponent
)) {
503 $this->_formComponent
['relationship_civireport'] = "FROM
504 civicrm_relationship {$this->_aliases['civicrm_relationship']}
506 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']} ON
507 {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_relationship']}.contact_id_b
508 LEFT JOIN civicrm_contact contact_a ON
509 contact_a.id = {$this->_aliases['civicrm_relationship']}.contact_id_a ";
517 foreach ($this->_columns
as $tableName => $table) {
518 if (array_key_exists('filters', $table)) {
519 foreach ($table['filters'] as $fieldName => $field) {
521 $op = CRM_Utils_Array
::value("{$fieldName}_op", $this->_params
);
523 $clause = $this->whereClause($field,
525 CRM_Utils_Array
::value("{$fieldName}_value", $this->_params
),
526 CRM_Utils_Array
::value("{$fieldName}_min", $this->_params
),
527 CRM_Utils_Array
::value("{$fieldName}_max", $this->_params
)
530 if (!empty($clause)) {
531 $clauses[] = $clause;
537 if (empty($clauses)) {
538 $this->_where
= "WHERE ( 1 ) ";
541 $this->_where
= "WHERE " . implode(' AND ', $clauses);
544 if ($this->_aclWhere
) {
545 $this->_where
.= " AND {$this->_aclWhere} ";
548 $this->_where
.= " GROUP BY {$this->_aliases['civicrm_contact']}.id ";
551 function clauseComponent() {
552 $selectedContacts = implode(',', $this->_contactSelected
);
553 $contribution = $membership = $participant = NULL;
554 $eligibleResult = $rows = $tempArray = array();
555 foreach ($this->_component
as $val) {
556 if (CRM_Utils_Array
::value($val, $this->_selectComponent
) && ($val != 'activity_civireport' && $val != 'relationship_civireport')) {
557 $sql = "{$this->_selectComponent[$val]} {$this->_formComponent[$val]}
558 WHERE {$this->_aliases['civicrm_contact']}.id IN ( $selectedContacts )
559 GROUP BY {$this->_aliases['civicrm_contact']}.id,{$val}.id ";
561 $dao = CRM_Core_DAO
::executeQuery($sql);
562 while ($dao->fetch()) {
564 $eligibleResult[$val] = $val;
565 $CC = 'civicrm_' . substr_replace($val, '', -11, 11) . '_contact_id';
567 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
569 $row[$key] = $dao->$key;
572 //if record exist for component(except contact_id)
573 //since contact_id is selected for every component
574 if ($countRecord > 1) {
575 $rows[$dao->$CC][$val][] = $row;
577 $tempArray[$dao->$CC] = $dao->$CC;
582 if (CRM_Utils_Array
::value('relationship_civireport', $this->_selectComponent
)) {
584 $relTypes = CRM_Contact_BAO_Relationship
::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE);
586 $val = 'relationship_civireport';
587 $eligibleResult[$val] = $val;
588 $sql = "{$this->_selectComponent[$val]},{$this->_aliases['civicrm_contact']}.display_name as contact_b_name, contact_a.id as contact_a_id , contact_a.display_name as contact_a_name {$this->_formComponent[$val]}
589 WHERE ({$this->_aliases['civicrm_contact']}.id IN ( $selectedContacts )
591 contact_a.id IN ( $selectedContacts ) ) AND
592 {$this->_aliases['civicrm_relationship']}.is_active = 1 AND
593 contact_a.is_deleted = 0 AND
594 {$this->_aliases['civicrm_contact']}.is_deleted = 0
595 GROUP BY {$this->_aliases['civicrm_relationship']}.id";
597 $dao = CRM_Core_DAO
::executeQuery($sql);
598 while ($dao->fetch()) {
599 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
600 if ($key == 'civicrm_relationship_contact_id_b') {
601 $row[$key] = $dao->contact_b_name
;
605 $row[$key] = $dao->$key;
608 $relTitle = "" . $dao->civicrm_relationship_relationship_type_id
. '_a_b';
609 $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle];
611 $rows[$dao->contact_a_id
][$val][] = $row;
613 $row['civicrm_relationship_contact_id_b'] = $dao->contact_a_name
;
614 $relTitle = "" . $dao->civicrm_relationship_relationship_type_id
. '_b_a';
615 if (isset($relTypes[$relTitle])) {
616 $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle];
618 $rows[$dao->civicrm_relationship_contact_id_b
][$val][] = $row;
622 if (CRM_Utils_Array
::value('activity_civireport', $this->_selectComponent
)) {
624 $componentClause = "civicrm_option_value.component_id IS NULL";
625 $componentsIn = NULL;
626 $compInfo = CRM_Core_Component
::getEnabledComponents();
627 foreach ($compInfo as $compObj) {
628 if ($compObj->info
['showActivitiesInCore']) {
629 $componentsIn = $componentsIn ?
($componentsIn . ', ' . $compObj->componentID
) : $compObj->componentID
;
633 $componentClause = "( $componentClause OR
634 civicrm_option_value.component_id IN ($componentsIn) )";
637 $val = 'activity_civireport';
638 $eligibleResult[$val] = $val;
639 $sql = "{$this->_selectComponent[$val]} ,
640 sourceContact.display_name as added_by {$this->_formComponent[$val]}
642 WHERE ( {$this->_aliases['civicrm_activity']}.source_contact_id IN ($selectedContacts) OR
643 civicrm_activity_target.contact_id IN ($selectedContacts) OR
644 civicrm_activity_assignment.contact_id IN ($selectedContacts) OR
645 civicrm_case_contact.contact_id IN ($selectedContacts) ) AND
646 civicrm_option_group.name = 'activity_type' AND
647 {$this->_aliases['civicrm_activity']}.is_test = 0 AND
650 GROUP BY {$this->_aliases['civicrm_activity']}.id
652 ORDER BY {$this->_aliases['civicrm_activity']}.activity_date_time desc ";
654 $dao = CRM_Core_DAO
::executeQuery($sql);
655 while ($dao->fetch()) {
656 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
657 if ($key == 'civicrm_activity_source_contact_id') {
658 $row[$key] = $dao->added_by
;
661 $row[$key] = $dao->$key;
664 if (isset($dao->civicrm_activity_source_contact_id
)) {
665 $rows[$dao->civicrm_activity_source_contact_id
][$val][] = $row;
667 if (isset($dao->target_contact_id
)) {
668 $rows[$dao->target_contact_id
][$val][] = $row;
670 if (isset($dao->assignee_contact_id
)) {
671 $rows[$dao->assignee_contact_id
][$val][] = $row;
675 //unset the component header if data is not present
676 foreach ($this->_component
as $val) {
677 if (!in_array($val, $eligibleResult)) {
679 unset($this->_columnHeadersComponent
[$val]);
687 function statistics(&$rows) {
688 $statistics = array();
690 $count = count($rows);
691 if ($this->_rollup
&& ($this->_rollup
!= '')) {
695 $this->countStat($statistics, $count);
696 $this->filterStat($statistics);
701 //Override to set limit is 10
702 function limit($rowCount = self
::ROW_COUNT_LIMIT
) {
703 parent
::limit($rowCount);
706 //Override to set pager with limit is 10
707 function setPager($rowCount = self
::ROW_COUNT_LIMIT
) {
708 parent
::setPager($rowCount);
711 function postProcess() {
713 $this->beginPostProcess();
715 // get the acl clauses built before we assemble the query
716 $this->buildACLClause($this->_aliases
['civicrm_contact']);
718 $sql = $this->buildQuery(TRUE);
720 $rows = $graphRows = $this->_contactSelected
= array();
721 $this->buildRows($sql, $rows);
722 foreach ($rows as $key => $val) {
723 $rows[$key]['contactID'] = $val['civicrm_contact_id'];
724 $this->_contactSelected
[] = $val['civicrm_contact_id'];
727 $this->formatDisplay($rows);
729 if (!empty($this->_contactSelected
)) {
730 $componentRows = $this->clauseComponent();
731 $this->alterComponentDisplay($componentRows);
733 //unset Conmponent id and contact id from display
734 foreach ($this->_columnHeadersComponent
as $componentTitle => $headers) {
735 $id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_' . substr_replace($componentTitle, '', -11, 11) . '_id';
736 $contact_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_contact_id';
737 if ($componentTitle == 'activity_civireport') {
738 $id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_id';
741 unset($this->_columnHeadersComponent
[$componentTitle][$id_header]);
742 unset($this->_columnHeadersComponent
[$componentTitle][$contact_header]);
745 $this->assign_by_ref('columnHeadersComponent', $this->_columnHeadersComponent
);
746 $this->assign_by_ref('componentRows', $componentRows);
749 $this->doTemplateAssignment($rows);
750 $this->endPostProcess();
753 function alterDisplay(&$rows) {
754 // custom code to alter rows
758 foreach ($rows as $rowNum => $row) {
759 // make count columns point to detail report
761 // change contact name with link
762 if (array_key_exists('civicrm_contact_sort_name', $row) &&
763 array_key_exists('civicrm_contact_id', $row)
766 $url = CRM_Utils_System
::url('civicrm/contact/view',
767 'reset=1&cid=' . $row['civicrm_contact_id'],
770 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
771 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts('View Contact Summary for this Contact');
775 if (array_key_exists('civicrm_address_state_province_id', $row)) {
776 if ($value = $row['civicrm_address_state_province_id']) {
777 $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant
::stateProvince($value, FALSE);
783 // skip looking further in rows, if first row itself doesn't
784 // have the column we need
791 function alterComponentDisplay(&$componentRows) {
792 // custom code to alter rows
793 $activityTypes = CRM_Core_PseudoConstant
::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
794 $activityStatus = CRM_Core_PseudoConstant
::activityStatus();
797 foreach ($componentRows as $contactID => $components) {
798 foreach ($components as $component => $rows) {
799 foreach ($rows as $rowNum => $row) {
800 // handle contribution
801 if ($component == 'contribution_civireport') {
802 if ($val = CRM_Utils_Array
::value('civicrm_contribution_financial_type_id', $row)) {
803 $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_financial_type_id'] =
804 CRM_Contribute_PseudoConstant
::financialType($val, false);
807 if ($val = CRM_Utils_Array
::value('civicrm_contribution_contribution_status_id', $row)) {
808 $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_contribution_status_id'] = CRM_Contribute_PseudoConstant
::contributionStatus($val);
813 if ($component == 'membership_civireport') {
814 if ($val = CRM_Utils_Array
::value('civicrm_membership_membership_type_id', $row)) {
815 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_type_id'] = CRM_Member_PseudoConstant
::membershipType($val, FALSE);
818 if ($val = CRM_Utils_Array
::value('civicrm_membership_status_id', $row)) {
819 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_status_id'] = CRM_Member_PseudoConstant
::membershipStatus($val, FALSE);
824 if ($component == 'participant_civireport') {
825 if ($val = CRM_Utils_Array
::value('civicrm_participant_event_id', $row)) {
826 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant
::event($val, FALSE);
827 $url = CRM_Report_Utils_Report
::getNextUrl('event/income',
828 'reset=1&force=1&id_op=in&id_value=' . $val,
829 $this->_absoluteUrl
, $this->_id
831 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_link'] = $url;
832 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_hover'] = ts('View Event Income details for this Event.');
836 if ($val = CRM_Utils_Array
::value('civicrm_participant_participant_status_id', $row)) {
837 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_participant_status_id'] = CRM_Event_PseudoConstant
::participantStatus($val, FALSE);
839 if ($val = CRM_Utils_Array
::value('civicrm_participant_role_id', $row)) {
840 $roles = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $val);
842 foreach ($roles as $role) {
843 $value[$role] = CRM_Event_PseudoConstant
::participantRole($role, FALSE);
845 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_role_id'] = implode(', ', $value);
851 if ($component == 'activity_civireport') {
852 if ($val = CRM_Utils_Array
::value('civicrm_activity_activity_type_id', $row)) {
853 $componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_type_id'] = $activityTypes[$val];
855 if ($val = CRM_Utils_Array
::value('civicrm_activity_activity_status_id', $row)) {
856 $componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_status_id'] = $activityStatus[$val];
861 if ($component == 'membership_civireport') {
862 if ($val = CRM_Utils_Array
::value('civicrm_membership_membership_status_id', $row)) {
863 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_status_id'] = CRM_Member_PseudoConstant
::membershipStatus($val);
868 // skip looking further in rows, if first row itself doesn't
869 // have the column we need