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');
48 function __construct() {
50 // Check if CiviCampaign is a) enabled and b) has active campaigns
51 $config = CRM_Core_Config
::singleton();
52 $campaignEnabled = in_array("CiviCampaign", $config->enableComponents
);
53 if ($campaignEnabled) {
54 $getCampaigns = CRM_Campaign_BAO_Campaign
::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
55 $this->activeCampaigns
= $getCampaigns['campaigns'];
56 asort($this->activeCampaigns
);
59 $this->_columns
= array(
62 'dao' => 'CRM_Contact_DAO_Contact',
66 array('title' => ts('Contact Name'),
69 'postal_greeting_display' =>
70 array('title' => ts('Postal Greeting')),
78 'title' => ts('Contact Type'),
82 'title' => ts('Contact SubType'),
85 'grouping' => 'contact-fields',
89 array('title' => ts('Contact ID')),
91 array('title' => ts('Contact Name'),
97 'dao' => 'CRM_Core_DAO_Email',
101 array('title' => ts('Email'),
105 'grouping' => 'contact-fields',
109 'dao' => 'CRM_Core_DAO_Phone',
113 array('title' => ts('Phone'),
117 'grouping' => 'contact-fields',
119 'civicrm_financial_type' =>
120 array('dao' => 'CRM_Financial_DAO_FinancialType',
121 'fields' => array('financial_type' => null,),
122 'grouping' => 'contri-fields',
123 'group_bys' => array(
124 'financial_type' => array('title' => ts('Financial Type')),
127 'civicrm_contribution' =>
129 'dao' => 'CRM_Contribute_DAO_Contribution',
130 //'bao' => 'CRM_Contribute_BAO_Contribution',
133 'contribution_source' => array('title' => ts('Source'), ),
135 array('required' => TRUE,
136 'no_display' => TRUE,
139 array('title' => ts('Contribution Amount Stats'),
142 array('sum' => ts('Contributions Aggregate'),
143 'count' => ts('Contributions'),
144 'avg' => ts('Contributions Avg'),
148 'grouping' => 'contri-fields',
152 array('operatorType' => CRM_Report_Form
::OP_DATE
),
153 'contribution_status_id' =>
154 array('title' => ts('Donation Status'),
155 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
156 'options' => CRM_Contribute_PseudoConstant
::contributionStatus(),
157 'default' => array(1),
158 'type' => CRM_Utils_Type
::T_INT
,
161 array('title' => 'Currency',
162 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
163 'options' => CRM_Core_OptionGroup
::values('currencies_enabled'),
165 'type' => CRM_Utils_Type
::T_STRING
,
167 'financial_type_id' =>
168 array('title' => ts('Financial Type'),
169 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
170 'options' => CRM_Contribute_PseudoConstant
::financialType(),
171 'type' => CRM_Utils_Type
::T_INT
,
173 'contribution_page_id' =>
174 array('title' => ts('Contribution Page'),
175 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
176 'options' => CRM_Contribute_PseudoConstant
::contributionPage(),
177 'type' => CRM_Utils_Type
::T_INT
,
180 array('title' => ts('Contribution Amount'),
183 array('title' => ts('Contributions Aggregate'),
184 'type' => CRM_Report_Form
::OP_INT
,
185 'dbAlias' => 'civicrm_contribution_total_amount_sum',
189 array('title' => ts('Contributions Count'),
190 'type' => CRM_Report_Form
::OP_INT
,
191 'dbAlias' => 'civicrm_contribution_total_amount_count',
195 array('title' => ts('Contributions Avg'),
196 'type' => CRM_Report_Form
::OP_INT
,
197 'dbAlias' => 'civicrm_contribution_total_amount_avg',
209 'contribution_source' => NULL,
212 'civicrm_contribution_soft' =>
214 'dao' => 'CRM_Contribute_DAO_ContributionSoft',
219 'title' => ts('Soft Credit Amount Stats'),
222 array('sum' => ts('Soft Credit Aggregate'),
223 'count' => ts('Soft Credits'),
224 'avg' => ts('Soft Credit Avg'),
228 'grouping' => 'contri-fields',
232 array('title' => ts('Soft Credit Amount'),
234 'soft_credit_type_id' =>
235 array('title' => 'Soft Credit Type',
236 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
237 'options' => CRM_Core_OptionGroup
::values('soft_credit_type'),
239 'type' => CRM_Utils_Type
::T_STRING
,
242 array('title' => ts('Soft Credit Aggregate'),
243 'type' => CRM_Report_Form
::OP_INT
,
244 'dbAlias' => 'civicrm_contribution_soft_soft_amount_sum',
248 array('title' => ts('Soft Credits Count'),
249 'type' => CRM_Report_Form
::OP_INT
,
250 'dbAlias' => 'civicrm_contribution_soft_soft_amount_count',
254 array('title' => ts('Soft Credit Avg'),
255 'type' => CRM_Report_Form
::OP_INT
,
256 'dbAlias' => 'civicrm_contribution_soft_soft_amount_avg',
263 'dao' => 'CRM_Contact_DAO_GroupContact',
269 'name' => 'group_id',
270 'title' => ts('Group'),
271 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
273 'options' => CRM_Core_PseudoConstant
::group(),
274 'type' => CRM_Utils_Type
::T_INT
,
278 ) +
$this->addAddressFields();
280 // If we have a campaign, build out the relevant elements
281 $this->_tagFilter
= TRUE;
282 if ($campaignEnabled && !empty($this->activeCampaigns
)) {
283 $this->_columns
['civicrm_contribution']['fields']['campaign_id'] = array(
284 'title' => 'Campaign',
285 'default' => 'false',
287 $this->_columns
['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'),
288 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
289 'options' => $this->activeCampaigns
,
291 $this->_columns
['civicrm_contribution']['group_bys']['campaign_id'] = array('title' => ts('Campaign'));
294 $this->_currencyColumn
= 'civicrm_contribution_currency';
295 parent
::__construct();
298 function preProcess() {
299 parent
::preProcess();
302 function setDefaultValues($freeze = TRUE) {
303 return parent
::setDefaultValues($freeze);
308 $this->_columnHeaders
= array();
309 foreach ($this->_columns
as $tableName => $table) {
310 if (array_key_exists('group_bys', $table)) {
311 foreach ($table['group_bys'] as $fieldName => $field) {
312 if ($tableName == 'civicrm_address') {
313 $this->_addressField
= TRUE;
315 if (!empty($this->_params
['group_bys'][$fieldName])) {
316 switch (CRM_Utils_Array
::value($fieldName, $this->_params
['group_bys_freq'])) {
318 $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start";
319 $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
320 $select[] = "WEEKOFYEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
321 $field['title'] = 'Week';
325 $select[] = "MAKEDATE(YEAR({$field['dbAlias']}), 1) AS {$tableName}_{$fieldName}_start";
326 $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
327 $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
328 $field['title'] = 'Year';
332 $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL (DAYOFMONTH({$field['dbAlias']})-1) DAY) as {$tableName}_{$fieldName}_start";
333 $select[] = "MONTH({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
334 $select[] = "MONTHNAME({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
335 $field['title'] = 'Month';
339 $select[] = "STR_TO_DATE(CONCAT( 3 * QUARTER( {$field['dbAlias']} ) -2 , '/', '1', '/', YEAR( {$field['dbAlias']} ) ), '%m/%d/%Y') AS {$tableName}_{$fieldName}_start";
340 $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
341 $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
342 $field['title'] = 'Quarter';
345 if (!empty($this->_params
['group_bys_freq'][$fieldName])) {
346 $this->_interval
= $field['title'];
347 $this->_columnHeaders
["{$tableName}_{$fieldName}_start"]['title'] = $field['title'] . ' Beginning';
348 $this->_columnHeaders
["{$tableName}_{$fieldName}_start"]['type'] = $field['type'];
349 $this->_columnHeaders
["{$tableName}_{$fieldName}_start"]['group_by'] = $this->_params
['group_bys_freq'][$fieldName];
351 // just to make sure these values are transfered to rows.
352 // since we need that for calculation purpose,
353 // e.g making subtotals look nicer or graphs
354 $this->_columnHeaders
["{$tableName}_{$fieldName}_interval"] = array('no_display' => TRUE);
355 $this->_columnHeaders
["{$tableName}_{$fieldName}_subtotal"] = array('no_display' => TRUE);
361 if (array_key_exists('fields', $table)) {
362 foreach ($table['fields'] as $fieldName => $field) {
363 if ($tableName == 'civicrm_address') {
364 $this->_addressField
= TRUE;
366 if (!empty($field['required']) ||
!empty($this->_params
['fields'][$fieldName])) {
368 // only include statistics columns if set
369 if (!empty($field['statistics'])) {
370 foreach ($field['statistics'] as $stat => $label) {
371 switch (strtolower($stat)) {
373 $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}";
374 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
375 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = $field['type'];
376 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
380 $select[] = "COUNT({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}";
381 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = CRM_Utils_Type
::T_INT
;
382 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
383 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
387 $select[] = "ROUND(AVG({$field['dbAlias']}),2) as {$tableName}_{$fieldName}_{$stat}";
388 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = $field['type'];
389 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
390 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
396 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
397 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
398 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
405 $this->_select
= "SELECT " . implode(', ', $select) . " ";
408 static function formRule($fields, $files, $self) {
409 $errors = $grouping = array();
410 //check for searching combination of dispaly columns and
412 $ignoreFields = array('total_amount', 'sort_name');
413 $errors = $self->customDataFormRule($fields, $ignoreFields);
415 if (empty($fields['group_bys']['receive_date'])) {
416 if (!empty($fields['receive_date_relative']) ||
417 CRM_Utils_Date
::isDate($fields['receive_date_from']) ||
418 CRM_Utils_Date
::isDate($fields['receive_date_to'])
420 $errors['receive_date_relative'] = ts("Do not use filter on Date if group by Receive Date is not used ");
423 if (empty($fields['fields']['total_amount'])) {
425 'total_count_value', 'total_sum_value', 'total_avg_value') as $val) {
426 if (!empty($fields[$val])) {
427 $errors[$val] = ts("Please select the Amount Statistics");
436 $softCreditJoin = "LEFT";
437 if (!empty($this->_params
['fields']['soft_amount']) && empty($this->_params
['fields']['total_amount'])) {
438 // if its only soft credit stats, use inner join
439 $softCreditJoin = "INNER";
443 FROM civicrm_contact {$this->_aliases['civicrm_contact']}
444 INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
445 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id AND
446 {$this->_aliases['civicrm_contribution']}.is_test = 0
447 {$softCreditJoin} JOIN civicrm_contribution_soft {$this->_aliases['civicrm_contribution_soft']}
448 ON {$this->_aliases['civicrm_contribution_soft']}.contribution_id = {$this->_aliases['civicrm_contribution']}.id
449 LEFT JOIN civicrm_financial_type {$this->_aliases['civicrm_financial_type']}
450 ON {$this->_aliases['civicrm_contribution']}.financial_type_id ={$this->_aliases['civicrm_financial_type']}.id
451 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
452 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
453 {$this->_aliases['civicrm_email']}.is_primary = 1)
455 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
456 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
457 {$this->_aliases['civicrm_phone']}.is_primary = 1)";
459 if ($this->_addressField
) {
461 LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
462 ON {$this->_aliases['civicrm_contact']}.id =
463 {$this->_aliases['civicrm_address']}.contact_id AND
464 {$this->_aliases['civicrm_address']}.is_primary = 1\n";
469 $this->_groupBy
= "";
471 if (is_array($this->_params
['group_bys']) &&
472 !empty($this->_params
['group_bys'])
474 foreach ($this->_columns
as $tableName => $table) {
475 if (array_key_exists('group_bys', $table)) {
476 foreach ($table['group_bys'] as $fieldName => $field) {
477 if (!empty($this->_params
['group_bys'][$fieldName])) {
478 if (!empty($field['chart'])) {
479 $this->assign('chartSupported', TRUE);
482 if (!empty($table['group_bys'][$fieldName]['frequency']) && !empty($this->_params
['group_bys_freq'][$fieldName])) {
484 $append = "YEAR({$field['dbAlias']}),";
485 if (in_array(strtolower($this->_params
['group_bys_freq'][$fieldName]),
490 $this->_groupBy
[] = "$append {$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})";
494 $this->_groupBy
[] = $field['dbAlias'];
501 if (!empty($this->_statFields
) &&
502 (($append && count($this->_groupBy
) <= 1) ||
(!$append)) && !$this->_having
504 $this->_rollup
= " WITH ROLLUP";
506 $this->_groupBy
= "GROUP BY " . implode(', ', $this->_groupBy
) . " {$this->_rollup} ";
509 $this->_groupBy
= "GROUP BY {$this->_aliases['civicrm_contact']}.id";
513 function storeWhereHavingClauseArray(){
514 parent
::storeWhereHavingClauseArray();
515 if (empty($this->_params
['fields']['soft_amount']) && !empty($this->_havingClauses
)){
516 foreach ($this->_havingClauses
as $key => $havingClause) {
517 if (stristr($havingClause, 'soft_soft')){
518 unset($this->_havingClauses
[$key]);
524 function statistics(&$rows) {
525 $statistics = parent
::statistics($rows);
527 $softCredit = CRM_Utils_Array
::value('soft_amount', $this->_params
['fields']);
528 $onlySoftCredit = $softCredit && !CRM_Utils_Array
::value('total_amount', $this->_params
['fields']);
529 $totalAmount = $average = $softTotalAmount = $softAverage = array();
532 COUNT({$this->_aliases['civicrm_contribution']}.total_amount ) as civicrm_contribution_total_amount_count,
533 SUM({$this->_aliases['civicrm_contribution']}.total_amount ) as civicrm_contribution_total_amount_sum,
534 ROUND(AVG({$this->_aliases['civicrm_contribution']}.total_amount), 2) as civicrm_contribution_total_amount_avg,
535 {$this->_aliases['civicrm_contribution']}.currency as currency";
539 COUNT({$this->_aliases['civicrm_contribution_soft']}.amount ) as civicrm_contribution_soft_soft_amount_count,
540 SUM({$this->_aliases['civicrm_contribution_soft']}.amount ) as civicrm_contribution_soft_soft_amount_sum,
541 ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_contribution_soft_soft_amount_avg";
543 $group = "\nGROUP BY {$this->_aliases['civicrm_contribution']}.currency";
544 $sql = "{$select} {$this->_from} {$this->_where} {$group} {$this->_having}";
546 $dao = CRM_Core_DAO
::executeQuery($sql);
547 $totalAmount = $average = $softTotalAmount = $softAverage = array();
548 $count = $softCount = 0;
549 while ($dao->fetch()) {
550 $totalAmount[] = CRM_Utils_Money
::format($dao->civicrm_contribution_total_amount_sum
, $dao->currency
)." (".$dao->civicrm_contribution_total_amount_count
.")";
551 $average[] = CRM_Utils_Money
::format($dao->civicrm_contribution_total_amount_avg
, $dao->currency
);
552 $count +
= $dao->civicrm_contribution_total_amount_count
;
555 $softTotalAmount[] = CRM_Utils_Money
::format($dao->civicrm_contribution_soft_soft_amount_sum
, $dao->currency
)." (".$dao->civicrm_contribution_soft_soft_amount_count
.")";
556 $softAverage[] = CRM_Utils_Money
::format($dao->civicrm_contribution_soft_soft_amount_avg
, $dao->currency
);
557 $softCount +
= $dao->civicrm_contribution_soft_soft_amount_count
;
561 if (!$onlySoftCredit) {
562 $statistics['counts']['amount'] = array(
563 'title' => ts('Total Amount'),
564 'value' => implode(', ', $totalAmount),
565 'type' => CRM_Utils_Type
::T_STRING
,
567 $statistics['counts']['count'] = array(
568 'title' => ts('Total Donations'),
571 $statistics['counts']['avg'] = array(
572 'title' => ts('Average'),
573 'value' => implode(', ', $average),
574 'type' => CRM_Utils_Type
::T_STRING
,
578 $statistics['counts']['soft_amount'] = array(
579 'title' => ts('Total Soft Credit Amount'),
580 'value' => implode(', ', $softTotalAmount),
581 'type' => CRM_Utils_Type
::T_STRING
,
583 $statistics['counts']['soft_count'] = array(
584 'title' => ts('Total Soft Credits'),
585 'value' => $softCount,
587 $statistics['counts']['soft_avg'] = array(
588 'title' => ts('Average Soft Credit'),
589 'value' => implode(', ', $softAverage),
590 'type' => CRM_Utils_Type
::T_STRING
,
596 function postProcess() {
597 $this->buildACLClause($this->_aliases
['civicrm_contact']);
598 parent
::postProcess();
601 function buildChart(&$rows) {
602 $graphRows = array();
604 if (!empty($this->_params
['charts'])) {
605 if (!empty($this->_params
['group_bys']['receive_date'])) {
607 $contrib = !empty($this->_params
['fields']['total_amount']) ?
TRUE : FALSE;
608 $softContrib = !empty($this->_params
['fields']['soft_amount']) ?
TRUE : FALSE;
610 foreach ($rows as $key => $row) {
611 if ($row['civicrm_contribution_receive_date_subtotal']) {
612 $graphRows['receive_date'][] = $row['civicrm_contribution_receive_date_start'];
613 $graphRows[$this->_interval
][] = $row['civicrm_contribution_receive_date_interval'];
614 if ($softContrib && $contrib) {
615 // both contri & soft contri stats are present
616 $graphRows['multiValue'][0][] = $row['civicrm_contribution_total_amount_sum'];
617 $graphRows['multiValue'][1][] = $row['civicrm_contribution_soft_soft_amount_sum'];
618 } else if ($softContrib) {
619 // only soft contributions
620 $graphRows['multiValue'][0][] = $row['civicrm_contribution_soft_soft_amount_sum'];
622 // only contributions
623 $graphRows['multiValue'][0][] = $row['civicrm_contribution_total_amount_sum'];
628 if ($softContrib && $contrib) {
629 $graphRows['barKeys'][0] = ts('Contributions');
630 $graphRows['barKeys'][1] = ts('Soft Credits');
631 $graphRows['legend'] = ts('Contributions and Soft Credits');
632 } else if ($softContrib) {
633 $graphRows['legend'] = ts('Soft Credits');
637 $config = CRM_Core_Config
::Singleton();
638 $graphRows['xname'] = $this->_interval
;
639 $graphRows['yname'] = "Amount ({$config->defaultCurrency})";
640 CRM_Utils_OpenFlashChart
::chart($graphRows, $this->_params
['charts'], $this->_interval
);
641 $this->assign('chartType', $this->_params
['charts']);
646 function alterDisplay(&$rows) {
647 // custom code to alter rows
650 foreach ($rows as $rowNum => $row) {
651 // make count columns point to detail report
652 if (!empty($this->_params
['group_bys']['receive_date']) && !empty($row['civicrm_contribution_receive_date_start']) &&
653 CRM_Utils_Array
::value('civicrm_contribution_receive_date_start', $row) && !empty($row['civicrm_contribution_receive_date_subtotal'])) {
655 $dateStart = CRM_Utils_Date
::customFormat($row['civicrm_contribution_receive_date_start'], '%Y%m%d');
656 $endDate = new DateTime($dateStart);
659 list($dateEnd['Y'], $dateEnd['M'], $dateEnd['d']) = explode(':', $endDate->format('Y:m:d'));
661 switch (strtolower($this->_params
['group_bys_freq']['receive_date'])) {
663 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] +
1,
664 $dateEnd['d'] - 1, $dateEnd['Y']
669 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'],
670 $dateEnd['d'] - 1, $dateEnd['Y'] +
1
675 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'],
676 $dateEnd['d'] +
6, $dateEnd['Y']
681 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] +
3,
682 $dateEnd['d'] - 1, $dateEnd['Y']
686 $url = CRM_Report_Utils_Report
::getNextUrl('contribute/detail',
687 "reset=1&force=1&receive_date_from={$dateStart}&receive_date_to={$dateEnd}",
690 $this->_drilldownReport
692 $rows[$rowNum]['civicrm_contribution_receive_date_start_link'] = $url;
693 $rows[$rowNum]['civicrm_contribution_receive_date_start_hover'] = ts('List all contribution(s) for this date unit.');
697 // make subtotals look nicer
698 if (array_key_exists('civicrm_contribution_receive_date_subtotal', $row) &&
699 !$row['civicrm_contribution_receive_date_subtotal']
701 $this->fixSubTotalDisplay($rows[$rowNum], $this->_statFields
);
705 // convert display name to links
706 if (array_key_exists('civicrm_contact_sort_name', $row) &&
707 array_key_exists('civicrm_contact_id', $row)
709 $url = CRM_Report_Utils_Report
::getNextUrl('contribute/detail',
710 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'],
711 $this->_absoluteUrl
, $this->_id
, $this->_drilldownReport
713 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
714 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("Lists detailed contribution(s) for this record.");
718 // If using campaigns, convert campaign_id to campaign title
719 if (array_key_exists('civicrm_contribution_campaign_id', $row)) {
720 if ($value = $row['civicrm_contribution_campaign_id']) {
721 $rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->activeCampaigns
[$value];
726 $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s) for this ') ?
TRUE : $entryFound;
728 // skip looking further in rows, if first row itself doesn't
729 // have the column we need