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('Contributions Aggregate'),
149 'count' => ts('Contributions'),
150 'avg' => ts('Contributions Avg'),
154 'grouping' => 'contri-fields',
158 array('operatorType' => CRM_Report_Form
::OP_DATE
),
159 'contribution_status_id' =>
160 array('title' => ts('Donation 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('Contributions Aggregate'),
190 'type' => CRM_Report_Form
::OP_INT
,
191 'dbAlias' => 'civicrm_contribution_total_amount_sum',
195 array('title' => ts('Contributions Count'),
196 'type' => CRM_Report_Form
::OP_INT
,
197 'dbAlias' => 'civicrm_contribution_total_amount_count',
201 array('title' => ts('Contributions 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',
269 'dao' => 'CRM_Contact_DAO_GroupContact',
275 'name' => 'group_id',
276 'title' => ts('Group'),
277 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
279 'options' => CRM_Core_PseudoConstant
::group(),
280 'type' => CRM_Utils_Type
::T_INT
,
284 ) +
$this->addAddressFields();
286 // If we have a campaign, build out the relevant elements
287 $this->_tagFilter
= TRUE;
288 if ($campaignEnabled && !empty($this->activeCampaigns
)) {
289 $this->_columns
['civicrm_contribution']['fields']['campaign_id'] = array(
290 'title' => 'Campaign',
291 'default' => 'false',
293 $this->_columns
['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'),
294 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
295 'options' => $this->activeCampaigns
,
297 $this->_columns
['civicrm_contribution']['group_bys']['campaign_id'] = array('title' => ts('Campaign'));
300 $this->_currencyColumn
= 'civicrm_contribution_currency';
301 parent
::__construct();
304 function preProcess() {
305 parent
::preProcess();
309 * @param bool $freeze
313 function setDefaultValues($freeze = TRUE) {
314 return parent
::setDefaultValues($freeze);
319 $this->_columnHeaders
= array();
320 foreach ($this->_columns
as $tableName => $table) {
321 if (array_key_exists('group_bys', $table)) {
322 foreach ($table['group_bys'] as $fieldName => $field) {
323 if ($tableName == 'civicrm_address') {
324 $this->_addressField
= TRUE;
326 if (!empty($this->_params
['group_bys'][$fieldName])) {
327 switch (CRM_Utils_Array
::value($fieldName, $this->_params
['group_bys_freq'])) {
329 $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start";
330 $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
331 $select[] = "WEEKOFYEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
332 $field['title'] = 'Week';
336 $select[] = "MAKEDATE(YEAR({$field['dbAlias']}), 1) AS {$tableName}_{$fieldName}_start";
337 $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
338 $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
339 $field['title'] = 'Year';
343 $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL (DAYOFMONTH({$field['dbAlias']})-1) DAY) as {$tableName}_{$fieldName}_start";
344 $select[] = "MONTH({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
345 $select[] = "MONTHNAME({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
346 $field['title'] = 'Month';
350 $select[] = "STR_TO_DATE(CONCAT( 3 * QUARTER( {$field['dbAlias']} ) -2 , '/', '1', '/', YEAR( {$field['dbAlias']} ) ), '%m/%d/%Y') AS {$tableName}_{$fieldName}_start";
351 $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
352 $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
353 $field['title'] = 'Quarter';
356 if (!empty($this->_params
['group_bys_freq'][$fieldName])) {
357 $this->_interval
= $field['title'];
358 $this->_columnHeaders
["{$tableName}_{$fieldName}_start"]['title'] = $field['title'] . ' Beginning';
359 $this->_columnHeaders
["{$tableName}_{$fieldName}_start"]['type'] = $field['type'];
360 $this->_columnHeaders
["{$tableName}_{$fieldName}_start"]['group_by'] = $this->_params
['group_bys_freq'][$fieldName];
362 // just to make sure these values are transfered to rows.
363 // since we need that for calculation purpose,
364 // e.g making subtotals look nicer or graphs
365 $this->_columnHeaders
["{$tableName}_{$fieldName}_interval"] = array('no_display' => TRUE);
366 $this->_columnHeaders
["{$tableName}_{$fieldName}_subtotal"] = array('no_display' => TRUE);
372 if (array_key_exists('fields', $table)) {
373 foreach ($table['fields'] as $fieldName => $field) {
374 if ($tableName == 'civicrm_address') {
375 $this->_addressField
= TRUE;
377 if (!empty($field['required']) ||
!empty($this->_params
['fields'][$fieldName])) {
379 // only include statistics columns if set
380 if (!empty($field['statistics'])) {
381 foreach ($field['statistics'] as $stat => $label) {
382 switch (strtolower($stat)) {
384 $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}";
385 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
386 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = $field['type'];
387 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
391 $select[] = "COUNT({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}";
392 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = CRM_Utils_Type
::T_INT
;
393 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
394 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
398 $select[] = "ROUND(AVG({$field['dbAlias']}),2) as {$tableName}_{$fieldName}_{$stat}";
399 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = $field['type'];
400 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
401 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
407 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
408 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array
::value('type', $field);
409 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array
::value('title', $field);
416 $this->_select
= "SELECT " . implode(', ', $select) . " ";
426 static function formRule($fields, $files, $self) {
427 $errors = $grouping = array();
428 //check for searching combination of dispaly columns and
430 $ignoreFields = array('total_amount', 'sort_name');
431 $errors = $self->customDataFormRule($fields, $ignoreFields);
433 if (empty($fields['group_bys']['receive_date'])) {
434 if (!empty($fields['receive_date_relative']) ||
435 CRM_Utils_Date
::isDate($fields['receive_date_from']) ||
436 CRM_Utils_Date
::isDate($fields['receive_date_to'])
438 $errors['receive_date_relative'] = ts("Do not use filter on Date if group by Receive Date is not used ");
441 if (empty($fields['fields']['total_amount'])) {
443 'total_count_value', 'total_sum_value', 'total_avg_value') as $val) {
444 if (!empty($fields[$val])) {
445 $errors[$val] = ts("Please select the Amount Statistics");
454 $softCreditJoin = "LEFT";
455 if (!empty($this->_params
['fields']['soft_amount']) && empty($this->_params
['fields']['total_amount'])) {
456 // if its only soft credit stats, use inner join
457 $softCreditJoin = "INNER";
461 FROM civicrm_contact {$this->_aliases['civicrm_contact']}
462 INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
463 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id AND
464 {$this->_aliases['civicrm_contribution']}.is_test = 0
465 {$softCreditJoin} JOIN civicrm_contribution_soft {$this->_aliases['civicrm_contribution_soft']}
466 ON {$this->_aliases['civicrm_contribution_soft']}.contribution_id = {$this->_aliases['civicrm_contribution']}.id
467 LEFT JOIN civicrm_financial_type {$this->_aliases['civicrm_financial_type']}
468 ON {$this->_aliases['civicrm_contribution']}.financial_type_id ={$this->_aliases['civicrm_financial_type']}.id
469 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
470 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
471 {$this->_aliases['civicrm_email']}.is_primary = 1)
473 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
474 ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
475 {$this->_aliases['civicrm_phone']}.is_primary = 1)";
477 if ($this->_addressField
) {
479 LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
480 ON {$this->_aliases['civicrm_contact']}.id =
481 {$this->_aliases['civicrm_address']}.contact_id AND
482 {$this->_aliases['civicrm_address']}.is_primary = 1\n";
487 $this->_groupBy
= "";
489 if (is_array($this->_params
['group_bys']) &&
490 !empty($this->_params
['group_bys'])
492 foreach ($this->_columns
as $tableName => $table) {
493 if (array_key_exists('group_bys', $table)) {
494 foreach ($table['group_bys'] as $fieldName => $field) {
495 if (!empty($this->_params
['group_bys'][$fieldName])) {
496 if (!empty($field['chart'])) {
497 $this->assign('chartSupported', TRUE);
500 if (!empty($table['group_bys'][$fieldName]['frequency']) && !empty($this->_params
['group_bys_freq'][$fieldName])) {
502 $append = "YEAR({$field['dbAlias']}),";
503 if (in_array(strtolower($this->_params
['group_bys_freq'][$fieldName]),
508 $this->_groupBy
[] = "$append {$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})";
512 $this->_groupBy
[] = $field['dbAlias'];
519 if (!empty($this->_statFields
) &&
520 (($append && count($this->_groupBy
) <= 1) ||
(!$append)) && !$this->_having
522 $this->_rollup
= " WITH ROLLUP";
524 $this->_groupBy
= "GROUP BY " . implode(', ', $this->_groupBy
) . " {$this->_rollup} ";
527 $this->_groupBy
= "GROUP BY {$this->_aliases['civicrm_contact']}.id";
531 function storeWhereHavingClauseArray(){
532 parent
::storeWhereHavingClauseArray();
533 if (empty($this->_params
['fields']['soft_amount']) && !empty($this->_havingClauses
)){
534 foreach ($this->_havingClauses
as $key => $havingClause) {
535 if (stristr($havingClause, 'soft_soft')){
536 unset($this->_havingClauses
[$key]);
547 function statistics(&$rows) {
548 $statistics = parent
::statistics($rows);
550 $softCredit = CRM_Utils_Array
::value('soft_amount', $this->_params
['fields']);
551 $onlySoftCredit = $softCredit && !CRM_Utils_Array
::value('total_amount', $this->_params
['fields']);
552 $totalAmount = $average = $softTotalAmount = $softAverage = array();
555 COUNT({$this->_aliases['civicrm_contribution']}.total_amount ) as civicrm_contribution_total_amount_count,
556 SUM({$this->_aliases['civicrm_contribution']}.total_amount ) as civicrm_contribution_total_amount_sum,
557 ROUND(AVG({$this->_aliases['civicrm_contribution']}.total_amount), 2) as civicrm_contribution_total_amount_avg,
558 {$this->_aliases['civicrm_contribution']}.currency as currency";
562 COUNT({$this->_aliases['civicrm_contribution_soft']}.amount ) as civicrm_contribution_soft_soft_amount_count,
563 SUM({$this->_aliases['civicrm_contribution_soft']}.amount ) as civicrm_contribution_soft_soft_amount_sum,
564 ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_contribution_soft_soft_amount_avg";
566 $group = "\nGROUP BY {$this->_aliases['civicrm_contribution']}.currency";
567 $sql = "{$select} {$this->_from} {$this->_where} {$group} {$this->_having}";
569 $dao = CRM_Core_DAO
::executeQuery($sql);
570 $totalAmount = $average = $softTotalAmount = $softAverage = array();
571 $count = $softCount = 0;
572 while ($dao->fetch()) {
573 $totalAmount[] = CRM_Utils_Money
::format($dao->civicrm_contribution_total_amount_sum
, $dao->currency
)." (".$dao->civicrm_contribution_total_amount_count
.")";
574 $average[] = CRM_Utils_Money
::format($dao->civicrm_contribution_total_amount_avg
, $dao->currency
);
575 $count +
= $dao->civicrm_contribution_total_amount_count
;
578 $softTotalAmount[] = CRM_Utils_Money
::format($dao->civicrm_contribution_soft_soft_amount_sum
, $dao->currency
)." (".$dao->civicrm_contribution_soft_soft_amount_count
.")";
579 $softAverage[] = CRM_Utils_Money
::format($dao->civicrm_contribution_soft_soft_amount_avg
, $dao->currency
);
580 $softCount +
= $dao->civicrm_contribution_soft_soft_amount_count
;
584 if (!$onlySoftCredit) {
585 $statistics['counts']['amount'] = array(
586 'title' => ts('Total Amount'),
587 'value' => implode(', ', $totalAmount),
588 'type' => CRM_Utils_Type
::T_STRING
,
590 $statistics['counts']['count'] = array(
591 'title' => ts('Total Donations'),
594 $statistics['counts']['avg'] = array(
595 'title' => ts('Average'),
596 'value' => implode(', ', $average),
597 'type' => CRM_Utils_Type
::T_STRING
,
601 $statistics['counts']['soft_amount'] = array(
602 'title' => ts('Total Soft Credit Amount'),
603 'value' => implode(', ', $softTotalAmount),
604 'type' => CRM_Utils_Type
::T_STRING
,
606 $statistics['counts']['soft_count'] = array(
607 'title' => ts('Total Soft Credits'),
608 'value' => $softCount,
610 $statistics['counts']['soft_avg'] = array(
611 'title' => ts('Average Soft Credit'),
612 'value' => implode(', ', $softAverage),
613 'type' => CRM_Utils_Type
::T_STRING
,
619 function postProcess() {
620 $this->buildACLClause($this->_aliases
['civicrm_contact']);
621 parent
::postProcess();
627 function buildChart(&$rows) {
628 $graphRows = array();
630 if (!empty($this->_params
['charts'])) {
631 if (!empty($this->_params
['group_bys']['receive_date'])) {
633 $contrib = !empty($this->_params
['fields']['total_amount']) ?
TRUE : FALSE;
634 $softContrib = !empty($this->_params
['fields']['soft_amount']) ?
TRUE : FALSE;
636 foreach ($rows as $key => $row) {
637 if ($row['civicrm_contribution_receive_date_subtotal']) {
638 $graphRows['receive_date'][] = $row['civicrm_contribution_receive_date_start'];
639 $graphRows[$this->_interval
][] = $row['civicrm_contribution_receive_date_interval'];
640 if ($softContrib && $contrib) {
641 // both contri & soft contri stats are present
642 $graphRows['multiValue'][0][] = $row['civicrm_contribution_total_amount_sum'];
643 $graphRows['multiValue'][1][] = $row['civicrm_contribution_soft_soft_amount_sum'];
644 } else if ($softContrib) {
645 // only soft contributions
646 $graphRows['multiValue'][0][] = $row['civicrm_contribution_soft_soft_amount_sum'];
648 // only contributions
649 $graphRows['multiValue'][0][] = $row['civicrm_contribution_total_amount_sum'];
654 if ($softContrib && $contrib) {
655 $graphRows['barKeys'][0] = ts('Contributions');
656 $graphRows['barKeys'][1] = ts('Soft Credits');
657 $graphRows['legend'] = ts('Contributions and Soft Credits');
658 } else if ($softContrib) {
659 $graphRows['legend'] = ts('Soft Credits');
663 $config = CRM_Core_Config
::Singleton();
664 $graphRows['xname'] = $this->_interval
;
665 $graphRows['yname'] = "Amount ({$config->defaultCurrency})";
666 CRM_Utils_OpenFlashChart
::chart($graphRows, $this->_params
['charts'], $this->_interval
);
667 $this->assign('chartType', $this->_params
['charts']);
675 function alterDisplay(&$rows) {
676 // custom code to alter rows
679 foreach ($rows as $rowNum => $row) {
680 // make count columns point to detail report
681 if (!empty($this->_params
['group_bys']['receive_date']) && !empty($row['civicrm_contribution_receive_date_start']) &&
682 CRM_Utils_Array
::value('civicrm_contribution_receive_date_start', $row) && !empty($row['civicrm_contribution_receive_date_subtotal'])) {
684 $dateStart = CRM_Utils_Date
::customFormat($row['civicrm_contribution_receive_date_start'], '%Y%m%d');
685 $endDate = new DateTime($dateStart);
688 list($dateEnd['Y'], $dateEnd['M'], $dateEnd['d']) = explode(':', $endDate->format('Y:m:d'));
690 switch (strtolower($this->_params
['group_bys_freq']['receive_date'])) {
692 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] +
1,
693 $dateEnd['d'] - 1, $dateEnd['Y']
698 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'],
699 $dateEnd['d'] - 1, $dateEnd['Y'] +
1
704 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'],
705 $dateEnd['d'] +
6, $dateEnd['Y']
710 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] +
3,
711 $dateEnd['d'] - 1, $dateEnd['Y']
715 $url = CRM_Report_Utils_Report
::getNextUrl('contribute/detail',
716 "reset=1&force=1&receive_date_from={$dateStart}&receive_date_to={$dateEnd}",
719 $this->_drilldownReport
721 $rows[$rowNum]['civicrm_contribution_receive_date_start_link'] = $url;
722 $rows[$rowNum]['civicrm_contribution_receive_date_start_hover'] = ts('List all contribution(s) for this date unit.');
726 // make subtotals look nicer
727 if (array_key_exists('civicrm_contribution_receive_date_subtotal', $row) &&
728 !$row['civicrm_contribution_receive_date_subtotal']
730 $this->fixSubTotalDisplay($rows[$rowNum], $this->_statFields
);
734 // convert display name to links
735 if (array_key_exists('civicrm_contact_sort_name', $row) &&
736 array_key_exists('civicrm_contact_id', $row)
738 $url = CRM_Report_Utils_Report
::getNextUrl('contribute/detail',
739 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'],
740 $this->_absoluteUrl
, $this->_id
, $this->_drilldownReport
742 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
743 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("Lists detailed contribution(s) for this record.");
747 // If using campaigns, convert campaign_id to campaign title
748 if (array_key_exists('civicrm_contribution_campaign_id', $row)) {
749 if ($value = $row['civicrm_contribution_campaign_id']) {
750 $rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->activeCampaigns
[$value];
755 $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s) for this ') ?
TRUE : $entryFound;
757 // skip looking further in rows, if first row itself doesn't
758 // have the column we need