3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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-2014
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');
49 function __construct() {
50 $this->_autoIncludeIndexedFieldsAsOrderBys
= 1;
51 $this->_columns
= array(
54 'dao' => 'CRM_Contact_DAO_Contact',
58 array('title' => ts('Contact Name'),
62 'first_name' => array(
63 'title' => ts('First Name'),
66 'title' => ts('Last Name'),
75 'title' => ts('Contact Type'),
79 'title' => ts('Contact SubType'),
83 'title' => ts('Birth Date'),
89 array('title' => ts('Contact ID'),
93 array('title' => ts('Contact Name'),
97 'title' => ts('Birth Date'),
98 'operatorType' => CRM_Report_Form
::OP_DATE
,
101 'grouping' => 'contact-fields',
105 array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'),
110 'dao' => 'CRM_Core_DAO_Address',
111 'grouping' => 'contact-fields',
114 'street_address' => NULL,
116 'postal_code' => NULL,
117 'state_province_id' =>
118 array('title' => ts('State/Province'),
122 array('state_province_id' => array('title' => 'State/Province'),
123 'city' => array('title' => 'City'),
124 'postal_code' => array('title' => 'Postal Code'),
129 'dao' => 'CRM_Core_DAO_Country',
133 array('title' => 'Country', 'default' => TRUE),
138 array('title' => 'Country'),
140 'grouping' => 'contact-fields',
144 'dao' => 'CRM_Core_DAO_Email',
148 array('title' => ts('Email'),
152 'grouping' => 'contact-fields',
156 array('title' => ts('Email'),
160 'civicrm_contribution' =>
162 'dao' => 'CRM_Contribute_DAO_Contribution',
167 'no_display' => TRUE,
171 array('title' => ts('Contribution'),
175 'total_amount' => array('default' => TRUE),
176 'financial_type_id' => array('title' => ts('Financial Type'),
180 'receive_date' => array('default' => TRUE),
181 'receipt_date' => NULL,
182 'contribution_status_id' => array('title' => ts('Contribution Status'),
185 'contribution_source' => NULL,
188 'civicrm_membership' =>
190 'dao' => 'CRM_Member_DAO_Membership',
195 'no_display' => TRUE,
199 array('title' => ts('Membership'),
203 'membership_type_id' => array('title' => ts('Membership Type'),
207 'membership_start_date' => array('title' => ts('Start Date'),
210 'membership_end_date' => array('title' => ts('End Date'),
213 'membership_status_id' => array(
214 'name' => 'status_id',
215 'title' => ts('Membership Status'),
218 'source' => array('title' => 'Membership Source'),
221 'civicrm_participant' =>
223 'dao' => 'CRM_Event_DAO_Participant',
228 'no_display' => TRUE,
232 array('title' => ts('Participant'),
236 'event_id' => array('default' => TRUE),
237 'participant_status_id' => array(
238 'name' => 'status_id',
239 'title' => ts('Participant Status'),
242 'role_id' => array('title' => ts('Role'),
245 'participant_register_date' => array('title' => ts('Register Date'),
248 'fee_level' => array('title' => ts('Fee Level'),
251 'fee_amount' => array('title' => ts('Fee Amount'),
256 'civicrm_relationship' =>
258 'dao' => 'CRM_Contact_DAO_Relationship',
264 'title' => ts('Relationship'),
268 'relationship_type_id' =>
269 array('title' => ts('Relationship Type'),
273 array('title' => ts('Relationship With'),
278 'title' => 'Start Date ',
279 'type' => CRM_Report_Form
::OP_DATE
,
283 'title' => 'End Date ',
284 'type' => CRM_Report_Form
::OP_DATE
,
288 'civicrm_activity' =>
290 'dao' => 'CRM_Activity_DAO_Activity',
294 array('title' => ts('Activity'),
298 'activity_type_id' =>
299 array('title' => ts('Activity Type'),
303 array('title' => ts('Subject'),
306 'activity_date_time' =>
307 array('title' => ts('Activity Date'),
310 'activity_status_id' =>
312 'name' => 'status_id',
313 'title' => ts('Activity Status'),
317 'grouping' => 'activity-fields',
319 'civicrm_activity_target' =>
321 'dao' => 'CRM_Activity_DAO_ActivityContact',
324 'target_contact_id' =>
325 array('title' => ts('With Contact'),
326 'name' => 'contact_id',
330 'grouping' => 'activity-fields',
332 'civicrm_activity_assignment' =>
334 'dao' => 'CRM_Activity_DAO_ActivityContact',
337 'assignee_contact_id' =>
338 array('title' => ts('Assigned to'),
339 'name' => 'contact_id',
343 'grouping' => 'activity-fields',
345 'civicrm_activity_source' =>
347 'dao' => 'CRM_Activity_DAO_ActivityContact',
350 'source_contact_id' =>
352 'title' => ts('Added By'),
353 'name' => 'contact_id',
357 'grouping' => 'activity-fields',
361 'dao' => 'CRM_Core_DAO_Phone',
367 'title' => ts('Phone Extension')
370 'grouping' => 'contact-fields',
373 $this->_groupFilter
= TRUE;
374 $this->_tagFilter
= TRUE;
375 parent
::__construct();
378 function preProcess() {
379 $this->_csvSupported
= FALSE;
380 parent
::preProcess();
385 $this->_columnHeaders
= array();
386 $this->_component
= array('contribution_civireport', 'membership_civireport', 'participant_civireport', 'relationship_civireport', 'activity_civireport');
387 foreach ($this->_columns
as $tableName => $table) {
388 if (array_key_exists('fields', $table)) {
389 foreach ($table['fields'] as $fieldName => $field) {
390 if (!empty($field['required']) ||
!empty($this->_params
['fields'][$fieldName])) {
391 //isolate the select clause compoenent wise
392 if (in_array($table['alias'], $this->_component
)) {
393 $select[$table['alias']][] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
394 $this->_columnHeadersComponent
[$table['alias']]["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
395 $this->_columnHeadersComponent
[$table['alias']]["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
397 elseif ($table['alias'] == $this->_aliases
['civicrm_activity_target'] ||
398 $table['alias'] == $this->_aliases
['civicrm_activity_assignment'] ||
399 $table['alias'] == $this->_aliases
['civicrm_activity_source']
401 if ($table['alias'] == $this->_aliases
['civicrm_activity_target']) {
402 $addContactId = 'civicrm_activity_target.contact_id as target_contact_id';
404 elseif ($table['alias'] == $this->_aliases
['civicrm_activity_source']) {
405 $addContactId = 'civicrm_activity_source.contact_id';
408 $addContactId = 'civicrm_activity_assignment.contact_id as assignee_contact_id';
411 $tableName = $table['alias'];
412 $select['activity_civireport'][] = "$tableName.display_name as {$tableName}_{$fieldName}, $addContactId ";
413 $this->_columnHeadersComponent
['activity_civireport']["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
414 $this->_columnHeadersComponent
['activity_civireport']["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
417 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
418 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
419 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = $field['title'];
426 foreach ($this->_component
as $val) {
427 if (!empty($select[$val])) {
428 $this->_selectComponent
[$val] = "SELECT " . implode(', ', $select[$val]) . " ";
429 unset($select[$val]);
433 $this->_select
= "SELECT " . implode(', ', $select) . " ";
443 static function formRule($fields, $files, $self) {
451 FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom}";
453 if ($this->isTableSelected('civicrm_country') ||
$this->isTableSelected('civicrm_address')) {
455 LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
456 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND
457 {$this->_aliases['civicrm_address']}.is_primary = 1 ) ";
460 if ($this->isTableSelected('civicrm_email')) {
462 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
463 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
464 {$this->_aliases['civicrm_email']}.is_primary = 1) ";
467 if ($this->isTableSelected('civicrm_phone')) {
469 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
470 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
471 {$this->_aliases['civicrm_phone']}.is_primary = 1 ";
474 if ($this->isTableSelected('civicrm_country')) {
476 LEFT JOIN civicrm_country {$this->_aliases['civicrm_country']}
477 ON {$this->_aliases['civicrm_address']}.country_id = {$this->_aliases['civicrm_country']}.id AND
478 {$this->_aliases['civicrm_address']}.is_primary = 1 ";
481 $this->_from
.= "{$group}";
483 foreach ($this->_component
as $val) {
484 if (!empty($this->_selectComponent
['contribution_civireport'])) {
485 $this->_formComponent
['contribution_civireport'] = " FROM
486 civicrm_contact {$this->_aliases['civicrm_contact']}
487 INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
488 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id
492 if (!empty($this->_selectComponent
['membership_civireport'])) {
493 $this->_formComponent
['membership_civireport'] = " FROM
494 civicrm_contact {$this->_aliases['civicrm_contact']}
495 INNER JOIN civicrm_membership {$this->_aliases['civicrm_membership']}
496 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_membership']}.contact_id
499 if (!empty($this->_selectComponent
['participant_civireport'])) {
500 $this->_formComponent
['participant_civireport'] = " FROM
501 civicrm_contact {$this->_aliases['civicrm_contact']}
502 INNER JOIN civicrm_participant {$this->_aliases['civicrm_participant']}
503 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_participant']}.contact_id
507 if (!empty($this->_selectComponent
['activity_civireport'])) {
508 $activityContacts = CRM_Core_OptionGroup
::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
509 $assigneeID = CRM_Utils_Array
::key('Activity Assignees', $activityContacts);
510 $targetID = CRM_Utils_Array
::key('Activity Targets', $activityContacts);
511 $sourceID = CRM_Utils_Array
::key('Activity Source', $activityContacts);
513 $this->_formComponent
['activity_civireport'] = "FROM
514 civicrm_activity {$this->_aliases['civicrm_activity']}
515 LEFT JOIN civicrm_activity_contact civicrm_activity_target ON
516 {$this->_aliases['civicrm_activity']}.id = civicrm_activity_target.activity_id AND
517 civicrm_activity_target.record_type_id = {$targetID}
518 LEFT JOIN civicrm_activity_contact civicrm_activity_assignment ON
519 {$this->_aliases['civicrm_activity']}.id = civicrm_activity_assignment.activity_id AND civicrm_activity_assignment.record_type_id = {$assigneeID}
520 LEFT JOIN civicrm_activity_contact civicrm_activity_source
521 ON {$this->_aliases['civicrm_activity']}.id = civicrm_activity_source.activity_id AND
522 civicrm_activity_source.record_type_id = {$sourceID}
523 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_target']} ON
524 civicrm_activity_target.contact_id = {$this->_aliases['civicrm_activity_target']}.id
526 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_assignment']} ON
527 civicrm_activity_assignment.contact_id = {$this->_aliases['civicrm_activity_assignment']}.id
528 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_source']} ON
529 civicrm_activity_source.contact_id = {$this->_aliases['civicrm_activity_source']}.id
530 LEFT JOIN civicrm_option_value ON
531 ( {$this->_aliases['civicrm_activity']}.activity_type_id = civicrm_option_value.value )
532 LEFT JOIN civicrm_option_group ON
533 civicrm_option_group.id = civicrm_option_value.option_group_id
534 LEFT JOIN civicrm_case_activity ON
535 civicrm_case_activity.activity_id = {$this->_aliases['civicrm_activity']}.id
536 LEFT JOIN civicrm_case ON
537 civicrm_case_activity.case_id = civicrm_case.id
538 LEFT JOIN civicrm_case_contact ON
539 civicrm_case_contact.case_id = civicrm_case.id ";
542 if (!empty($this->_selectComponent
['relationship_civireport'])) {
543 $this->_formComponent
['relationship_civireport'] = "FROM
544 civicrm_relationship {$this->_aliases['civicrm_relationship']}
546 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']} ON
547 {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_relationship']}.contact_id_b
548 LEFT JOIN civicrm_contact contact_a ON
549 contact_a.id = {$this->_aliases['civicrm_relationship']}.contact_id_a ";
557 foreach ($this->_columns
as $tableName => $table) {
558 if (array_key_exists('filters', $table)) {
559 foreach ($table['filters'] as $fieldName => $field) {
561 if (CRM_Utils_Array
::value('operatorType', $field) & CRM_Report_Form
::OP_DATE
) {
562 $relative = CRM_Utils_Array
::value("{$fieldName}_relative", $this->_params
);
563 $from = CRM_Utils_Array
::value("{$fieldName}_from", $this->_params
);
564 $to = CRM_Utils_Array
::value("{$fieldName}_to", $this->_params
);
566 $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to);
569 $op = CRM_Utils_Array
::value("{$fieldName}_op", $this->_params
);
570 $clause = $this->whereClause($field,
572 CRM_Utils_Array
::value("{$fieldName}_value", $this->_params
),
573 CRM_Utils_Array
::value("{$fieldName}_min", $this->_params
),
574 CRM_Utils_Array
::value("{$fieldName}_max", $this->_params
)
577 if (!empty($clause)) {
578 $clauses[] = $clause;
584 if (empty($clauses)) {
585 $this->_where
= "WHERE ( 1 ) ";
588 $this->_where
= "WHERE " . implode(' AND ', $clauses);
591 if ($this->_aclWhere
) {
592 $this->_where
.= " AND {$this->_aclWhere} ";
595 $this->_where
.= " GROUP BY {$this->_aliases['civicrm_contact']}.id ";
601 function clauseComponent() {
602 $selectedContacts = implode(',', $this->_contactSelected
);
603 $contribution = $membership = $participant = NULL;
604 $eligibleResult = $rows = $tempArray = array();
605 foreach ($this->_component
as $val) {
606 if (!empty($this->_selectComponent
[$val]) && ($val != 'activity_civireport' && $val != 'relationship_civireport')) {
607 $sql = "{$this->_selectComponent[$val]} {$this->_formComponent[$val]}
608 WHERE {$this->_aliases['civicrm_contact']}.id IN ( $selectedContacts )
609 GROUP BY {$this->_aliases['civicrm_contact']}.id,{$val}.id ";
611 $dao = CRM_Core_DAO
::executeQuery($sql);
612 while ($dao->fetch()) {
614 $eligibleResult[$val] = $val;
615 $CC = 'civicrm_' . substr_replace($val, '', -11, 11) . '_contact_id';
617 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
619 $row[$key] = $dao->$key;
622 //if record exist for component(except contact_id)
623 //since contact_id is selected for every component
624 if ($countRecord > 1) {
625 $rows[$dao->$CC][$val][] = $row;
627 $tempArray[$dao->$CC] = $dao->$CC;
632 if (!empty($this->_selectComponent
['relationship_civireport'])) {
634 $relTypes = CRM_Contact_BAO_Relationship
::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE);
636 $val = 'relationship_civireport';
637 $eligibleResult[$val] = $val;
638 $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]}
639 WHERE ({$this->_aliases['civicrm_contact']}.id IN ( $selectedContacts )
641 contact_a.id IN ( $selectedContacts ) ) AND
642 {$this->_aliases['civicrm_relationship']}.is_active = 1 AND
643 contact_a.is_deleted = 0 AND
644 {$this->_aliases['civicrm_contact']}.is_deleted = 0
645 GROUP BY {$this->_aliases['civicrm_relationship']}.id";
647 $dao = CRM_Core_DAO
::executeQuery($sql);
648 while ($dao->fetch()) {
649 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
650 if ($key == 'civicrm_relationship_contact_id_b') {
651 $row[$key] = $dao->contact_b_name
;
655 $row[$key] = $dao->$key;
658 $relTitle = "" . $dao->civicrm_relationship_relationship_type_id
. '_a_b';
659 $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle];
661 $rows[$dao->contact_a_id
][$val][] = $row;
663 $row['civicrm_relationship_contact_id_b'] = $dao->contact_a_name
;
664 $relTitle = "" . $dao->civicrm_relationship_relationship_type_id
. '_b_a';
665 if (isset($relTypes[$relTitle])) {
666 $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle];
668 $rows[$dao->civicrm_relationship_contact_id_b
][$val][] = $row;
672 if (!empty($this->_selectComponent
['activity_civireport'])) {
674 $componentClause = "civicrm_option_value.component_id IS NULL";
675 $componentsIn = NULL;
676 $compInfo = CRM_Core_Component
::getEnabledComponents();
677 foreach ($compInfo as $compObj) {
678 if ($compObj->info
['showActivitiesInCore']) {
679 $componentsIn = $componentsIn ?
($componentsIn . ', ' . $compObj->componentID
) : $compObj->componentID
;
683 $componentClause = "( $componentClause OR
684 civicrm_option_value.component_id IN ($componentsIn) )";
687 $val = 'activity_civireport';
688 $eligibleResult[$val] = $val;
689 $sql = "{$this->_selectComponent[$val]} ,
690 {$this->_aliases['civicrm_activity_source']}.display_name as added_by {$this->_formComponent[$val]}
692 WHERE ( civicrm_activity_source.contact_id IN ($selectedContacts) OR
693 civicrm_activity_target.contact_id IN ($selectedContacts) OR
694 civicrm_activity_assignment.contact_id IN ($selectedContacts) OR
695 civicrm_case_contact.contact_id IN ($selectedContacts) ) AND
696 civicrm_option_group.name = 'activity_type' AND
697 {$this->_aliases['civicrm_activity']}.is_test = 0 AND
700 GROUP BY {$this->_aliases['civicrm_activity']}.id
702 ORDER BY {$this->_aliases['civicrm_activity']}.activity_date_time desc ";
704 $dao = CRM_Core_DAO
::executeQuery($sql);
705 while ($dao->fetch()) {
706 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
707 if ($key == 'civicrm_activity_source_contact_id') {
708 $row[$key] = $dao->added_by
;
711 $row[$key] = $dao->$key;
714 if (isset($dao->civicrm_activity_source_contact_id
)) {
715 $rows[$dao->civicrm_activity_source_contact_id
][$val][] = $row;
717 if (isset($dao->target_contact_id
)) {
718 $rows[$dao->target_contact_id
][$val][] = $row;
720 if (isset($dao->assignee_contact_id
)) {
721 $rows[$dao->assignee_contact_id
][$val][] = $row;
725 //unset the component header if data is not present
726 foreach ($this->_component
as $val) {
727 if (!in_array($val, $eligibleResult)) {
729 unset($this->_columnHeadersComponent
[$val]);
742 function statistics(&$rows) {
743 $statistics = array();
745 $count = count($rows);
746 if ($this->_rollup
&& ($this->_rollup
!= '')) {
750 $this->countStat($statistics, $count);
751 $this->filterStat($statistics);
756 //Override to set limit is 10
758 * @param int $rowCount
760 function limit($rowCount = self
::ROW_COUNT_LIMIT
) {
761 parent
::limit($rowCount);
764 //Override to set pager with limit is 10
766 * @param int $rowCount
768 function setPager($rowCount = self
::ROW_COUNT_LIMIT
) {
769 parent
::setPager($rowCount);
772 function postProcess() {
774 $this->beginPostProcess();
776 // get the acl clauses built before we assemble the query
777 $this->buildACLClause($this->_aliases
['civicrm_contact']);
779 $sql = $this->buildQuery(TRUE);
781 $rows = $graphRows = $this->_contactSelected
= array();
782 $this->buildRows($sql, $rows);
783 foreach ($rows as $key => $val) {
784 $rows[$key]['contactID'] = $val['civicrm_contact_id'];
785 $this->_contactSelected
[] = $val['civicrm_contact_id'];
788 $this->formatDisplay($rows);
790 if (!empty($this->_contactSelected
)) {
791 $componentRows = $this->clauseComponent();
792 $this->alterComponentDisplay($componentRows);
794 //unset Conmponent id and contact id from display
795 foreach ($this->_columnHeadersComponent
as $componentTitle => $headers) {
796 $id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_' . substr_replace($componentTitle, '', -11, 11) . '_id';
797 $contact_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_contact_id';
798 if ($componentTitle == 'activity_civireport') {
799 $id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_id';
802 unset($this->_columnHeadersComponent
[$componentTitle][$id_header]);
803 unset($this->_columnHeadersComponent
[$componentTitle][$contact_header]);
806 $this->assign_by_ref('columnHeadersComponent', $this->_columnHeadersComponent
);
807 $this->assign_by_ref('componentRows', $componentRows);
810 $this->doTemplateAssignment($rows);
811 $this->endPostProcess();
817 function alterDisplay(&$rows) {
818 // custom code to alter rows
822 foreach ($rows as $rowNum => $row) {
823 // make count columns point to detail report
825 // change contact name with link
826 if (array_key_exists('civicrm_contact_sort_name', $row) &&
827 array_key_exists('civicrm_contact_id', $row)
830 $url = CRM_Utils_System
::url('civicrm/contact/view',
831 'reset=1&cid=' . $row['civicrm_contact_id'],
834 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
835 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts('View Contact Summary for this Contact');
839 if (array_key_exists('civicrm_address_state_province_id', $row)) {
840 if ($value = $row['civicrm_address_state_province_id']) {
841 $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant
::stateProvince($value, FALSE);
847 // skip looking further in rows, if first row itself doesn't
848 // have the column we need
856 * @param $componentRows
858 function alterComponentDisplay(&$componentRows) {
859 // custom code to alter rows
860 $activityTypes = CRM_Core_PseudoConstant
::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
861 $activityStatus = CRM_Core_PseudoConstant
::activityStatus();
864 foreach ($componentRows as $contactID => $components) {
865 foreach ($components as $component => $rows) {
866 foreach ($rows as $rowNum => $row) {
867 // handle contribution
868 if ($component == 'contribution_civireport') {
869 if ($val = CRM_Utils_Array
::value('civicrm_contribution_financial_type_id', $row)) {
870 $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_financial_type_id'] =
871 CRM_Contribute_PseudoConstant
::financialType($val, false);
874 if ($val = CRM_Utils_Array
::value('civicrm_contribution_contribution_status_id', $row)) {
875 $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_contribution_status_id'] = CRM_Contribute_PseudoConstant
::contributionStatus($val);
880 if ($component == 'membership_civireport') {
881 if ($val = CRM_Utils_Array
::value('civicrm_membership_membership_type_id', $row)) {
882 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_type_id'] = CRM_Member_PseudoConstant
::membershipType($val, FALSE);
885 if ($val = CRM_Utils_Array
::value('civicrm_membership_status_id', $row)) {
886 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_status_id'] = CRM_Member_PseudoConstant
::membershipStatus($val, FALSE);
891 if ($component == 'participant_civireport') {
892 if ($val = CRM_Utils_Array
::value('civicrm_participant_event_id', $row)) {
893 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant
::event($val, FALSE);
894 $url = CRM_Report_Utils_Report
::getNextUrl('event/income',
895 'reset=1&force=1&id_op=in&id_value=' . $val,
896 $this->_absoluteUrl
, $this->_id
898 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_link'] = $url;
899 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_hover'] = ts('View Event Income details for this Event.');
903 if ($val = CRM_Utils_Array
::value('civicrm_participant_participant_status_id', $row)) {
904 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_participant_status_id'] = CRM_Event_PseudoConstant
::participantStatus($val, FALSE);
906 if ($val = CRM_Utils_Array
::value('civicrm_participant_role_id', $row)) {
907 $roles = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $val);
909 foreach ($roles as $role) {
910 $value[$role] = CRM_Event_PseudoConstant
::participantRole($role, FALSE);
912 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_role_id'] = implode(', ', $value);
918 if ($component == 'activity_civireport') {
919 if ($val = CRM_Utils_Array
::value('civicrm_activity_activity_type_id', $row)) {
920 $componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_type_id'] = $activityTypes[$val];
922 if ($val = CRM_Utils_Array
::value('civicrm_activity_activity_status_id', $row)) {
923 $componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_status_id'] = $activityStatus[$val];
928 if ($component == 'membership_civireport') {
929 if ($val = CRM_Utils_Array
::value('civicrm_membership_membership_status_id', $row)) {
930 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_status_id'] = CRM_Member_PseudoConstant
::membershipStatus($val);
935 // skip looking further in rows, if first row itself doesn't
936 // have the column we need