From 577d1236c1edb84a983e86a10c7dcb32fa1d35db Mon Sep 17 00:00:00 2001 From: Web Access Date: Fri, 22 May 2015 18:34:56 +0530 Subject: [PATCH] CRM-16285: recurring_interval not checked in Backoffice form New CreditCard Payment --- CRM/Contribute/BAO/ContributionRecur.php | 11 +++++++++++ CRM/Contribute/Form/Contribution.php | 4 ++++ CRM/Contribute/Form/Contribution/Main.php | 10 ++-------- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index be0fbc9c3e..8c531f3caf 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -457,4 +457,15 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) } } + //CRM-16285 - Function to handle validation errors on form, for recurring contribution field. + public static function validateRecurContribution($fields, $files, $self, &$errors) { + if (!empty($fields['is_recur'])) { + if ($fields['frequency_interval'] <= 0) { + $errors['frequency_interval'] = ts('Please enter a number for how often you want to make this recurring contribution (EXAMPLE: Every 3 months).'); + } + if ($fields['frequency_unit'] == '0') { + $errors['frequency_unit'] = ts('Please select a period (e.g. months, years ...) for how often you want to make this recurring contribution (EXAMPLE: Every 3 MONTHS).'); + } + } + } } diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index e77e62ff4d..537ab02d64 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -954,6 +954,10 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $errors['total_amount'] = ts('The sum of fee amount and net amount must be equal to total amount'); } } + + //CRM-16285 - Function to handle validation errors on form, for recurring contribution field. + 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']) { CRM_Contribute_BAO_Contribution::checkStatusValidation($self->_values, $fields, $errors); diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 9c103e6c96..5f633b3e92 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -976,14 +976,8 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu } } - if (!empty($fields['is_recur'])) { - if ($fields['frequency_interval'] <= 0) { - $errors['frequency_interval'] = ts('Please enter a number for how often you want to make this recurring contribution (EXAMPLE: Every 3 months).'); - } - if ($fields['frequency_unit'] == '0') { - $errors['frequency_unit'] = ts('Please select a period (e.g. months, years ...) for how often you want to make this recurring contribution (EXAMPLE: Every 3 MONTHS).'); - } - } + //CRM-16285 - Function to handle validation errors on form, for recurring contribution field. + CRM_Contribute_BAO_ContributionRecur::validateRecurContribution($fields, $files, $self, $errors); if (!empty($fields['is_recur']) && CRM_Utils_Array::value('payment_processor', $fields) == 0 -- 2.25.1