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_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');
54 function __construct() {
56 // Check if CiviCampaign is a) enabled and b) has active campaigns
57 $config = CRM_Core_Config
::singleton();
58 $campaignEnabled = in_array("CiviCampaign", $config->enableComponents
);
59 if ($campaignEnabled) {
60 $getCampaigns = CRM_Campaign_BAO_Campaign
::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
61 $this->activeCampaigns
= $getCampaigns['campaigns'];
62 asort($this->activeCampaigns
);
65 $this->_columns
= array(
68 'dao' => 'CRM_Contact_DAO_Contact',
72 array('title' => ts('Contact Name'),
75 'postal_greeting_display' =>
76 array('title' => ts('Postal Greeting')),
84 'title' => ts('Contact Type'),
88 'title' => ts('Contact Subtype'),
91 'grouping' => 'contact-fields',
95 array('title' => ts('Contact ID')),
97 array('title' => ts('Contact Name'),
103 'dao' => 'CRM_Core_DAO_Email',
107 array('title' => ts('Email'),
111 'grouping' => 'contact-fields',
115 'dao' => 'CRM_Core_DAO_Phone',
119 array('title' => ts('Phone'),
123 'grouping' => 'contact-fields',
125 'civicrm_financial_type' =>
126 array('dao' => 'CRM_Financial_DAO_FinancialType',
127 'fields' => array('financial_type' => null,),
128 'grouping' => 'contri-fields',
129 'group_bys' => array(
130 'financial_type' => array('title' => ts('Financial Type')),
133 'civicrm_contribution' =>
135 'dao' => 'CRM_Contribute_DAO_Contribution',
136 //'bao' => 'CRM_Contribute_BAO_Contribution',
139 'contribution_source' => array('title' => ts('Source'), ),
141 array('required' => TRUE,
142 'no_display' => TRUE,
145 array('title' => ts('Contribution Amount Stats'),
148 array('sum' => ts('Contribution Aggregate'),
149 'count' => ts('Contributions'),
150 'avg' => ts('Contribution Avg'),
154 'grouping' => 'contri-fields',
158 array('operatorType' => CRM_Report_Form
::OP_DATE
),
159 'contribution_status_id' =>
160 array('title' => ts('Contribution Status'),
161 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
162 'options' => CRM_Contribute_PseudoConstant
::contributionStatus(),
163 'default' => array(1),
164 'type' => CRM_Utils_Type
::T_INT
,
167 array('title' => 'Currency',
168 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
169 'options' => CRM_Core_OptionGroup
::values('currencies_enabled'),
171 'type' => CRM_Utils_Type
::T_STRING
,
173 'financial_type_id' =>
174 array('title' => ts('Financial Type'),
175 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
176 'options' => CRM_Contribute_PseudoConstant
::financialType(),
177 'type' => CRM_Utils_Type
::T_INT
,
179 'contribution_page_id' =>
180 array('title' => ts('Contribution Page'),
181 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
182 'options' => CRM_Contribute_PseudoConstant
::contributionPage(),
183 'type' => CRM_Utils_Type
::T_INT
,
186 array('title' => ts('Contribution Amount'),
189 array('title' => ts('Contribution Aggregate'),
190 'type' => CRM_Report_Form
::OP_INT
,
191 'dbAlias' => 'civicrm_contribution_total_amount_sum',
195 array('title' => ts('Contribution Count'),
196 'type' => CRM_Report_Form
::OP_INT
,
197 'dbAlias' => 'civicrm_contribution_total_amount_count',
201 array('title' => ts('Contribution Avg'),
202 'type' => CRM_Report_Form
::OP_INT
,
203 'dbAlias' => 'civicrm_contribution_total_amount_avg',
215 'contribution_source' => NULL,
218 'civicrm_contribution_soft' =>
220 'dao' => 'CRM_Contribute_DAO_ContributionSoft',
225 'title' => ts('Soft Credit Amount Stats'),
228 array('sum' => ts('Soft Credit Aggregate'),
229 'count' => ts('Soft Credits'),
230 'avg' => ts('Soft Credit Avg'),
234 'grouping' => 'contri-fields',
238 array('title' => ts('Soft Credit Amount'),
240 'soft_credit_type_id' =>
241 array('title' => 'Soft Credit Type',
242 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
243 'options' => CRM_Core_OptionGroup
::values('soft_credit_type'),
245 'type' => CRM_Utils_Type
::T_STRING
,
248 array('title' => ts('Soft Credit Aggregate'),
249 'type' => CRM_Report_Form
::OP_INT
,
250 'dbAlias' => 'civicrm_contribution_soft_soft_amount_sum',
254 array('title' => ts('Soft Credits Count'),
255 'type' => CRM_Report_Form
::OP_INT
,
256 'dbAlias' => 'civicrm_contribution_soft_soft_amount_count',
260 array('title' => ts('Soft Credit Avg'),
261 'type' => CRM_Report_Form
::OP_INT
,
262 'dbAlias' => 'civicrm_contribution_soft_soft_amount_avg',
267 ) +
$this->addAddressFields();
269 // If we have a campaign, build out the relevant elements
270 if ($campaignEnabled && !empty($this->activeCampaigns
)) {
271 $this->_columns
['civicrm_contribution']['fields']['campaign_id'] = array(
272 'title' => 'Campaign',
273 'default' => 'false',
275 $this->_columns
['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'),
276 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
277 'options' => $this->activeCampaigns
,
279 $this->_columns
['civicrm_contribution']['group_bys']['campaign_id'] = array('title' => ts('Campaign'));
282 $this->_tagFilter
= TRUE;
283 $this->_groupFilter
= TRUE;
284 $this->_currencyColumn
= 'civicrm_contribution_currency';
285 parent
::__construct();
288 function preProcess() {
289 parent
::preProcess();
293 * @param bool $freeze
297 function setDefaultValues($freeze = TRUE) {
298 return parent
::setDefaultValues($freeze);
303 $this->_columnHeaders
= array();
304 foreach ($this->_columns
as $tableName => $table) {
305 if (array_key_exists('group_bys', $table)) {
306 foreach ($table['group_bys'] as $fieldName => $field) {
307 if ($tableName == 'civicrm_address') {
308 $this->_addressField
= TRUE;
310 if (!empty($this->_params
['group_bys'][$fieldName])) {
311 switch (CRM_Utils_Array
::value($fieldName, $this->_params
['group_bys_freq'])) {
313 $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start";
314 $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
315 $select[] = "WEEKOFYEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
316 $field['title'] = 'Week';
320 $select[] = "MAKEDATE(YEAR({$field['dbAlias']}), 1) AS {$tableName}_{$fieldName}_start";
321 $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
322 $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
323 $field['title'] = 'Year';
327 $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL (DAYOFMONTH({$field['dbAlias']})-1) DAY) as {$tableName}_{$fieldName}_start";
328 $select[] = "MONTH({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
329 $select[] = "MONTHNAME({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
330 $field['title'] = 'Month';
334 $select[] = "STR_TO_DATE(CONCAT( 3 * QUARTER( {$field['dbAlias']} ) -2 , '/', '1', '/', YEAR( {$field['dbAlias']} ) ), '%m/%d/%Y') AS {$tableName}_{$fieldName}_start";
335 $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
336 $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
337 $field['title'] = 'Quarter';
340 if (!empty($this->_params
['group_bys_freq'][$fieldName])) {
341 $this->_interval
= $field['title'];
342 $this->_columnHeaders
["{$tableName}_{$fieldName}_start"]['title'] = $field['title'] . ' Beginning';
343 $this->_columnHeaders
["{$tableName}_{$fieldName}_start"]['type'] = $field['type'];
344 $this->_columnHeaders
["{$tableName}_{$fieldName}_start"]['group_by'] = $this->_params
['group_bys_freq'][$fieldName];
346 // just to make sure these values are transfered to rows.
347 // since we need that for calculation purpose,
348 // e.g making subtotals look nicer or graphs
349 $this->_columnHeaders
["{$tableName}_{$fieldName}_interval"] = array('no_display' => TRUE);
350 $this->_columnHeaders
["{$tableName}_{$fieldName}_subtotal"] = array('no_display' => TRUE);
356 if (array_key_exists('fields', $table)) {
357 foreach ($table['fields'] as $fieldName => $field) {
358 if ($tableName == 'civicrm_address') {
359 $this->_addressField
= TRUE;
361 if (!empty($field['required']) ||
!empty($this->_params
['fields'][$fieldName])) {
363 // only include statistics columns if set
364 if (!empty($field['statistics'])) {
365 foreach ($field['statistics'] as $stat => $label) {
366 switch (strtolower($stat)) {
368 $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}";
369 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
370 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = $field['type'];
371 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
375 $select[] = "COUNT({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}";
376 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = CRM_Utils_Type
::T_INT
;
377 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
378 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
382 $select[] = "ROUND(AVG({$field['dbAlias']}),2) as {$tableName}_{$fieldName}_{$stat}";
383 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = $field['type'];
384 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
385 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
391 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
392 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
393 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
400 $this->_select
= "SELECT " . implode(', ', $select) . " ";
410 static function formRule($fields, $files, $self) {
411 $errors = $grouping = array();
412 //check for searching combination of dispaly columns and
414 $ignoreFields = array('total_amount', 'sort_name');
415 $errors = $self->customDataFormRule($fields, $ignoreFields);
417 if (empty($fields['group_bys']['receive_date'])) {
418 if (!empty($fields['receive_date_relative']) ||
419 CRM_Utils_Date
::isDate($fields['receive_date_from']) ||
420 CRM_Utils_Date
::isDate($fields['receive_date_to'])
422 $errors['receive_date_relative'] = ts("Do not use filter on Date if group by Receive Date is not used ");
425 if (empty($fields['fields']['total_amount'])) {
427 'total_count_value', 'total_sum_value', 'total_avg_value') as $val) {
428 if (!empty($fields[$val])) {
429 $errors[$val] = ts("Please select the Amount Statistics");
438 $softCreditJoin = "LEFT";
439 if (!empty($this->_params
['fields']['soft_amount']) && empty($this->_params
['fields']['total_amount'])) {
440 // if its only soft credit stats, use inner join
441 $softCreditJoin = "INNER";
445 FROM civicrm_contact {$this->_aliases['civicrm_contact']}
446 INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
447 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id AND
448 {$this->_aliases['civicrm_contribution']}.is_test = 0
449 {$softCreditJoin} JOIN civicrm_contribution_soft {$this->_aliases['civicrm_contribution_soft']}
450 ON {$this->_aliases['civicrm_contribution_soft']}.contribution_id = {$this->_aliases['civicrm_contribution']}.id
451 LEFT JOIN civicrm_financial_type {$this->_aliases['civicrm_financial_type']}
452 ON {$this->_aliases['civicrm_contribution']}.financial_type_id ={$this->_aliases['civicrm_financial_type']}.id
453 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
454 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
455 {$this->_aliases['civicrm_email']}.is_primary = 1)
457 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
458 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
459 {$this->_aliases['civicrm_phone']}.is_primary = 1)";
461 if ($this->_addressField
) {
463 LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
464 ON {$this->_aliases['civicrm_contact']}.id =
465 {$this->_aliases['civicrm_address']}.contact_id AND
466 {$this->_aliases['civicrm_address']}.is_primary = 1\n";
471 $this->_groupBy
= "";
473 if (is_array($this->_params
['group_bys']) &&
474 !empty($this->_params
['group_bys'])
476 foreach ($this->_columns
as $tableName => $table) {
477 if (array_key_exists('group_bys', $table)) {
478 foreach ($table['group_bys'] as $fieldName => $field) {
479 if (!empty($this->_params
['group_bys'][$fieldName])) {
480 if (!empty($field['chart'])) {
481 $this->assign('chartSupported', TRUE);
484 if (!empty($table['group_bys'][$fieldName]['frequency']) && !empty($this->_params
['group_bys_freq'][$fieldName])) {
486 $append = "YEAR({$field['dbAlias']}),";
487 if (in_array(strtolower($this->_params
['group_bys_freq'][$fieldName]),
492 $this->_groupBy
[] = "$append {$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})";
496 $this->_groupBy
[] = $field['dbAlias'];
503 if (!empty($this->_statFields
) &&
504 (($append && count($this->_groupBy
) <= 1) ||
(!$append)) && !$this->_having
506 $this->_rollup
= " WITH ROLLUP";
508 $this->_groupBy
= "GROUP BY " . implode(', ', $this->_groupBy
) . " {$this->_rollup} ";
511 $this->_groupBy
= "GROUP BY {$this->_aliases['civicrm_contact']}.id";
515 function storeWhereHavingClauseArray(){
516 parent
::storeWhereHavingClauseArray();
517 if (empty($this->_params
['fields']['soft_amount']) && !empty($this->_havingClauses
)){
518 foreach ($this->_havingClauses
as $key => $havingClause) {
519 if (stristr($havingClause, 'soft_soft')){
520 unset($this->_havingClauses
[$key]);
531 function statistics(&$rows) {
532 $statistics = parent
::statistics($rows);
534 $softCredit = CRM_Utils_Array
::value('soft_amount', $this->_params
['fields']);
535 $onlySoftCredit = $softCredit && !CRM_Utils_Array
::value('total_amount', $this->_params
['fields']);
536 $totalAmount = $average = $softTotalAmount = $softAverage = array();
539 COUNT({$this->_aliases['civicrm_contribution']}.total_amount ) as civicrm_contribution_total_amount_count,
540 SUM({$this->_aliases['civicrm_contribution']}.total_amount ) as civicrm_contribution_total_amount_sum,
541 ROUND(AVG({$this->_aliases['civicrm_contribution']}.total_amount), 2) as civicrm_contribution_total_amount_avg,
542 {$this->_aliases['civicrm_contribution']}.currency as currency";
546 COUNT({$this->_aliases['civicrm_contribution_soft']}.amount ) as civicrm_contribution_soft_soft_amount_count,
547 SUM({$this->_aliases['civicrm_contribution_soft']}.amount ) as civicrm_contribution_soft_soft_amount_sum,
548 ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_contribution_soft_soft_amount_avg";
550 $group = "\nGROUP BY {$this->_aliases['civicrm_contribution']}.currency";
551 $sql = "{$select} {$this->_from} {$this->_where} {$group} {$this->_having}";
553 $dao = CRM_Core_DAO
::executeQuery($sql);
554 $totalAmount = $average = $softTotalAmount = $softAverage = array();
555 $count = $softCount = 0;
556 while ($dao->fetch()) {
557 $totalAmount[] = CRM_Utils_Money
::format($dao->civicrm_contribution_total_amount_sum
, $dao->currency
)." (".$dao->civicrm_contribution_total_amount_count
.")";
558 $average[] = CRM_Utils_Money
::format($dao->civicrm_contribution_total_amount_avg
, $dao->currency
);
559 $count +
= $dao->civicrm_contribution_total_amount_count
;
562 $softTotalAmount[] = CRM_Utils_Money
::format($dao->civicrm_contribution_soft_soft_amount_sum
, $dao->currency
)." (".$dao->civicrm_contribution_soft_soft_amount_count
.")";
563 $softAverage[] = CRM_Utils_Money
::format($dao->civicrm_contribution_soft_soft_amount_avg
, $dao->currency
);
564 $softCount +
= $dao->civicrm_contribution_soft_soft_amount_count
;
568 if (!$onlySoftCredit) {
569 $statistics['counts']['amount'] = array(
570 'title' => ts('Total Amount'),
571 'value' => implode(', ', $totalAmount),
572 'type' => CRM_Utils_Type
::T_STRING
,
574 $statistics['counts']['count'] = array(
575 'title' => ts('Total Contributions'),
578 $statistics['counts']['avg'] = array(
579 'title' => ts('Average'),
580 'value' => implode(', ', $average),
581 'type' => CRM_Utils_Type
::T_STRING
,
585 $statistics['counts']['soft_amount'] = array(
586 'title' => ts('Total Soft Credit Amount'),
587 'value' => implode(', ', $softTotalAmount),
588 'type' => CRM_Utils_Type
::T_STRING
,
590 $statistics['counts']['soft_count'] = array(
591 'title' => ts('Total Soft Credits'),
592 'value' => $softCount,
594 $statistics['counts']['soft_avg'] = array(
595 'title' => ts('Average Soft Credit'),
596 'value' => implode(', ', $softAverage),
597 'type' => CRM_Utils_Type
::T_STRING
,
603 function postProcess() {
604 $this->buildACLClause($this->_aliases
['civicrm_contact']);
605 parent
::postProcess();
611 function buildChart(&$rows) {
612 $graphRows = array();
614 if (!empty($this->_params
['charts'])) {
615 if (!empty($this->_params
['group_bys']['receive_date'])) {
617 $contrib = !empty($this->_params
['fields']['total_amount']) ?
TRUE : FALSE;
618 $softContrib = !empty($this->_params
['fields']['soft_amount']) ?
TRUE : FALSE;
620 foreach ($rows as $key => $row) {
621 if ($row['civicrm_contribution_receive_date_subtotal']) {
622 $graphRows['receive_date'][] = $row['civicrm_contribution_receive_date_start'];
623 $graphRows[$this->_interval
][] = $row['civicrm_contribution_receive_date_interval'];
624 if ($softContrib && $contrib) {
625 // both contri & soft contri stats are present
626 $graphRows['multiValue'][0][] = $row['civicrm_contribution_total_amount_sum'];
627 $graphRows['multiValue'][1][] = $row['civicrm_contribution_soft_soft_amount_sum'];
628 } else if ($softContrib) {
629 // only soft contributions
630 $graphRows['multiValue'][0][] = $row['civicrm_contribution_soft_soft_amount_sum'];
632 // only contributions
633 $graphRows['multiValue'][0][] = $row['civicrm_contribution_total_amount_sum'];
638 if ($softContrib && $contrib) {
639 $graphRows['barKeys'][0] = ts('Contributions');
640 $graphRows['barKeys'][1] = ts('Soft Credits');
641 $graphRows['legend'] = ts('Contributions and Soft Credits');
642 } else if ($softContrib) {
643 $graphRows['legend'] = ts('Soft Credits');
647 $config = CRM_Core_Config
::Singleton();
648 $graphRows['xname'] = $this->_interval
;
649 $graphRows['yname'] = "Amount ({$config->defaultCurrency})";
650 CRM_Utils_OpenFlashChart
::chart($graphRows, $this->_params
['charts'], $this->_interval
);
651 $this->assign('chartType', $this->_params
['charts']);
659 function alterDisplay(&$rows) {
660 // custom code to alter rows
663 foreach ($rows as $rowNum => $row) {
664 // make count columns point to detail report
665 if (!empty($this->_params
['group_bys']['receive_date']) && !empty($row['civicrm_contribution_receive_date_start']) &&
666 CRM_Utils_Array
::value('civicrm_contribution_receive_date_start', $row) && !empty($row['civicrm_contribution_receive_date_subtotal'])) {
668 $dateStart = CRM_Utils_Date
::customFormat($row['civicrm_contribution_receive_date_start'], '%Y%m%d');
669 $endDate = new DateTime($dateStart);
672 list($dateEnd['Y'], $dateEnd['M'], $dateEnd['d']) = explode(':', $endDate->format('Y:m:d'));
674 switch (strtolower($this->_params
['group_bys_freq']['receive_date'])) {
676 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] +
1,
677 $dateEnd['d'] - 1, $dateEnd['Y']
682 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'],
683 $dateEnd['d'] - 1, $dateEnd['Y'] +
1
688 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'],
689 $dateEnd['d'] +
6, $dateEnd['Y']
694 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] +
3,
695 $dateEnd['d'] - 1, $dateEnd['Y']
699 $url = CRM_Report_Utils_Report
::getNextUrl('contribute/detail',
700 "reset=1&force=1&receive_date_from={$dateStart}&receive_date_to={$dateEnd}",
703 $this->_drilldownReport
705 $rows[$rowNum]['civicrm_contribution_receive_date_start_link'] = $url;
706 $rows[$rowNum]['civicrm_contribution_receive_date_start_hover'] = ts('List all contribution(s) for this date unit.');
710 // make subtotals look nicer
711 if (array_key_exists('civicrm_contribution_receive_date_subtotal', $row) &&
712 !$row['civicrm_contribution_receive_date_subtotal']
714 $this->fixSubTotalDisplay($rows[$rowNum], $this->_statFields
);
718 // convert display name to links
719 if (array_key_exists('civicrm_contact_sort_name', $row) &&
720 array_key_exists('civicrm_contact_id', $row)
722 $url = CRM_Report_Utils_Report
::getNextUrl('contribute/detail',
723 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'],
724 $this->_absoluteUrl
, $this->_id
, $this->_drilldownReport
726 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
727 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("Lists detailed contribution(s) for this record.");
731 // If using campaigns, convert campaign_id to campaign title
732 if (array_key_exists('civicrm_contribution_campaign_id', $row)) {
733 if ($value = $row['civicrm_contribution_campaign_id']) {
734 $rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->activeCampaigns
[$value];
739 $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s) for this ') ?
TRUE : $entryFound;
741 // skip looking further in rows, if first row itself doesn't
742 // have the column we need