From b219e49fbdc63a34aa9278d4a64fcf36c678f2a5 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 3 Dec 2018 19:51:18 +1100 Subject: [PATCH] dev/core#561 Convert Scheduled Reminders Form to use datepicker and ensure that either start_action_offset or absolute_date is filled in --- CRM/Admin/Form/ScheduleReminders.php | 18 ++++++++---------- templates/CRM/Admin/Form/ScheduleReminders.tpl | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/CRM/Admin/Form/ScheduleReminders.php b/CRM/Admin/Form/ScheduleReminders.php index 2c59e0c032..87fd5d0d49 100644 --- a/CRM/Admin/Form/ScheduleReminders.php +++ b/CRM/Admin/Form/ScheduleReminders.php @@ -194,7 +194,7 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $freqUnitsDisplay[$val] = ts('%1(s)', array(1 => $label)); } - $this->addDate('absolute_date', ts('Start Date'), FALSE, array('formatType' => 'mailing')); + $this->add('datepicker', 'absolute_date', ts('Start Date'), [], FALSE, array('time' => FALSE)); //reminder_frequency $this->add('select', 'start_action_unit', ts('Frequency'), $freqUnitsDisplay, TRUE); @@ -342,10 +342,15 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { } if (!CRM_Utils_System::isNull($fields['absolute_date'])) { - if (CRM_Utils_Date::format(CRM_Utils_Date::processDate($fields['absolute_date'], NULL)) < CRM_Utils_Date::format(date('Ymd'))) { + if ($fields['absolute_date'] < date('Y-m-d')) { $errors['absolute_date'] = ts('Absolute date cannot be earlier than the current time.'); } } + else { + if (CRM_Utils_System::isNull($fields['start_action_offset'])) { + $errors['start_action_offset'] = ts('Start Action Offset must be filled in or Absolute Date set'); + } + } if (!CRM_Utils_Rule::email($fields['from_email']) && (!$mode || $mode != 'SMS')) { $errors['from_email'] = ts('Please enter a valid email address.'); } @@ -404,10 +409,6 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { else { $defaults['entity'] = $entityStatus; } - if ($absoluteDate = CRM_Utils_Array::value('absolute_date', $defaults)) { - list($date, $time) = CRM_Utils_Date::setDateDefaults($absoluteDate); - $defaults['absolute_date'] = $date; - } if ($recipientListing = CRM_Utils_Array::value('recipient_listing', $defaults)) { $defaults['recipient_listing'] = explode(CRM_Core_DAO::VALUE_SEPARATOR, @@ -522,10 +523,7 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { 'end_date', ); - if ($absoluteDate = CRM_Utils_Array::value('absolute_date', $params)) { - $params['absolute_date'] = CRM_Utils_Date::processDate($absoluteDate); - } - else { + if (!CRM_Utils_Array::value('absolute_date', $params)) { $params['absolute_date'] = 'null'; } foreach ($moreKeys as $mkey) { diff --git a/templates/CRM/Admin/Form/ScheduleReminders.tpl b/templates/CRM/Admin/Form/ScheduleReminders.tpl index 7614164820..f1ba9a5ef6 100644 --- a/templates/CRM/Admin/Form/ScheduleReminders.tpl +++ b/templates/CRM/Admin/Form/ScheduleReminders.tpl @@ -44,7 +44,7 @@ {$form.start_action_offset.label} - {include file="CRM/common/jcalendar.tpl" elementName=absolute_date} OR
+ {$form.absolute_date.html} OR
-- 2.25.1