Kanboard-Prod/app/Controller/SubtaskStatusController.php

53 lines
1.4 KiB
PHP

<?php
namespace Kanboard\Controller;
/**
* Subtask Status
*
* @package Kanboard\Controller
* @author Frederic Guillot
*/
class SubtaskStatusController extends BaseController
{
/**
* Change status to the next status: Toto -> In Progress -> Done
*
* @access public
*/
public function change()
{
$task = $this->getTask();
$subtask = $this->getSubtask();
$status = $this->subtaskStatusModel->toggleStatus($subtask['id']);
$subtask['status'] = $status;
$this->response->html($this->helper->subtask->renderToggleStatus($task, $subtask));
}
/**
* Start/stop timer for subtasks
*
* @access public
*/
public function timer()
{
$task = $this->getTask();
$subtaskId = $this->request->getIntegerParam('subtask_id');
$timer = $this->request->getStringParam('timer');
if ($timer === 'start') {
$this->subtaskTimeTrackingModel->logStartTime($subtaskId, $this->userSession->getId());
} elseif ($timer === 'stop') {
$this->subtaskTimeTrackingModel->logEndTime($subtaskId, $this->userSession->getId());
$this->subtaskTimeTrackingModel->updateTaskTimeTracking($task['id']);
}
$this->response->html($this->template->render('subtask/timer', array(
'task' => $task,
'subtask' => $this->subtaskModel->getByIdWithDetails($subtaskId),
)));
}
}