Working on time tracker

This commit is contained in:
Hillel Coren 2017-09-24 21:44:37 +03:00
parent 27813567b2
commit 5e0f838271
2 changed files with 6 additions and 2 deletions

View File

@ -152,12 +152,14 @@ class TaskRepository extends BaseRepository
} elseif ($data['action'] == 'offline'){ } elseif ($data['action'] == 'offline'){
$task->is_running = $data['is_running'] ? 1 : 0; $task->is_running = $data['is_running'] ? 1 : 0;
} }
} elseif (isset($data['is_running'])) {
$task->is_running = $data['is_running'] ? 1 : 0;
} }
/* /*
if ($count = count($timeLog)) { if ($count = count($timeLog)) {
$lastTime = $timeLog[$count - 1]; $lastTime = $timeLog[$count - 1];
$task->is_running = count($lastTime) == 2 && $lastTime[1]; $task->is_running = count($lastTime) == 2 && intval($lastTime[1]);
\Log::info('is running: ' . $task->is_running); \Log::info('is running: ' . $task->is_running);
} }
*/ */

View File

@ -431,14 +431,16 @@
self.onStartClick = function() { self.onStartClick = function() {
if (self.isRunning()) { if (self.isRunning()) {
var data = 'is_running=0&';
var time = self.lastTime(); var time = self.lastTime();
time.endTime(moment().unix()); time.endTime(moment().unix());
} else { } else {
var data = 'is_running=1&';
var time = new TimeModel(); var time = new TimeModel();
time.startTime(moment().unix()); time.startTime(moment().unix());
self.addTime(time); self.addTime(time);
} }
self.save('time_log=' + JSON.stringify(self.times())); self.save(data + 'time_log=' + JSON.stringify(self.times()));
} }
self.listItemState = ko.computed(function() { self.listItemState = ko.computed(function() {