From d4849da4c35abff46423429fa55edcbd341edee0 Mon Sep 17 00:00:00 2001 From: systopia Date: Thu, 7 Jan 2016 09:09:22 +0100 Subject: [PATCH] improved fix for CRM-17589 --- CRM/Contribute/Form/Contribution.php | 9 +++++++++ templates/CRM/Contribute/Form/Contribution.tpl | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index e9d5bb8db2..e4aac0752b 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -681,6 +681,15 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP } } + // define the status IDs that show the cancellation info, see CRM-17589 + $cancelInfo_show_ids = array(); + foreach ($statusName as $status_id => $status_name) { + if ($status_name == 'Cancelled' || $status_name == 'Refunded') { + $cancelInfo_show_ids[] = "'$status_id'"; + } + } + $this->assign('cancelInfo_show_ids', implode(',', $cancelInfo_show_ids)); + if ($this->_id) { $contributionStatus = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $this->_id, 'contribution_status_id'); $name = CRM_Utils_Array::value($contributionStatus, $statusName); diff --git a/templates/CRM/Contribute/Form/Contribution.tpl b/templates/CRM/Contribute/Form/Contribution.tpl index 668f70580e..1cb854d5cd 100644 --- a/templates/CRM/Contribute/Form/Contribution.tpl +++ b/templates/CRM/Contribute/Form/Contribution.tpl @@ -488,7 +488,9 @@ }); function showHideCancelInfo(obj) { - if (obj.find(":selected").val() == '7' || obj.find(":selected").val() == '3') { + var selected_status_id = obj.find(":selected").val(); + var cancelInfo_show_ids = [{/literal}{$cancelInfo_show_ids}{literal}]; + if (cancelInfo_show_ids.indexOf(selected_status_id) > -1) { cj('#cancelInfo').show( ); cj('#total_amount').attr('readonly', true); } -- 2.25.1