1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Start / Stop task via API

This commit is contained in:
David Bomba 2022-03-10 17:26:03 +11:00
parent 48cec13b99
commit 3967d074ed

View File

@ -185,11 +185,38 @@ class TaskRepository extends BaseRepository
public function start(Task $task) public function start(Task $task)
{ {
$log = $task->time_log;
$last = end($log);
if($last[1] !== 0){
$new = [time(), 0];
array_push($log, $new);
$task->time_log = $log;
$task->save();
}
} }
public function stop(Task $task) public function stop(Task $task)
{ {
$log = $task->time_log;
$last = end($log);
if($last[1] === 0){
$last[1] = time();
array_pop($log);
array_push($log, $last);
$task->time_log = $log;
$task->save();
}
} }
} }