Skip to content
Snippets Groups Projects
Commit d30b0706 authored by Dave Greenberg's avatar Dave Greenberg
Browse files

Merge pull request #1386 from kurund/CRM-13170-fixes

CRM-13170, fixes for contribution search to respect batch criteria
parents b36758b8 61412579
No related branches found
No related tags found
No related merge requests found
......@@ -528,7 +528,7 @@ class CRM_Contribute_BAO_Query {
return;
case 'contribution_batch_id':
$batches = CRM_Batch_BAO_Batch::getBatches();
$batches = CRM_Contribute_PseudoConstant::batch();
$query->_where[$grouping][] = " civicrm_entity_batch.batch_id $op $value";
$query->_qill[$grouping][] = ts('Batch Name %1 %2', array(1 => $op, 2 => $batches[$value]));
$query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1;
......@@ -678,8 +678,16 @@ class CRM_Contribute_BAO_Query {
break;
case 'contribution_batch':
$from .= " $side JOIN civicrm_entity_batch ON ( civicrm_entity_batch.entity_table = 'civicrm_contribution' AND
civicrm_contribution.id = civicrm_entity_batch.entity_id )";
$from .= " $side JOIN civicrm_entity_financial_trxn ON (
civicrm_entity_financial_trxn.entity_table = 'civicrm_contribution'
AND civicrm_contribution.id = civicrm_entity_financial_trxn.entity_id )";
$from .= " $side JOIN civicrm_financial_trxn ON (
civicrm_entity_financial_trxn.financial_trxn_id = civicrm_financial_trxn.id )";
$from .= " $side JOIN civicrm_entity_batch ON ( civicrm_entity_batch.entity_table = 'civicrm_financial_trxn'
AND civicrm_financial_trxn.id = civicrm_entity_batch.entity_id )";
$from .= " $side JOIN civicrm_batch ON civicrm_entity_batch.batch_id = civicrm_batch.id";
break;
}
......@@ -851,7 +859,7 @@ class CRM_Contribute_BAO_Query {
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'contribution_campaign_id');
// Add batch select
$batches = CRM_Batch_BAO_Batch::getBatches();
$batches = CRM_Contribute_PseudoConstant::batch();
if ( !empty( $batches ) ) {
$form->add('select', 'contribution_batch_id',
......
......@@ -113,6 +113,13 @@ class CRM_Contribute_PseudoConstant extends CRM_Core_PseudoConstant {
*/
private static $pcpStatus;
/**
* contribution / financial batches
* @var array
* @static
*/
private static $batch;
/**
* Get all the financial types
*
......@@ -415,5 +422,34 @@ class CRM_Contribute_PseudoConstant extends CRM_Core_PseudoConstant {
return self::$financialTypeAccount[$financialTypeId];
}
/**
* Get all batches
*
* @access public
*
* @return array - array reference of all batches if any
* @static
*/
public static function &batch($id = NULL) {
if (!self::$batch) {
$orderBy = " id DESC ";
CRM_Core_PseudoConstant::populate(
self::$batch,
'CRM_Batch_DAO_Batch',
TRUE,
'title',
NULL,
NULL,
$orderBy
);
}
if ($id) {
$result = CRM_Utils_Array::value($id, self::$batch);
return $result;
}
return self::$batch;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment