CRM-21342 - Contribution note is not wiped if the value is removed
authoryashodha <yashodha@cividesk.com>
Tue, 24 Oct 2017 08:23:17 +0000 (13:53 +0530)
committeryashodha <yashodha@cividesk.com>
Tue, 24 Oct 2017 08:23:17 +0000 (13:53 +0530)
CRM/Contribute/Form/AdditionalInfo.php
CRM/Contribute/Form/Contribution.php

index 9498393a50b882bced3062a9023ec5aac6132a16..e6423b02f462a2905d85bd00251af041ef05c888 100644 (file)
@@ -254,6 +254,10 @@ class CRM_Contribute_Form_AdditionalInfo {
    * @param int $contributionNoteID
    */
   public static function processNote($params, $contactID, $contributionID, $contributionNoteID = NULL) {
+    if (CRM_Utils_System::isNull($params['note']) && $contributionNoteID) {
+      CRM_Core_BAO_Note::del($contributionNoteID);
+      return;
+    }
     //process note
     $noteParams = array(
       'entity_table' => 'civicrm_contribution',
index 5b56bd0c1aa07f0ea7b7668a94ef84162c04b44a..865e90639a3f8f02d5b5adc5557e8db52f63a001 100644 (file)
@@ -534,7 +534,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
     }
 
     if ($this->_noteID &&
-      isset($this->_values['note'])
+      !CRM_Utils_System::isNull($this->_values['note'])
     ) {
       $defaults['hidden_AdditionalDetail'] = 1;
     }
@@ -1701,7 +1701,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       );
     }
 
-    if ($contribution->id && !empty($submittedValues['note'])) {
+    if ($contribution->id) {
       CRM_Contribute_Form_AdditionalInfo::processNote($submittedValues, $this->_contactID, $contribution->id, $this->_noteID);
     }