3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
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(
57 'title' => ts('First Name'),
60 'title' => ts('Last Name'),
69 'title' => ts('Contact Type'),
73 'title' => ts('Contact SubType'),
77 'title' => ts('Birth Date'),
83 array('title' => ts('Contact ID'),
87 array('title' => ts('Contact Name'),
91 'title' => ts('Birth Date'),
92 'operatorType' => CRM_Report_Form
::OP_DATE
,
95 'grouping' => 'contact-fields',
99 array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'),
104 'dao' => 'CRM_Core_DAO_Address',
105 'grouping' => 'contact-fields',
108 'street_address' => NULL,
110 'postal_code' => NULL,
111 'state_province_id' =>
112 array('title' => ts('State/Province'),
116 array('state_province_id' => array('title' => 'State/Province'),
117 'city' => array('title' => 'City'),
118 'postal_code' => array('title' => 'Postal Code'),
123 'dao' => 'CRM_Core_DAO_Country',
127 array('title' => 'Country', 'default' => TRUE),
132 array('title' => 'Country'),
134 'grouping' => 'contact-fields',
138 'dao' => 'CRM_Core_DAO_Email',
142 array('title' => ts('Email'),
146 'grouping' => 'contact-fields',
150 array('title' => ts('Email'),
154 'civicrm_contribution' =>
156 'dao' => 'CRM_Contribute_DAO_Contribution',
161 'no_display' => TRUE,
165 array('title' => ts('Contribution'),
169 'total_amount' => array('default' => TRUE),
170 'financial_type_id' => array('title' => ts('Financial Type'),
174 'receive_date' => array('default' => TRUE),
175 'receipt_date' => NULL,
176 'contribution_status_id' => array('title' => ts('Contribution Status'),
179 'contribution_source' => NULL,
182 'civicrm_membership' =>
184 'dao' => 'CRM_Member_DAO_Membership',
189 'no_display' => TRUE,
193 array('title' => ts('Membership'),
197 'membership_type_id' => array('title' => ts('Membership Type'),
201 'membership_start_date' => array('title' => ts('Start Date'),
204 'membership_end_date' => array('title' => ts('End Date'),
207 'membership_status_id' => array(
208 'name' => 'status_id',
209 'title' => ts('Membership Status'),
212 'source' => array('title' => 'Membership Source'),
215 'civicrm_participant' =>
217 'dao' => 'CRM_Event_DAO_Participant',
222 'no_display' => TRUE,
226 array('title' => ts('Participant'),
230 'event_id' => array('default' => TRUE),
231 'participant_status_id' => array(
232 'name' => 'status_id',
233 'title' => ts('Participant Status'),
236 'role_id' => array('title' => ts('Role'),
239 'participant_register_date' => array('title' => ts('Register Date'),
242 'fee_level' => array('title' => ts('Fee Level'),
245 'fee_amount' => array('title' => ts('Fee Amount'),
250 'civicrm_relationship' =>
252 'dao' => 'CRM_Contact_DAO_Relationship',
258 'title' => ts('Relationship'),
262 'relationship_type_id' =>
263 array('title' => ts('Relationship Type'),
267 array('title' => ts('Relationship With'),
272 'title' => 'Start Date ',
273 'type' => CRM_Report_Form
::OP_DATE
,
277 'title' => 'End Date ',
278 'type' => CRM_Report_Form
::OP_DATE
,
282 'civicrm_activity' =>
284 'dao' => 'CRM_Activity_DAO_Activity',
288 array('title' => ts('Activity'),
292 'activity_type_id' =>
293 array('title' => ts('Activity Type'),
297 array('title' => ts('Subject'),
300 'activity_date_time' =>
301 array('title' => ts('Activity Date'),
304 'activity_status_id' =>
306 'name' => 'status_id',
307 'title' => ts('Activity Status'),
311 'grouping' => 'activity-fields',
313 'civicrm_activity_target' =>
315 'dao' => 'CRM_Activity_DAO_ActivityContact',
318 'target_contact_id' =>
319 array('title' => ts('With Contact'),
320 'name' => 'contact_id',
324 'grouping' => 'activity-fields',
326 'civicrm_activity_assignment' =>
328 'dao' => 'CRM_Activity_DAO_ActivityContact',
331 'assignee_contact_id' =>
332 array('title' => ts('Assigned To'),
333 'name' => 'contact_id',
337 'grouping' => 'activity-fields',
339 'civicrm_activity_source' =>
341 'dao' => 'CRM_Activity_DAO_ActivityContact',
344 'source_contact_id' =>
346 'title' => ts('Added By'),
347 'name' => 'contact_id',
351 'grouping' => 'activity-fields',
355 'dao' => 'CRM_Contact_DAO_Group',
361 'name' => 'group_id',
362 'title' => ts('Group'),
363 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
365 'options' => CRM_Core_PseudoConstant
::group(),
371 'dao' => 'CRM_Core_DAO_Phone',
377 'title' => ts('Phone Extension')
380 'grouping' => 'contact-fields',
384 $this->_tagFilter
= TRUE;
385 parent
::__construct();
388 function preProcess() {
389 $this->_csvSupported
= FALSE;
390 parent
::preProcess();
395 $this->_columnHeaders
= array();
396 $this->_component
= array('contribution_civireport', 'membership_civireport', 'participant_civireport', 'relationship_civireport', 'activity_civireport');
397 foreach ($this->_columns
as $tableName => $table) {
398 if (array_key_exists('fields', $table)) {
399 foreach ($table['fields'] as $fieldName => $field) {
400 if (!empty($field['required']) ||
!empty($this->_params
['fields'][$fieldName])) {
401 //isolate the select clause compoenent wise
402 if (in_array($table['alias'], $this->_component
)) {
403 $select[$table['alias']][] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
404 $this->_columnHeadersComponent
[$table['alias']]["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
405 $this->_columnHeadersComponent
[$table['alias']]["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
407 elseif ($table['alias'] == $this->_aliases
['civicrm_activity_target'] ||
408 $table['alias'] == $this->_aliases
['civicrm_activity_assignment'] ||
409 $table['alias'] == $this->_aliases
['civicrm_activity_source']
411 if ($table['alias'] == $this->_aliases
['civicrm_activity_target']) {
412 $addContactId = 'civicrm_activity_target.contact_id as target_contact_id';
414 elseif ($table['alias'] == $this->_aliases
['civicrm_activity_source']) {
415 $addContactId = 'civicrm_activity_source.contact_id';
418 $addContactId = 'civicrm_activity_assignment.contact_id as assignee_contact_id';
421 $tableName = $table['alias'];
422 $select['activity_civireport'][] = "$tableName.display_name as {$tableName}_{$fieldName}, $addContactId ";
423 $this->_columnHeadersComponent
['activity_civireport']["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
424 $this->_columnHeadersComponent
['activity_civireport']["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
427 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
428 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
429 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = $field['title'];
436 foreach ($this->_component
as $val) {
437 if (!empty($select[$val])) {
438 $this->_selectComponent
[$val] = "SELECT " . implode(', ', $select[$val]) . " ";
439 unset($select[$val]);
443 $this->_select
= "SELECT " . implode(', ', $select) . " ";
446 static function formRule($fields, $files, $self) {
454 FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom}";
456 if ($this->isTableSelected('civicrm_country') ||
$this->isTableSelected('civicrm_address')) {
458 LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
459 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND
460 {$this->_aliases['civicrm_address']}.is_primary = 1 ) ";
463 if ($this->isTableSelected('civicrm_email')) {
465 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
466 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
467 {$this->_aliases['civicrm_email']}.is_primary = 1) ";
470 if ($this->isTableSelected('civicrm_phone')) {
472 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
473 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
474 {$this->_aliases['civicrm_phone']}.is_primary = 1 ";
477 if ($this->isTableSelected('civicrm_country')) {
479 LEFT JOIN civicrm_country {$this->_aliases['civicrm_country']}
480 ON {$this->_aliases['civicrm_address']}.country_id = {$this->_aliases['civicrm_country']}.id AND
481 {$this->_aliases['civicrm_address']}.is_primary = 1 ";
484 $this->_from
.= "{$group}";
486 foreach ($this->_component
as $val) {
487 if (!empty($this->_selectComponent
['contribution_civireport'])) {
488 $this->_formComponent
['contribution_civireport'] = " FROM
489 civicrm_contact {$this->_aliases['civicrm_contact']}
490 INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
491 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id
495 if (!empty($this->_selectComponent
['membership_civireport'])) {
496 $this->_formComponent
['membership_civireport'] = " FROM
497 civicrm_contact {$this->_aliases['civicrm_contact']}
498 INNER JOIN civicrm_membership {$this->_aliases['civicrm_membership']}
499 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_membership']}.contact_id
502 if (!empty($this->_selectComponent
['participant_civireport'])) {
503 $this->_formComponent
['participant_civireport'] = " FROM
504 civicrm_contact {$this->_aliases['civicrm_contact']}
505 INNER JOIN civicrm_participant {$this->_aliases['civicrm_participant']}
506 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_participant']}.contact_id
510 if (!empty($this->_selectComponent
['activity_civireport'])) {
511 $activityContacts = CRM_Core_OptionGroup
::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
512 $assigneeID = CRM_Utils_Array
::key('Activity Assignees', $activityContacts);
513 $targetID = CRM_Utils_Array
::key('Activity Targets', $activityContacts);
514 $sourceID = CRM_Utils_Array
::key('Activity Source', $activityContacts);
516 $this->_formComponent
['activity_civireport'] = "FROM
517 civicrm_activity {$this->_aliases['civicrm_activity']}
518 LEFT JOIN civicrm_activity_contact civicrm_activity_target ON
519 {$this->_aliases['civicrm_activity']}.id = civicrm_activity_target.activity_id AND
520 civicrm_activity_target.record_type_id = {$targetID}
521 LEFT JOIN civicrm_activity_contact civicrm_activity_assignment ON
522 {$this->_aliases['civicrm_activity']}.id = civicrm_activity_assignment.activity_id AND civicrm_activity_assignment.record_type_id = {$assigneeID}
523 LEFT JOIN civicrm_activity_contact civicrm_activity_source
524 ON {$this->_aliases['civicrm_activity']}.id = civicrm_activity_source.activity_id AND
525 civicrm_activity_source.record_type_id = {$sourceID}
526 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_target']} ON
527 civicrm_activity_target.contact_id = {$this->_aliases['civicrm_activity_target']}.id
529 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_assignment']} ON
530 civicrm_activity_assignment.contact_id = {$this->_aliases['civicrm_activity_assignment']}.id
531 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_source']} ON
532 civicrm_activity_source.contact_id = {$this->_aliases['civicrm_activity_source']}.id
533 LEFT JOIN civicrm_option_value ON
534 ( {$this->_aliases['civicrm_activity']}.activity_type_id = civicrm_option_value.value )
535 LEFT JOIN civicrm_option_group ON
536 civicrm_option_group.id = civicrm_option_value.option_group_id
537 LEFT JOIN civicrm_case_activity ON
538 civicrm_case_activity.activity_id = {$this->_aliases['civicrm_activity']}.id
539 LEFT JOIN civicrm_case ON
540 civicrm_case_activity.case_id = civicrm_case.id
541 LEFT JOIN civicrm_case_contact ON
542 civicrm_case_contact.case_id = civicrm_case.id ";
545 if (!empty($this->_selectComponent
['relationship_civireport'])) {
546 $this->_formComponent
['relationship_civireport'] = "FROM
547 civicrm_relationship {$this->_aliases['civicrm_relationship']}
549 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']} ON
550 {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_relationship']}.contact_id_b
551 LEFT JOIN civicrm_contact contact_a ON
552 contact_a.id = {$this->_aliases['civicrm_relationship']}.contact_id_a ";
560 foreach ($this->_columns
as $tableName => $table) {
561 if (array_key_exists('filters', $table)) {
562 foreach ($table['filters'] as $fieldName => $field) {
564 if (CRM_Utils_Array
::value('operatorType', $field) & CRM_Report_Form
::OP_DATE
) {
565 $relative = CRM_Utils_Array
::value("{$fieldName}_relative", $this->_params
);
566 $from = CRM_Utils_Array
::value("{$fieldName}_from", $this->_params
);
567 $to = CRM_Utils_Array
::value("{$fieldName}_to", $this->_params
);
569 $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to);
572 $op = CRM_Utils_Array
::value("{$fieldName}_op", $this->_params
);
573 $clause = $this->whereClause($field,
575 CRM_Utils_Array
::value("{$fieldName}_value", $this->_params
),
576 CRM_Utils_Array
::value("{$fieldName}_min", $this->_params
),
577 CRM_Utils_Array
::value("{$fieldName}_max", $this->_params
)
580 if (!empty($clause)) {
581 $clauses[] = $clause;
587 if (empty($clauses)) {
588 $this->_where
= "WHERE ( 1 ) ";
591 $this->_where
= "WHERE " . implode(' AND ', $clauses);
594 if ($this->_aclWhere
) {
595 $this->_where
.= " AND {$this->_aclWhere} ";
598 $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]);
737 function statistics(&$rows) {
738 $statistics = array();
740 $count = count($rows);
741 if ($this->_rollup
&& ($this->_rollup
!= '')) {
745 $this->countStat($statistics, $count);
746 $this->filterStat($statistics);
751 //Override to set limit is 10
752 function limit($rowCount = self
::ROW_COUNT_LIMIT
) {
753 parent
::limit($rowCount);
756 //Override to set pager with limit is 10
757 function setPager($rowCount = self
::ROW_COUNT_LIMIT
) {
758 parent
::setPager($rowCount);
761 function postProcess() {
763 $this->beginPostProcess();
765 // get the acl clauses built before we assemble the query
766 $this->buildACLClause($this->_aliases
['civicrm_contact']);
768 $sql = $this->buildQuery(TRUE);
770 $rows = $graphRows = $this->_contactSelected
= array();
771 $this->buildRows($sql, $rows);
772 foreach ($rows as $key => $val) {
773 $rows[$key]['contactID'] = $val['civicrm_contact_id'];
774 $this->_contactSelected
[] = $val['civicrm_contact_id'];
777 $this->formatDisplay($rows);
779 if (!empty($this->_contactSelected
)) {
780 $componentRows = $this->clauseComponent();
781 $this->alterComponentDisplay($componentRows);
783 //unset Conmponent id and contact id from display
784 foreach ($this->_columnHeadersComponent
as $componentTitle => $headers) {
785 $id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_' . substr_replace($componentTitle, '', -11, 11) . '_id';
786 $contact_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_contact_id';
787 if ($componentTitle == 'activity_civireport') {
788 $id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_id';
791 unset($this->_columnHeadersComponent
[$componentTitle][$id_header]);
792 unset($this->_columnHeadersComponent
[$componentTitle][$contact_header]);
795 $this->assign_by_ref('columnHeadersComponent', $this->_columnHeadersComponent
);
796 $this->assign_by_ref('componentRows', $componentRows);
799 $this->doTemplateAssignment($rows);
800 $this->endPostProcess();
803 function alterDisplay(&$rows) {
804 // custom code to alter rows
808 foreach ($rows as $rowNum => $row) {
809 // make count columns point to detail report
811 // change contact name with link
812 if (array_key_exists('civicrm_contact_sort_name', $row) &&
813 array_key_exists('civicrm_contact_id', $row)
816 $url = CRM_Utils_System
::url('civicrm/contact/view',
817 'reset=1&cid=' . $row['civicrm_contact_id'],
820 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
821 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts('View Contact Summary for this Contact');
825 if (array_key_exists('civicrm_address_state_province_id', $row)) {
826 if ($value = $row['civicrm_address_state_province_id']) {
827 $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant
::stateProvince($value, FALSE);
833 // skip looking further in rows, if first row itself doesn't
834 // have the column we need
841 function alterComponentDisplay(&$componentRows) {
842 // custom code to alter rows
843 $activityTypes = CRM_Core_PseudoConstant
::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
844 $activityStatus = CRM_Core_PseudoConstant
::activityStatus();
847 foreach ($componentRows as $contactID => $components) {
848 foreach ($components as $component => $rows) {
849 foreach ($rows as $rowNum => $row) {
850 // handle contribution
851 if ($component == 'contribution_civireport') {
852 if ($val = CRM_Utils_Array
::value('civicrm_contribution_financial_type_id', $row)) {
853 $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_financial_type_id'] =
854 CRM_Contribute_PseudoConstant
::financialType($val, false);
857 if ($val = CRM_Utils_Array
::value('civicrm_contribution_contribution_status_id', $row)) {
858 $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_contribution_status_id'] = CRM_Contribute_PseudoConstant
::contributionStatus($val);
863 if ($component == 'membership_civireport') {
864 if ($val = CRM_Utils_Array
::value('civicrm_membership_membership_type_id', $row)) {
865 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_type_id'] = CRM_Member_PseudoConstant
::membershipType($val, FALSE);
868 if ($val = CRM_Utils_Array
::value('civicrm_membership_status_id', $row)) {
869 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_status_id'] = CRM_Member_PseudoConstant
::membershipStatus($val, FALSE);
874 if ($component == 'participant_civireport') {
875 if ($val = CRM_Utils_Array
::value('civicrm_participant_event_id', $row)) {
876 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant
::event($val, FALSE);
877 $url = CRM_Report_Utils_Report
::getNextUrl('event/income',
878 'reset=1&force=1&id_op=in&id_value=' . $val,
879 $this->_absoluteUrl
, $this->_id
881 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_link'] = $url;
882 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_hover'] = ts('View Event Income details for this Event.');
886 if ($val = CRM_Utils_Array
::value('civicrm_participant_participant_status_id', $row)) {
887 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_participant_status_id'] = CRM_Event_PseudoConstant
::participantStatus($val, FALSE);
889 if ($val = CRM_Utils_Array
::value('civicrm_participant_role_id', $row)) {
890 $roles = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $val);
892 foreach ($roles as $role) {
893 $value[$role] = CRM_Event_PseudoConstant
::participantRole($role, FALSE);
895 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_role_id'] = implode(', ', $value);
901 if ($component == 'activity_civireport') {
902 if ($val = CRM_Utils_Array
::value('civicrm_activity_activity_type_id', $row)) {
903 $componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_type_id'] = $activityTypes[$val];
905 if ($val = CRM_Utils_Array
::value('civicrm_activity_activity_status_id', $row)) {
906 $componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_status_id'] = $activityStatus[$val];
911 if ($component == 'membership_civireport') {
912 if ($val = CRM_Utils_Array
::value('civicrm_membership_membership_status_id', $row)) {
913 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_status_id'] = CRM_Member_PseudoConstant
::membershipStatus($val);
918 // skip looking further in rows, if first row itself doesn't
919 // have the column we need