mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Fix task timer #1109
This commit is contained in:
parent
19bd3e844b
commit
b448f459f8
@ -182,7 +182,6 @@ class TaskController extends BaseController
|
|||||||
'method' => 'PUT',
|
'method' => 'PUT',
|
||||||
'url' => 'tasks/'.$task->public_id,
|
'url' => 'tasks/'.$task->public_id,
|
||||||
'title' => trans('texts.edit_task'),
|
'title' => trans('texts.edit_task'),
|
||||||
'duration' => $task->is_running ? $task->getCurrentDuration() : $task->getDuration(),
|
|
||||||
'actions' => $actions,
|
'actions' => $actions,
|
||||||
'timezone' => Auth::user()->account->timezone ? Auth::user()->account->timezone->name : DEFAULT_TIMEZONE,
|
'timezone' => Auth::user()->account->timezone ? Auth::user()->account->timezone->name : DEFAULT_TIMEZONE,
|
||||||
'datetimeFormat' => Auth::user()->account->getMomentDateTimeFormat(),
|
'datetimeFormat' => Auth::user()->account->getMomentDateTimeFormat(),
|
||||||
|
@ -82,6 +82,18 @@ class Task extends EntityModel
|
|||||||
return self::calcStartTime($this);
|
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
|
* @param $task
|
||||||
* @return int
|
* @return int
|
||||||
|
@ -222,12 +222,14 @@
|
|||||||
@endif
|
@endif
|
||||||
}
|
}
|
||||||
|
|
||||||
function tock(duration) {
|
function tock(startTime) {
|
||||||
|
var duration = new Date().getTime() - startTime;
|
||||||
|
duration = Math.floor(duration / 100) / 10;
|
||||||
var str = convertDurationToString(duration);
|
var str = convertDurationToString(duration);
|
||||||
$('#duration-text').html(str);
|
$('#duration-text').html(str);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
tock(duration+1);
|
tock(startTime);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,7 +485,7 @@
|
|||||||
|
|
||||||
@if ($task)
|
@if ($task)
|
||||||
@if ($task->is_running)
|
@if ($task->is_running)
|
||||||
tock({{ $duration }});
|
tock({{ $task->getLastStartTime() * 1000 }});
|
||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user