3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
33 class CRM_Report_Form_Contribute_Lybunt
extends CRM_Report_Form
{
35 protected $_charts = array(
37 'barChart' => 'Bar Chart',
38 'pieChart' => 'Pie Chart',
42 * This is the report that links will lead to.
44 * It is a bit problematic to use contribute/detail for anything other than a single contact
45 * as the filtering from this report does not carry over to that report.
49 public $_drilldownReport = array('contribute/detail' => 'Link to Detail Report');
51 protected $lifeTime_from = NULL;
52 protected $lifeTime_where = NULL;
53 protected $_customGroupExtends = array(
61 * Table containing list of contact IDs.
65 protected $contactTempTable = '';
68 * Table containing list of contact IDs.
72 protected $groupTempTable = '';
77 public function __construct() {
78 $this->_rollup
= 'WITH ROLLUP';
79 $this->_autoIncludeIndexedFieldsAsOrderBys
= 1;
82 $date = CRM_Core_SelectValues
::date('custom', NULL, $yearsInPast, $yearsInFuture);
83 $count = $date['maxYear'];
84 while ($date['minYear'] <= $count) {
85 $optionYear[$date['minYear']] = $date['minYear'];
89 // Check if CiviCampaign is a) enabled and b) has active campaigns
90 $config = CRM_Core_Config
::singleton();
91 $campaignEnabled = in_array("CiviCampaign", $config->enableComponents
);
92 if ($campaignEnabled) {
93 $getCampaigns = CRM_Campaign_BAO_Campaign
::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
94 $this->activeCampaigns
= $getCampaigns['campaigns'];
95 asort($this->activeCampaigns
);
98 $this->_columns
= array(
99 'civicrm_contact' => array(
100 'dao' => 'CRM_Contact_DAO_Contact',
101 'grouping' => 'contact-field',
102 'fields' => $this->getBasicContactFields(),
103 'order_bys' => array(
104 'sort_name' => array(
105 'title' => ts('Last Name, First Name'),
107 'default_order' => 'ASC',
109 'first_name' => array(
110 'name' => 'first_name',
111 'title' => ts('First Name'),
113 'gender_id' => array(
114 'name' => 'gender_id',
115 'title' => ts('Gender'),
117 'birth_date' => array(
118 'name' => 'birth_date',
119 'title' => ts('Birth Date'),
121 'contact_type' => array(
122 'title' => ts('Contact Type'),
124 'contact_sub_type' => array(
125 'title' => ts('Contact Subtype'),
129 'sort_name' => array(
130 'title' => ts('Donor Name'),
131 'operator' => 'like',
134 'title' => ts('Contact ID'),
135 'no_display' => TRUE,
137 'gender_id' => array(
138 'title' => ts('Gender'),
139 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
140 'options' => CRM_Core_PseudoConstant
::get('CRM_Contact_DAO_Contact', 'gender_id'),
142 'birth_date' => array(
143 'title' => ts('Birth Date'),
144 'operatorType' => CRM_Report_Form
::OP_DATE
,
146 'contact_type' => array(
147 'title' => ts('Contact Type'),
149 'contact_sub_type' => array(
150 'title' => ts('Contact Subtype'),
152 'is_deceased' => array(),
153 'do_not_phone' => array(),
154 'do_not_email' => array(),
155 'do_not_sms' => array(),
156 'do_not_mail' => array(),
157 'is_opt_out' => array(),
160 'civicrm_line_item' => array(
161 'dao' => 'CRM_Price_DAO_LineItem',
163 'civicrm_email' => array(
164 'dao' => 'CRM_Core_DAO_Email',
165 'grouping' => 'contact-field',
168 'title' => ts('Email'),
172 'title' => ts('Email on hold'),
176 'civicrm_phone' => array(
177 'dao' => 'CRM_Core_DAO_Phone',
178 'grouping' => 'contact-field',
181 'title' => ts('Phone'),
187 $this->_columns +
= $this->addAddressFields(FALSE);
188 $this->_columns +
= array(
189 'civicrm_contribution' => array(
190 'dao' => 'CRM_Contribute_DAO_Contribution',
192 'contact_id' => array(
193 'title' => ts('contactId'),
194 'no_display' => TRUE,
198 'receive_date' => array(
199 'title' => ts('Year'),
200 'no_display' => TRUE,
204 'last_year_total_amount' => array(
205 'title' => ts('Last Year Total'),
207 'type' => CRM_Utils_Type
::T_MONEY
,
210 'civicrm_life_time_total' => array(
211 'title' => ts('Lifetime Total'),
213 'type' => CRM_Utils_Type
::T_MONEY
,
214 'statistics' => array('sum' => ts('Lifetime total')),
219 'name' => 'receive_date',
220 'title' => ts('This Year'),
221 'operatorType' => CRM_Report_Form
::OP_SELECT
,
222 'options' => $optionYear,
223 'default' => date('Y'),
224 'type' => CRM_Utils_Type
::T_INT
,
226 'financial_type_id' => array(
227 'title' => ts('Financial Type'),
228 'type' => CRM_Utils_Type
::T_INT
,
229 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
230 'options' => CRM_Financial_BAO_FinancialType
::getAvailableFinancialTypes(),
232 'contribution_status_id' => array(
233 'title' => ts('Contribution Status'),
234 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
235 'options' => CRM_Contribute_PseudoConstant
::contributionStatus(),
236 'default' => array('1'),
239 'order_bys' => array(
240 'last_year_total_amount' => array(
241 'title' => ts('Total amount last year'),
243 'default_weight' => '0',
244 'default_order' => 'DESC',
250 // If we have a campaign, build out the relevant elements
251 if ($campaignEnabled && !empty($this->activeCampaigns
)) {
252 $this->_columns
['civicrm_contribution']['fields']['campaign_id'] = array(
253 'title' => ts('Campaign'),
254 'default' => 'false',
256 $this->_columns
['civicrm_contribution']['filters']['campaign_id'] = array(
257 'title' => ts('Campaign'),
258 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
259 'options' => $this->activeCampaigns
,
263 $this->_groupFilter
= TRUE;
264 $this->_tagFilter
= TRUE;
265 parent
::__construct();
269 * Build select clause for a single field.
271 * @param string $tableName
272 * @param string $tableKey
273 * @param string $fieldName
274 * @param string $field
278 public function selectClause(&$tableName, $tableKey, &$fieldName, &$field) {
279 if ($fieldName == 'last_year_total_amount') {
280 $this->_columnHeaders
["{$tableName}_{$fieldName}"] = $field;
281 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = $this->getLastYearColumnTitle();
282 $this->_statFields
[$this->getLastYearColumnTitle()] = "{$tableName}_{$fieldName}";
283 return "SUM(IF(" . $this->whereClauseLastYear('contribution_civireport.receive_date') . ", contribution_civireport.total_amount, 0)) as {$tableName}_{$fieldName}";
285 if ($fieldName == 'civicrm_life_time_total') {
286 $this->_columnHeaders
["{$tableName}_{$fieldName}"] = $field;
287 $this->_statFields
[$field['title']] = "{$tableName}_{$fieldName}";
288 return "SUM({$this->_aliases[$tableName]}.total_amount) as {$tableName}_{$fieldName}";
290 if ($fieldName == 'receive_date') {
291 return self
::fiscalYearOffset($field['dbAlias']) .
292 " as {$tableName}_{$fieldName} ";
298 * Get the title for the last year column.
300 public function getLastYearColumnTitle() {
301 if ($this->getYearFilterType() == 'calendar') {
302 return ts('Total for ') . ($this->getCurrentYear() - 1);
304 return ts('Total for Fiscal Year ') . ($this->getCurrentYear() - 1) . '-' . ($this->getCurrentYear());
308 * Construct from clause.
310 * On the first run we are creating a table of contacts to include in the report.
312 * Once contactTempTable is populated we should avoid using any further filters that affect
313 * the contacts that should be visible.
315 public function from() {
316 if (!empty($this->contactTempTable
)) {
318 FROM civicrm_contribution {$this->_aliases['civicrm_contribution']}
319 INNER JOIN $this->contactTempTable restricted_contacts
320 ON restricted_contacts.cid = {$this->_aliases['civicrm_contribution']}.contact_id
321 AND {$this->_aliases['civicrm_contribution']}.is_test = 0
322 INNER JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
323 ON restricted_contacts.cid = {$this->_aliases['civicrm_contact']}.id";
324 if ($this->isTableSelected('civicrm_email')) {
326 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
327 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id
328 AND {$this->_aliases['civicrm_email']}.is_primary = 1";
330 if ($this->isTableSelected('civicrm_phone')) {
332 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
333 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id
334 AND {$this->_aliases['civicrm_phone']}.is_primary = 1";
336 $this->addAddressFromClause();
339 if ($this->groupTempTable
) {
340 $this->_from
.= "FROM $this->groupTempTable {$this->_aliases['civicrm_contact']}";
343 $this->_from
.= "FROM civicrm_contact {$this->_aliases['civicrm_contact']}";
346 $this->_from
.= " INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} ";
347 if (!$this->groupTempTable
) {
348 // The received_date index is better than the contribution_status_id index (fairly substantially).
349 // But if we have already pre-filtered down to a group of contacts then we want that to be the
350 // primary filter and the index hint will block that.
351 $this->_from
.= "USE index (received_date)";
353 $this->_from
.= " ON {$this->_aliases['civicrm_contribution']}.contact_id = {$this->_aliases['civicrm_contact']}.id
354 AND {$this->_aliases['civicrm_contribution']}.is_test = 0
355 AND " . $this->whereClauseLastYear("{$this->_aliases['civicrm_contribution']}.receive_date") . "
357 LEFT JOIN civicrm_contribution cont_exclude ON cont_exclude.contact_id = {$this->_aliases['civicrm_contact']}.id
358 AND " . $this->whereClauseThisYear('cont_exclude.receive_date');
359 $this->selectivelyAddLocationTablesJoinsToFilterQuery();
365 * Generate where clause.
367 * We are overriding this primarily for 'before-after' handling of the receive_date placeholder field.
369 * We call this twice. The first time we are generating a temp table and we want to do an IS NULL on the
370 * join that draws in contributions from this year. The second time we are filtering elsewhere (contacts via
371 * the temp table & contributions via selective addition of contributions in the select function).
373 * If lifetime total is NOT selected we can add a further filter here to possibly improve performance
374 * but the benefit if unproven as yet.
375 * $clause = $this->whereClauseLastYear("{$this->_aliases['civicrm_contribution']}.receive_date");
377 * @param array $field Field specifications
378 * @param string $op Query operator (not an exact match to sql)
379 * @param mixed $value
383 * @return null|string
385 public function whereClause(&$field, $op, $value, $min, $max) {
386 if ($field['name'] == 'receive_date') {
388 if (empty($this->contactTempTable
)) {
389 $this->_whereClauses
[] = "cont_exclude.id IS NULL";
393 $clause = parent
::whereClause($field, $op, $value, $min, $max);
399 * Build where clause for groups.
401 * This has been overridden in order to:
402 * 1) only build the group clause when filtering
403 * 2) render the id field as id rather than contact_id in
404 * order to allow us to join on hte created temp table as if it
405 * were the contact table.
407 * Further refactoring could break down the parent function so it can be selectively
410 * @param string $field
411 * @param mixed $value
416 public function whereGroupClause($field, $value, $op) {
417 if ($op == 'notin') {
418 // We do not have an optimisation for this scenario at this stage. Use
420 return parent
::whereGroupClause($field, $value, $op);
423 if (empty($this->groupTempTable
)) {
424 $group = new CRM_Contact_DAO_Group();
425 $group->is_active
= 1;
427 $smartGroups = array();
428 while ($group->fetch()) {
429 if (in_array($group->id
, $this->_params
['gid_value']) &&
430 $group->saved_search_id
432 $smartGroups[] = $group->id
;
436 CRM_Contact_BAO_GroupContactCache
::check($smartGroups);
438 $smartGroupQuery = '';
439 if (!empty($smartGroups)) {
440 $smartGroups = implode(',', $smartGroups);
441 $smartGroupQuery = " UNION DISTINCT
442 SELECT DISTINCT smartgroup_contact.contact_id as id
443 FROM civicrm_group_contact_cache smartgroup_contact
444 WHERE smartgroup_contact.group_id IN ({$smartGroups}) ";
447 $sqlOp = $this->getSQLOperator($op);
448 if (!is_array($value)) {
449 $value = array($value);
451 $clause = "{$field['dbAlias']} IN (" . implode(', ', $value) . ")";
453 $query = "SELECT DISTINCT {$this->_aliases['civicrm_group']}.contact_id as id
454 FROM civicrm_group_contact {$this->_aliases['civicrm_group']}
455 WHERE {$clause} AND {$this->_aliases['civicrm_group']}.status = 'Added'
456 {$smartGroupQuery} ";
457 $this->buildGroupTempTable($query);
462 * Generate where clause for last calendar year or fiscal year.
464 * @todo must be possible to re-use relative dates stuff.
466 * @param string $fieldName
470 public function whereClauseLastYear($fieldName) {
471 return "$fieldName BETWEEN '" . $this->getFirstDateOfPriorRange() . "' AND '" . $this->getLastDateOfPriorRange() . "'";
475 * Generate where clause for last calendar year or fiscal year.
477 * @todo must be possible to re-use relative dates stuff.
479 * @param string $fieldName
481 * @param int $current_year
482 * @return null|string
484 public function whereClauseThisYear($fieldName, $current_year = NULL) {
485 return "$fieldName BETWEEN '" . $this->getFirstDateOfCurrentRange() . "' AND '" . $this->getLastDateOfCurrentRange() . "'";
490 * Get the year value for the current year.
494 public function getCurrentYear() {
495 return $this->_params
['yid_value'];
499 * Get the date time of the first date in the 'this year' range.
503 public function getFirstDateOfCurrentRange() {
504 $current_year = $this->getCurrentYear();
505 if ($this->getYearFilterType() == 'calendar') {
506 return "{$current_year }-01-01";
509 $fiscalYear = CRM_Core_Config
::singleton()->fiscalYearStart
;
510 return "{$current_year}-{$fiscalYear['M']}-{$fiscalYear['d']}";
515 * Get the year value for the current year.
519 public function getYearFilterType() {
520 return CRM_Utils_Array
::value('yid_op', $this->_params
, 'calendar');
524 * Get the date time of the last date in the 'this year' range.
528 public function getLastDateOfCurrentRange() {
529 return date('YmdHis', strtotime('+ 1 year - 1 second', strtotime($this->getFirstDateOfCurrentRange())));
533 * Get the date time of the first date in the 'last year' range.
537 public function getFirstDateOfPriorRange() {
538 return date('YmdHis', strtotime('- 1 year', strtotime($this->getFirstDateOfCurrentRange())));
542 * Get the date time of the last date in the 'last year' range.
546 public function getLastDateOfPriorRange() {
547 return date('YmdHis', strtotime('+ 1 year - 1 second', strtotime($this->getFirstDateOfPriorRange())));
551 public function groupBy() {
552 $this->_groupBy
= "GROUP BY {$this->_aliases['civicrm_contribution']}.contact_id ";
553 $this->assign('chartSupported', TRUE);
561 public function statistics(&$rows) {
563 $statistics = parent
::statistics($rows);
564 // The parent class does something odd where it adds an extra row to the count for the grand total.
565 // Perhaps that works on some other report? But here it just seems odd.
566 $this->countStat($statistics, count($rows));
568 if (!empty($this->rollupRow
) && !empty($this->rollupRow
['civicrm_contribution_last_year_total_amount'])) {
569 $statistics['counts']['civicrm_contribution_last_year_total_amount'] = array(
570 'value' => $this->rollupRow
['civicrm_contribution_last_year_total_amount'],
571 'title' => $this->getLastYearColumnTitle(),
572 'type' => CRM_Utils_Type
::T_MONEY
,
576 if (!empty($this->rollupRow
) && !empty($this->rollupRow
['civicrm_contribution_civicrm_life_time_total'])) {
577 $statistics['counts']['civicrm_contribution_civicrm_life_time_total'] = array(
578 'value' => $this->rollupRow
['civicrm_contribution_civicrm_life_time_total'],
579 'title' => ts('Total LifeTime'),
580 'type' => CRM_Utils_Type
::T_MONEY
,
584 $select = "SELECT SUM({$this->_aliases['civicrm_contribution']}.total_amount) as amount,
585 SUM(IF( " . $this->whereClauseLastYear('contribution_civireport.receive_date') . ", contribution_civireport.total_amount, 0)) as last_year
587 $sql = "{$select} {$this->_from} {$this->_where}";
588 $dao = CRM_Core_DAO
::executeQuery($sql);
590 $statistics['counts']['amount'] = array(
591 'value' => $dao->amount
,
592 'title' => ts('Total LifeTime'),
593 'type' => CRM_Utils_Type
::T_MONEY
,
595 $statistics['counts']['last_year'] = array(
596 'value' => $dao->last_year
,
597 'title' => $this->getLastYearColumnTitle(),
598 'type' => CRM_Utils_Type
::T_MONEY
,
608 * This function is called by both the api (tests) and the UI.
610 public function beginPostProcessCommon() {
612 // @todo this acl has no test coverage and is very hard to test manually so could be fragile.
613 $this->getPermissionedFTQuery($this);
614 $this->resetFormSqlAndWhereHavingClauses();
616 $this->contactTempTable
= 'civicrm_report_temp_lybunt_c_' . date('Ymd_') . uniqid();
619 CREATE TEMPORARY TABLE $this->contactTempTable
620 SELECT SQL_CALC_FOUND_ROWS {$this->_aliases['civicrm_contact']}.id as cid {$this->_from} {$this->_where}
621 GROUP BY {$this->_aliases['civicrm_contact']}.id";
622 $this->addToDeveloperTab($getContacts);
623 CRM_Core_DAO
::executeQuery($getContacts);
624 if (empty($this->_params
['charts'])) {
628 // Reset where clauses to be regenerated in postProcess.
629 $this->_whereClauses
= array();
633 * This function is called by both the api (tests) and the UI.
635 * @todo consider moving this to the parent class & reusing the filter then render logic.
637 * (this approach is taken to it's extreme in the extended reports extension with it's 'preconstrain'
640 * @param string $clause
642 public function buildGroupTempTable($clause) {
643 if (empty($this->groupTempTable
)) {
644 $this->groupTempTable
= 'civicrm_report_temp_lybunt_g_' . date('Ymd_') . uniqid();
645 CRM_Core_DAO
::executeQuery("
646 CREATE TEMPORARY TABLE $this->groupTempTable
649 CRM_Core_DAO
::executeQuery("ALTER TABLE $this->groupTempTable ADD INDEX i_id(id)");
654 * Build the report query.
656 * The issue we are hitting is that if we want to do group by & then ORDER BY we have to
657 * wrap the query in an outer query with the order by - otherwise the group by takes precedent.
658 * This is an issue when we want to group by contact but order by the maximum aggregate donation.
660 * @param bool $applyLimit
664 public function buildQuery($applyLimit = TRUE) {
666 // Calling where & select before FROM allows us to build temp tables to use in from.
670 $this->customDataFrom(empty($this->contactTempTable
));
674 $this->getPermissionedFTQuery($this);
677 // order_by columns not selected for display need to be included in SELECT
678 // This differs from parent in that we are getting those not in order by rather than not in
679 // sections, as we need to adapt to our contact group by.
680 $unselectedSectionColumns = array_diff_key($this->_orderByFields
, $this->getSelectColumns());
681 foreach ($unselectedSectionColumns as $alias => $section) {
682 $this->_select
.= ", {$section['dbAlias']} as {$alias}";
685 if ($applyLimit && empty($this->_params
['charts'])) {
689 $sql = "{$this->_select} {$this->_from} {$this->_where} $limitFilter {$this->_groupBy} {$this->_having} {$this->_rollup}";
691 if (!empty($this->_orderByArray
)) {
692 $this->_orderBy
= str_replace('contact_civireport.', 'civicrm_contact_', "ORDER BY ISNULL(civicrm_contribution_contact_id), " . implode(', ', $this->_orderByArray
));
693 $this->_orderBy
= str_replace('contribution_civireport.', 'civicrm_contribution_', $this->_orderBy
);
694 foreach ($this->_orderByFields
as $field) {
695 $this->_orderBy
= str_replace($field['dbAlias'], $field['tplField'], $this->_orderBy
);
697 $sql = str_replace('SQL_CALC_FOUND_ROWS', '', $sql);
698 $sql = "SELECT SQL_CALC_FOUND_ROWS * FROM ( $sql ) as inner_query {$this->_orderBy} $this->_limit";
701 CRM_Utils_Hook
::alterReportVar('sql', $this, $this);
702 $this->addToDeveloperTab($sql);
708 * Reset the form sql and where / having clause arrays.
710 * We do an early iteration of the report queries to generate the temp table.
712 * However, that iteration populates the sql for the developer tab,
713 * the whereClauses & the havingClauses and they are populated again in the normal
714 * report flow. This is harmless but confusing - ie. the where clause winds up repeating
715 * the same filters and the dev tab shows the query twice, so we rest them.
717 protected function resetFormSqlAndWhereHavingClauses() {
719 $this->_havingClauses
= array();
720 $this->_whereClauses
= array();
721 $this->sqlArray
= array();
727 public function buildChart(&$rows) {
729 $graphRows = array();
733 $current_year = $this->_params
['yid_value'];
734 $previous_year = $current_year - 1;
735 $interval[$previous_year] = $previous_year;
736 $interval['life_time'] = 'Life Time';
738 foreach ($rows as $key => $row) {
739 $display['life_time'] = CRM_Utils_Array
::value('life_time', $display) +
740 $row['civicrm_life_time_total'];
741 $display[$previous_year] = CRM_Utils_Array
::value($previous_year, $display) +
$row[$previous_year];
744 $config = CRM_Core_Config
::Singleton();
745 $graphRows['value'] = $display;
747 'legend' => ts('Lybunt Report'),
748 'xname' => ts('Year'),
749 'yname' => ts('Amount (%1)', array(1 => $config->defaultCurrency
)),
751 if ($this->_params
['charts']) {
753 CRM_Utils_OpenFlashChart
::reportChart($graphRows, $this->_params
['charts'], $interval, $chartInfo);
754 $this->assign('chartType', $this->_params
['charts']);
759 * Alter display of rows.
761 * Iterate through the rows retrieved via SQL and make changes for display purposes,
762 * such as rendering contacts as links.
765 * Rows generated by SQL, with an array for each row.
767 public function alterDisplay(&$rows) {
770 foreach ($rows as $rowNum => $row) {
771 //Convert Display name into link
772 if (array_key_exists('civicrm_contact_sort_name', $row) &&
773 array_key_exists('civicrm_contribution_contact_id', $row)
775 $url = CRM_Report_Utils_Report
::getNextUrl('contribute/detail',
776 'reset=1&force=1&id_op=eq&id_value=' .
777 $row['civicrm_contribution_contact_id'],
778 $this->_absoluteUrl
, $this->_id
, $this->_drilldownReport
780 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
781 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contribution Details for this Contact.");
785 // convert campaign_id to campaign title
786 if (array_key_exists('civicrm_contribution_campaign_id', $row)) {
787 if ($value = $row['civicrm_contribution_campaign_id']) {
788 $rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->activeCampaigns
[$value];
792 // Display 'Yes' if the email is on hold (leave blank for no so it stands out better).
793 if (array_key_exists('civicrm_email_on_hold', $row)) {
794 $rows[$rowNum]['civicrm_email_on_hold'] = $row['civicrm_email_on_hold'] ?
ts('Yes') : '';
798 $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, NULL, 'List all contribution(s)') ?
TRUE : $entryFound;
799 $entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, NULL, 'List all contribution(s)') ?
TRUE : $entryFound;
801 if (array_key_exists('civicrm_contact_gender_id', $row)) {
802 if ($value = $row['civicrm_contact_gender_id']) {
803 $gender = CRM_Core_PseudoConstant
::get('CRM_Contact_DAO_Contact', 'gender_id');
804 $rows[$rowNum]['civicrm_contact_gender_id'] = $gender[$value];
809 // display birthday in the configured custom format
810 if (array_key_exists('civicrm_contact_birth_date', $row)) {
811 $birthDate = $row['civicrm_contact_birth_date'];
813 $rows[$rowNum]['civicrm_contact_birth_date'] = CRM_Utils_Date
::customFormat($birthDate, '%Y%m%d');
818 // skip looking further in rows, if first row itself doesn't
819 // have the column we need
827 * Override "This Year" $op options
828 * @param string $type
829 * @param null $fieldName
833 public function getOperationPair($type = "string", $fieldName = NULL) {
834 if ($fieldName == 'yid') {
836 'calendar' => ts('Is Calendar Year'),
837 'fiscal' => ts('Fiscal Year Starting'),
840 return parent
::getOperationPair($type, $fieldName);