CRM-13968, handled In-progress to Completed contribution status change
authorPradeep Nayak <pradeep.nayak@webaccess.co.in>
Sat, 1 Feb 2014 18:11:31 +0000 (23:41 +0530)
committerPradeep Nayak <pradeep.nayak@webaccess.co.in>
Sat, 1 Feb 2014 18:11:31 +0000 (23:41 +0530)
----------------------------------------
* CRM-13968: Contributions with "In Progress" status can't be edited and saved
  http://issues.civicrm.org/jira/browse/CRM-13968

CRM/Contribute/BAO/Contribution.php
CRM/Contribute/Form/Contribution.php

index f61917da9ee9f6c60086e28a54b744c38415571c..ed0794a816f563cc7392a6e90cd4cd5d56e89fa0 100644 (file)
@@ -2868,6 +2868,7 @@ WHERE  contribution_id = %1 ";
       'Cancelled' => array('Completed', 'Refunded'),
       'Completed' => array('Cancelled', 'Refunded'),
       'Pending' => array('Cancelled', 'Completed', 'Failed'),
+      'In Progress' => array('Cancelled', 'Completed', 'Failed'),
       'Refunded' => array('Cancelled', 'Completed')
     );
 
index 6dd36b9930806746868fa005568490e6aa323792..dbc6731bc1e6631c69f2ab95ecdeba624e6685b4 100644 (file)
@@ -679,13 +679,26 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       }
     }
     elseif ((!$this->_ppID && $this->_id) || !$this->_id) {
-      foreach (array(
-                 'Overdue',
-                 'In Progress'
-               ) as $suppress) {
-        unset($status[CRM_Utils_Array::key($suppress, $statusName)]);
+      $suppressFlag = FALSE;
+      if ($this->_id) {
+        $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
+        if (CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails)) {
+          $suppressFlag = TRUE;
+        }
+      }
+      if (!$suppressFlag) {
+        foreach (array(
+                   'Overdue',
+                   'In Progress'
+                 ) as $suppress) {
+          unset($status[CRM_Utils_Array::key($suppress, $statusName)]);
+        }
+      }
+      else {
+        unset($status[CRM_Utils_Array::key('Overdue', $statusName)]);
       }
     }
+    
     if ($this->_id) {
       $contributionStatus = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $this->_id, 'contribution_status_id');
       $name = CRM_Utils_Array::value($contributionStatus, $statusName);
@@ -693,10 +706,12 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
         case 'Completed':
         case 'Cancelled':
         case 'Refunded':
+          unset($status[CRM_Utils_Array::key('In Progress', $statusName)]);
           unset($status[CRM_Utils_Array::key('Pending', $statusName)]);
           unset($status[CRM_Utils_Array::key('Failed', $statusName)]);
           break;
         case 'Pending':
+        case 'In Progress':
           unset($status[CRM_Utils_Array::key('Refunded', $statusName)]);
           break;
         case 'Failed':
@@ -704,6 +719,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
                      'Pending',
                      'Refunded',
                      'Completed',
+                     'In Progress',
                      'Cancelled'
                    ) as $suppress) {
             unset($status[CRM_Utils_Array::key($suppress, $statusName)]);