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:
parent
48cec13b99
commit
3967d074ed
@ -185,11 +185,38 @@ class TaskRepository extends BaseRepository
|
||||
|
||||
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)
|
||||
{
|
||||
$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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user