From ed1c698a218ad5c0e999c9d51bbd861292d66f06 Mon Sep 17 00:00:00 2001 From: yashodha Date: Tue, 27 Mar 2018 09:03:59 +0530 Subject: [PATCH] CRM-21854 - Contribution start date and end dates are not respected --- CRM/Contribute/Form/ContributionBase.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index a94e06a652..df82cb3042 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -313,6 +313,17 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { throw new CRM_Contribute_Exception_InactiveContributionPageException(ts('The page you requested is currently unavailable.'), $this->_id); } + $endDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value('end_date', $this->_values)); + $now = date('YmdHis'); + if ($endDate && $endDate < $now) { + throw new Exception(ts('The page you requested has past its end date on '. CRM_Utils_Date::customFormat($endDate) ), $this->_id); + } + + $startDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value('start_date', $this->_values)); + if ($startDate && $startDate > $now) { + throw new Exception(ts('The page you requested will be active from '. CRM_Utils_Date::customFormat($startDate)), $this->_id); + } + $this->assignBillingType(); // check for is_monetary status -- 2.25.1