}
// a few auto fills for filters
- if ($fieldGrp == 'filters') {
+ if ($fieldGrp == 'filters') {
// fill operator types
if (!array_key_exists('operatorType', $this->_columns[$tableName][$fieldGrp][$fieldName])) {
switch (CRM_Utils_Array::value('type', $this->_columns[$tableName][$fieldGrp][$fieldName])) {
$this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_INT;
break;
case CRM_Utils_Type::T_DATE:
- $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_DATE;
+ $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_DATE;
break;
case CRM_Utils_Type::T_BOOLEAN:
$this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_SELECT;
if (!array_key_exists('options', $this->_columns[$tableName][$fieldGrp][$fieldName])) {
- $this->_columns[$tableName][$fieldGrp][$fieldName]['options'] =
+ $this->_columns[$tableName][$fieldGrp][$fieldName]['options'] =
array('' => ts('Any'), '0' => ts('No'), '1' => ts('Yes'));
}
break;
default:
- if ($daoOrBaoName &&
- (array_key_exists('pseudoconstant', $this->_columns[$tableName][$fieldGrp][$fieldName])
+ if ($daoOrBaoName &&
+ (array_key_exists('pseudoconstant', $this->_columns[$tableName][$fieldGrp][$fieldName])
|| array_key_exists('enumValues', $this->_columns[$tableName][$fieldGrp][$fieldName]))
) {
// with multiple options operator-type is generally multi-select
protected $_summary = NULL;
protected $_allBatches = NULL;
- protected $_customGroupExtends = array(
- 'Contribution');
+ protected $_customGroupExtends = array( 'Contribution');
function __construct() {
// copy _from for later use of stats calculation for soft credits, and reset $this->_from to main query
$this->_softFrom = $this->_from;
- $this->from(); // simple reset of ->_from
+
+ // simple reset of ->_from
+ $this->from();
+ $this->customDataFrom();
// 3. Decide where to populate temp3 table from
if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == 'contributions_only') {
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Contribute_PseudoConstant::contributionPage(),
'type' => CRM_Utils_Type::T_INT,
- ),
+ ),
'total_amount' =>
array('title' => ts('Contribution Amount'),
),
function from() {
$softCreditJoin = "LEFT";
- if (CRM_Utils_Array::value('soft_amount', $this->_params['fields']) &&
+ if (CRM_Utils_Array::value('soft_amount', $this->_params['fields']) &&
!CRM_Utils_Array::value('total_amount', $this->_params['fields'])) {
// if its only soft credit stats, use inner join
$softCreditJoin = "INNER";
$softCredit = CRM_Utils_Array::value('soft_amount', $this->_params['fields']);
$onlySoftCredit = $softCredit && !CRM_Utils_Array::value('total_amount', $this->_params['fields']);
- $select = "SELECT
+ $select = "SELECT
COUNT({$this->_aliases['civicrm_contribution']}.total_amount ) as civicrm_contribution_total_amount_count,
SUM({$this->_aliases['civicrm_contribution']}.total_amount ) as civicrm_contribution_total_amount_sum,
ROUND(AVG({$this->_aliases['civicrm_contribution']}.total_amount), 2) as civicrm_contribution_total_amount_avg,
{$this->_aliases['civicrm_contribution']}.currency as currency";
if ($softCredit) {
- $select .= ",
+ $select .= ",
COUNT({$this->_aliases['civicrm_contribution_soft']}.amount ) as civicrm_contribution_soft_soft_amount_count,
SUM({$this->_aliases['civicrm_contribution_soft']}.amount ) as civicrm_contribution_soft_soft_amount_sum,
ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_contribution_soft_soft_amount_avg";
}
$group = "\nGROUP BY {$this->_aliases['civicrm_contribution']}.currency";
$sql = "{$select} {$this->_from} {$this->_where} {$group} {$this->_having}";
-
+
$dao = CRM_Core_DAO::executeQuery($sql);
$totalAmount = $average = $softTotalAmount = $softAverage = array();
$count = $softCount = 0;
$totalAmount[] = CRM_Utils_Money::format($dao->civicrm_contribution_total_amount_sum, $dao->currency)." (".$dao->civicrm_contribution_total_amount_count.")";
$average[] = CRM_Utils_Money::format($dao->civicrm_contribution_total_amount_avg, $dao->currency);
$count += $dao->civicrm_contribution_total_amount_count;
-
+
if ($softCredit) {
$softTotalAmount[] = CRM_Utils_Money::format($dao->civicrm_contribution_soft_soft_amount_sum, $dao->currency)." (".$dao->civicrm_contribution_soft_soft_amount_count.")";
$softAverage[] = CRM_Utils_Money::format($dao->civicrm_contribution_soft_soft_amount_avg, $dao->currency);
$softCount += $dao->civicrm_contribution_soft_soft_amount_count;
}
}
-
+
if (!$onlySoftCredit) {
$statistics['counts']['amount'] = array(
'title' => ts('Total Amount'),