1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Fix task timer #1109

This commit is contained in:
Hillel Coren 2016-10-19 10:17:23 +03:00
parent 19bd3e844b
commit b448f459f8
3 changed files with 17 additions and 4 deletions

View File

@ -182,7 +182,6 @@ class TaskController extends BaseController
'method' => 'PUT',
'url' => 'tasks/'.$task->public_id,
'title' => trans('texts.edit_task'),
'duration' => $task->is_running ? $task->getCurrentDuration() : $task->getDuration(),
'actions' => $actions,
'timezone' => Auth::user()->account->timezone ? Auth::user()->account->timezone->name : DEFAULT_TIMEZONE,
'datetimeFormat' => Auth::user()->account->getMomentDateTimeFormat(),

View File

@ -82,6 +82,18 @@ class Task extends EntityModel
return self::calcStartTime($this);
}
public function getLastStartTime()
{
$parts = json_decode($this->time_log) ?: [];
if (count($parts)) {
$index = count($parts) - 1;
return $parts[$index][0];
} else {
return '';
}
}
/**
* @param $task
* @return int

View File

@ -222,12 +222,14 @@
@endif
}
function tock(duration) {
function tock(startTime) {
var duration = new Date().getTime() - startTime;
duration = Math.floor(duration / 100) / 10;
var str = convertDurationToString(duration);
$('#duration-text').html(str);
setTimeout(function() {
tock(duration+1);
tock(startTime);
}, 1000);
}
@ -483,7 +485,7 @@
@if ($task)
@if ($task->is_running)
tock({{ $duration }});
tock({{ $task->getLastStartTime() * 1000 }});
@endif
@endif