+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
+ | Copyright CiviCRM LLC (c) 2004-2016 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
+ * @copyright CiviCRM LLC (c) 2004-2016
* $Id$
*
*/
),
'credit_accounting_code' => array(
'title' => ts('Financial Account Code - Credit'),
+ 'type' => CRM_Utils_Type::T_INT,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Contribute_PseudoConstant::financialAccount(NULL, NULL, 'accounting_code', 'accounting_code'),
),
'debit_name' => array(
'title' => ts('Financial Account Name - Debit'),
+ 'type' => CRM_Utils_Type::T_STRING,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Contribute_PseudoConstant::financialAccount(),
'name' => 'id',
),
'credit_name' => array(
'title' => ts('Financial Account Name - Credit'),
+ 'type' => CRM_Utils_Type::T_STRING,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Contribute_PseudoConstant::financialAccount(),
),
'filters' => array(
'financial_type_id' => array(
'title' => ts('Financial Type'),
+ 'type' => CRM_Utils_Type::T_INT,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes(),
),
'financial_type_id' => array('title' => ts('Financial Type')),
),
),
+ 'civicrm_batch' => array(
+ 'dao' => 'CRM_Batch_DAO_Batch',
+ 'fields' => array(
+ 'title' => array(
+ 'title' => ts('Batch Title'),
+ 'alias' => 'batch',
+ 'default' => FALSE,
+ ),
+ 'name' => array(
+ 'title' => ts('Batch Name'),
+ 'alias' => 'batch',
+ 'default' => TRUE,
+ ),
+ ),
+ ),
'civicrm_contribution' => array(
'dao' => 'CRM_Contribute_DAO_Contribution',
'fields' => array(
'filters' => array(
'payment_instrument_id' => array(
'title' => ts('Payment Method'),
+ 'type' => CRM_Utils_Type::T_INT,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Contribute_PseudoConstant::paymentInstrument(),
),
}
}
}
+ $this->_selectClauses = $select;
$this->_select = 'SELECT ' . implode(', ', $select) . ' ';
}
ON fitem.financial_account_id = {$this->_aliases['civicrm_financial_account']}_credit_2.id
LEFT JOIN civicrm_line_item {$this->_aliases['civicrm_line_item']}
ON fitem.entity_id = {$this->_aliases['civicrm_line_item']}.id AND fitem.entity_table = 'civicrm_line_item' ";
+ if ($this->isTableSelected('civicrm_batch')) {
+ $this->_from .= "LEFT JOIN civicrm_entity_batch ent_batch
+ ON {$this->_aliases['civicrm_financial_trxn']}.id = ent_batch.entity_id AND ent_batch.entity_table = 'civicrm_financial_trxn'
+ LEFT JOIN civicrm_batch batch
+ ON ent_batch.batch_id = batch.id";
+ }
+
$this->getPermissionedFTQuery($this, "civicrm_line_item_1");
}
}
public function groupBy() {
- $this->_groupBy = " GROUP BY {$this->_aliases['civicrm_entity_financial_trxn']}.id, {$this->_aliases['civicrm_line_item']}.id ";
+ $groupFromSelect = '';
+ $groupBy = array(
+ "{$this->_aliases['civicrm_entity_financial_trxn']}.id",
+ "{$this->_aliases['civicrm_line_item']}.id"
+ );
+ $groupFromSelect = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $groupBy);
+ $this->_groupBy = " GROUP BY " . implode(', ', $groupBy) . " {$groupFromSelect}";
}
/**
public function statistics(&$rows) {
$statistics = parent::statistics($rows);
$tempTableName = CRM_Core_DAO::createTempTableName('civicrm_contribution');
- $select = "SELECT {$this->_aliases['civicrm_contribution']}.id, {$this->_aliases['civicrm_entity_financial_trxn']}.id as trxnID, {$this->_aliases['civicrm_contribution']}.currency,
- CASE
- WHEN {$this->_aliases['civicrm_entity_financial_trxn']}_item.entity_id IS NOT NULL
- THEN {$this->_aliases['civicrm_entity_financial_trxn']}_item.amount
- ELSE {$this->_aliases['civicrm_entity_financial_trxn']}.amount
- END as amount
-";
+
+ $this->_selectClauses = array(
+ "{$this->_aliases['civicrm_contribution']}.id",
+ "{$this->_aliases['civicrm_entity_financial_trxn']}.id as trxnID",
+ "{$this->_aliases['civicrm_contribution']}.currency",
+ "CASE
+ WHEN {$this->_aliases['civicrm_entity_financial_trxn']}_item.entity_id IS NOT NULL
+ THEN {$this->_aliases['civicrm_entity_financial_trxn']}_item.amount
+ ELSE {$this->_aliases['civicrm_entity_financial_trxn']}.amount
+ END as amount",
+ );
+ $select = "SELECT " . implode(', ', $this->_selectClauses);
+
+ $this->groupBy();
$tempQuery = "CREATE TEMPORARY TABLE {$tempTableName} CHARACTER SET utf8 COLLATE utf8_unicode_ci AS
{$select} {$this->_from} {$this->_where} {$this->_groupBy} ";