CRM-18406: When a contribution is edited it doesn't update the activity to match
authorWeb Access <rohan.katkar@webaccessglobal.com>
Tue, 17 May 2016 11:32:48 +0000 (17:02 +0530)
committerWeb Access <rohan.katkar@webaccessglobal.com>
Tue, 17 May 2016 11:41:45 +0000 (17:11 +0530)
CRM-18406: Warning Fix

CRM/Activity/BAO/Activity.php
CRM/Contribute/BAO/Contribution.php

index 154729bbee70f7ab721da8acbe0999200780796b..8256673f34ce016063295b3f27ae8611ba4dc56e 100644 (file)
@@ -1880,6 +1880,9 @@ SELECT  display_name
       'campaign_id' => $activity->campaign_id,
     );
 
+    if (!empty($activity->activity_id)) {
+      $activityParams['id'] = $activity->activity_id;
+    }
     // create activity with target contacts
     $session = CRM_Core_Session::singleton();
     $id = $session->get('userID');
index b6319bed46744d4a73172346a15c4b59f2f51213..e5f2a3d39e69c333df27819149c015607bebcab4 100644 (file)
@@ -541,16 +541,14 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
       'Contribution',
       'name'
     );
-    if (!$activity->find(TRUE)) {
-      if (empty($contribution->contact_id)) {
-        $contribution->find(TRUE);
-      }
-      CRM_Activity_BAO_Activity::addActivity($contribution, 'Offline');
-    }
-    else {
+
+    //CRM-18406: Update activity when edit contribution.
+    if ($activity->find(TRUE)) {
       // CRM-13237 : if activity record found, update it with campaign id of contribution
       CRM_Core_DAO::setFieldValue('CRM_Activity_BAO_Activity', $activity->id, 'campaign_id', $contribution->campaign_id);
+      $contribution->activity_id = $activity->id;
     }
+    CRM_Activity_BAO_Activity::addActivity($contribution, 'Offline');
 
     // do not add to recent items for import, CRM-4399
     if (empty($params['skipRecentView'])) {