public function preProcess() {
parent::preProcess();
+ $this->setContext();
CRM_Utils_System::setTitle(ts('Manage - Scheduled Jobs'));
$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;
}
$this->_action = CRM_Utils_Request::retrieve('action', 'String',
$this, FALSE, 0
);
+ $this->_context = CRM_Utils_Request::retrieve('context', 'String',
+ $this, FALSE, 0
+ );
if (($this->_action & CRM_Core_Action::COPY) && (!empty($this->_id))) {
try {
* Browse all jobs.
*/
public function browse() {
- $jid = CRM_Utils_Request::retrieve('jid', 'Positive', $this);
+ $jid = CRM_Utils_Request::retrieve('jid', 'Positive');
$sj = new CRM_Core_JobManager();
- $jobName = NULL;
if ($jid) {
$jobName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Job', $jid);
+ $this->assign('jobName', $jobName);
+ $jobRunUrl = CRM_Utils_System::url('civicrm/admin/job', 'action=view&reset=1&context=joblog&id=' . $jid);
+ $this->assign('jobRunUrl', $jobRunUrl);
}
- $this->assign('jobName', $jobName);
-
$dao = new CRM_Core_DAO_JobLog();
$dao->orderBy('id desc');
<div class="action-link">
<a href="{crmURL p='civicrm/admin/job' q="reset=1"}" id="jobsList-top" class="button"><span><i class="crm-i fa-chevron-left" aria-hidden="true"></i> {ts}Back to Scheduled Jobs Listing{/ts}</span></a>
+ {if $jobRunUrl}
+ <a href="{$jobRunUrl}" id="jobsList-run-top" class="button"><span><i class="crm-i fa-play" aria-hidden="true"></i> {ts}Execute Now{/ts}</span></a>
+ {/if}
</div>
{if $rows}
<div class="action-link">
<a href="{crmURL p='civicrm/admin/job' q="reset=1"}" id="jobsList-bottom" class="button"><span><i class="crm-i fa-chevron-left" aria-hidden="true"></i> {ts}Back to Scheduled Jobs Listing{/ts}</span></a>
+ {if $jobRunUrl}
+ <a href="{$jobRunUrl}" id="jobsList-run-bottom" class="button"><span><i class="crm-i fa-play" aria-hidden="true"></i> {ts}Execute Now{/ts}</span></a>
+ {/if}
</div>
</div>