CRM-16534 Fix-Contribution Export Places Campaign IDs in Campaign Title Column, Nothi...
authorpratikshad <pratiksha.dubey@webaccess.co.in>
Thu, 4 Jun 2015 10:30:58 +0000 (16:00 +0530)
committerpratikshad <pratiksha.dubey@webaccess.co.in>
Thu, 4 Jun 2015 10:30:58 +0000 (16:00 +0530)
----------------------------------------
* CRM-16534: Contribution Export Places Campaign IDs in Campaign Title Column, Nothing in Campaign ID Column
  https://issues.civicrm.org/jira/browse/CRM-16534

CRM/Contribute/BAO/Query.php
CRM/Export/BAO/Export.php

index e3b2a24ebd2a996b4c58ab536aebb3d3960d16d9..9bee323ed93557395e576810bc4b5d9f26996e27 100644 (file)
@@ -213,6 +213,10 @@ class CRM_Contribute_BAO_Query {
       $query->_tables['civicrm_contribution_soft_contact'] = 1;
       $query->_tables['civicrm_contribution_soft_phone'] = 1;
     }
+    if (!empty($query->_returnProperties['contribution_campaign_title'])) {
+      $query->_select['contribution_campaign_title'] = "civicrm_campaign.title as contribution_campaign_title";
+      $query->_element['contribution_campaign_title'] = $query->_tables['civicrm_campaign'] = 1;
+    }
     // LCD 716 END
   }
 
@@ -640,6 +644,10 @@ class CRM_Contribute_BAO_Query {
         $from .= " $side  JOIN civicrm_membership ON civicrm_membership_payment.membership_id = civicrm_membership.id ";
         break;
 
+      case 'civicrm_campaign':
+        $from = " $side  JOIN civicrm_campaign ON civicrm_campaign.id = civicrm_contribution.campaign_id";
+        break;
+
       case 'contribution_participant':
         $from = " $side  JOIN civicrm_participant_payment ON civicrm_participant_payment.contribution_id = civicrm_contribution.id";
         $from .= " $side  JOIN civicrm_participant ON civicrm_participant_payment.participant_id = civicrm_participant.id ";
@@ -801,6 +809,7 @@ class CRM_Contribute_BAO_Query {
         'amount_level' => 1,
         'contribution_note' => 1,
         'contribution_batch' => 1,
+        'contribution_campaign_title' => 1,
         'contribution_campaign_id' => 1,
       );
       if (self::isSoftCreditOptionEnabled()) {
index a2fbc61a1b5f515bad3ac6a6f41b7851e88c58ff..9a650476443b405d3d8eb11fcdf9d4d97f918e56 100644 (file)
@@ -667,11 +667,6 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
     // as the array is not actually 'returnProperties' after the sql query is formed - making the alterations to it confusing
     foreach ($returnProperties as $key => $value) {
       $outputColumns[$key] = $value;
-      if (substr($key, -11) == 'campaign_id') {
-        // the field $dao->x_campaign_id_id holds the id whereas the field $dao->campaign_id
-        // we want to insert it directly after campaign id
-        $outputColumns[$key . '_id'] = 1;
-      }
     }
     while (1) {
       $limitQuery = "{$queryString} LIMIT {$offset}, {$rowCount}";
@@ -704,10 +699,10 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
           if ($setHeader) {
             $sqlDone = FALSE;
             // Split campaign into 2 fields for id and title
-            if (substr($field, -11) == 'campaign_id') {
+            if (substr($field, -14) == 'campaign_title') {
               $headerRows[] = ts('Campaign Title');
             }
-            elseif (substr($field, -14) == 'campaign_id_id') {
+            elseif (substr($field, -11) == 'campaign_id') {
               $headerRows[] = ts('Campaign ID');
             }
             elseif (isset($query->_fields[$field]['title'])) {
@@ -1343,7 +1338,6 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
     if (substr($fieldName, -11) == 'campaign_id') {
       // CRM-14398
       $sqlColumns[$fieldName] = "$fieldName varchar(128)";
-      $sqlColumns[$fieldName . '_id'] = "{$fieldName}_id varchar(16)";
       return;
     }