From f73acc7835ed122a4a322870ee997f858830abe0 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Sat, 1 Feb 2014 23:41:31 +0530 Subject: [PATCH] CRM-13968, handled In-progress to Completed contribution status change ---------------------------------------- * 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 | 1 + CRM/Contribute/Form/Contribution.php | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index f61917da9e..ed0794a816 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -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') ); diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 6dd36b9930..dbc6731bc1 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -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)]); -- 2.25.1