- if ($this->_id) {
- $contributionStatus = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $this->_id, 'contribution_status_id');
- $name = CRM_Utils_Array::value($contributionStatus, $statusName);
- switch ($name) {
- case 'Completed':
- // [CRM-17498] Removing unsupported status change options.
- unset($status[CRM_Utils_Array::key('Pending', $statusName)]);
- unset($status[CRM_Utils_Array::key('Failed', $statusName)]);
- unset($status[CRM_Utils_Array::key('Partially paid', $statusName)]);
- unset($status[CRM_Utils_Array::key('Pending refund', $statusName)]);
- case 'Cancelled':
- case 'Chargeback':
- 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)]);
- unset($status[CRM_Utils_Array::key('Chargeback', $statusName)]);
- break;
-
- case 'Failed':
- foreach (array(
- 'Pending',
- 'Refunded',
- 'Chargeback',
- 'Completed',
- 'In Progress',
- 'Cancelled',
- ) as $suppress) {
- unset($status[CRM_Utils_Array::key($suppress, $statusName)]);
- }
- break;
- }
- }
- else {
- unset($status[CRM_Utils_Array::key('Refunded', $statusName)]);
- unset($status[CRM_Utils_Array::key('Chargeback', $statusName)]);
- }
-