From 9ee4786b7dd2703a910a4e1aef04f78bbb410eef Mon Sep 17 00:00:00 2001 From: David Reedy Jr Date: Tue, 29 Dec 2015 16:42:07 -0600 Subject: [PATCH] CRM-17686 switch to datepicker --- CRM/Admin/Form/Job.php | 18 +++++------------- templates/CRM/Admin/Form/Job.tpl | 7 +++---- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/CRM/Admin/Form/Job.php b/CRM/Admin/Form/Job.php index 5830af3402..5209a92af0 100644 --- a/CRM/Admin/Form/Job.php +++ b/CRM/Admin/Form/Job.php @@ -97,7 +97,7 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { $this->add('select', 'run_frequency', ts('Run frequency'), CRM_Core_SelectValues::getJobFrequency()); // CRM-17686 - $this->addDateTime('scheduled_run_date', ts('Scheduled Run Date'), FALSE, array('formatType' => 'activityDateTime')); + $this->add('datepicker', 'scheduled_run_date', ts('Scheduled Run Date'), NULL, FALSE, array('minDate' => time())); $this->add('textarea', 'parameters', ts('Command parameters'), "cols=50 rows=6" @@ -162,8 +162,7 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { // CRM-17686 if (!empty($dao->scheduled_run_date)) { $ts = strtotime($dao->scheduled_run_date); - $defaults['scheduled_run_date'] = date('m/d/Y', $ts); - $defaults['scheduled_run_date_time'] = date('h:iA', $ts); + $defaults['scheduled_run_date'] = date("Y-m-d H:i:s", $ts); } // CRM-10708 @@ -205,14 +204,7 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { $dao->is_active = CRM_Utils_Array::value('is_active', $values, 0); // CRM-17686 - $dt = ''; - if (!empty($values['scheduled_run_date'])) { - $dt = $values['scheduled_run_date'] . ' ';; - } - if (!empty($values['scheduled_run_date_time'])) { - $dt .= $values['scheduled_run_date_time']; - } - $ts = strtotime(trim($dt)); + $ts = strtotime($values['scheduled_run_date']); // if a date/time is supplied and not in the past, then set the next scheduled run... if ($ts > time()) { $dao->scheduled_run_date = CRM_Utils_Date::currentDBDate($ts); @@ -222,7 +214,7 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { if ($info['mday'] > 28) { CRM_Core_Session::setStatus( ts('Relative month values are calculated based on the length of month(s) that they pass through. - The result will land on the same day of the month except for days 29-31 when the target month contains fewer days. + The result will land on the same day of the month except for days 29-31 when the target month contains fewer days than the previous month. For example, if a job is scheduled to run on August 31st, the following invocation will occur on October 1st, and then the 1st of every month thereafter. To avoid this issue, please schedule Monthly and Quarterly jobs to run within the first 28 days of the month.'), ts('Warning'), 'info', array('expires' => 0)); @@ -230,7 +222,7 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { } } // ...otherwise, if this isn't a new scheduled job, clear the next scheduled run - elseif ($this->_id) { + elseif ($dao->id) { $job = new CRM_Core_ScheduledJob(array('id' => $dao->id)); $job->clearScheduledRunDate(); } diff --git a/templates/CRM/Admin/Form/Job.tpl b/templates/CRM/Admin/Form/Job.tpl index 72a77da530..ca95cdf714 100644 --- a/templates/CRM/Admin/Form/Job.tpl +++ b/templates/CRM/Admin/Form/Job.tpl @@ -107,10 +107,9 @@ CRM.$(function($) { {$form.scheduled_run_date.label} - - {if $hideCalender neq true}{include file="CRM/common/jcalendar.tpl" elementName=scheduled_run_date}{else}{$scheduled_run_date|crmDate}{/if}
-
{ts}Do not run this job before this date / time. - Leave blank to run {if $action eq 1}as soon as possible{else}at next run frequency{/if}.{/ts} + {$form.scheduled_run_date.html}
+
{ts}Do not run this job before this date / time. The run frequency selected above will apply thereafter.{/ts}
+ {ts}Leave blank to run{/ts} {if $action eq 1}{ts}as soon as possible{/ts}{else}{ts}at next run frequency{/ts}{/if}.
-- 2.25.1