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_Summary
extends CRM_Report_Form
{
36 protected $_addressField = FALSE;
38 protected $_charts = array(
40 'barChart' => 'Bar Chart',
41 'pieChart' => 'Pie Chart',
43 protected $_customGroupExtends = array('Contribution');
44 protected $_customGroupGroupBy = TRUE;
46 public $_drilldownReport = array('contribute/detail' => 'Link to Detail Report');
52 public function __construct() {
54 // Check if CiviCampaign is a) enabled and b) has active campaigns
55 $config = CRM_Core_Config
::singleton();
56 $campaignEnabled = in_array("CiviCampaign", $config->enableComponents
);
57 if ($campaignEnabled) {
58 $getCampaigns = CRM_Campaign_BAO_Campaign
::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
59 $this->activeCampaigns
= $getCampaigns['campaigns'];
60 asort($this->activeCampaigns
);
63 $this->_columns
= array(
64 'civicrm_contact' => array(
65 'dao' => 'CRM_Contact_DAO_Contact',
68 'title' => ts('Contact Name'),
71 'postal_greeting_display' => array('title' => ts('Postal Greeting')),
76 'contact_type' => array(
77 'title' => ts('Contact Type'),
79 'contact_sub_type' => array(
80 'title' => ts('Contact Subtype'),
83 'grouping' => 'contact-fields',
85 'id' => array('title' => ts('Contact ID')),
87 'title' => ts('Contact Name'),
91 'civicrm_email' => array(
92 'dao' => 'CRM_Core_DAO_Email',
95 'title' => ts('Email'),
99 'grouping' => 'contact-fields',
101 'civicrm_phone' => array(
102 'dao' => 'CRM_Core_DAO_Phone',
105 'title' => ts('Phone'),
109 'grouping' => 'contact-fields',
111 'civicrm_financial_type' => array(
112 'dao' => 'CRM_Financial_DAO_FinancialType',
113 'fields' => array('financial_type' => NULL),
114 'grouping' => 'contri-fields',
115 'group_bys' => array(
116 'financial_type' => array('title' => ts('Financial Type')),
119 'civicrm_contribution' => array(
120 'dao' => 'CRM_Contribute_DAO_Contribution',
121 //'bao' => 'CRM_Contribute_BAO_Contribution',
123 'contribution_source' => array('title' => ts('Source')),
126 'no_display' => TRUE,
128 'total_amount' => array(
129 'title' => ts('Contribution Amount Stats'),
131 'statistics' => array(
132 'sum' => ts('Contribution Aggregate'),
133 'count' => ts('Contributions'),
134 'avg' => ts('Contribution Avg'),
138 'grouping' => 'contri-fields',
140 'receive_date' => array('operatorType' => CRM_Report_Form
::OP_DATE
),
141 'contribution_status_id' => array(
142 'title' => ts('Contribution Status'),
143 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
144 'options' => CRM_Contribute_PseudoConstant
::contributionStatus(),
145 'default' => array(1),
146 'type' => CRM_Utils_Type
::T_INT
,
149 'title' => 'Currency',
150 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
151 'options' => CRM_Core_OptionGroup
::values('currencies_enabled'),
153 'type' => CRM_Utils_Type
::T_STRING
,
155 'financial_type_id' => array(
156 'title' => ts('Financial Type'),
157 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
158 'options' => CRM_Contribute_PseudoConstant
::financialType(),
159 'type' => CRM_Utils_Type
::T_INT
,
161 'contribution_page_id' => array(
162 'title' => ts('Contribution Page'),
163 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
164 'options' => CRM_Contribute_PseudoConstant
::contributionPage(),
165 'type' => CRM_Utils_Type
::T_INT
,
167 'total_amount' => array(
168 'title' => ts('Contribution Amount'),
170 'total_sum' => array(
171 'title' => ts('Contribution Aggregate'),
172 'type' => CRM_Report_Form
::OP_INT
,
173 'dbAlias' => 'civicrm_contribution_total_amount_sum',
176 'total_count' => array(
177 'title' => ts('Contribution Count'),
178 'type' => CRM_Report_Form
::OP_INT
,
179 'dbAlias' => 'civicrm_contribution_total_amount_count',
182 'total_avg' => array(
183 'title' => ts('Contribution Avg'),
184 'type' => CRM_Report_Form
::OP_INT
,
185 'dbAlias' => 'civicrm_contribution_total_amount_avg',
189 'group_bys' => array(
190 'receive_date' => array(
195 'contribution_source' => NULL,
198 'civicrm_contribution_soft' => array(
199 'dao' => 'CRM_Contribute_DAO_ContributionSoft',
201 'soft_amount' => array(
202 'title' => ts('Soft Credit Amount Stats'),
204 'statistics' => array(
205 'sum' => ts('Soft Credit Aggregate'),
206 'count' => ts('Soft Credits'),
207 'avg' => ts('Soft Credit Avg'),
211 'grouping' => 'contri-fields',
214 'title' => ts('Soft Credit Amount'),
216 'soft_credit_type_id' => array(
217 'title' => 'Soft Credit Type',
218 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
219 'options' => CRM_Core_OptionGroup
::values('soft_credit_type'),
221 'type' => CRM_Utils_Type
::T_STRING
,
224 'title' => ts('Soft Credit Aggregate'),
225 'type' => CRM_Report_Form
::OP_INT
,
226 'dbAlias' => 'civicrm_contribution_soft_soft_amount_sum',
229 'soft_count' => array(
230 'title' => ts('Soft Credits Count'),
231 'type' => CRM_Report_Form
::OP_INT
,
232 'dbAlias' => 'civicrm_contribution_soft_soft_amount_count',
236 'title' => ts('Soft Credit Avg'),
237 'type' => CRM_Report_Form
::OP_INT
,
238 'dbAlias' => 'civicrm_contribution_soft_soft_amount_avg',
243 ) +
$this->addAddressFields();
245 // If we have a campaign, build out the relevant elements
246 if ($campaignEnabled && !empty($this->activeCampaigns
)) {
247 $this->_columns
['civicrm_contribution']['fields']['campaign_id'] = array(
248 'title' => 'Campaign',
249 'default' => 'false',
251 $this->_columns
['civicrm_contribution']['filters']['campaign_id'] = array(
252 'title' => ts('Campaign'),
253 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
254 'options' => $this->activeCampaigns
,
256 $this->_columns
['civicrm_contribution']['group_bys']['campaign_id'] = array('title' => ts('Campaign'));
259 $this->_tagFilter
= TRUE;
260 $this->_groupFilter
= TRUE;
261 $this->_currencyColumn
= 'civicrm_contribution_currency';
262 parent
::__construct();
265 public function preProcess() {
266 parent
::preProcess();
270 * @param bool $freeze
274 public function setDefaultValues($freeze = TRUE) {
275 return parent
::setDefaultValues($freeze);
278 public function select() {
280 $this->_columnHeaders
= array();
281 foreach ($this->_columns
as $tableName => $table) {
282 if (array_key_exists('group_bys', $table)) {
283 foreach ($table['group_bys'] as $fieldName => $field) {
284 if ($tableName == 'civicrm_address') {
285 $this->_addressField
= TRUE;
287 if (!empty($this->_params
['group_bys'][$fieldName])) {
288 switch (CRM_Utils_Array
::value($fieldName, $this->_params
['group_bys_freq'])) {
290 $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start";
291 $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
292 $select[] = "WEEKOFYEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
293 $field['title'] = 'Week';
297 $select[] = "MAKEDATE(YEAR({$field['dbAlias']}), 1) AS {$tableName}_{$fieldName}_start";
298 $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
299 $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
300 $field['title'] = 'Year';
304 $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL (DAYOFMONTH({$field['dbAlias']})-1) DAY) as {$tableName}_{$fieldName}_start";
305 $select[] = "MONTH({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
306 $select[] = "MONTHNAME({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
307 $field['title'] = 'Month';
311 $select[] = "STR_TO_DATE(CONCAT( 3 * QUARTER( {$field['dbAlias']} ) -2 , '/', '1', '/', YEAR( {$field['dbAlias']} ) ), '%m/%d/%Y') AS {$tableName}_{$fieldName}_start";
312 $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
313 $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
314 $field['title'] = 'Quarter';
317 if (!empty($this->_params
['group_bys_freq'][$fieldName])) {
318 $this->_interval
= $field['title'];
319 $this->_columnHeaders
["{$tableName}_{$fieldName}_start"]['title'] =
320 $field['title'] . ' Beginning';
321 $this->_columnHeaders
["{$tableName}_{$fieldName}_start"]['type'] = $field['type'];
322 $this->_columnHeaders
["{$tableName}_{$fieldName}_start"]['group_by'] = $this->_params
['group_bys_freq'][$fieldName];
324 // just to make sure these values are transfered to rows.
325 // since we need that for calculation purpose,
326 // e.g making subtotals look nicer or graphs
327 $this->_columnHeaders
["{$tableName}_{$fieldName}_interval"] = array('no_display' => TRUE);
328 $this->_columnHeaders
["{$tableName}_{$fieldName}_subtotal"] = array('no_display' => TRUE);
334 if (array_key_exists('fields', $table)) {
335 foreach ($table['fields'] as $fieldName => $field) {
336 if ($tableName == 'civicrm_address') {
337 $this->_addressField
= TRUE;
339 if (!empty($field['required']) ||
340 !empty($this->_params
['fields'][$fieldName])
343 // only include statistics columns if set
344 if (!empty($field['statistics'])) {
345 foreach ($field['statistics'] as $stat => $label) {
346 switch (strtolower($stat)) {
348 $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}";
349 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
350 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = $field['type'];
351 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
355 $select[] = "COUNT({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}";
356 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = CRM_Utils_Type
::T_INT
;
357 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
358 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
362 $select[] = "ROUND(AVG({$field['dbAlias']}),2) as {$tableName}_{$fieldName}_{$stat}";
363 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = $field['type'];
364 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
365 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
371 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
372 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
373 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
380 $this->_select
= "SELECT " . implode(', ', $select) . " ";
390 public static function formRule($fields, $files, $self) {
391 $errors = $grouping = array();
392 //check for searching combination of dispaly columns and
394 $ignoreFields = array('total_amount', 'sort_name');
395 $errors = $self->customDataFormRule($fields, $ignoreFields);
397 if (empty($fields['group_bys']['receive_date'])) {
398 if (!empty($fields['receive_date_relative']) ||
399 CRM_Utils_Date
::isDate($fields['receive_date_from']) ||
400 CRM_Utils_Date
::isDate($fields['receive_date_to'])
402 $errors['receive_date_relative'] = ts("Do not use filter on Date if group by Receive Date is not used ");
405 if (empty($fields['fields']['total_amount'])) {
411 if (!empty($fields[$val])) {
412 $errors[$val] = ts("Please select the Amount Statistics");
420 public function from() {
421 $softCreditJoin = "LEFT";
422 if (!empty($this->_params
['fields']['soft_amount']) &&
423 empty($this->_params
['fields']['total_amount'])
425 // if its only soft credit stats, use inner join
426 $softCreditJoin = "INNER";
430 FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom}
431 INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
432 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id AND
433 {$this->_aliases['civicrm_contribution']}.is_test = 0
434 {$softCreditJoin} JOIN civicrm_contribution_soft {$this->_aliases['civicrm_contribution_soft']}
435 ON {$this->_aliases['civicrm_contribution_soft']}.contribution_id = {$this->_aliases['civicrm_contribution']}.id
436 LEFT JOIN civicrm_financial_type {$this->_aliases['civicrm_financial_type']}
437 ON {$this->_aliases['civicrm_contribution']}.financial_type_id ={$this->_aliases['civicrm_financial_type']}.id
438 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
439 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
440 {$this->_aliases['civicrm_email']}.is_primary = 1)
442 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
443 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
444 {$this->_aliases['civicrm_phone']}.is_primary = 1)";
446 if ($this->_addressField
) {
448 LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
449 ON {$this->_aliases['civicrm_contact']}.id =
450 {$this->_aliases['civicrm_address']}.contact_id AND
451 {$this->_aliases['civicrm_address']}.is_primary = 1\n";
455 public function groupBy() {
456 $this->_groupBy
= "";
458 if (is_array($this->_params
['group_bys']) &&
459 !empty($this->_params
['group_bys'])
461 foreach ($this->_columns
as $tableName => $table) {
462 if (array_key_exists('group_bys', $table)) {
463 foreach ($table['group_bys'] as $fieldName => $field) {
464 if (!empty($this->_params
['group_bys'][$fieldName])) {
465 if (!empty($field['chart'])) {
466 $this->assign('chartSupported', TRUE);
469 if (!empty($table['group_bys'][$fieldName]['frequency']) &&
470 !empty($this->_params
['group_bys_freq'][$fieldName])
473 $append = "YEAR({$field['dbAlias']}),";
474 if (in_array(strtolower($this->_params
['group_bys_freq'][$fieldName]),
479 $this->_groupBy
[] = "$append {$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})";
483 $this->_groupBy
[] = $field['dbAlias'];
490 if (!empty($this->_statFields
) &&
491 (($append && count($this->_groupBy
) <= 1) ||
(!$append)) &&
494 $this->_rollup
= " WITH ROLLUP";
496 $this->_groupBy
= "GROUP BY " . implode(', ', $this->_groupBy
) .
497 " {$this->_rollup} ";
500 $this->_groupBy
= "GROUP BY {$this->_aliases['civicrm_contact']}.id";
504 public function storeWhereHavingClauseArray() {
505 parent
::storeWhereHavingClauseArray();
506 if (empty($this->_params
['fields']['soft_amount']) &&
507 !empty($this->_havingClauses
)
509 foreach ($this->_havingClauses
as $key => $havingClause) {
510 if (stristr($havingClause, 'soft_soft')) {
511 unset($this->_havingClauses
[$key]);
522 public function statistics(&$rows) {
523 $statistics = parent
::statistics($rows);
525 $softCredit = CRM_Utils_Array
::value('soft_amount', $this->_params
['fields']);
526 $onlySoftCredit = $softCredit &&
527 !CRM_Utils_Array
::value('total_amount', $this->_params
['fields']);
528 $totalAmount = $average = $softTotalAmount = $softAverage = array();
531 COUNT({$this->_aliases['civicrm_contribution']}.total_amount ) as civicrm_contribution_total_amount_count,
532 SUM({$this->_aliases['civicrm_contribution']}.total_amount ) as civicrm_contribution_total_amount_sum,
533 ROUND(AVG({$this->_aliases['civicrm_contribution']}.total_amount), 2) as civicrm_contribution_total_amount_avg,
534 {$this->_aliases['civicrm_contribution']}.currency as currency";
538 COUNT({$this->_aliases['civicrm_contribution_soft']}.amount ) as civicrm_contribution_soft_soft_amount_count,
539 SUM({$this->_aliases['civicrm_contribution_soft']}.amount ) as civicrm_contribution_soft_soft_amount_sum,
540 ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_contribution_soft_soft_amount_avg";
542 $group = "\nGROUP BY {$this->_aliases['civicrm_contribution']}.currency";
543 $sql = "{$select} {$this->_from} {$this->_where} {$group} {$this->_having}";
545 $dao = CRM_Core_DAO
::executeQuery($sql);
546 $totalAmount = $average = $softTotalAmount = $softAverage = array();
547 $count = $softCount = 0;
548 while ($dao->fetch()) {
550 CRM_Utils_Money
::format($dao->civicrm_contribution_total_amount_sum
, $dao->currency
) .
551 " (" . $dao->civicrm_contribution_total_amount_count
. ")";
552 $average[] = CRM_Utils_Money
::format($dao->civicrm_contribution_total_amount_avg
, $dao->currency
);
553 $count +
= $dao->civicrm_contribution_total_amount_count
;
557 CRM_Utils_Money
::format($dao->civicrm_contribution_soft_soft_amount_sum
, $dao->currency
) .
558 " (" . $dao->civicrm_contribution_soft_soft_amount_count
. ")";
559 $softAverage[] = CRM_Utils_Money
::format($dao->civicrm_contribution_soft_soft_amount_avg
, $dao->currency
);
560 $softCount +
= $dao->civicrm_contribution_soft_soft_amount_count
;
564 if (!$onlySoftCredit) {
565 $statistics['counts']['amount'] = array(
566 'title' => ts('Total Amount'),
567 'value' => implode(', ', $totalAmount),
568 'type' => CRM_Utils_Type
::T_STRING
,
570 $statistics['counts']['count'] = array(
571 'title' => ts('Total Contributions'),
574 $statistics['counts']['avg'] = array(
575 'title' => ts('Average'),
576 'value' => implode(', ', $average),
577 'type' => CRM_Utils_Type
::T_STRING
,
581 $statistics['counts']['soft_amount'] = array(
582 'title' => ts('Total Soft Credit Amount'),
583 'value' => implode(', ', $softTotalAmount),
584 'type' => CRM_Utils_Type
::T_STRING
,
586 $statistics['counts']['soft_count'] = array(
587 'title' => ts('Total Soft Credits'),
588 'value' => $softCount,
590 $statistics['counts']['soft_avg'] = array(
591 'title' => ts('Average Soft Credit'),
592 'value' => implode(', ', $softAverage),
593 'type' => CRM_Utils_Type
::T_STRING
,
599 public function postProcess() {
600 $this->buildACLClause($this->_aliases
['civicrm_contact']);
601 parent
::postProcess();
607 public function buildChart(&$rows) {
608 $graphRows = array();
610 if (!empty($this->_params
['charts'])) {
611 if (!empty($this->_params
['group_bys']['receive_date'])) {
613 $contrib = !empty($this->_params
['fields']['total_amount']) ?
TRUE : FALSE;
614 $softContrib = !empty($this->_params
['fields']['soft_amount']) ?
TRUE : FALSE;
616 foreach ($rows as $key => $row) {
617 if ($row['civicrm_contribution_receive_date_subtotal']) {
618 $graphRows['receive_date'][] = $row['civicrm_contribution_receive_date_start'];
619 $graphRows[$this->_interval
][] = $row['civicrm_contribution_receive_date_interval'];
620 if ($softContrib && $contrib) {
621 // both contri & soft contri stats are present
622 $graphRows['multiValue'][0][] = $row['civicrm_contribution_total_amount_sum'];
623 $graphRows['multiValue'][1][] = $row['civicrm_contribution_soft_soft_amount_sum'];
625 elseif ($softContrib) {
626 // only soft contributions
627 $graphRows['multiValue'][0][] = $row['civicrm_contribution_soft_soft_amount_sum'];
630 // only contributions
631 $graphRows['multiValue'][0][] = $row['civicrm_contribution_total_amount_sum'];
636 if ($softContrib && $contrib) {
637 $graphRows['barKeys'][0] = ts('Contributions');
638 $graphRows['barKeys'][1] = ts('Soft Credits');
639 $graphRows['legend'] = ts('Contributions and Soft Credits');
641 elseif ($softContrib) {
642 $graphRows['legend'] = ts('Soft Credits');
646 $config = CRM_Core_Config
::Singleton();
647 $graphRows['xname'] = $this->_interval
;
648 $graphRows['yname'] = "Amount ({$config->defaultCurrency})";
649 CRM_Utils_OpenFlashChart
::chart($graphRows, $this->_params
['charts'], $this->_interval
);
650 $this->assign('chartType', $this->_params
['charts']);
658 public function alterDisplay(&$rows) {
659 // custom code to alter rows
662 foreach ($rows as $rowNum => $row) {
663 // make count columns point to detail report
664 if (!empty($this->_params
['group_bys']['receive_date']) &&
665 !empty($row['civicrm_contribution_receive_date_start']) &&
666 CRM_Utils_Array
::value('civicrm_contribution_receive_date_start', $row) &&
667 !empty($row['civicrm_contribution_receive_date_subtotal'])
670 $dateStart = CRM_Utils_Date
::customFormat($row['civicrm_contribution_receive_date_start'], '%Y%m%d');
671 $endDate = new DateTime($dateStart);
674 list($dateEnd['Y'], $dateEnd['M'], $dateEnd['d']) = explode(':', $endDate->format('Y:m:d'));
676 switch (strtolower($this->_params
['group_bys_freq']['receive_date'])) {
678 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] +
1,
679 $dateEnd['d'] - 1, $dateEnd['Y']
684 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'],
685 $dateEnd['d'] - 1, $dateEnd['Y'] +
1
690 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'],
691 $dateEnd['d'] +
6, $dateEnd['Y']
696 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] +
3,
697 $dateEnd['d'] - 1, $dateEnd['Y']
701 $url = CRM_Report_Utils_Report
::getNextUrl('contribute/detail',
702 "reset=1&force=1&receive_date_from={$dateStart}&receive_date_to={$dateEnd}",
705 $this->_drilldownReport
707 $rows[$rowNum]['civicrm_contribution_receive_date_start_link'] = $url;
708 $rows[$rowNum]['civicrm_contribution_receive_date_start_hover'] = ts('List all contribution(s) for this date unit.');
712 // make subtotals look nicer
713 if (array_key_exists('civicrm_contribution_receive_date_subtotal', $row) &&
714 !$row['civicrm_contribution_receive_date_subtotal']
716 $this->fixSubTotalDisplay($rows[$rowNum], $this->_statFields
);
720 // convert display name to links
721 if (array_key_exists('civicrm_contact_sort_name', $row) &&
722 array_key_exists('civicrm_contact_id', $row)
724 $url = CRM_Report_Utils_Report
::getNextUrl('contribute/detail',
725 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'],
726 $this->_absoluteUrl
, $this->_id
, $this->_drilldownReport
728 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
729 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("Lists detailed contribution(s) for this record.");
733 // If using campaigns, convert campaign_id to campaign title
734 if (array_key_exists('civicrm_contribution_campaign_id', $row)) {
735 if ($value = $row['civicrm_contribution_campaign_id']) {
736 $rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->activeCampaigns
[$value];
741 $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s) for this ') ?
TRUE : $entryFound;
743 // skip looking further in rows, if first row itself doesn't
744 // have the column we need