From fb357d6e568437a01d7ef15dec4db5b53012e03f Mon Sep 17 00:00:00 2001 From: yashodha Date: Fri, 1 Apr 2016 14:04:38 +0530 Subject: [PATCH] CRM-18299: Auto-Renew chkbox does not display if Pay Later is selected in configuration ---------------------------------------- * CRM-18299: Auto-Renew chkbox does not display if Pay Later is selected in configuration https://issues.civicrm.org/jira/browse/CRM-18299 --- CRM/Contribute/Form/Contribution/Main.php | 5 +++++ CRM/Contribute/Form/ContributionBase.php | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 80543409cc..abd7bce7ad 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -600,6 +600,11 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu public static function formRule($fields, $files, $self) { $errors = array(); $amount = self::computeAmount($fields, $self->_values); + if (CRM_Utils_Array::value('auto_renew', $fields) && + CRM_Utils_Array::value('payment_processor_id', $fields) == 0 + ) { + $errors['auto_renew'] = ts('You cannot have auto-renewal on if you are paying later.'); + } if ((!empty($fields['selectMembership']) && $fields['selectMembership'] != 'no_thanks' diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index 0419da7da3..4bd0558559 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -1108,7 +1108,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { $allowAutoRenewOpt = (int) $memType['auto_renew']; if (is_array($this->_paymentProcessors)) { foreach ($this->_paymentProcessors as $id => $val) { - if (!$val['is_recur']) { + if ($id && !$val['is_recur']) { $allowAutoRenewOpt = 0; continue; } @@ -1199,7 +1199,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { $this->assign('autoRenewOption', $autoRenewOption); } - if (!$this->_values['is_pay_later'] && is_array($this->_paymentProcessors) && ($allowAutoRenewMembership || $autoRenewOption)) { + if ((!$this->_values['is_pay_later'] || is_array($this->_paymentProcessors)) && ($allowAutoRenewMembership || $autoRenewOption)) { $this->addElement('checkbox', 'auto_renew', ts('Please renew my membership automatically.')); } -- 2.25.1