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_Contribute_History
extends CRM_Report_Form
{
36 // Primary Contacts count limitCONSTROW_COUNT_LIMIT = 10;
38 protected $_addressField = FALSE;
39 protected $_emailField = FALSE;
40 protected $_phoneField = FALSE;
41 protected $_relationshipColumns = array();
43 protected $_customGroupExtends = array('Contribution');
45 protected $_referenceYear = array(
49 protected $_yearStatisticsFrom = '';
51 protected $_yearStatisticsTo = '';
57 public function __construct() {
59 $date = CRM_Core_SelectValues
::date('custom', NULL, $yearsInPast, 0);
60 $count = $date['maxYear'];
61 $optionYear = array('' => ts('- select -'));
63 $this->_yearStatisticsFrom
= $date['minYear'];
64 $this->_yearStatisticsTo
= $date['maxYear'];
66 while ($date['minYear'] <= $count) {
67 $optionYear[$date['minYear']] = $date['minYear'];
71 $relationTypeOp = array();
72 $relationshipTypes = CRM_Core_PseudoConstant
::relationshipType();
73 foreach ($relationshipTypes as $rid => $rtype) {
74 if ($rtype['label_a_b'] != $rtype['label_b_a']) {
75 $relationTypeOp[$rid] = "{$rtype['label_a_b']}/{$rtype['label_b_a']}";
78 $relationTypeOp[$rid] = $rtype['label_a_b'];
82 $this->_columns
= array(
83 'civicrm_contact' => array(
84 'dao' => 'CRM_Contact_DAO_Contact',
87 'title' => ts('Contact Name'),
97 'contact_type' => array(
98 'title' => ts('Contact Type'),
100 'contact_sub_type' => array(
101 'title' => ts('Contact Subtype'),
104 'grouping' => 'contact-fields',
106 'sort_name' => array('title' => ts('Contact Name')),
108 'title' => ts('Contact ID'),
109 'no_display' => TRUE,
113 'civicrm_email' => array(
114 'dao' => 'CRM_Core_DAO_Email',
117 'title' => ts('Email'),
121 'grouping' => 'contact-fields',
123 'civicrm_phone' => array(
124 'dao' => 'CRM_Core_DAO_Phone',
127 'title' => ts('Phone'),
131 'grouping' => 'contact-fields',
133 ) +
$this->addAddressFields(FALSE, FALSE, FALSE, array()) +
array(
134 'civicrm_relationship' => array(
135 'dao' => 'CRM_Contact_DAO_Relationship',
137 'relationship_type_id' => array(
138 'title' => ts('Relationship Type'),
141 'contact_id_a' => array('no_display' => TRUE),
142 'contact_id_b' => array('no_display' => TRUE),
145 'relationship_type_id' => array(
146 'title' => ts('Relationship Type'),
147 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
148 'options' => $relationTypeOp,
149 'type' => CRM_Utils_Type
::T_STRING
,
154 'civicrm_contribution' => array(
155 'dao' => 'CRM_Contribute_DAO_Contribution',
157 'total_amount' => array(
158 'title' => ts('Amount Statistics'),
161 'no_display' => TRUE,
162 'statistics' => array('sum' => ts('Aggregate Amount')),
164 'receive_date' => array(
167 'no_display' => TRUE,
170 'grouping' => 'contri-fields',
172 'this_year' => array(
173 'title' => ts('This Year'),
174 'operatorType' => CRM_Report_Form
::OP_SELECT
,
175 'options' => $optionYear,
178 'other_year' => array(
179 'title' => ts('Other Years'),
180 'operatorType' => CRM_Report_Form
::OP_SELECT
,
181 'options' => $optionYear,
184 'receive_date' => array('operatorType' => CRM_Report_Form
::OP_DATE
),
185 'contribution_status_id' => array(
186 'title' => ts('Contribution Status'),
187 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
188 'options' => CRM_Contribute_PseudoConstant
::contributionStatus(),
189 'default' => array(1),
191 'financial_type_id' => array(
192 'title' => ts('Financial Type'),
193 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
194 'options' => CRM_Contribute_PseudoConstant
::financialType(),
196 'total_amount' => array(
197 'title' => ts('Contribution Amount'),
199 'total_sum' => array(
200 'title' => ts('Aggregate Amount'),
201 'type' => CRM_Report_Form
::OP_INT
,
202 'dbAlias' => 'civicrm_contribution_total_amount_sum',
209 $this->_columns
['civicrm_contribution']['fields']['civicrm_upto_' .
210 $this->_yearStatisticsFrom
] = array(
211 'title' => ts('Up To %1 Donation', array(1 => $this->_yearStatisticsFrom
)),
213 'type' => CRM_Utils_Type
::T_MONEY
,
214 'is_statistics' => TRUE,
217 $yearConter = $this->_yearStatisticsFrom
;
219 while ($yearConter <= $this->_yearStatisticsTo
) {
220 $this->_columns
['civicrm_contribution']['fields'][$yearConter] = array(
221 'title' => ts('%1 Donation', array(1 => $yearConter)),
223 'type' => CRM_Utils_Type
::T_MONEY
,
224 'is_statistics' => TRUE,
229 $this->_columns
['civicrm_contribution']['fields']['aggregate_amount'] = array(
230 'title' => ts('Aggregate Amount'),
231 'type' => CRM_Utils_Type
::T_MONEY
,
232 'is_statistics' => TRUE,
235 $this->_groupFilter
= TRUE;
236 $this->_tagFilter
= TRUE;
237 parent
::__construct();
240 public function preProcess() {
241 parent
::preProcess();
244 public function select() {
246 $this->_columnHeaders
= array();
248 foreach ($this->_columns
as $tableName => $table) {
249 if (array_key_exists('fields', $table)) {
250 foreach ($table['fields'] as $fieldName => $field) {
252 if (!empty($field['required']) ||
253 !empty($this->_params
['fields'][$fieldName])
255 if ($tableName == 'civicrm_address') {
256 $this->_addressField
= TRUE;
258 if ($tableName == 'civicrm_email') {
259 $this->_emailField
= TRUE;
261 if ($tableName == 'civicrm_phone') {
262 $this->_phoneField
= TRUE;
264 if ($tableName == 'civicrm_relationship') {
265 $this->_relationshipColumns
["{$tableName}_{$fieldName}"] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
266 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
267 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = $field['title'];
271 if (!empty($field['is_statistics'])) {
272 $this->_columnHeaders
[$fieldName]['type'] = $field['type'];
273 $this->_columnHeaders
[$fieldName]['title'] = $field['title'];
276 elseif ($fieldName == 'receive_date') {
277 if ((CRM_Utils_Array
::value('this_year_op', $this->_params
) ==
278 'fiscal' && !empty($this->_params
['this_year_value'])) ||
279 (CRM_Utils_Array
::value('other_year_op', $this->_params
==
280 'fiscal') && !empty($this->_params
['other_year_value']))
282 $select[] = self
::fiscalYearOffset($field['dbAlias']) .
283 " as {$tableName}_{$fieldName}";
286 $select[] = " YEAR(" . $field['dbAlias'] . ")" .
287 " as {$tableName}_{$fieldName}";
290 elseif ($fieldName == 'total_amount') {
291 $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}";
294 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
295 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
296 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = $field['title'];
298 if (!empty($field['no_display'])) {
299 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['no_display'] = TRUE;
306 $this->_select
= "SELECT " . implode(', ', $select) . " ";
309 public function from() {
311 FROM civicrm_contact {$this->_aliases['civicrm_contact']}
312 INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
313 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id AND
314 {$this->_aliases['civicrm_contribution']}.is_test = 0 ";
316 if ($this->_emailField
) {
317 $this->_from
.= " LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
318 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
319 {$this->_aliases['civicrm_email']}.is_primary = 1) ";
322 if ($this->_phoneField
) {
323 $this->_from
.= " LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
324 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
325 {$this->_aliases['civicrm_phone']}.is_primary = 1) ";
328 $relContacAlias = 'contact_relationship';
329 $this->_relationshipFrom
= " INNER JOIN civicrm_relationship {$this->_aliases['civicrm_relationship']}
330 ON (({$this->_aliases['civicrm_relationship']}.contact_id_a = {$relContacAlias}.id OR {$this->_aliases['civicrm_relationship']}.contact_id_b = {$relContacAlias}.id ) AND {$this->_aliases['civicrm_relationship']}.is_active = 1) ";
332 if ($this->_addressField
) {
334 LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
335 ON {$this->_aliases['civicrm_contact']}.id =
336 {$this->_aliases['civicrm_address']}.contact_id AND
337 {$this->_aliases['civicrm_address']}.is_primary = 1\n";
341 public function where() {
342 $whereClauses = $havingClauses = $relationshipWhere = array();
343 $this->_relationshipWhere
= '';
344 $this->_statusClause
= '';
346 foreach ($this->_columns
as $tableName => $table) {
347 if (array_key_exists('filters', $table)) {
348 foreach ($table['filters'] as $fieldName => $field) {
350 if ($fieldName == 'this_year' ||
$fieldName == 'other_year') {
353 elseif (CRM_Utils_Array
::value('type', $field) & CRM_Utils_Type
::T_DATE
355 $relative = CRM_Utils_Array
::value("{$fieldName}_relative", $this->_params
);
356 $from = CRM_Utils_Array
::value("{$fieldName}_from", $this->_params
);
357 $to = CRM_Utils_Array
::value("{$fieldName}_to", $this->_params
);
359 $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
362 $op = CRM_Utils_Array
::value("{$fieldName}_op", $this->_params
);
364 $clause = $this->whereClause($field,
366 CRM_Utils_Array
::value("{$fieldName}_value", $this->_params
),
367 CRM_Utils_Array
::value("{$fieldName}_min", $this->_params
),
368 CRM_Utils_Array
::value("{$fieldName}_max", $this->_params
)
373 if (!empty($clause)) {
374 if ($tableName == 'civicrm_relationship') {
375 $relationshipWhere[] = $clause;
379 if ($fieldName == 'contribution_status_id') {
380 $this->_statusClause
= " AND " . $clause;
383 if (!empty($field['having'])) {
384 $havingClauses[] = $clause;
387 $whereClauses[] = $clause;
394 if (empty($whereClauses)) {
395 $this->_where
= "WHERE ( 1 ) ";
399 $this->_where
= "WHERE " . implode(' AND ', $whereClauses);
402 if ($this->_aclWhere
) {
403 $this->_where
.= " AND {$this->_aclWhere} ";
406 if (!empty($havingClauses)) {
407 // use this clause to construct group by clause.
408 $this->_having
= "HAVING " . implode(' AND ', $havingClauses);
411 if (!empty($relationshipWhere)) {
412 $this->_relationshipWhere
= ' AND ' .
413 implode(' AND ', $relationshipWhere);
417 public function groupBy() {
418 $this->_groupBy
= "GROUP BY {$this->_aliases['civicrm_contribution']}.contact_id, YEAR({$this->_aliases['civicrm_contribution']}.receive_date)";
422 * Override to set limit is 10
423 * @param int $rowCount
425 public function limit($rowCount = self
::ROW_COUNT_LIMIT
) {
426 parent
::limit($rowCount);
430 * Override to set pager with limit is 10
431 * @param int $rowCount
433 public function setPager($rowCount = self
::ROW_COUNT_LIMIT
) {
434 parent
::setPager($rowCount);
442 public function statistics(&$rows) {
443 $statistics = parent
::statistics($rows);
445 foreach ($rows as $rownum => $row) {
446 if (is_numeric($rownum)) {
450 $statistics['counts']['rowCount'] = array(
451 'title' => ts('Primary Contact(s) Listed'),
455 if ($this->_rowsFound
&& ($this->_rowsFound
> $count)) {
456 $statistics['counts']['rowsFound'] = array(
457 'title' => ts('Total Primary Contact(s)'),
458 'value' => $this->_rowsFound
,
472 public static function formRule($fields, $files, $self) {
474 if (!empty($fields['this_year_value']) &&
475 !empty($fields['other_year_value']) &&
476 ($fields['this_year_value'] == $fields['other_year_value'])
478 $errors['other_year_value'] = ts("Value for filters 'This Year' and 'Other Years' can not be same.");
483 public function postProcess() {
484 // get ready with post process params
485 $this->beginPostProcess();
486 $this->fixReportParams();
488 $this->buildACLClause($this->_aliases
['civicrm_contact']);
492 $this->customDataFrom();
498 // build array of result based on column headers. This method also allows
499 // modifying column headers before using it to build result set i.e $rows.
500 $this->buildRows($sql, $rows);
502 // format result set.
503 $this->formatDisplay($rows, FALSE);
505 // assign variables to templates
506 $this->doTemplateAssignment($rows);
508 // do print / pdf / instance stuff if needed
509 $this->endPostProcess($rows);
512 public function fixReportParams() {
513 if (!empty($this->_params
['this_year_value'])) {
514 $this->_referenceYear
['this_year'] = $this->_params
['this_year_value'];
516 if (!empty($this->_params
['other_year_value'])) {
517 $this->_referenceYear
['other_year'] = $this->_params
['other_year_value'];
524 public function buildRows($sql, &$rows) {
525 $contactIds = array();
529 if (!empty($this->_referenceYear
['other_year'])) {
530 (CRM_Utils_Array
::value('other_year_op', $this->_params
) ==
531 'calendar') ?
$other_receive_date = 'YEAR (contri.receive_date)' : $other_receive_date = self
::fiscalYearOffset('contri.receive_date');
532 $addWhere .= " AND {$this->_aliases['civicrm_contact']}.id NOT IN ( SELECT DISTINCT cont.id FROM civicrm_contact cont, civicrm_contribution contri WHERE cont.id = contri.contact_id AND {$other_receive_date} = {$this->_referenceYear['other_year']} AND contri.is_test = 0 ) ";
534 if (!empty($this->_referenceYear
['this_year'])) {
535 (CRM_Utils_Array
::value('this_year_op', $this->_params
) ==
536 'calendar') ?
$receive_date = 'YEAR (contri.receive_date)' : $receive_date = self
::fiscalYearOffset('contri.receive_date');
537 $addWhere .= " AND {$this->_aliases['civicrm_contact']}.id IN ( SELECT DISTINCT cont.id FROM civicrm_contact cont, civicrm_contribution contri WHERE cont.id = contri.contact_id AND {$receive_date} = {$this->_referenceYear['this_year']} AND contri.is_test = 0 ) ";
540 $getContacts = "SELECT SQL_CALC_FOUND_ROWS {$this->_aliases['civicrm_contact']}.id as cid, SUM({$this->_aliases['civicrm_contribution']}.total_amount) as civicrm_contribution_total_amount_sum {$this->_from} {$this->_where} {$addWhere} GROUP BY {$this->_aliases['civicrm_contact']}.id {$this->_having} {$this->_limit}";
542 $dao = CRM_Core_DAO
::executeQuery($getContacts);
544 while ($dao->fetch()) {
545 $contactIds[] = $dao->cid
;
550 $relationshipRows = array();
551 if (empty($contactIds)) {
555 $primaryContributions = $this->buildContributionRows($contactIds);
557 list($relationshipRows, $relatedContactIds) = $this->buildRelationshipRows($contactIds);
559 if (empty($relatedContactIds)) {
560 $rows = $primaryContributions;
564 $relatedContributions = $this->buildContributionRows($relatedContactIds);
566 $summaryYears = array();
567 $summaryYears[] = "civicrm_upto_{$this->_yearStatisticsFrom}";
568 $yearConter = $this->_yearStatisticsFrom
;
570 while ($yearConter <= $this->_yearStatisticsTo
) {
571 $summaryYears[] = $yearConter;
574 $summaryYears[] = 'aggregate_amount';
576 foreach ($primaryContributions as $cid => $primaryRow) {
578 if (!isset($relationshipRows[$cid])) {
583 $total['civicrm_contact_sort_name'] = ts('Total');
584 foreach ($summaryYears as $year) {
585 $total[$year] = CRM_Utils_Array
::value($year, $primaryRow, 0);
588 $relatedContact = FALSE;
590 foreach ($relationshipRows[$cid] as $relcid => $relRow) {
591 if (!isset($relatedContributions[$relcid])) {
594 $relatedContact = TRUE;
595 $relatedRow = $relatedContributions[$relcid];
596 foreach ($summaryYears as $year) {
597 $total[$year] +
= CRM_Utils_Array
::value($year, $relatedRow, 0);
600 foreach (array_keys($this->_relationshipColumns
) as $col) {
601 if (!empty($relRow[$col])) {
602 $relatedRow[$col] = $relRow[$col];
605 $rows["{$cid}_{$relcid}"] = $relatedRow;
607 if ($relatedContact) {
608 $rows["{$cid}_total"] = $total;
609 $rows["{$cid}_bank"] = array('civicrm_contact_sort_name' => ' ');
619 public function buildContributionRows($contactIds) {
621 if (empty($contactIds)) {
626 "{$this->_select} {$this->_from} WHERE {$this->_aliases['civicrm_contact']}.id IN (" .
627 implode(',', $contactIds) .
628 ") AND {$this->_aliases['civicrm_contribution']}.is_test = 0 {$this->_statusClause} {$this->_groupBy} ";
630 $dao = CRM_Core_DAO
::executeQuery($sqlContribution);
631 $contributionSum = 0;
633 while ($dao->fetch()) {
634 if (!$dao->civicrm_contact_id
) {
638 foreach ($this->_columnHeaders
as $key => $value) {
639 if (property_exists($dao, $key)) {
640 $rows[$dao->civicrm_contact_id
][$key] = $dao->$key;
643 if ($dao->civicrm_contribution_receive_date
) {
644 if ($dao->civicrm_contribution_receive_date
>
645 $this->_yearStatisticsFrom
647 $rows[$dao->civicrm_contact_id
][$dao->civicrm_contribution_receive_date
] = $dao->civicrm_contribution_total_amount
;
650 if (!isset($rows[$dao->civicrm_contact_id
]["civicrm_upto_{$this->_yearStatisticsFrom}"])) {
651 $rows[$dao->civicrm_contact_id
]["civicrm_upto_{$this->_yearStatisticsFrom}"] = 0;
654 $rows[$dao->civicrm_contact_id
]["civicrm_upto_{$this->_yearStatisticsFrom}"] +
= $dao->civicrm_contribution_total_amount
;
658 if (!isset($rows[$dao->civicrm_contact_id
]['aggregate_amount'])) {
659 $rows[$dao->civicrm_contact_id
]['aggregate_amount'] = 0;
661 $rows[$dao->civicrm_contact_id
]['aggregate_amount'] +
= $dao->civicrm_contribution_total_amount
;
672 public function buildRelationshipRows($contactIds) {
673 $relationshipRows = $relatedContactIds = array();
674 if (empty($contactIds)) {
675 return array($relationshipRows, $relatedContactIds);
678 $relContactAlias = 'contact_relationship';
680 if (!empty($this->_relationshipColumns
)) {
681 $addRelSelect = ', ' . implode(', ', $this->_relationshipColumns
);
684 "SELECT {$this->_aliases['civicrm_relationship']}.relationship_type_id as relationship_type_id, {$this->_aliases['civicrm_relationship']}.contact_id_a as contact_id_a, {$this->_aliases['civicrm_relationship']}.contact_id_b as contact_id_b {$addRelSelect} FROM civicrm_contact {$relContactAlias} {$this->_relationshipFrom} WHERE {$relContactAlias}.id IN (" .
685 implode(',', $contactIds) .
686 ") AND {$this->_aliases['civicrm_relationship']}.is_active = 1 {$this->_relationshipWhere} GROUP BY {$this->_aliases['civicrm_relationship']}.contact_id_a, {$this->_aliases['civicrm_relationship']}.contact_id_b";
687 $relationshipTypes = CRM_Core_PseudoConstant
::relationshipType();
689 $dao = CRM_Core_DAO
::executeQuery($sqlRelationship);
690 while ($dao->fetch()) {
692 foreach (array_keys($this->_relationshipColumns
) as $rel_column) {
693 $row[$rel_column] = $dao->$rel_column;
695 if (in_array($dao->contact_id_a
, $contactIds)) {
696 $row['civicrm_relationship_relationship_type_id'] = $relationshipTypes[$dao->relationship_type_id
]['label_a_b'];
697 $row['civicrm_relationship_contact_id'] = $dao->contact_id_b
;
698 $relationshipRows[$dao->contact_id_a
][$dao->contact_id_b
] = $row;
699 $relatedContactIds[$dao->contact_id_b
] = $dao->contact_id_b
;
701 if (in_array($dao->contact_id_b
, $contactIds)) {
702 $row['civicrm_relationship_contact_id'] = $dao->contact_id_a
;
703 $row['civicrm_relationship_relationship_type_id'] = $relationshipTypes[$dao->relationship_type_id
]['label_b_a'];
704 $relationshipRows[$dao->contact_id_b
][$dao->contact_id_a
] = $row;
705 $relatedContactIds[$dao->contact_id_a
] = $dao->contact_id_a
;
709 return array($relationshipRows, $relatedContactIds);
713 * Override "This Year" $op options
714 * @param string $type
715 * @param null $fieldName
719 public function getOperationPair($type = "string", $fieldName = NULL) {
720 if ($fieldName == 'this_year' ||
$fieldName == 'other_year') {
722 'calendar' => ts('Is Calendar Year'),
723 'fiscal' => ts('Fiscal Year Starting'),
726 return parent
::getOperationPair($type, $fieldName);
732 public function alterDisplay(&$rows) {
737 $last_primary = NULL;
738 foreach ($rows as $rowNum => $row) {
739 // Highlight primary contact and amount row
740 if (is_numeric($rowNum) ||
741 ($last_primary && ($rowNum == "{$last_primary}_total"))
743 if (is_numeric($rowNum)) {
744 $last_primary = $rowNum;
746 foreach ($row as $key => $value) {
747 if ($key == 'civicrm_contact_id') {
755 if ($last_primary && ($rowNum == "{$last_primary}_total")) {
756 $value = CRM_Utils_Money
::format($value, ' ');
758 $row[$key] = '<strong>' . $value . '</strong>';
760 $rows[$rowNum] = $row;
763 // Convert Display name into link
764 if (!empty($row['civicrm_contact_sort_name']) &&
765 !empty($row['civicrm_contact_id'])
767 $url = CRM_Report_Utils_Report
::getNextUrl('contribute/detail',
768 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'],
769 $this->_absoluteUrl
, $this->_id
771 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
772 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contribution Details for this Contact.");