improved fix for CRM-17589
authorsystopia <endres@systopia.de>
Thu, 7 Jan 2016 08:09:22 +0000 (09:09 +0100)
committersystopia <endres@systopia.de>
Thu, 7 Jan 2016 08:09:22 +0000 (09:09 +0100)
CRM/Contribute/Form/Contribution.php
templates/CRM/Contribute/Form/Contribution.tpl

index e9d5bb8db2d5eaaf7b87cf040738a8475b04040f..e4aac0752b325f9c4c00f4a95200419ec5da68cf 100644 (file)
@@ -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);
index 668f70580e2e75473b14abf4d1e61f4960e9a423..1cb854d5cd4b0d95cb35cc1c642dd4c1b9bdbb99 100644 (file)
      });
 
      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);
        }