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'),
79 array('title' => ts('Contact ID'),
83 array('title' => ts('Contact Name'),
86 'grouping' => 'contact-fields',
90 array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'),
95 'dao' => 'CRM_Core_DAO_Address',
96 'grouping' => 'contact-fields',
99 'street_address' => NULL,
101 'postal_code' => NULL,
102 'state_province_id' =>
103 array('title' => ts('State/Province'),
107 array('state_province_id' => array('title' => 'State/Province'),
108 'city' => array('title' => 'City'),
109 'postal_code' => array('title' => 'Postal Code'),
114 'dao' => 'CRM_Core_DAO_Country',
118 array('title' => 'Country', 'default' => TRUE),
123 array('title' => 'Country'),
125 'grouping' => 'contact-fields',
129 'dao' => 'CRM_Core_DAO_Email',
133 array('title' => ts('Email'),
137 'grouping' => 'contact-fields',
141 array('title' => ts('Email'),
145 'civicrm_contribution' =>
147 'dao' => 'CRM_Contribute_DAO_Contribution',
152 'no_display' => TRUE,
156 array('title' => ts('Contribution'),
160 'total_amount' => array('default' => TRUE),
161 'financial_type_id' => array('title' => ts('Financial Type'),
165 'receive_date' => array('default' => TRUE),
166 'receipt_date' => NULL,
167 'contribution_status_id' => array('title' => ts('Contribution Status'),
170 'contribution_source' => NULL,
173 'civicrm_membership' =>
175 'dao' => 'CRM_Member_DAO_Membership',
180 'no_display' => TRUE,
184 array('title' => ts('Membership'),
188 'membership_type_id' => array('title' => ts('Membership Type'),
192 'membership_start_date' => array('title' => ts('Start Date'),
195 'membership_end_date' => array('title' => ts('End Date'),
198 'membership_status_id' => array(
199 'name' => 'status_id',
200 'title' => ts('Membership Status'),
203 'source' => array('title' => 'Membership Source'),
206 'civicrm_participant' =>
208 'dao' => 'CRM_Event_DAO_Participant',
213 'no_display' => TRUE,
217 array('title' => ts('Participant'),
221 'event_id' => array('default' => TRUE),
222 'participant_status_id' => array(
223 'name' => 'status_id',
224 'title' => ts('Participant Status'),
227 'role_id' => array('title' => ts('Role'),
230 'participant_register_date' => array('title' => ts('Register Date'),
233 'fee_level' => array('title' => ts('Fee Level'),
236 'fee_amount' => array('title' => ts('Fee Amount'),
241 'civicrm_relationship' =>
243 'dao' => 'CRM_Contact_DAO_Relationship',
249 'title' => ts('Relationship'),
253 'relationship_type_id' =>
254 array('title' => ts('Relationship Type'),
258 array('title' => ts('Relationship With'),
263 'title' => 'Start Date ',
264 'type' => CRM_Report_Form
::OP_DATE
,
268 'title' => 'End Date ',
269 'type' => CRM_Report_Form
::OP_DATE
,
273 'civicrm_activity' =>
275 'dao' => 'CRM_Activity_DAO_Activity',
279 array('title' => ts('Activity'),
283 'activity_type_id' =>
284 array('title' => ts('Activity Type'),
288 array('title' => ts('Subject'),
291 'activity_date_time' =>
292 array('title' => ts('Activity Date'),
295 'activity_status_id' =>
297 'name' => 'status_id',
298 'title' => ts('Activity Status'),
302 'grouping' => 'activity-fields',
304 'civicrm_activity_target' =>
306 'dao' => 'CRM_Activity_DAO_ActivityContact',
309 'target_contact_id' =>
310 array('title' => ts('With Contact'),
311 'name' => 'contact_id',
315 'grouping' => 'activity-fields',
317 'civicrm_activity_assignment' =>
319 'dao' => 'CRM_Activity_DAO_ActivityContact',
322 'assignee_contact_id' =>
323 array('title' => ts('Assigned To'),
324 'name' => 'contact_id',
328 'grouping' => 'activity-fields',
330 'civicrm_activity_source' =>
332 'dao' => 'CRM_Activity_DAO_ActivityContact',
335 'source_contact_id' =>
337 'title' => ts('Added By'),
338 'name' => 'contact_id',
342 'grouping' => 'activity-fields',
346 'dao' => 'CRM_Contact_DAO_Group',
352 'name' => 'group_id',
353 'title' => ts('Group'),
354 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
356 'options' => CRM_Core_PseudoConstant
::group(),
362 'dao' => 'CRM_Core_DAO_Phone',
368 'title' => ts('Phone Extension')
371 'grouping' => 'contact-fields',
375 $this->_tagFilter
= TRUE;
376 parent
::__construct();
379 function preProcess() {
380 $this->_csvSupported
= FALSE;
381 parent
::preProcess();
386 $this->_columnHeaders
= array();
387 $this->_component
= array('contribution_civireport', 'membership_civireport', 'participant_civireport', 'relationship_civireport', 'activity_civireport');
388 foreach ($this->_columns
as $tableName => $table) {
389 if (array_key_exists('fields', $table)) {
390 foreach ($table['fields'] as $fieldName => $field) {
391 if (CRM_Utils_Array
::value('required', $field) ||
392 CRM_Utils_Array
::value($fieldName, $this->_params
['fields'])
394 //isolate the select clause compoenent wise
395 if (in_array($table['alias'], $this->_component
)) {
396 $select[$table['alias']][] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
397 $this->_columnHeadersComponent
[$table['alias']]["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
398 $this->_columnHeadersComponent
[$table['alias']]["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
400 elseif ($table['alias'] == $this->_aliases
['civicrm_activity_target'] ||
401 $table['alias'] == $this->_aliases
['civicrm_activity_assignment'] ||
402 $table['alias'] == $this->_aliases
['civicrm_activity_source']
404 if ($table['alias'] == $this->_aliases
['civicrm_activity_target']) {
405 $addContactId = 'civicrm_activity_target.contact_id as target_contact_id';
407 elseif ($table['alias'] == $this->_aliases
['civicrm_activity_source']) {
408 $addContactId = 'civicrm_activity_source.contact_id';
411 $addContactId = 'civicrm_activity_assignment.contact_id as assignee_contact_id';
414 $tableName = $table['alias'];
415 $select['activity_civireport'][] = "$tableName.display_name as {$tableName}_{$fieldName}, $addContactId ";
416 $this->_columnHeadersComponent
['activity_civireport']["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
417 $this->_columnHeadersComponent
['activity_civireport']["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
420 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
421 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
422 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = $field['title'];
429 foreach ($this->_component
as $val) {
430 if (CRM_Utils_Array
::value($val, $select)) {
431 $this->_selectComponent
[$val] = "SELECT " . implode(', ', $select[$val]) . " ";
432 unset($select[$val]);
436 $this->_select
= "SELECT " . implode(', ', $select) . " ";
439 static function formRule($fields, $files, $self) {
447 FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom}";
449 if ($this->isTableSelected('civicrm_country') ||
$this->isTableSelected('civicrm_address')) {
451 LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
452 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND
453 {$this->_aliases['civicrm_address']}.is_primary = 1 ) ";
456 if ($this->isTableSelected('civicrm_email')) {
458 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
459 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
460 {$this->_aliases['civicrm_email']}.is_primary = 1) ";
463 if ($this->isTableSelected('civicrm_phone')) {
465 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
466 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
467 {$this->_aliases['civicrm_phone']}.is_primary = 1 ";
470 if ($this->isTableSelected('civicrm_country')) {
472 LEFT JOIN civicrm_country {$this->_aliases['civicrm_country']}
473 ON {$this->_aliases['civicrm_address']}.country_id = {$this->_aliases['civicrm_country']}.id AND
474 {$this->_aliases['civicrm_address']}.is_primary = 1 ";
477 $this->_from
.= "{$group}";
479 foreach ($this->_component
as $val) {
480 if (CRM_Utils_Array
::value('contribution_civireport', $this->_selectComponent
)) {
481 $this->_formComponent
['contribution_civireport'] = " FROM
482 civicrm_contact {$this->_aliases['civicrm_contact']}
483 INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
484 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id
488 if (CRM_Utils_Array
::value('membership_civireport', $this->_selectComponent
)) {
489 $this->_formComponent
['membership_civireport'] = " FROM
490 civicrm_contact {$this->_aliases['civicrm_contact']}
491 INNER JOIN civicrm_membership {$this->_aliases['civicrm_membership']}
492 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_membership']}.contact_id
495 if (CRM_Utils_Array
::value('participant_civireport', $this->_selectComponent
)) {
496 $this->_formComponent
['participant_civireport'] = " FROM
497 civicrm_contact {$this->_aliases['civicrm_contact']}
498 INNER JOIN civicrm_participant {$this->_aliases['civicrm_participant']}
499 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_participant']}.contact_id
503 if (CRM_Utils_Array
::value('activity_civireport', $this->_selectComponent
)) {
504 $activityContacts = CRM_Core_OptionGroup
::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
505 $assigneeID = CRM_Utils_Array
::key('Activity Assignees', $activityContacts);
506 $targetID = CRM_Utils_Array
::key('Activity Targets', $activityContacts);
507 $sourceID = CRM_Utils_Array
::key('Activity Source', $activityContacts);
509 $this->_formComponent
['activity_civireport'] = "FROM
510 civicrm_activity {$this->_aliases['civicrm_activity']}
511 LEFT JOIN civicrm_activity_contact civicrm_activity_target ON
512 {$this->_aliases['civicrm_activity']}.id = civicrm_activity_target.activity_id AND
513 civicrm_activity_target.record_type_id = {$targetID}
514 LEFT JOIN civicrm_activity_contact civicrm_activity_assignment ON
515 {$this->_aliases['civicrm_activity']}.id = civicrm_activity_assignment.activity_id AND civicrm_activity_assignment.record_type_id = {$assigneeID}
516 LEFT JOIN civicrm_activity_contact civicrm_activity_source
517 ON {$this->_aliases['civicrm_activity']}.id = civicrm_activity_source.activity_id AND
518 civicrm_activity_source.record_type_id = {$sourceID}
519 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_target']} ON
520 civicrm_activity_target.contact_id = {$this->_aliases['civicrm_activity_target']}.id
522 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_assignment']} ON
523 civicrm_activity_assignment.contact_id = {$this->_aliases['civicrm_activity_assignment']}.id
524 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_source']} ON
525 civicrm_activity_source.contact_id = {$this->_aliases['civicrm_activity_source']}.id
526 LEFT JOIN civicrm_option_value ON
527 ( {$this->_aliases['civicrm_activity']}.activity_type_id = civicrm_option_value.value )
528 LEFT JOIN civicrm_option_group ON
529 civicrm_option_group.id = civicrm_option_value.option_group_id
530 LEFT JOIN civicrm_case_activity ON
531 civicrm_case_activity.activity_id = {$this->_aliases['civicrm_activity']}.id
532 LEFT JOIN civicrm_case ON
533 civicrm_case_activity.case_id = civicrm_case.id
534 LEFT JOIN civicrm_case_contact ON
535 civicrm_case_contact.case_id = civicrm_case.id ";
538 if (CRM_Utils_Array
::value('relationship_civireport', $this->_selectComponent
)) {
539 $this->_formComponent
['relationship_civireport'] = "FROM
540 civicrm_relationship {$this->_aliases['civicrm_relationship']}
542 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']} ON
543 {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_relationship']}.contact_id_b
544 LEFT JOIN civicrm_contact contact_a ON
545 contact_a.id = {$this->_aliases['civicrm_relationship']}.contact_id_a ";
553 foreach ($this->_columns
as $tableName => $table) {
554 if (array_key_exists('filters', $table)) {
555 foreach ($table['filters'] as $fieldName => $field) {
557 if (CRM_Utils_Array
::value('operatorType', $field) & CRM_Report_Form
::OP_DATE
) {
558 $relative = CRM_Utils_Array
::value("{$fieldName}_relative", $this->_params
);
559 $from = CRM_Utils_Array
::value("{$fieldName}_from", $this->_params
);
560 $to = CRM_Utils_Array
::value("{$fieldName}_to", $this->_params
);
562 $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to);
565 $op = CRM_Utils_Array
::value("{$fieldName}_op", $this->_params
);
566 $clause = $this->whereClause($field,
568 CRM_Utils_Array
::value("{$fieldName}_value", $this->_params
),
569 CRM_Utils_Array
::value("{$fieldName}_min", $this->_params
),
570 CRM_Utils_Array
::value("{$fieldName}_max", $this->_params
)
573 if (!empty($clause)) {
574 $clauses[] = $clause;
580 if (empty($clauses)) {
581 $this->_where
= "WHERE ( 1 ) ";
584 $this->_where
= "WHERE " . implode(' AND ', $clauses);
587 if ($this->_aclWhere
) {
588 $this->_where
.= " AND {$this->_aclWhere} ";
591 $this->_where
.= " GROUP BY {$this->_aliases['civicrm_contact']}.id ";
594 function clauseComponent() {
595 $selectedContacts = implode(',', $this->_contactSelected
);
596 $contribution = $membership = $participant = NULL;
597 $eligibleResult = $rows = $tempArray = array();
598 foreach ($this->_component
as $val) {
599 if (CRM_Utils_Array
::value($val, $this->_selectComponent
) && ($val != 'activity_civireport' && $val != 'relationship_civireport')) {
600 $sql = "{$this->_selectComponent[$val]} {$this->_formComponent[$val]}
601 WHERE {$this->_aliases['civicrm_contact']}.id IN ( $selectedContacts )
602 GROUP BY {$this->_aliases['civicrm_contact']}.id,{$val}.id ";
604 $dao = CRM_Core_DAO
::executeQuery($sql);
605 while ($dao->fetch()) {
607 $eligibleResult[$val] = $val;
608 $CC = 'civicrm_' . substr_replace($val, '', -11, 11) . '_contact_id';
610 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
612 $row[$key] = $dao->$key;
615 //if record exist for component(except contact_id)
616 //since contact_id is selected for every component
617 if ($countRecord > 1) {
618 $rows[$dao->$CC][$val][] = $row;
620 $tempArray[$dao->$CC] = $dao->$CC;
625 if (CRM_Utils_Array
::value('relationship_civireport', $this->_selectComponent
)) {
627 $relTypes = CRM_Contact_BAO_Relationship
::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE);
629 $val = 'relationship_civireport';
630 $eligibleResult[$val] = $val;
631 $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]}
632 WHERE ({$this->_aliases['civicrm_contact']}.id IN ( $selectedContacts )
634 contact_a.id IN ( $selectedContacts ) ) AND
635 {$this->_aliases['civicrm_relationship']}.is_active = 1 AND
636 contact_a.is_deleted = 0 AND
637 {$this->_aliases['civicrm_contact']}.is_deleted = 0
638 GROUP BY {$this->_aliases['civicrm_relationship']}.id";
640 $dao = CRM_Core_DAO
::executeQuery($sql);
641 while ($dao->fetch()) {
642 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
643 if ($key == 'civicrm_relationship_contact_id_b') {
644 $row[$key] = $dao->contact_b_name
;
648 $row[$key] = $dao->$key;
651 $relTitle = "" . $dao->civicrm_relationship_relationship_type_id
. '_a_b';
652 $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle];
654 $rows[$dao->contact_a_id
][$val][] = $row;
656 $row['civicrm_relationship_contact_id_b'] = $dao->contact_a_name
;
657 $relTitle = "" . $dao->civicrm_relationship_relationship_type_id
. '_b_a';
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 (CRM_Utils_Array
::value('activity_civireport', $this->_selectComponent
)) {
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 . ', ' . $compObj->componentID
) : $compObj->componentID
;
676 $componentClause = "( $componentClause OR
677 civicrm_option_value.component_id IN ($componentsIn) )";
680 $val = 'activity_civireport';
681 $eligibleResult[$val] = $val;
682 $sql = "{$this->_selectComponent[$val]} ,
683 {$this->_aliases['civicrm_activity_source']}.display_name as added_by {$this->_formComponent[$val]}
685 WHERE ( civicrm_activity_source.contact_id IN ($selectedContacts) OR
686 civicrm_activity_target.contact_id IN ($selectedContacts) OR
687 civicrm_activity_assignment.contact_id IN ($selectedContacts) OR
688 civicrm_case_contact.contact_id IN ($selectedContacts) ) AND
689 civicrm_option_group.name = 'activity_type' AND
690 {$this->_aliases['civicrm_activity']}.is_test = 0 AND
693 GROUP BY {$this->_aliases['civicrm_activity']}.id
695 ORDER BY {$this->_aliases['civicrm_activity']}.activity_date_time desc ";
697 $dao = CRM_Core_DAO
::executeQuery($sql);
698 while ($dao->fetch()) {
699 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
700 if ($key == 'civicrm_activity_source_contact_id') {
701 $row[$key] = $dao->added_by
;
704 $row[$key] = $dao->$key;
707 if (isset($dao->civicrm_activity_source_contact_id
)) {
708 $rows[$dao->civicrm_activity_source_contact_id
][$val][] = $row;
710 if (isset($dao->target_contact_id
)) {
711 $rows[$dao->target_contact_id
][$val][] = $row;
713 if (isset($dao->assignee_contact_id
)) {
714 $rows[$dao->assignee_contact_id
][$val][] = $row;
718 //unset the component header if data is not present
719 foreach ($this->_component
as $val) {
720 if (!in_array($val, $eligibleResult)) {
722 unset($this->_columnHeadersComponent
[$val]);
730 function statistics(&$rows) {
731 $statistics = array();
733 $count = count($rows);
734 if ($this->_rollup
&& ($this->_rollup
!= '')) {
738 $this->countStat($statistics, $count);
739 $this->filterStat($statistics);
744 //Override to set limit is 10
745 function limit($rowCount = self
::ROW_COUNT_LIMIT
) {
746 parent
::limit($rowCount);
749 //Override to set pager with limit is 10
750 function setPager($rowCount = self
::ROW_COUNT_LIMIT
) {
751 parent
::setPager($rowCount);
754 function postProcess() {
756 $this->beginPostProcess();
758 // get the acl clauses built before we assemble the query
759 $this->buildACLClause($this->_aliases
['civicrm_contact']);
761 $sql = $this->buildQuery(TRUE);
763 $rows = $graphRows = $this->_contactSelected
= array();
764 $this->buildRows($sql, $rows);
765 foreach ($rows as $key => $val) {
766 $rows[$key]['contactID'] = $val['civicrm_contact_id'];
767 $this->_contactSelected
[] = $val['civicrm_contact_id'];
770 $this->formatDisplay($rows);
772 if (!empty($this->_contactSelected
)) {
773 $componentRows = $this->clauseComponent();
774 $this->alterComponentDisplay($componentRows);
776 //unset Conmponent id and contact id from display
777 foreach ($this->_columnHeadersComponent
as $componentTitle => $headers) {
778 $id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_' . substr_replace($componentTitle, '', -11, 11) . '_id';
779 $contact_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_contact_id';
780 if ($componentTitle == 'activity_civireport') {
781 $id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_id';
784 unset($this->_columnHeadersComponent
[$componentTitle][$id_header]);
785 unset($this->_columnHeadersComponent
[$componentTitle][$contact_header]);
788 $this->assign_by_ref('columnHeadersComponent', $this->_columnHeadersComponent
);
789 $this->assign_by_ref('componentRows', $componentRows);
792 $this->doTemplateAssignment($rows);
793 $this->endPostProcess();
796 function alterDisplay(&$rows) {
797 // custom code to alter rows
801 foreach ($rows as $rowNum => $row) {
802 // make count columns point to detail report
804 // change contact name with link
805 if (array_key_exists('civicrm_contact_sort_name', $row) &&
806 array_key_exists('civicrm_contact_id', $row)
809 $url = CRM_Utils_System
::url('civicrm/contact/view',
810 'reset=1&cid=' . $row['civicrm_contact_id'],
813 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
814 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts('View Contact Summary for this Contact');
818 if (array_key_exists('civicrm_address_state_province_id', $row)) {
819 if ($value = $row['civicrm_address_state_province_id']) {
820 $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant
::stateProvince($value, FALSE);
826 // skip looking further in rows, if first row itself doesn't
827 // have the column we need
834 function alterComponentDisplay(&$componentRows) {
835 // custom code to alter rows
836 $activityTypes = CRM_Core_PseudoConstant
::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
837 $activityStatus = CRM_Core_PseudoConstant
::activityStatus();
840 foreach ($componentRows as $contactID => $components) {
841 foreach ($components as $component => $rows) {
842 foreach ($rows as $rowNum => $row) {
843 // handle contribution
844 if ($component == 'contribution_civireport') {
845 if ($val = CRM_Utils_Array
::value('civicrm_contribution_financial_type_id', $row)) {
846 $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_financial_type_id'] =
847 CRM_Contribute_PseudoConstant
::financialType($val, false);
850 if ($val = CRM_Utils_Array
::value('civicrm_contribution_contribution_status_id', $row)) {
851 $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_contribution_status_id'] = CRM_Contribute_PseudoConstant
::contributionStatus($val);
856 if ($component == 'membership_civireport') {
857 if ($val = CRM_Utils_Array
::value('civicrm_membership_membership_type_id', $row)) {
858 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_type_id'] = CRM_Member_PseudoConstant
::membershipType($val, FALSE);
861 if ($val = CRM_Utils_Array
::value('civicrm_membership_status_id', $row)) {
862 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_status_id'] = CRM_Member_PseudoConstant
::membershipStatus($val, FALSE);
867 if ($component == 'participant_civireport') {
868 if ($val = CRM_Utils_Array
::value('civicrm_participant_event_id', $row)) {
869 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant
::event($val, FALSE);
870 $url = CRM_Report_Utils_Report
::getNextUrl('event/income',
871 'reset=1&force=1&id_op=in&id_value=' . $val,
872 $this->_absoluteUrl
, $this->_id
874 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_link'] = $url;
875 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_hover'] = ts('View Event Income details for this Event.');
879 if ($val = CRM_Utils_Array
::value('civicrm_participant_participant_status_id', $row)) {
880 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_participant_status_id'] = CRM_Event_PseudoConstant
::participantStatus($val, FALSE);
882 if ($val = CRM_Utils_Array
::value('civicrm_participant_role_id', $row)) {
883 $roles = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $val);
885 foreach ($roles as $role) {
886 $value[$role] = CRM_Event_PseudoConstant
::participantRole($role, FALSE);
888 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_role_id'] = implode(', ', $value);
894 if ($component == 'activity_civireport') {
895 if ($val = CRM_Utils_Array
::value('civicrm_activity_activity_type_id', $row)) {
896 $componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_type_id'] = $activityTypes[$val];
898 if ($val = CRM_Utils_Array
::value('civicrm_activity_activity_status_id', $row)) {
899 $componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_status_id'] = $activityStatus[$val];
904 if ($component == 'membership_civireport') {
905 if ($val = CRM_Utils_Array
::value('civicrm_membership_membership_status_id', $row)) {
906 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_status_id'] = CRM_Member_PseudoConstant
::membershipStatus($val);
911 // skip looking further in rows, if first row itself doesn't
912 // have the column we need