summaryrefslogtreecommitdiff
path: root/app/Controller/Timer.php
blob: 0267fcddc4a3aa8435010b890089246c0947da3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

namespace Kanboard\Controller;

/**
 * Time Tracking controller
 *
 * @package  controller
 * @author   Frederic Guillot
 */
class Timer extends Base
{
    /**
     * Start/stop timer for subtasks
     *
     * @access public
     */
    public function subtask()
    {
        $project_id = $this->request->getIntegerParam('project_id');
        $task_id = $this->request->getIntegerParam('task_id');
        $subtask_id = $this->request->getIntegerParam('subtask_id');
        $timer = $this->request->getStringParam('timer');

        if ($timer === 'start') {
            $this->subtaskTimeTracking->logStartTime($subtask_id, $this->userSession->getId());
        } elseif ($timer === 'stop') {
            $this->subtaskTimeTracking->logEndTime($subtask_id, $this->userSession->getId());
            $this->subtaskTimeTracking->updateTaskTimeTracking($task_id);
        }

        $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $project_id, 'task_id' => $task_id)).'#subtasks');
    }
}