From: pratikshad Date: Thu, 4 Jun 2015 10:30:58 +0000 (+0530) Subject: CRM-16534 Fix-Contribution Export Places Campaign IDs in Campaign Title Column, Nothi... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9ebd33867e2e2e5b0f5b85c20ad6f7286492a78a;p=civicrm-core.git CRM-16534 Fix-Contribution Export Places Campaign IDs in Campaign Title Column, Nothing in Campaign ID Column ---------------------------------------- * CRM-16534: Contribution Export Places Campaign IDs in Campaign Title Column, Nothing in Campaign ID Column https://issues.civicrm.org/jira/browse/CRM-16534 --- diff --git a/CRM/Contribute/BAO/Query.php b/CRM/Contribute/BAO/Query.php index e3b2a24ebd..9bee323ed9 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -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()) { diff --git a/CRM/Export/BAO/Export.php b/CRM/Export/BAO/Export.php index a2fbc61a1b..9a65047644 100644 --- a/CRM/Export/BAO/Export.php +++ b/CRM/Export/BAO/Export.php @@ -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; }