+--------------------------------------------------------------------+
| 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$
*
*/
protected $_emailField = FALSE;
protected $_summary = NULL;
- protected $_allBatches = NULL;
protected $_customGroupExtends = array(
'Contribution',
'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE),
'financial_type_id' => array(
'title' => ts('Financial Type'),
+ 'type' => CRM_Utils_Type::T_INT,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Contribute_PseudoConstant::financialType(),
),
),
'payment_instrument_id' => array(
'title' => ts('Payment Type'),
+ 'type' => CRM_Utils_Type::T_INT,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Contribute_PseudoConstant::paymentInstrument(),
),
),
),
),
+ 'civicrm_batch' => array(
+ 'dao' => 'CRM_Batch_DAO_EntityBatch',
+ 'grouping' => 'contri-fields',
+ 'fields' => array(
+ 'batch_id' => array(
+ 'name' => 'id',
+ 'title' => ts('Batch Name'),
+ ),
+ ),
+ 'filters' => array(
+ 'bid' => array(
+ 'title' => ts('Batch Name'),
+ 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
+ 'options' => CRM_Batch_BAO_Batch::getBatches(),
+ 'type' => CRM_Utils_Type::T_INT,
+ 'dbAlias' => 'batch_civireport.batch_id',
+ ),
+ ),
+ ),
'civicrm_contribution_product' => array(
'dao' => 'CRM_Contribute_DAO_ContributionProduct',
'fields' => array(
'filters' => array(
'ordinality' => array(
'title' => ts('Contribution Ordinality'),
+ 'type' => CRM_Utils_Type::T_INT,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => array(
0 => 'First by Contributor',
$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
- // Don't show Batch display column and filter unless batches are being used
- $this->_allBatches = CRM_Batch_BAO_Batch::getBatches();
- if (!empty($this->_allBatches)) {
- $this->_columns['civicrm_batch']['dao'] = 'CRM_Batch_DAO_Batch';
- $this->_columns['civicrm_batch']['fields']['batch_id'] = array(
- 'name' => 'id',
- 'title' => ts('Batch Name'),
- );
- $this->_columns['civicrm_batch']['filters']['bid'] = array(
- 'name' => 'id',
- 'title' => ts('Batch Name'),
- 'type' => CRM_Utils_Type::T_INT,
- 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'options' => $this->_allBatches,
- );
- $this->_columns['civicrm_entity_batch']['dao'] = 'CRM_Batch_DAO_EntityBatch';
- $this->_columns['civicrm_entity_batch']['fields']['entity_batch_id'] = array(
- 'name' => 'batch_id',
- 'default' => TRUE,
- 'no_display' => TRUE,
- );
- }
-
if ($campaignEnabled && !empty($this->activeCampaigns)) {
$this->_columns['civicrm_contribution']['fields']['campaign_id'] = array(
'title' => ts('Campaign'),
'title' => ts('Campaign'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => $this->activeCampaigns,
+ 'type' => CRM_Utils_Type::T_INT,
);
$this->_columns['civicrm_contribution']['order_bys']['campaign_id'] = array('title' => ts('Campaign'));
}
}
}
+ $this->_selectClauses = $select;
$this->_select = 'SELECT ' . implode(', ', $select) . ' ';
}
{$this->_aliases['civicrm_phone']}.is_primary = 1)";
}
//for contribution batches
- if ($this->_allBatches &&
- (!empty($this->_params['fields']['batch_id']) ||
- !empty($this->_params['bid_value']))
+ if (!empty($this->_params['fields']['batch_id']) ||
+ !empty($this->_params['bid_value'])
) {
$this->_from .= "
- LEFT JOIN civicrm_entity_financial_trxn tx ON (tx.entity_id = {$this->_aliases['civicrm_contribution']}.id AND
- tx.entity_table = 'civicrm_contribution')
- LEFT JOIN civicrm_entity_batch {$this->_aliases['civicrm_entity_batch']}
- ON ({$this->_aliases['civicrm_entity_batch']}.entity_id = tx.financial_trxn_id AND
- {$this->_aliases['civicrm_entity_batch']}.entity_table = 'civicrm_financial_trxn')
- LEFT JOIN civicrm_batch {$this->_aliases['civicrm_batch']}
- ON {$this->_aliases['civicrm_batch']}.id = {$this->_aliases['civicrm_entity_batch']}.batch_id";
+ LEFT JOIN civicrm_entity_financial_trxn eft
+ ON eft.entity_id = {$this->_aliases['civicrm_contribution']}.id AND
+ eft.entity_table = 'civicrm_contribution'
+ LEFT JOIN civicrm_entity_batch {$this->_aliases['civicrm_batch']}
+ ON ({$this->_aliases['civicrm_batch']}.entity_id = eft.financial_trxn_id
+ AND {$this->_aliases['civicrm_batch']}.entity_table = 'civicrm_financial_trxn')";
}
if ($this->_addressField OR
CRM_Core_DAO::executeQuery($dropTempTable);
$sql = 'CREATE TEMPORARY TABLE civireport_membership_contribution_detail
- (contribution_id int, INDEX USING HASH(contribution_id), contact_id int, INDEX USING HASH(contact_id),
+ (contribution_id int, INDEX USING HASH(contribution_id), contact_id int, INDEX USING HASH(contact_id),
membership_id int, INDEX USING HASH(membership_id), payment_id int, INDEX USING HASH(payment_id)) ENGINE=MEMORY';
CRM_Core_DAO::executeQuery($sql);
}
$sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy} {$this->_having} {$this->_orderBy} {$this->_limit}";
+ $this->addToDeveloperTab($sql);
return $sql;
}
public function groupBy() {
- $this->_groupBy = " GROUP BY {$this->_aliases['civicrm_contact']}.id, {$this->_aliases['civicrm_contribution']}.id ";
+ $groupBy = array(
+ "{$this->_aliases['civicrm_contact']}.id",
+ "{$this->_aliases['civicrm_contribution']}.id",
+ );
+ $this->_groupBy = " GROUP BY " . implode(', ', $groupBy);
+ $this->_groupBy .= CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $groupBy);
}
public function orderBy() {
$contributionTypes = CRM_Contribute_PseudoConstant::financialType();
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
$paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument();
+ $batches = CRM_Batch_BAO_Batch::getBatches();
//altering the csv display adding additional fields
if ($this->_outputMode == 'csv') {
$entryFound = TRUE;
}
- if (array_key_exists('civicrm_batch_batch_id', $row)) {
- if ($value = $row['civicrm_batch_batch_id']) {
- $rows[$rowNum]['civicrm_batch_batch_id'] = CRM_Core_DAO::getFieldValue('CRM_Batch_DAO_Batch', $value, 'title');
- }
+ if (!empty($row['civicrm_batch_batch_id'])) {
+ $rows[$rowNum]['civicrm_batch_batch_id'] = CRM_Utils_Array::value($row['civicrm_batch_batch_id'], $batches);
$entryFound = TRUE;
}