From a25f7a5392c5d07b0cb73b23d9ec04e205c6f3cb Mon Sep 17 00:00:00 2001 From: Edsel Date: Wed, 1 Apr 2015 17:55:38 +0530 Subject: [PATCH] CIVI-34 Adding fix for search builder --- CRM/Contribute/BAO/Query.php | 49 ++++++------------------------------ 1 file changed, 7 insertions(+), 42 deletions(-) diff --git a/CRM/Contribute/BAO/Query.php b/CRM/Contribute/BAO/Query.php index 7cf7b19ff5f8..3eb95c5e9dc3 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -317,7 +317,12 @@ public static function whereClauseSingle(&$values, &$query) { $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_contribution.receipt_date", $op); $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1; return; - + case 'financial_type': + case 'contribution_page': + case 'payment_instrument': + case 'contribution_payment_instrument': + case 'contribution_status': + $name .= '_id'; case 'financial_type_id': CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes); $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_contribution.$name", 'IN', array_keys($financialTypes), 'String'); @@ -340,6 +345,7 @@ public static function whereClauseSingle(&$values, &$query) { 'contribution_source', 'contribution_trxn_id', 'contribution_check_number', + 'contribution_payment_instrument_id', ) ) ) { @@ -361,47 +367,6 @@ public static function whereClauseSingle(&$values, &$query) { $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1; return; - case 'financial_type': - $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fields[$name]['where'], $op, $value, 'String'); - list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contribute_DAO_Contribution', $name, $value, $op); - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$name]['title'], 2 => $op, 3 => $value)); - $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1; - $query->_tables['civicrm_financial_type'] = $query->_whereTables['civicrm_financial_type'] = 1; - return; - - case 'contribution_page': - $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fields[$name]['where'], $op, $value, 'String'); - list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contribute_DAO_Contribution', $name, $value, $op); - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$name]['title'], 2 => $op, 3 => $value)); - $query->_tables['civicrm_contribution_page'] = $query->_whereTables['civicrm_contribution_page'] = 1; - $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1; - return; - - case 'contribution_payment_instrument': - case 'contribution_payment_instrument_id': - $name = str_replace('contribution_', '', $name); - case 'payment_instrument': - case 'payment_instrument_id': - if ($name == 'payment_instrument') { - $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("contribution_payment_instrument.label", $op, $value); - } - else { - $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("contribution_payment_instrument.value", $op, $value, 'Int'); - } - list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contribute_DAO_Contribution', 'payment_instrument_id', $value, $op); - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields['payment_instrument']['title'], 2 => $op, 3 => $value)); - $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1; - $query->_tables['contribution_payment_instrument'] = $query->_whereTables['contribution_payment_instrument'] = 1; - return; - - case 'contribution_status': - $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$name.label", $op, $value, 'String'); - list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contribute_DAO_Contribution', $name, $value, $op); - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$name]['title'], 2 => $op, 3 => $value)); - $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1; - $query->_tables[$name] = $query->_whereTables[$name] = 1; - break; - case 'contribution_pcp_made_through_id': case 'contribution_soft_credit_type_id': $qillName = $name;