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 'activity_date_time' =>
282 array('title' => ts('Activity Date'),
285 'activity_status_id' =>
287 'name' => 'status_id',
288 'title' => ts('Activity Status'),
292 'grouping' => 'activity-fields',
294 'civicrm_activity_target' =>
296 'dao' => 'CRM_Activity_DAO_ActivityContact',
299 'target_contact_id' =>
300 array('title' => ts('With Contact'),
301 'name' => 'contact_id',
305 'grouping' => 'activity-fields',
307 'civicrm_activity_assignment' =>
309 'dao' => 'CRM_Activity_DAO_ActivityContact',
312 'assignee_contact_id' =>
313 array('title' => ts('Assigned To'),
314 'name' => 'contact_id',
318 'grouping' => 'activity-fields',
320 'civicrm_activity_source' =>
322 'dao' => 'CRM_Activity_DAO_ActivityContact',
325 'source_contact_id' =>
327 'title' => ts('Added By'),
328 'name' => 'contact_id',
332 'grouping' => 'activity-fields',
336 'dao' => 'CRM_Contact_DAO_Group',
342 'name' => 'group_id',
343 'title' => ts('Group'),
344 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
346 'options' => CRM_Core_PseudoConstant
::group(),
352 'dao' => 'CRM_Core_DAO_Phone',
354 array('phone' => NULL),
355 'grouping' => 'contact-fields',
359 $this->_tagFilter
= TRUE;
360 parent
::__construct();
363 function preProcess() {
364 $this->_csvSupported
= FALSE;
365 parent
::preProcess();
370 $this->_columnHeaders
= array();
371 $this->_component
= array('contribution_civireport', 'membership_civireport', 'participant_civireport', 'relationship_civireport', 'activity_civireport');
372 foreach ($this->_columns
as $tableName => $table) {
373 if (array_key_exists('fields', $table)) {
374 foreach ($table['fields'] as $fieldName => $field) {
375 if (CRM_Utils_Array
::value('required', $field) ||
376 CRM_Utils_Array
::value($fieldName, $this->_params
['fields'])
378 //isolate the select clause compoenent wise
379 if (in_array($table['alias'], $this->_component
)) {
380 $select[$table['alias']][] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
381 $this->_columnHeadersComponent
[$table['alias']]["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
382 $this->_columnHeadersComponent
[$table['alias']]["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
384 elseif ($table['alias'] == $this->_aliases
['civicrm_activity_target'] ||
385 $table['alias'] == $this->_aliases
['civicrm_activity_assignment'] ||
386 $table['alias'] == $this->_aliases
['civicrm_activity_source']
388 if ($table['alias'] == $this->_aliases
['civicrm_activity_target']) {
389 $addContactId = 'civicrm_activity_target.contact_id as target_contact_id';
391 elseif ($table['alias'] == $this->_aliases
['civicrm_activity_source']) {
392 $addContactId = 'civicrm_activity_source.contact_id';
395 $addContactId = 'civicrm_activity_assignment.contact_id as assignee_contact_id';
398 $tableName = $table['alias'];
399 $select['activity_civireport'][] = "$tableName.display_name as {$tableName}_{$fieldName}, $addContactId ";
400 $this->_columnHeadersComponent
['activity_civireport']["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
401 $this->_columnHeadersComponent
['activity_civireport']["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
404 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
405 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
406 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = $field['title'];
413 foreach ($this->_component
as $val) {
414 if (CRM_Utils_Array
::value($val, $select)) {
415 $this->_selectComponent
[$val] = "SELECT " . implode(', ', $select[$val]) . " ";
416 unset($select[$val]);
420 $this->_select
= "SELECT " . implode(', ', $select) . " ";
423 static function formRule($fields, $files, $self) {
431 FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom}";
433 if ($this->isTableSelected('civicrm_country') ||
$this->isTableSelected('civicrm_address')) {
435 LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
436 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND
437 {$this->_aliases['civicrm_address']}.is_primary = 1 ) ";
440 if ($this->isTableSelected('civicrm_email')) {
442 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
443 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
444 {$this->_aliases['civicrm_email']}.is_primary = 1) ";
447 if ($this->isTableSelected('civicrm_phone')) {
449 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
450 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
451 {$this->_aliases['civicrm_phone']}.is_primary = 1 ";
454 if ($this->isTableSelected('civicrm_country')) {
456 LEFT JOIN civicrm_country {$this->_aliases['civicrm_country']}
457 ON {$this->_aliases['civicrm_address']}.country_id = {$this->_aliases['civicrm_country']}.id AND
458 {$this->_aliases['civicrm_address']}.is_primary = 1 ";
461 $this->_from
.= "{$group}";
463 foreach ($this->_component
as $val) {
464 if (CRM_Utils_Array
::value('contribution_civireport', $this->_selectComponent
)) {
465 $this->_formComponent
['contribution_civireport'] = " FROM
466 civicrm_contact {$this->_aliases['civicrm_contact']}
467 INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
468 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id
472 if (CRM_Utils_Array
::value('membership_civireport', $this->_selectComponent
)) {
473 $this->_formComponent
['membership_civireport'] = " FROM
474 civicrm_contact {$this->_aliases['civicrm_contact']}
475 INNER JOIN civicrm_membership {$this->_aliases['civicrm_membership']}
476 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_membership']}.contact_id
479 if (CRM_Utils_Array
::value('participant_civireport', $this->_selectComponent
)) {
480 $this->_formComponent
['participant_civireport'] = " FROM
481 civicrm_contact {$this->_aliases['civicrm_contact']}
482 INNER JOIN civicrm_participant {$this->_aliases['civicrm_participant']}
483 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_participant']}.contact_id
487 if (CRM_Utils_Array
::value('activity_civireport', $this->_selectComponent
)) {
488 $activityContacts = CRM_Core_OptionGroup
::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
489 $assigneeID = CRM_Utils_Array
::key('Activity Assignees', $activityContacts);
490 $targetID = CRM_Utils_Array
::key('Activity Targets', $activityContacts);
491 $sourceID = CRM_Utils_Array
::key('Activity Source', $activityContacts);
493 $this->_formComponent
['activity_civireport'] = "FROM
494 civicrm_activity {$this->_aliases['civicrm_activity']}
495 LEFT JOIN civicrm_activity_contact civicrm_activity_target ON
496 {$this->_aliases['civicrm_activity']}.id = civicrm_activity_target.activity_id AND
497 civicrm_activity_target.record_type_id = {$targetID}
498 LEFT JOIN civicrm_activity_contact civicrm_activity_assignment ON
499 {$this->_aliases['civicrm_activity']}.id = civicrm_activity_assignment.activity_id AND civicrm_activity_assignment.record_type_id = {$assigneeID}
500 LEFT JOIN civicrm_activity_contact civicrm_activity_source
501 ON {$this->_aliases['civicrm_activity']}.id = civicrm_activity_source.activity_id AND
502 civicrm_activity_source.record_type_id = {$sourceID}
503 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_target']} ON
504 civicrm_activity_target.contact_id = {$this->_aliases['civicrm_activity_target']}.id
506 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_assignment']} ON
507 civicrm_activity_assignment.contact_id = {$this->_aliases['civicrm_activity_assignment']}.id
508 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_source']} ON
509 civicrm_activity_source.contact_id = {$this->_aliases['civicrm_activity_source']}.id
510 LEFT JOIN civicrm_option_value ON
511 ( {$this->_aliases['civicrm_activity']}.activity_type_id = civicrm_option_value.value )
512 LEFT JOIN civicrm_option_group ON
513 civicrm_option_group.id = civicrm_option_value.option_group_id
514 LEFT JOIN civicrm_case_activity ON
515 civicrm_case_activity.activity_id = {$this->_aliases['civicrm_activity']}.id
516 LEFT JOIN civicrm_case ON
517 civicrm_case_activity.case_id = civicrm_case.id
518 LEFT JOIN civicrm_case_contact ON
519 civicrm_case_contact.case_id = civicrm_case.id ";
522 if (CRM_Utils_Array
::value('relationship_civireport', $this->_selectComponent
)) {
523 $this->_formComponent
['relationship_civireport'] = "FROM
524 civicrm_relationship {$this->_aliases['civicrm_relationship']}
526 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']} ON
527 {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_relationship']}.contact_id_b
528 LEFT JOIN civicrm_contact contact_a ON
529 contact_a.id = {$this->_aliases['civicrm_relationship']}.contact_id_a ";
537 foreach ($this->_columns
as $tableName => $table) {
538 if (array_key_exists('filters', $table)) {
539 foreach ($table['filters'] as $fieldName => $field) {
541 if (CRM_Utils_Array
::value('operatorType', $field) & CRM_Report_Form
::OP_DATE
) {
542 $relative = CRM_Utils_Array
::value("{$fieldName}_relative", $this->_params
);
543 $from = CRM_Utils_Array
::value("{$fieldName}_from", $this->_params
);
544 $to = CRM_Utils_Array
::value("{$fieldName}_to", $this->_params
);
546 $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to);
549 $op = CRM_Utils_Array
::value("{$fieldName}_op", $this->_params
);
550 $clause = $this->whereClause($field,
552 CRM_Utils_Array
::value("{$fieldName}_value", $this->_params
),
553 CRM_Utils_Array
::value("{$fieldName}_min", $this->_params
),
554 CRM_Utils_Array
::value("{$fieldName}_max", $this->_params
)
557 if (!empty($clause)) {
558 $clauses[] = $clause;
564 if (empty($clauses)) {
565 $this->_where
= "WHERE ( 1 ) ";
568 $this->_where
= "WHERE " . implode(' AND ', $clauses);
571 if ($this->_aclWhere
) {
572 $this->_where
.= " AND {$this->_aclWhere} ";
575 $this->_where
.= " GROUP BY {$this->_aliases['civicrm_contact']}.id ";
578 function clauseComponent() {
579 $selectedContacts = implode(',', $this->_contactSelected
);
580 $contribution = $membership = $participant = NULL;
581 $eligibleResult = $rows = $tempArray = array();
582 foreach ($this->_component
as $val) {
583 if (CRM_Utils_Array
::value($val, $this->_selectComponent
) && ($val != 'activity_civireport' && $val != 'relationship_civireport')) {
584 $sql = "{$this->_selectComponent[$val]} {$this->_formComponent[$val]}
585 WHERE {$this->_aliases['civicrm_contact']}.id IN ( $selectedContacts )
586 GROUP BY {$this->_aliases['civicrm_contact']}.id,{$val}.id ";
588 $dao = CRM_Core_DAO
::executeQuery($sql);
589 while ($dao->fetch()) {
591 $eligibleResult[$val] = $val;
592 $CC = 'civicrm_' . substr_replace($val, '', -11, 11) . '_contact_id';
594 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
596 $row[$key] = $dao->$key;
599 //if record exist for component(except contact_id)
600 //since contact_id is selected for every component
601 if ($countRecord > 1) {
602 $rows[$dao->$CC][$val][] = $row;
604 $tempArray[$dao->$CC] = $dao->$CC;
609 if (CRM_Utils_Array
::value('relationship_civireport', $this->_selectComponent
)) {
611 $relTypes = CRM_Contact_BAO_Relationship
::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE);
613 $val = 'relationship_civireport';
614 $eligibleResult[$val] = $val;
615 $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]}
616 WHERE ({$this->_aliases['civicrm_contact']}.id IN ( $selectedContacts )
618 contact_a.id IN ( $selectedContacts ) ) AND
619 {$this->_aliases['civicrm_relationship']}.is_active = 1 AND
620 contact_a.is_deleted = 0 AND
621 {$this->_aliases['civicrm_contact']}.is_deleted = 0
622 GROUP BY {$this->_aliases['civicrm_relationship']}.id";
624 $dao = CRM_Core_DAO
::executeQuery($sql);
625 while ($dao->fetch()) {
626 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
627 if ($key == 'civicrm_relationship_contact_id_b') {
628 $row[$key] = $dao->contact_b_name
;
632 $row[$key] = $dao->$key;
635 $relTitle = "" . $dao->civicrm_relationship_relationship_type_id
. '_a_b';
636 $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle];
638 $rows[$dao->contact_a_id
][$val][] = $row;
640 $row['civicrm_relationship_contact_id_b'] = $dao->contact_a_name
;
641 $relTitle = "" . $dao->civicrm_relationship_relationship_type_id
. '_b_a';
642 if (isset($relTypes[$relTitle])) {
643 $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle];
645 $rows[$dao->civicrm_relationship_contact_id_b
][$val][] = $row;
649 if (CRM_Utils_Array
::value('activity_civireport', $this->_selectComponent
)) {
651 $componentClause = "civicrm_option_value.component_id IS NULL";
652 $componentsIn = NULL;
653 $compInfo = CRM_Core_Component
::getEnabledComponents();
654 foreach ($compInfo as $compObj) {
655 if ($compObj->info
['showActivitiesInCore']) {
656 $componentsIn = $componentsIn ?
($componentsIn . ', ' . $compObj->componentID
) : $compObj->componentID
;
660 $componentClause = "( $componentClause OR
661 civicrm_option_value.component_id IN ($componentsIn) )";
664 $val = 'activity_civireport';
665 $eligibleResult[$val] = $val;
666 $sql = "{$this->_selectComponent[$val]} ,
667 {$this->_aliases['civicrm_activity_source']}.display_name as added_by {$this->_formComponent[$val]}
669 WHERE ( civicrm_activity_source.contact_id IN ($selectedContacts) OR
670 civicrm_activity_target.contact_id IN ($selectedContacts) OR
671 civicrm_activity_assignment.contact_id IN ($selectedContacts) OR
672 civicrm_case_contact.contact_id IN ($selectedContacts) ) AND
673 civicrm_option_group.name = 'activity_type' AND
674 {$this->_aliases['civicrm_activity']}.is_test = 0 AND
677 GROUP BY {$this->_aliases['civicrm_activity']}.id
679 ORDER BY {$this->_aliases['civicrm_activity']}.activity_date_time desc ";
681 $dao = CRM_Core_DAO
::executeQuery($sql);
682 while ($dao->fetch()) {
683 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
684 if ($key == 'civicrm_activity_source_contact_id') {
685 $row[$key] = $dao->added_by
;
688 $row[$key] = $dao->$key;
691 if (isset($dao->civicrm_activity_source_contact_id
)) {
692 $rows[$dao->civicrm_activity_source_contact_id
][$val][] = $row;
694 if (isset($dao->target_contact_id
)) {
695 $rows[$dao->target_contact_id
][$val][] = $row;
697 if (isset($dao->assignee_contact_id
)) {
698 $rows[$dao->assignee_contact_id
][$val][] = $row;
702 //unset the component header if data is not present
703 foreach ($this->_component
as $val) {
704 if (!in_array($val, $eligibleResult)) {
706 unset($this->_columnHeadersComponent
[$val]);
714 function statistics(&$rows) {
715 $statistics = array();
717 $count = count($rows);
718 if ($this->_rollup
&& ($this->_rollup
!= '')) {
722 $this->countStat($statistics, $count);
723 $this->filterStat($statistics);
728 //Override to set limit is 10
729 function limit($rowCount = self
::ROW_COUNT_LIMIT
) {
730 parent
::limit($rowCount);
733 //Override to set pager with limit is 10
734 function setPager($rowCount = self
::ROW_COUNT_LIMIT
) {
735 parent
::setPager($rowCount);
738 function postProcess() {
740 $this->beginPostProcess();
742 // get the acl clauses built before we assemble the query
743 $this->buildACLClause($this->_aliases
['civicrm_contact']);
745 $sql = $this->buildQuery(TRUE);
747 $rows = $graphRows = $this->_contactSelected
= array();
748 $this->buildRows($sql, $rows);
749 foreach ($rows as $key => $val) {
750 $rows[$key]['contactID'] = $val['civicrm_contact_id'];
751 $this->_contactSelected
[] = $val['civicrm_contact_id'];
754 $this->formatDisplay($rows);
756 if (!empty($this->_contactSelected
)) {
757 $componentRows = $this->clauseComponent();
758 $this->alterComponentDisplay($componentRows);
760 //unset Conmponent id and contact id from display
761 foreach ($this->_columnHeadersComponent
as $componentTitle => $headers) {
762 $id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_' . substr_replace($componentTitle, '', -11, 11) . '_id';
763 $contact_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_contact_id';
764 if ($componentTitle == 'activity_civireport') {
765 $id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_id';
768 unset($this->_columnHeadersComponent
[$componentTitle][$id_header]);
769 unset($this->_columnHeadersComponent
[$componentTitle][$contact_header]);
772 $this->assign_by_ref('columnHeadersComponent', $this->_columnHeadersComponent
);
773 $this->assign_by_ref('componentRows', $componentRows);
776 $this->doTemplateAssignment($rows);
777 $this->endPostProcess();
780 function alterDisplay(&$rows) {
781 // custom code to alter rows
785 foreach ($rows as $rowNum => $row) {
786 // make count columns point to detail report
788 // change contact name with link
789 if (array_key_exists('civicrm_contact_sort_name', $row) &&
790 array_key_exists('civicrm_contact_id', $row)
793 $url = CRM_Utils_System
::url('civicrm/contact/view',
794 'reset=1&cid=' . $row['civicrm_contact_id'],
797 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
798 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts('View Contact Summary for this Contact');
802 if (array_key_exists('civicrm_address_state_province_id', $row)) {
803 if ($value = $row['civicrm_address_state_province_id']) {
804 $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant
::stateProvince($value, FALSE);
810 // skip looking further in rows, if first row itself doesn't
811 // have the column we need
818 function alterComponentDisplay(&$componentRows) {
819 // custom code to alter rows
820 $activityTypes = CRM_Core_PseudoConstant
::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
821 $activityStatus = CRM_Core_PseudoConstant
::activityStatus();
824 foreach ($componentRows as $contactID => $components) {
825 foreach ($components as $component => $rows) {
826 foreach ($rows as $rowNum => $row) {
827 // handle contribution
828 if ($component == 'contribution_civireport') {
829 if ($val = CRM_Utils_Array
::value('civicrm_contribution_financial_type_id', $row)) {
830 $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_financial_type_id'] =
831 CRM_Contribute_PseudoConstant
::financialType($val, false);
834 if ($val = CRM_Utils_Array
::value('civicrm_contribution_contribution_status_id', $row)) {
835 $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_contribution_status_id'] = CRM_Contribute_PseudoConstant
::contributionStatus($val);
840 if ($component == 'membership_civireport') {
841 if ($val = CRM_Utils_Array
::value('civicrm_membership_membership_type_id', $row)) {
842 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_type_id'] = CRM_Member_PseudoConstant
::membershipType($val, FALSE);
845 if ($val = CRM_Utils_Array
::value('civicrm_membership_status_id', $row)) {
846 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_status_id'] = CRM_Member_PseudoConstant
::membershipStatus($val, FALSE);
851 if ($component == 'participant_civireport') {
852 if ($val = CRM_Utils_Array
::value('civicrm_participant_event_id', $row)) {
853 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant
::event($val, FALSE);
854 $url = CRM_Report_Utils_Report
::getNextUrl('event/income',
855 'reset=1&force=1&id_op=in&id_value=' . $val,
856 $this->_absoluteUrl
, $this->_id
858 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_link'] = $url;
859 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_hover'] = ts('View Event Income details for this Event.');
863 if ($val = CRM_Utils_Array
::value('civicrm_participant_participant_status_id', $row)) {
864 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_participant_status_id'] = CRM_Event_PseudoConstant
::participantStatus($val, FALSE);
866 if ($val = CRM_Utils_Array
::value('civicrm_participant_role_id', $row)) {
867 $roles = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $val);
869 foreach ($roles as $role) {
870 $value[$role] = CRM_Event_PseudoConstant
::participantRole($role, FALSE);
872 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_role_id'] = implode(', ', $value);
878 if ($component == 'activity_civireport') {
879 if ($val = CRM_Utils_Array
::value('civicrm_activity_activity_type_id', $row)) {
880 $componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_type_id'] = $activityTypes[$val];
882 if ($val = CRM_Utils_Array
::value('civicrm_activity_activity_status_id', $row)) {
883 $componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_status_id'] = $activityStatus[$val];
888 if ($component == 'membership_civireport') {
889 if ($val = CRM_Utils_Array
::value('civicrm_membership_membership_status_id', $row)) {
890 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_status_id'] = CRM_Member_PseudoConstant
::membershipStatus($val);
895 // skip looking further in rows, if first row itself doesn't
896 // have the column we need