3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
35 class CRM_Report_Form_Contact_Detail
extends CRM_Report_Form
{
36 CONST ROW_COUNT_LIMIT
= 10;
38 protected $_summary = NULL;
40 protected $_customGroupExtends = array(
41 'Contact', 'Individual', 'Household', 'Organization');
49 function __construct() {
50 $this->_autoIncludeIndexedFieldsAsOrderBys
= 1;
51 $this->_columns
= array(
54 'dao' => 'CRM_Contact_DAO_Contact',
58 array('title' => ts('Contact Name'),
62 'first_name' => array(
63 'title' => ts('First Name'),
66 'title' => ts('Last Name'),
75 'title' => ts('Contact Type'),
79 'title' => ts('Contact SubType'),
83 'title' => ts('Birth Date'),
89 array('title' => ts('Contact ID'),
93 array('title' => ts('Contact Name'),
97 'title' => ts('Birth Date'),
98 'operatorType' => CRM_Report_Form
::OP_DATE
,
101 'grouping' => 'contact-fields',
105 array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'),
110 'dao' => 'CRM_Core_DAO_Address',
111 'grouping' => 'contact-fields',
114 'street_address' => NULL,
116 'postal_code' => NULL,
117 'state_province_id' =>
118 array('title' => ts('State/Province'),
122 array('state_province_id' => array('title' => 'State/Province'),
123 'city' => array('title' => 'City'),
124 'postal_code' => array('title' => 'Postal Code'),
129 'dao' => 'CRM_Core_DAO_Country',
133 array('title' => 'Country', 'default' => TRUE),
138 array('title' => 'Country'),
140 'grouping' => 'contact-fields',
144 'dao' => 'CRM_Core_DAO_Email',
148 array('title' => ts('Email'),
152 'grouping' => 'contact-fields',
156 array('title' => ts('Email'),
160 'civicrm_contribution' =>
162 'dao' => 'CRM_Contribute_DAO_Contribution',
167 'no_display' => TRUE,
171 array('title' => ts('Contribution'),
175 'total_amount' => array('default' => TRUE),
176 'financial_type_id' => array('title' => ts('Financial Type'),
180 'receive_date' => array('default' => TRUE),
181 'receipt_date' => NULL,
182 'contribution_status_id' => array('title' => ts('Contribution Status'),
185 'contribution_source' => NULL,
188 'civicrm_membership' =>
190 'dao' => 'CRM_Member_DAO_Membership',
195 'no_display' => TRUE,
199 array('title' => ts('Membership'),
203 'membership_type_id' => array('title' => ts('Membership Type'),
207 'membership_start_date' => array('title' => ts('Start Date'),
210 'membership_end_date' => array('title' => ts('End Date'),
213 'membership_status_id' => array(
214 'name' => 'status_id',
215 'title' => ts('Membership Status'),
218 'source' => array('title' => 'Membership Source'),
221 'civicrm_participant' =>
223 'dao' => 'CRM_Event_DAO_Participant',
228 'no_display' => TRUE,
232 array('title' => ts('Participant'),
236 'event_id' => array('default' => TRUE),
237 'participant_status_id' => array(
238 'name' => 'status_id',
239 'title' => ts('Participant Status'),
242 'role_id' => array('title' => ts('Role'),
245 'participant_register_date' => array('title' => ts('Register Date'),
248 'fee_level' => array('title' => ts('Fee Level'),
251 'fee_amount' => array('title' => ts('Fee Amount'),
256 'civicrm_relationship' =>
258 'dao' => 'CRM_Contact_DAO_Relationship',
264 'title' => ts('Relationship'),
268 'relationship_type_id' =>
269 array('title' => ts('Relationship Type'),
273 array('title' => ts('Relationship With'),
278 'title' => 'Start Date ',
279 'type' => CRM_Report_Form
::OP_DATE
,
283 'title' => 'End Date ',
284 'type' => CRM_Report_Form
::OP_DATE
,
288 'civicrm_activity' =>
290 'dao' => 'CRM_Activity_DAO_Activity',
294 array('title' => ts('Activity'),
298 'activity_type_id' =>
299 array('title' => ts('Activity Type'),
303 array('title' => ts('Subject'),
306 'activity_date_time' =>
307 array('title' => ts('Activity Date'),
310 'activity_status_id' =>
312 'name' => 'status_id',
313 'title' => ts('Activity Status'),
317 'grouping' => 'activity-fields',
319 'civicrm_activity_target' =>
321 'dao' => 'CRM_Activity_DAO_ActivityContact',
324 'target_contact_id' =>
325 array('title' => ts('With Contact'),
326 'name' => 'contact_id',
330 'grouping' => 'activity-fields',
332 'civicrm_activity_assignment' =>
334 'dao' => 'CRM_Activity_DAO_ActivityContact',
337 'assignee_contact_id' =>
338 array('title' => ts('Assigned To'),
339 'name' => 'contact_id',
343 'grouping' => 'activity-fields',
345 'civicrm_activity_source' =>
347 'dao' => 'CRM_Activity_DAO_ActivityContact',
350 'source_contact_id' =>
352 'title' => ts('Added By'),
353 'name' => 'contact_id',
357 'grouping' => 'activity-fields',
361 'dao' => 'CRM_Contact_DAO_Group',
367 'name' => 'group_id',
368 'title' => ts('Group'),
369 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
371 'options' => CRM_Core_PseudoConstant
::group(),
377 'dao' => 'CRM_Core_DAO_Phone',
383 'title' => ts('Phone Extension')
386 'grouping' => 'contact-fields',
390 $this->_tagFilter
= TRUE;
391 parent
::__construct();
394 function preProcess() {
395 $this->_csvSupported
= FALSE;
396 parent
::preProcess();
401 $this->_columnHeaders
= array();
402 $this->_component
= array('contribution_civireport', 'membership_civireport', 'participant_civireport', 'relationship_civireport', 'activity_civireport');
403 foreach ($this->_columns
as $tableName => $table) {
404 if (array_key_exists('fields', $table)) {
405 foreach ($table['fields'] as $fieldName => $field) {
406 if (!empty($field['required']) ||
!empty($this->_params
['fields'][$fieldName])) {
407 //isolate the select clause compoenent wise
408 if (in_array($table['alias'], $this->_component
)) {
409 $select[$table['alias']][] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
410 $this->_columnHeadersComponent
[$table['alias']]["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
411 $this->_columnHeadersComponent
[$table['alias']]["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
413 elseif ($table['alias'] == $this->_aliases
['civicrm_activity_target'] ||
414 $table['alias'] == $this->_aliases
['civicrm_activity_assignment'] ||
415 $table['alias'] == $this->_aliases
['civicrm_activity_source']
417 if ($table['alias'] == $this->_aliases
['civicrm_activity_target']) {
418 $addContactId = 'civicrm_activity_target.contact_id as target_contact_id';
420 elseif ($table['alias'] == $this->_aliases
['civicrm_activity_source']) {
421 $addContactId = 'civicrm_activity_source.contact_id';
424 $addContactId = 'civicrm_activity_assignment.contact_id as assignee_contact_id';
427 $tableName = $table['alias'];
428 $select['activity_civireport'][] = "$tableName.display_name as {$tableName}_{$fieldName}, $addContactId ";
429 $this->_columnHeadersComponent
['activity_civireport']["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
430 $this->_columnHeadersComponent
['activity_civireport']["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
433 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
434 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
435 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = $field['title'];
442 foreach ($this->_component
as $val) {
443 if (!empty($select[$val])) {
444 $this->_selectComponent
[$val] = "SELECT " . implode(', ', $select[$val]) . " ";
445 unset($select[$val]);
449 $this->_select
= "SELECT " . implode(', ', $select) . " ";
459 static function formRule($fields, $files, $self) {
467 FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom}";
469 if ($this->isTableSelected('civicrm_country') ||
$this->isTableSelected('civicrm_address')) {
471 LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
472 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND
473 {$this->_aliases['civicrm_address']}.is_primary = 1 ) ";
476 if ($this->isTableSelected('civicrm_email')) {
478 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
479 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
480 {$this->_aliases['civicrm_email']}.is_primary = 1) ";
483 if ($this->isTableSelected('civicrm_phone')) {
485 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
486 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
487 {$this->_aliases['civicrm_phone']}.is_primary = 1 ";
490 if ($this->isTableSelected('civicrm_country')) {
492 LEFT JOIN civicrm_country {$this->_aliases['civicrm_country']}
493 ON {$this->_aliases['civicrm_address']}.country_id = {$this->_aliases['civicrm_country']}.id AND
494 {$this->_aliases['civicrm_address']}.is_primary = 1 ";
497 $this->_from
.= "{$group}";
499 foreach ($this->_component
as $val) {
500 if (!empty($this->_selectComponent
['contribution_civireport'])) {
501 $this->_formComponent
['contribution_civireport'] = " FROM
502 civicrm_contact {$this->_aliases['civicrm_contact']}
503 INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
504 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id
508 if (!empty($this->_selectComponent
['membership_civireport'])) {
509 $this->_formComponent
['membership_civireport'] = " FROM
510 civicrm_contact {$this->_aliases['civicrm_contact']}
511 INNER JOIN civicrm_membership {$this->_aliases['civicrm_membership']}
512 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_membership']}.contact_id
515 if (!empty($this->_selectComponent
['participant_civireport'])) {
516 $this->_formComponent
['participant_civireport'] = " FROM
517 civicrm_contact {$this->_aliases['civicrm_contact']}
518 INNER JOIN civicrm_participant {$this->_aliases['civicrm_participant']}
519 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_participant']}.contact_id
523 if (!empty($this->_selectComponent
['activity_civireport'])) {
524 $activityContacts = CRM_Core_OptionGroup
::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
525 $assigneeID = CRM_Utils_Array
::key('Activity Assignees', $activityContacts);
526 $targetID = CRM_Utils_Array
::key('Activity Targets', $activityContacts);
527 $sourceID = CRM_Utils_Array
::key('Activity Source', $activityContacts);
529 $this->_formComponent
['activity_civireport'] = "FROM
530 civicrm_activity {$this->_aliases['civicrm_activity']}
531 LEFT JOIN civicrm_activity_contact civicrm_activity_target ON
532 {$this->_aliases['civicrm_activity']}.id = civicrm_activity_target.activity_id AND
533 civicrm_activity_target.record_type_id = {$targetID}
534 LEFT JOIN civicrm_activity_contact civicrm_activity_assignment ON
535 {$this->_aliases['civicrm_activity']}.id = civicrm_activity_assignment.activity_id AND civicrm_activity_assignment.record_type_id = {$assigneeID}
536 LEFT JOIN civicrm_activity_contact civicrm_activity_source
537 ON {$this->_aliases['civicrm_activity']}.id = civicrm_activity_source.activity_id AND
538 civicrm_activity_source.record_type_id = {$sourceID}
539 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_target']} ON
540 civicrm_activity_target.contact_id = {$this->_aliases['civicrm_activity_target']}.id
542 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_assignment']} ON
543 civicrm_activity_assignment.contact_id = {$this->_aliases['civicrm_activity_assignment']}.id
544 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_source']} ON
545 civicrm_activity_source.contact_id = {$this->_aliases['civicrm_activity_source']}.id
546 LEFT JOIN civicrm_option_value ON
547 ( {$this->_aliases['civicrm_activity']}.activity_type_id = civicrm_option_value.value )
548 LEFT JOIN civicrm_option_group ON
549 civicrm_option_group.id = civicrm_option_value.option_group_id
550 LEFT JOIN civicrm_case_activity ON
551 civicrm_case_activity.activity_id = {$this->_aliases['civicrm_activity']}.id
552 LEFT JOIN civicrm_case ON
553 civicrm_case_activity.case_id = civicrm_case.id
554 LEFT JOIN civicrm_case_contact ON
555 civicrm_case_contact.case_id = civicrm_case.id ";
558 if (!empty($this->_selectComponent
['relationship_civireport'])) {
559 $this->_formComponent
['relationship_civireport'] = "FROM
560 civicrm_relationship {$this->_aliases['civicrm_relationship']}
562 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']} ON
563 {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_relationship']}.contact_id_b
564 LEFT JOIN civicrm_contact contact_a ON
565 contact_a.id = {$this->_aliases['civicrm_relationship']}.contact_id_a ";
573 foreach ($this->_columns
as $tableName => $table) {
574 if (array_key_exists('filters', $table)) {
575 foreach ($table['filters'] as $fieldName => $field) {
577 if (CRM_Utils_Array
::value('operatorType', $field) & CRM_Report_Form
::OP_DATE
) {
578 $relative = CRM_Utils_Array
::value("{$fieldName}_relative", $this->_params
);
579 $from = CRM_Utils_Array
::value("{$fieldName}_from", $this->_params
);
580 $to = CRM_Utils_Array
::value("{$fieldName}_to", $this->_params
);
582 $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to);
585 $op = CRM_Utils_Array
::value("{$fieldName}_op", $this->_params
);
586 $clause = $this->whereClause($field,
588 CRM_Utils_Array
::value("{$fieldName}_value", $this->_params
),
589 CRM_Utils_Array
::value("{$fieldName}_min", $this->_params
),
590 CRM_Utils_Array
::value("{$fieldName}_max", $this->_params
)
593 if (!empty($clause)) {
594 $clauses[] = $clause;
600 if (empty($clauses)) {
601 $this->_where
= "WHERE ( 1 ) ";
604 $this->_where
= "WHERE " . implode(' AND ', $clauses);
607 if ($this->_aclWhere
) {
608 $this->_where
.= " AND {$this->_aclWhere} ";
611 $this->_where
.= " GROUP BY {$this->_aliases['civicrm_contact']}.id ";
617 function clauseComponent() {
618 $selectedContacts = implode(',', $this->_contactSelected
);
619 $contribution = $membership = $participant = NULL;
620 $eligibleResult = $rows = $tempArray = array();
621 foreach ($this->_component
as $val) {
622 if (!empty($this->_selectComponent
[$val]) && ($val != 'activity_civireport' && $val != 'relationship_civireport')) {
623 $sql = "{$this->_selectComponent[$val]} {$this->_formComponent[$val]}
624 WHERE {$this->_aliases['civicrm_contact']}.id IN ( $selectedContacts )
625 GROUP BY {$this->_aliases['civicrm_contact']}.id,{$val}.id ";
627 $dao = CRM_Core_DAO
::executeQuery($sql);
628 while ($dao->fetch()) {
630 $eligibleResult[$val] = $val;
631 $CC = 'civicrm_' . substr_replace($val, '', -11, 11) . '_contact_id';
633 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
635 $row[$key] = $dao->$key;
638 //if record exist for component(except contact_id)
639 //since contact_id is selected for every component
640 if ($countRecord > 1) {
641 $rows[$dao->$CC][$val][] = $row;
643 $tempArray[$dao->$CC] = $dao->$CC;
648 if (!empty($this->_selectComponent
['relationship_civireport'])) {
650 $relTypes = CRM_Contact_BAO_Relationship
::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE);
652 $val = 'relationship_civireport';
653 $eligibleResult[$val] = $val;
654 $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]}
655 WHERE ({$this->_aliases['civicrm_contact']}.id IN ( $selectedContacts )
657 contact_a.id IN ( $selectedContacts ) ) AND
658 {$this->_aliases['civicrm_relationship']}.is_active = 1 AND
659 contact_a.is_deleted = 0 AND
660 {$this->_aliases['civicrm_contact']}.is_deleted = 0
661 GROUP BY {$this->_aliases['civicrm_relationship']}.id";
663 $dao = CRM_Core_DAO
::executeQuery($sql);
664 while ($dao->fetch()) {
665 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
666 if ($key == 'civicrm_relationship_contact_id_b') {
667 $row[$key] = $dao->contact_b_name
;
671 $row[$key] = $dao->$key;
674 $relTitle = "" . $dao->civicrm_relationship_relationship_type_id
. '_a_b';
675 $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle];
677 $rows[$dao->contact_a_id
][$val][] = $row;
679 $row['civicrm_relationship_contact_id_b'] = $dao->contact_a_name
;
680 $relTitle = "" . $dao->civicrm_relationship_relationship_type_id
. '_b_a';
681 if (isset($relTypes[$relTitle])) {
682 $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle];
684 $rows[$dao->civicrm_relationship_contact_id_b
][$val][] = $row;
688 if (!empty($this->_selectComponent
['activity_civireport'])) {
690 $componentClause = "civicrm_option_value.component_id IS NULL";
691 $componentsIn = NULL;
692 $compInfo = CRM_Core_Component
::getEnabledComponents();
693 foreach ($compInfo as $compObj) {
694 if ($compObj->info
['showActivitiesInCore']) {
695 $componentsIn = $componentsIn ?
($componentsIn . ', ' . $compObj->componentID
) : $compObj->componentID
;
699 $componentClause = "( $componentClause OR
700 civicrm_option_value.component_id IN ($componentsIn) )";
703 $val = 'activity_civireport';
704 $eligibleResult[$val] = $val;
705 $sql = "{$this->_selectComponent[$val]} ,
706 {$this->_aliases['civicrm_activity_source']}.display_name as added_by {$this->_formComponent[$val]}
708 WHERE ( civicrm_activity_source.contact_id IN ($selectedContacts) OR
709 civicrm_activity_target.contact_id IN ($selectedContacts) OR
710 civicrm_activity_assignment.contact_id IN ($selectedContacts) OR
711 civicrm_case_contact.contact_id IN ($selectedContacts) ) AND
712 civicrm_option_group.name = 'activity_type' AND
713 {$this->_aliases['civicrm_activity']}.is_test = 0 AND
716 GROUP BY {$this->_aliases['civicrm_activity']}.id
718 ORDER BY {$this->_aliases['civicrm_activity']}.activity_date_time desc ";
720 $dao = CRM_Core_DAO
::executeQuery($sql);
721 while ($dao->fetch()) {
722 foreach ($this->_columnHeadersComponent
[$val] as $key => $value) {
723 if ($key == 'civicrm_activity_source_contact_id') {
724 $row[$key] = $dao->added_by
;
727 $row[$key] = $dao->$key;
730 if (isset($dao->civicrm_activity_source_contact_id
)) {
731 $rows[$dao->civicrm_activity_source_contact_id
][$val][] = $row;
733 if (isset($dao->target_contact_id
)) {
734 $rows[$dao->target_contact_id
][$val][] = $row;
736 if (isset($dao->assignee_contact_id
)) {
737 $rows[$dao->assignee_contact_id
][$val][] = $row;
741 //unset the component header if data is not present
742 foreach ($this->_component
as $val) {
743 if (!in_array($val, $eligibleResult)) {
745 unset($this->_columnHeadersComponent
[$val]);
758 function statistics(&$rows) {
759 $statistics = array();
761 $count = count($rows);
762 if ($this->_rollup
&& ($this->_rollup
!= '')) {
766 $this->countStat($statistics, $count);
767 $this->filterStat($statistics);
772 //Override to set limit is 10
774 * @param int $rowCount
776 function limit($rowCount = self
::ROW_COUNT_LIMIT
) {
777 parent
::limit($rowCount);
780 //Override to set pager with limit is 10
782 * @param int $rowCount
784 function setPager($rowCount = self
::ROW_COUNT_LIMIT
) {
785 parent
::setPager($rowCount);
788 function postProcess() {
790 $this->beginPostProcess();
792 // get the acl clauses built before we assemble the query
793 $this->buildACLClause($this->_aliases
['civicrm_contact']);
795 $sql = $this->buildQuery(TRUE);
797 $rows = $graphRows = $this->_contactSelected
= array();
798 $this->buildRows($sql, $rows);
799 foreach ($rows as $key => $val) {
800 $rows[$key]['contactID'] = $val['civicrm_contact_id'];
801 $this->_contactSelected
[] = $val['civicrm_contact_id'];
804 $this->formatDisplay($rows);
806 if (!empty($this->_contactSelected
)) {
807 $componentRows = $this->clauseComponent();
808 $this->alterComponentDisplay($componentRows);
810 //unset Conmponent id and contact id from display
811 foreach ($this->_columnHeadersComponent
as $componentTitle => $headers) {
812 $id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_' . substr_replace($componentTitle, '', -11, 11) . '_id';
813 $contact_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_contact_id';
814 if ($componentTitle == 'activity_civireport') {
815 $id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_id';
818 unset($this->_columnHeadersComponent
[$componentTitle][$id_header]);
819 unset($this->_columnHeadersComponent
[$componentTitle][$contact_header]);
822 $this->assign_by_ref('columnHeadersComponent', $this->_columnHeadersComponent
);
823 $this->assign_by_ref('componentRows', $componentRows);
826 $this->doTemplateAssignment($rows);
827 $this->endPostProcess();
833 function alterDisplay(&$rows) {
834 // custom code to alter rows
838 foreach ($rows as $rowNum => $row) {
839 // make count columns point to detail report
841 // change contact name with link
842 if (array_key_exists('civicrm_contact_sort_name', $row) &&
843 array_key_exists('civicrm_contact_id', $row)
846 $url = CRM_Utils_System
::url('civicrm/contact/view',
847 'reset=1&cid=' . $row['civicrm_contact_id'],
850 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
851 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts('View Contact Summary for this Contact');
855 if (array_key_exists('civicrm_address_state_province_id', $row)) {
856 if ($value = $row['civicrm_address_state_province_id']) {
857 $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant
::stateProvince($value, FALSE);
863 // skip looking further in rows, if first row itself doesn't
864 // have the column we need
872 * @param $componentRows
874 function alterComponentDisplay(&$componentRows) {
875 // custom code to alter rows
876 $activityTypes = CRM_Core_PseudoConstant
::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
877 $activityStatus = CRM_Core_PseudoConstant
::activityStatus();
880 foreach ($componentRows as $contactID => $components) {
881 foreach ($components as $component => $rows) {
882 foreach ($rows as $rowNum => $row) {
883 // handle contribution
884 if ($component == 'contribution_civireport') {
885 if ($val = CRM_Utils_Array
::value('civicrm_contribution_financial_type_id', $row)) {
886 $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_financial_type_id'] =
887 CRM_Contribute_PseudoConstant
::financialType($val, false);
890 if ($val = CRM_Utils_Array
::value('civicrm_contribution_contribution_status_id', $row)) {
891 $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_contribution_status_id'] = CRM_Contribute_PseudoConstant
::contributionStatus($val);
896 if ($component == 'membership_civireport') {
897 if ($val = CRM_Utils_Array
::value('civicrm_membership_membership_type_id', $row)) {
898 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_type_id'] = CRM_Member_PseudoConstant
::membershipType($val, FALSE);
901 if ($val = CRM_Utils_Array
::value('civicrm_membership_status_id', $row)) {
902 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_status_id'] = CRM_Member_PseudoConstant
::membershipStatus($val, FALSE);
907 if ($component == 'participant_civireport') {
908 if ($val = CRM_Utils_Array
::value('civicrm_participant_event_id', $row)) {
909 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant
::event($val, FALSE);
910 $url = CRM_Report_Utils_Report
::getNextUrl('event/income',
911 'reset=1&force=1&id_op=in&id_value=' . $val,
912 $this->_absoluteUrl
, $this->_id
914 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_link'] = $url;
915 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_hover'] = ts('View Event Income details for this Event.');
919 if ($val = CRM_Utils_Array
::value('civicrm_participant_participant_status_id', $row)) {
920 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_participant_status_id'] = CRM_Event_PseudoConstant
::participantStatus($val, FALSE);
922 if ($val = CRM_Utils_Array
::value('civicrm_participant_role_id', $row)) {
923 $roles = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $val);
925 foreach ($roles as $role) {
926 $value[$role] = CRM_Event_PseudoConstant
::participantRole($role, FALSE);
928 $componentRows[$contactID][$component][$rowNum]['civicrm_participant_role_id'] = implode(', ', $value);
934 if ($component == 'activity_civireport') {
935 if ($val = CRM_Utils_Array
::value('civicrm_activity_activity_type_id', $row)) {
936 $componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_type_id'] = $activityTypes[$val];
938 if ($val = CRM_Utils_Array
::value('civicrm_activity_activity_status_id', $row)) {
939 $componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_status_id'] = $activityStatus[$val];
944 if ($component == 'membership_civireport') {
945 if ($val = CRM_Utils_Array
::value('civicrm_membership_membership_status_id', $row)) {
946 $componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_status_id'] = CRM_Member_PseudoConstant
::membershipStatus($val);
951 // skip looking further in rows, if first row itself doesn't
952 // have the column we need