|
35 | 35 | use core\output\single_button; |
36 | 36 | use core\task\manager; |
37 | 37 | use tool_lifecycle\action; |
38 | | -use tool_lifecycle\event\process_rollback; |
39 | 38 | use tool_lifecycle\event\process_triggered; |
40 | 39 | use tool_lifecycle\local\manager\delayed_courses_manager; |
41 | 40 | use tool_lifecycle\local\manager\lib_manager; |
|
227 | 226 | 'move_down' => get_string('move_down', 'tool_lifecycle'), |
228 | 227 | ]; |
229 | 228 |
|
230 | | -$nextrun = false; |
231 | 229 | $coursestriggered = 0; |
232 | 230 | $coursesdelayed = 0; |
233 | 231 | $hasotherwf = 0; |
|
242 | 240 | $coursestriggered = $amounts['all']->coursestriggered ?? 0; |
243 | 241 | $coursesdelayed = $amounts['all']->delayedcourses ?? 0; |
244 | 242 | $hasotherwf = $amounts['all']->hasotherwf ?? 0; |
245 | | - $nextrun = $amounts['all']->nextrun == 0 ? false : $amounts['all']->nextrun; |
246 | 243 | $displaytotaltriggered = !empty($triggers); |
247 | 244 | } |
248 | 245 |
|
249 | | -$task = manager::get_scheduled_task('tool_lifecycle\task\lifecycle_task'); |
250 | | -$lastrun = $task->get_last_run_time(); |
251 | | -$nextrunt = $task->get_next_run_time(); |
252 | | -$nextrunout = ""; |
253 | | -if (!$task->is_component_enabled() && !$task->get_run_if_component_disabled()) { |
254 | | - $nextrunt = get_string('plugindisabled', 'tool_task'); |
255 | | -} else if ($task->get_disabled()) { |
256 | | - $nextrunt = get_string('taskdisabled', 'tool_task'); |
257 | | -} else if (is_numeric($nextrunt) && $nextrunt < time()) { |
258 | | - $nextrunt = get_string('asap', 'tool_task'); |
259 | | -} |
260 | | -if (is_numeric($nextrunt) && is_numeric($nextrun)) { // Task nextrun and trigger nextrun are valid times: take the minimum. |
261 | | - $nextrunout = min($nextrunt, $nextrun); |
262 | | -} else if (!is_numeric($nextrunt) && is_numeric($nextrun)) { // Only trigger nextrun is valid time. |
263 | | - $nextrun = $nextrun; |
264 | | -} else if (is_numeric($nextrunt)) { // Only task next run is valid time. |
265 | | - $nextrunout = $nextrunt; |
266 | | -} else { // There is no valid next run time. Print the task message. |
267 | | - $nextrunout = $nextrunt; |
268 | | -} |
269 | | -if (is_numeric($nextrunout)) { |
270 | | - if ($nextrunout) { |
271 | | - $nextrunout = userdate($nextrunout, get_string('strftimedatetimeshort', 'langconfig'), |
272 | | - core_date::get_user_timezone($USER)); |
273 | | - } else { |
274 | | - $nextrunout = get_string('statusunknown'); |
275 | | - } |
276 | | -} |
277 | | - |
278 | 246 | $nomanualtriggerinvolved = true; |
279 | 247 | $displaytriggers = []; |
280 | 248 | $displaytimetriggers = []; |
|
309 | 277 | $sqlresult = trigger_manager::get_trigger_sqlresult($trigger); |
310 | 278 | if ($sqlresult == "false") { |
311 | 279 | $trigger->classfires = "border-danger"; |
312 | | - $trigger->additionalinfo = $amounts[$trigger->sortindex]->additionalinfo ?? "-"; |
313 | 280 | } else { |
314 | 281 | $settings = settings_manager::get_settings($trigger->id, settings_type::TRIGGER); |
315 | 282 | $trigger->exclude = $settings['exclude'] ?? false; |
|
344 | 311 | } |
345 | 312 | if ($response == trigger_response::triggertime()) { |
346 | 313 | $displaytimetriggers[] = $trigger; |
347 | | - if (isset($amounts[$trigger->sortindex]->lastrun) && $amounts[$trigger->sortindex]->lastrun) { |
348 | | - $lastrun = $amounts[$trigger->sortindex]->lastrun; |
349 | | - } else { |
350 | | - $lastrun = 0; |
351 | | - } |
352 | 314 | } else { |
353 | 315 | $displaytriggers[] = $trigger; |
354 | 316 | } |
|
538 | 500 | } |
539 | 501 | } |
540 | 502 |
|
541 | | -if (!($isactive || $isdeactivated)) { |
542 | | - $lastrun = 0; |
543 | | -} |
| 503 | +list($lastrun, $nextrun) = workflow_manager::get_lastrun_nextrun($workflow->id); |
| 504 | + |
544 | 505 | $data = [ |
545 | 506 | 'editsettingslink' => (new moodle_url(urls::EDIT_WORKFLOW, ['wf' => $workflow->id]))->out(false), |
546 | 507 | 'title' => $workflow->title, |
|
565 | 526 | 'showdetailslink' => $showdetailslink, |
566 | 527 | 'showdetailsicon' => $showdetails == 0, |
567 | 528 | 'isactive' => $isactive || $isdeactivated, |
568 | | - 'nextrun' => $nextrunout, |
569 | | - 'lastrun' => $lastrun != 0 ? |
570 | | - userdate($lastrun, get_string('strftimedatetimeshort', 'langconfig'), |
571 | | - core_date::get_user_timezone($USER)) : '--', |
| 529 | + 'nextrun' => $nextrun, |
| 530 | + 'lastrun' => $lastrun, |
572 | 531 | 'nomanualtriggerinvolved' => $nomanualtriggerinvolved, |
573 | 532 | 'disableworkflowlink' => $disableworkflowlink, |
574 | 533 | 'abortdisableworkflowlink' => $abortdisableworkflowlink, |
|
0 commit comments