--CRM-16198, fix for search builder
authorPradeep Nayak <pradpnayak@gmail.com>
Mon, 30 Mar 2015 07:34:28 +0000 (13:04 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Tue, 31 Mar 2015 15:10:11 +0000 (20:40 +0530)
CRM/Contribute/BAO/Query.php
xml/schema/Contribute/Contribution.xml

index e6c23aec99bc5248dd530d852a71b60b56b5b6a1..6309279eef297dc1bc480bb76ecc83d717a19374 100644 (file)
@@ -317,8 +317,16 @@ class CRM_Contribute_BAO_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':
+      case 'payment_instrument_id':
+      case 'contribution_payment_instrument_id':
       case 'contribution_page_id':
       case 'contribution_status_id':
       case 'contribution_id':
@@ -338,6 +346,7 @@ class CRM_Contribute_BAO_Query {
               'contribution_source',
               'contribution_trxn_id',
               'contribution_check_number',
+              'contribution_payment_instrument_id',
             )
           )
         ) {
@@ -359,47 +368,6 @@ class CRM_Contribute_BAO_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;
index 226c85871be9ec6636d1ba914ca9dcf09a82ac58..df7f9c0af1ddc330a990e35563531510267467b9 100644 (file)
   </foreignKey>
   <field>
     <name>payment_instrument_id</name>
-    <uniqueName>contribution_payment_instrument_id</uniqueName>
+    <uniqueName>payment_instrument_id</uniqueName>
     <title>Payment Instrument ID</title>
     <type>int unsigned</type>
     <comment>FK to Payment Instrument</comment>