3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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(
53 public function __construct() {
54 $this->_autoIncludeIndexedFieldsAsOrderBys
= 1;
55 $this->_columns
= array(
56 'civicrm_contact' => array(
57 'dao' => 'CRM_Contact_DAO_Contact',
60 'title' => ts('Contact Name'),
64 'first_name' => array(
65 'title' => ts('First Name'),
68 'title' => ts('Last Name'),
74 'contact_type' => array(
75 'title' => ts('Contact Type'),
77 'contact_sub_type' => array(
78 'title' => ts('Contact Subtype'),
80 'birth_date' => array(
81 'title' => ts('Birth Date'),
86 'title' => ts('Contact ID'),
90 'title' => ts('Contact Name'),
92 'birth_date' => array(
93 'title' => ts('Birth Date'),
94 'operatorType' => CRM_Report_Form
::OP_DATE
,
97 'grouping' => 'contact-fields',
100 'title' => ts('Last Name, First Name'),
102 'default_weight' => '0',
103 'default_order' => 'ASC'
107 'civicrm_address' => array(
108 'dao' => 'CRM_Core_DAO_Address',
109 'grouping' => 'contact-fields',
111 'street_address' => NULL,
113 'postal_code' => NULL,
114 'state_province_id' => array(
115 'title' => ts('State/Province'),
118 'order_bys' => array(
119 'state_province_id' => array('title' => 'State/Province'),
120 'city' => array('title' => 'City'),
121 'postal_code' => array('title' => 'Postal Code'),
124 'civicrm_country' => array(
125 'dao' => 'CRM_Core_DAO_Country',
127 'name' => array('title' => 'Country', 'default' => TRUE),
129 'order_bys' => array(
130 'name' => array('title' => 'Country'),
132 'grouping' => 'contact-fields',
134 'civicrm_email' => array(
135 'dao' => 'CRM_Core_DAO_Email',
138 'title' => ts('Email'),
142 'grouping' => 'contact-fields',
143 'order_bys' => array(
145 'title' => ts('Email'),
149 'civicrm_contribution' => array(
150 'dao' => 'CRM_Contribute_DAO_Contribution',
152 'contact_id' => array(
153 'no_display' => TRUE,
156 'contribution_id' => array(
157 'title' => ts('Contribution'),
161 'total_amount' => array('default' => TRUE),
162 'financial_type_id' => array(
163 'title' => ts('Financial Type'),
167 'receive_date' => array('default' => TRUE),
168 'receipt_date' => NULL,
169 'contribution_status_id' => array(
170 'title' => ts('Contribution Status'),
173 'contribution_source' => NULL,
176 'civicrm_membership' => array(
177 'dao' => 'CRM_Member_DAO_Membership',
179 'contact_id' => array(
180 'no_display' => TRUE,
183 'membership_id' => array(
184 'title' => ts('Membership'),
188 'membership_type_id' => array(
189 'title' => ts('Membership Type'),
193 'membership_start_date' => array(
194 'title' => ts('Start Date'),
197 'membership_end_date' => array(
198 'title' => ts('End Date'),
201 'membership_status_id' => array(
202 'name' => 'status_id',
203 'title' => ts('Membership Status'),
206 'source' => array('title' => 'Membership Source'),
209 'civicrm_participant' => array(
210 'dao' => 'CRM_Event_DAO_Participant',
212 'contact_id' => array(
213 'no_display' => TRUE,
216 'participant_id' => array(
217 'title' => ts('Participant'),
221 'event_id' => array('default' => TRUE),
222 'participant_status_id' => array(
223 'name' => 'status_id',
224 'title' => ts('Participant Status'),
228 'title' => ts('Role'),
231 'participant_register_date' => array(
232 'title' => ts('Register Date'),
235 'fee_level' => array(
236 'title' => ts('Fee Level'),
239 'fee_amount' => array(
240 'title' => ts('Fee Amount'),
245 'civicrm_relationship' => array(
246 'dao' => 'CRM_Contact_DAO_Relationship',
248 'relationship_id' => array(
250 'title' => ts('Relationship'),
254 'relationship_type_id' => array(
255 'title' => ts('Relationship Type'),
258 'contact_id_b' => array(
259 'title' => ts('Relationship With'),
262 'start_date' => array(
263 'title' => 'Start Date ',
264 'type' => CRM_Report_Form
::OP_DATE
,
267 'title' => 'End Date ',
268 'type' => CRM_Report_Form
::OP_DATE
,
272 'civicrm_activity' => array(
273 'dao' => 'CRM_Activity_DAO_Activity',
276 'title' => ts('Activity'),
280 'activity_type_id' => array(
281 'title' => ts('Activity Type'),
285 'title' => ts('Subject'),
288 'activity_date_time' => array(
289 'title' => ts('Activity Date'),
292 'activity_status_id' => array(
293 'name' => 'status_id',
294 'title' => ts('Activity Status'),
298 'grouping' => 'activity-fields',
300 'civicrm_activity_target' => array(
301 'dao' => 'CRM_Activity_DAO_ActivityContact',
303 'target_contact_id' => array(
304 'title' => ts('With Contact'),
305 'name' => 'contact_id',
309 'grouping' => 'activity-fields',
311 'civicrm_activity_assignment' => array(
312 'dao' => 'CRM_Activity_DAO_ActivityContact',
314 'assignee_contact_id' => array(
315 'title' => ts('Assigned to'),
316 'name' => 'contact_id',
320 'grouping' => 'activity-fields',
322 'civicrm_activity_source' => array(
323 'dao' => 'CRM_Activity_DAO_ActivityContact',
325 'source_contact_id' => array(
326 'title' => ts('Added By'),
327 'name' => 'contact_id',
331 'grouping' => 'activity-fields',
333 'civicrm_phone' => array(
334 'dao' => 'CRM_Core_DAO_Phone',
337 'phone_ext' => array(
338 'title' => ts('Phone Extension')
341 'grouping' => 'contact-fields',
344 $this->_groupFilter
= TRUE;
345 $this->_tagFilter
= TRUE;
346 parent
::__construct();
349 public function preProcess() {
350 $this->_csvSupported
= FALSE;
351 parent
::preProcess();
354 public function select() {
356 $this->_columnHeaders
= array();
357 $this->_component
= array(
358 'contribution_civireport',
359 'membership_civireport',
360 'participant_civireport',
361 'relationship_civireport',
362 'activity_civireport'
364 foreach ($this->_columns
as $tableName => $table) {
365 if (array_key_exists('fields', $table)) {
366 foreach ($table['fields'] as $fieldName => $field) {
367 if (!empty($field['required']) ||
368 !empty($this->_params
['fields'][$fieldName])
370 //isolate the select clause compoenent wise
371 if (in_array($table['alias'], $this->_component
)) {
372 $select[$table['alias']][] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
373 $this->_columnHeadersComponent
[$table['alias']]["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
374 $this->_columnHeadersComponent
[$table['alias']]["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
376 elseif ($table['alias'] ==
377 $this->_aliases
['civicrm_activity_target'] ||
379 $this->_aliases
['civicrm_activity_assignment'] ||
380 $table['alias'] == $this->_aliases
['civicrm_activity_source']
382 if ($table['alias'] == $this->_aliases
['civicrm_activity_target']
384 $addContactId = 'civicrm_activity_target.contact_id as target_contact_id';
386 elseif ($table['alias'] ==
387 $this->_aliases
['civicrm_activity_source']
389 $addContactId = 'civicrm_activity_source.contact_id';
392 $addContactId = 'civicrm_activity_assignment.contact_id as assignee_contact_id';
395 $tableName = $table['alias'];
396 $select['activity_civireport'][] = "$tableName.display_name as {$tableName}_{$fieldName}, $addContactId ";
397 $this->_columnHeadersComponent
['activity_civireport']["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
398 $this->_columnHeadersComponent
['activity_civireport']["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
401 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
402 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
403 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = $field['title'];
410 foreach ($this->_component
as $val) {
411 if (!empty($select[$val])) {
412 $this->_selectComponent
[$val] =
413 "SELECT " . implode(', ', $select[$val]) . " ";
414 unset($select[$val]);
418 $this->_select
= "SELECT " . implode(', ', $select) . " ";
428 public static function formRule($fields, $files, $self) {
433 public function from() {
436 FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom}";
438 if ($this->isTableSelected('civicrm_country') ||
439 $this->isTableSelected('civicrm_address')
442 LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
443 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND
444 {$this->_aliases['civicrm_address']}.is_primary = 1 ) ";
447 if ($this->isTableSelected('civicrm_email')) {
449 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
450 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
451 {$this->_aliases['civicrm_email']}.is_primary = 1) ";
454 if ($this->isTableSelected('civicrm_phone')) {
456 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
457 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
458 {$this->_aliases['civicrm_phone']}.is_primary = 1 ";
461 if ($this->isTableSelected('civicrm_country')) {
463 LEFT JOIN civicrm_country {$this->_aliases['civicrm_country']}
464 ON {$this->_aliases['civicrm_address']}.country_id = {$this->_aliases['civicrm_country']}.id AND
465 {$this->_aliases['civicrm_address']}.is_primary = 1 ";
468 $this->_from
.= "{$group}";
470 foreach ($this->_component
as $val) {
471 if (!empty($this->_selectComponent
['contribution_civireport'])) {
472 $this->_formComponent
['contribution_civireport'] = " FROM
473 civicrm_contact {$this->_aliases['civicrm_contact']}
474 INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
475 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id
479 if (!empty($this->_selectComponent
['membership_civireport'])) {
480 $this->_formComponent
['membership_civireport'] = " FROM
481 civicrm_contact {$this->_aliases['civicrm_contact']}
482 INNER JOIN civicrm_membership {$this->_aliases['civicrm_membership']}
483 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_membership']}.contact_id
486 if (!empty($this->_selectComponent
['participant_civireport'])) {
487 $this->_formComponent
['participant_civireport'] = " FROM
488 civicrm_contact {$this->_aliases['civicrm_contact']}
489 INNER JOIN civicrm_participant {$this->_aliases['civicrm_participant']}
490 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_participant']}.contact_id
494 if (!empty($this->_selectComponent
['activity_civireport'])) {
495 $activityContacts = CRM_Core_OptionGroup
::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
496 $assigneeID = CRM_Utils_Array
::key('Activity Assignees', $activityContacts);
497 $targetID = CRM_Utils_Array
::key('Activity Targets', $activityContacts);
498 $sourceID = CRM_Utils_Array
::key('Activity Source', $activityContacts);
500 $this->_formComponent
['activity_civireport'] = "FROM
501 civicrm_activity {$this->_aliases['civicrm_activity']}
502 LEFT JOIN civicrm_activity_contact civicrm_activity_target ON
503 {$this->_aliases['civicrm_activity']}.id = civicrm_activity_target.activity_id AND
504 civicrm_activity_target.record_type_id = {$targetID}
505 LEFT JOIN civicrm_activity_contact civicrm_activity_assignment ON
506 {$this->_aliases['civicrm_activity']}.id = civicrm_activity_assignment.activity_id AND civicrm_activity_assignment.record_type_id = {$assigneeID}
507 LEFT JOIN civicrm_activity_contact civicrm_activity_source
508 ON {$this->_aliases['civicrm_activity']}.id = civicrm_activity_source.activity_id AND
509 civicrm_activity_source.record_type_id = {$sourceID}
510 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_target']} ON
511 civicrm_activity_target.contact_id = {$this->_aliases['civicrm_activity_target']}.id
513 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_assignment']} ON
514 civicrm_activity_assignment.contact_id = {$this->_aliases['civicrm_activity_assignment']}.id
515 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_source']} ON
516 civicrm_activity_source.contact_id = {$this->_aliases['civicrm_activity_source']}.id
517 LEFT JOIN civicrm_option_value ON
518 ( {$this->_aliases['civicrm_activity']}.activity_type_id = civicrm_option_value.value )
519 LEFT JOIN civicrm_option_group ON
520 civicrm_option_group.id = civicrm_option_value.option_group_id
521 LEFT JOIN civicrm_case_activity ON
522 civicrm_case_activity.activity_id = {$this->_aliases['civicrm_activity']}.id
523 LEFT JOIN civicrm_case ON
524 civicrm_case_activity.case_id = civicrm_case.id
525 LEFT JOIN civicrm_case_contact ON
526 civicrm_case_contact.case_id = civicrm_case.id ";
529 if (!empty($this->_selectComponent
['relationship_civireport'])) {
530 $this->_formComponent
['relationship_civireport'] = "FROM
531 civicrm_relationship {$this->_aliases['civicrm_relationship']}
533 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']} ON
534 {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_relationship']}.contact_id_b
535 LEFT JOIN civicrm_contact contact_a ON
536 contact_a.id = {$this->_aliases['civicrm_relationship']}.contact_id_a ";
541 public function where() {
544 foreach ($this->_columns
as $tableName => $table) {
545 if (array_key_exists('filters', $table)) {
546 foreach ($table['filters'] as $fieldName => $field) {
548 if (CRM_Utils_Array
::value('operatorType', $field) &
549 CRM_Report_Form
::OP_DATE
551 $relative = CRM_Utils_Array
::value("{$fieldName}_relative", $this->_params
);
552 $from = CRM_Utils_Array
::value("{$fieldName}_from", $this->_params
);
553 $to = CRM_Utils_Array
::value("{$fieldName}_to", $this->_params
);
555 $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to);
558 $op = CRM_Utils_Array
::value("{$fieldName}_op", $this->_params
);
559 $clause = $this->whereClause($field,
561 CRM_Utils_Array
::value("{$fieldName}_value", $this->_params
),
562 CRM_Utils_Array
::value("{$fieldName}_min", $this->_params
),
563 CRM_Utils_Array
::value("{$fieldName}_max", $this->_params
)
566 if (!empty($clause)) {
567 $clauses[] = $clause;
573 if (empty($clauses)) {
574 $this->_where
= "WHERE ( 1 ) ";
577 $this->_where
= "WHERE " . implode(' AND ', $clauses);
580 if ($this->_aclWhere
) {
581 $this->_where
.= " AND {$this->_aclWhere} ";
584 $this->_where
.= " GROUP BY {$this->_aliases['civicrm_contact']}.id ";
590 public function clauseComponent() {
591 $selectedContacts = implode(',', $this->_contactSelected
);
592 $contribution = $membership = $participant = NULL;
593 $eligibleResult = $rows = $tempArray = array();
594 foreach ($this->_component
as $val) {
595 if (!empty($this->_selectComponent
[$val]) &&
596 ($val != 'activity_civireport' && $val != 'relationship_civireport')
598 $sql = "{$this->_selectComponent[$val]} {$this->_formComponent[$val]}
599 WHERE {$this->_aliases['civicrm_contact']}.id IN ( $selectedContacts )
600 GROUP BY {$this->_aliases['civicrm_contact']}.id,{$val}.id ";
602 $dao = CRM_Core_DAO
::executeQuery($sql);
603 while ($dao->fetch()) {
605 $eligibleResult[$val] = $val;
606 $CC = 'civicrm_' . substr_replace($val, '', -11, 11) . '_contact_id';
608 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
610 $row[$key] = $dao->$key;
613 //if record exist for component(except contact_id)
614 //since contact_id is selected for every component
615 if ($countRecord > 1) {
616 $rows[$dao->$CC][$val][] = $row;
618 $tempArray[$dao->$CC] = $dao->$CC;
623 if (!empty($this->_selectComponent
['relationship_civireport'])) {
625 $relTypes = CRM_Contact_BAO_Relationship
::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE);
627 $val = 'relationship_civireport';
628 $eligibleResult[$val] = $val;
629 $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]}
630 WHERE ({$this->_aliases['civicrm_contact']}.id IN ( $selectedContacts )
632 contact_a.id IN ( $selectedContacts ) ) AND
633 {$this->_aliases['civicrm_relationship']}.is_active = 1 AND
634 contact_a.is_deleted = 0 AND
635 {$this->_aliases['civicrm_contact']}.is_deleted = 0
636 GROUP BY {$this->_aliases['civicrm_relationship']}.id";
638 $dao = CRM_Core_DAO
::executeQuery($sql);
639 while ($dao->fetch()) {
640 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
641 if ($key == 'civicrm_relationship_contact_id_b') {
642 $row[$key] = $dao->contact_b_name
;
646 $row[$key] = $dao->$key;
649 $relTitle = "" . $dao->civicrm_relationship_relationship_type_id
.
651 $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle];
653 $rows[$dao->contact_a_id
][$val][] = $row;
655 $row['civicrm_relationship_contact_id_b'] = $dao->contact_a_name
;
656 $relTitle = "" . $dao->civicrm_relationship_relationship_type_id
.
658 if (isset($relTypes[$relTitle])) {
659 $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle];
661 $rows[$dao->civicrm_relationship_contact_id_b
][$val][] = $row;
665 if (!empty($this->_selectComponent
['activity_civireport'])) {
667 $componentClause = "civicrm_option_value.component_id IS NULL";
668 $componentsIn = NULL;
669 $compInfo = CRM_Core_Component
::getEnabledComponents();
670 foreach ($compInfo as $compObj) {
671 if ($compObj->info
['showActivitiesInCore']) {
672 $componentsIn = $componentsIn ?
($componentsIn . ', ' .
673 $compObj->componentID
) : $compObj->componentID
;
677 $componentClause = "( $componentClause OR
678 civicrm_option_value.component_id IN ($componentsIn) )";
681 $val = 'activity_civireport';
682 $eligibleResult[$val] = $val;
683 $sql = "{$this->_selectComponent[$val]} ,
684 {$this->_aliases['civicrm_activity_source']}.display_name as added_by {$this->_formComponent[$val]}
686 WHERE ( civicrm_activity_source.contact_id IN ($selectedContacts) OR
687 civicrm_activity_target.contact_id IN ($selectedContacts) OR
688 civicrm_activity_assignment.contact_id IN ($selectedContacts) OR
689 civicrm_case_contact.contact_id IN ($selectedContacts) ) AND
690 civicrm_option_group.name = 'activity_type' AND
691 {$this->_aliases['civicrm_activity']}.is_test = 0 AND
694 GROUP BY {$this->_aliases['civicrm_activity']}.id
696 ORDER BY {$this->_aliases['civicrm_activity']}.activity_date_time desc ";
698 $dao = CRM_Core_DAO
::executeQuery($sql);
699 while ($dao->fetch()) {
700 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
701 if ($key == 'civicrm_activity_source_contact_id') {
702 $row[$key] = $dao->added_by
;
705 $row[$key] = $dao->$key;
708 if (isset($dao->civicrm_activity_source_contact_id
)) {
709 $rows[$dao->civicrm_activity_source_contact_id
][$val][] = $row;
711 if (isset($dao->target_contact_id
)) {
712 $rows[$dao->target_contact_id
][$val][] = $row;
714 if (isset($dao->assignee_contact_id
)) {
715 $rows[$dao->assignee_contact_id
][$val][] = $row;
719 //unset the component header if data is not present
720 foreach ($this->_component
as $val) {
721 if (!in_array($val, $eligibleResult)) {
723 unset($this->_columnHeadersComponent
[$val]);
736 public function statistics(&$rows) {
737 $statistics = array();
739 $count = count($rows);
740 if ($this->_rollup
&& ($this->_rollup
!= '')) {
744 $this->countStat($statistics, $count);
745 $this->filterStat($statistics);
750 //Override to set limit is 10
752 * @param int $rowCount
754 public function limit($rowCount = self
::ROW_COUNT_LIMIT
) {
755 parent
::limit($rowCount);
758 //Override to set pager with limit is 10
760 * @param int $rowCount
762 public function setPager($rowCount = self
::ROW_COUNT_LIMIT
) {
763 parent
::setPager($rowCount);
766 public function postProcess() {
768 $this->beginPostProcess();
770 // get the acl clauses built before we assemble the query
771 $this->buildACLClause($this->_aliases
['civicrm_contact']);
773 $sql = $this->buildQuery(TRUE);
775 $rows = $graphRows = $this->_contactSelected
= array();
776 $this->buildRows($sql, $rows);
777 foreach ($rows as $key => $val) {
778 $rows[$key]['contactID'] = $val['civicrm_contact_id'];
779 $this->_contactSelected
[] = $val['civicrm_contact_id'];
782 $this->formatDisplay($rows);
784 if (!empty($this->_contactSelected
)) {
785 $componentRows = $this->clauseComponent();
786 $this->alterComponentDisplay($componentRows);
788 //unset Conmponent id and contact id from display
789 foreach ($this->_columnHeadersComponent
as $componentTitle => $headers) {
791 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_' .
792 substr_replace($componentTitle, '', -11, 11) . '_id';
794 'civicrm_' . substr_replace($componentTitle, '', -11, 11) .
796 if ($componentTitle == 'activity_civireport') {
798 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_id';
801 unset($this->_columnHeadersComponent
[$componentTitle][$id_header]);
802 unset($this->_columnHeadersComponent
[$componentTitle][$contact_header]);
805 $this->assign_by_ref('columnHeadersComponent', $this->_columnHeadersComponent
);
806 $this->assign_by_ref('componentRows', $componentRows);
809 $this->doTemplateAssignment($rows);
810 $this->endPostProcess();
816 public function alterDisplay(&$rows) {
817 // custom code to alter rows
821 foreach ($rows as $rowNum => $row) {
822 // make count columns point to detail report
824 // change contact name with link
825 if (array_key_exists('civicrm_contact_sort_name', $row) &&
826 array_key_exists('civicrm_contact_id', $row)
829 $url = CRM_Utils_System
::url('civicrm/contact/view',
830 'reset=1&cid=' . $row['civicrm_contact_id'],
833 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
834 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts('View Contact Summary for this Contact');
838 if (array_key_exists('civicrm_address_state_province_id', $row)) {
839 if ($value = $row['civicrm_address_state_province_id']) {
840 $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant
::stateProvince($value, FALSE);
846 // skip looking further in rows, if first row itself doesn't
847 // have the column we need
855 * @param $componentRows
857 public function alterComponentDisplay(&$componentRows) {
858 // custom code to alter rows
859 $activityTypes = CRM_Core_PseudoConstant
::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
860 $activityStatus = CRM_Core_PseudoConstant
::activityStatus();
863 foreach ($componentRows as $contactID => $components) {
864 foreach ($components as $component => $rows) {
865 foreach ($rows as $rowNum => $row) {
866 // handle contribution
867 if ($component == 'contribution_civireport') {
868 if ($val = CRM_Utils_Array
::value('civicrm_contribution_financial_type_id', $row)) {
869 $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_financial_type_id'] =
870 CRM_Contribute_PseudoConstant
::financialType($val, FALSE);
873 if ($val = CRM_Utils_Array
::value('civicrm_contribution_contribution_status_id', $row)) {
874 $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_contribution_status_id'] = CRM_Contribute_PseudoConstant
::contributionStatus($val);
879 if ($component == 'membership_civireport') {
880 if ($val = CRM_Utils_Array
::value('civicrm_membership_membership_type_id', $row)) {
881 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_type_id'] = CRM_Member_PseudoConstant
::membershipType($val, FALSE);
884 if ($val = CRM_Utils_Array
::value('civicrm_membership_status_id', $row)) {
885 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_status_id'] = CRM_Member_PseudoConstant
::membershipStatus($val, FALSE);
890 if ($component == 'participant_civireport') {
891 if ($val = CRM_Utils_Array
::value('civicrm_participant_event_id', $row)) {
892 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant
::event($val, FALSE);
893 $url = CRM_Report_Utils_Report
::getNextUrl('event/income',
894 'reset=1&force=1&id_op=in&id_value=' . $val,
895 $this->_absoluteUrl
, $this->_id
897 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_link'] = $url;
898 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_hover'] = ts('View Event Income details for this Event.');
902 if ($val = CRM_Utils_Array
::value('civicrm_participant_participant_status_id', $row)) {
903 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_participant_status_id'] = CRM_Event_PseudoConstant
::participantStatus($val, FALSE);
905 if ($val = CRM_Utils_Array
::value('civicrm_participant_role_id', $row)) {
906 $roles = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $val);
908 foreach ($roles as $role) {
909 $value[$role] = CRM_Event_PseudoConstant
::participantRole($role, FALSE);
911 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_role_id'] = implode(', ', $value);
917 if ($component == 'activity_civireport') {
918 if ($val = CRM_Utils_Array
::value('civicrm_activity_activity_type_id', $row)) {
919 $componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_type_id'] = $activityTypes[$val];
921 if ($val = CRM_Utils_Array
::value('civicrm_activity_activity_status_id', $row)) {
922 $componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_status_id'] = $activityStatus[$val];
927 if ($component == 'membership_civireport') {
928 if ($val = CRM_Utils_Array
::value('civicrm_membership_membership_status_id', $row)) {
929 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_status_id'] = CRM_Member_PseudoConstant
::membershipStatus($val);
934 // skip looking further in rows, if first row itself doesn't
935 // have the column we need