Add an 'Execute Now' button to the job log
[civicrm-core.git] / CRM / Admin / Form / Job.php
index 0f69059f7b3ec90eefc86173ac50b318b416f661..dec88aeeab13b922f399719a639cdceaf0b44866 100644 (file)
@@ -24,6 +24,7 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form {
   public function preProcess() {
 
     parent::preProcess();
+    $this->setContext();
 
     CRM_Utils_System::setTitle(ts('Manage - Scheduled Jobs'));
 
@@ -97,7 +98,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->add('datepicker', 'scheduled_run_date', ts('Scheduled Run Date'), NULL, FALSE, ['minDate' => time()]);
+    $this->add('datepicker', 'scheduled_run_date', ts('Scheduled Run Date'), NULL, FALSE, ['minDate' => date('Y-m-d')]);
 
     $this->add('textarea', 'parameters', ts('Command parameters'),
       "cols=50 rows=6"
@@ -194,7 +195,15 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form {
       $jm->executeJobById($this->_id);
       $jobName = self::getJobName($this->_id);
       CRM_Core_Session::setStatus(ts('%1 Scheduled Job has been executed. See the log for details.', [1 => $jobName]), ts("Executed"), "success");
-      CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/job', 'reset=1'));
+
+      if ($this->getContext() === 'joblog') {
+        // If we were triggered via the joblog form redirect back there when we finish
+        $redirectUrl = CRM_Utils_System::url('civicrm/admin/joblog', 'reset=1&jid=' . $this->_id);
+      }
+      else {
+        $redirectUrl = CRM_Utils_System::url('civicrm/admin/job', 'reset=1');
+      }
+      CRM_Utils_System::redirect($redirectUrl);
       return;
     }