CRM-16571, fixed notice error when contribution is deleted
authorPradeep Nayak <pradpnayak@gmail.com>
Fri, 21 Aug 2015 05:59:44 +0000 (11:29 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Fri, 21 Aug 2015 05:59:44 +0000 (11:29 +0530)
----------------------------------------
* CRM-16571: undefined indexes when deleting a contribution
  https://issues.civicrm.org/jira/browse/CRM-16571

CRM/Contribute/Form/Contribution.php

index bae0bb41e1c5c467ec451628e04bab963f779ff5..a41de6b7d486c43e9ecdcb61d957d5987c5ed26a 100644 (file)
@@ -929,7 +929,6 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
    */
   public static function formRule($fields, $files, $self) {
     $errors = array();
-
     // Check for Credit Card Contribution.
     if ($self->_mode) {
       if (empty($fields['payment_processor_id'])) {
@@ -971,11 +970,17 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
     CRM_Contribute_BAO_ContributionRecur::validateRecurContribution($fields, $files, $self, $errors);
 
     // Form rule for status http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+4.3+Data+Flow
-    if ($self->_id && $self->_values['contribution_status_id'] != $fields['contribution_status_id']) {
+    if (($self->_action & CRM_Core_Action::UPDATE)
+      && $self->_id
+      && $self->_values['contribution_status_id'] != $fields['contribution_status_id']
+    ) {
       CRM_Contribute_BAO_Contribution::checkStatusValidation($self->_values, $fields, $errors);
     }
     // CRM-16015, add form-rule to restrict change of financial type if using price field of different financial type
-    if ($self->_id && $self->_values['financial_type_id'] != $fields['financial_type_id']) {
+    if (($self->_action & CRM_Core_Action::UPDATE)
+      && $self->_id
+      && $self->_values['financial_type_id'] != $fields['financial_type_id']
+    ) {
       CRM_Contribute_BAO_Contribution::checkFinancialTypeChange(NULL, $self->_id, $errors);
     }
     //FIXME FOR NEW DATA FLOW http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+4.3+Data+Flow