Add timer for subtasks and remove settings for subtask time tracking
This commit is contained in:
@@ -41,6 +41,7 @@ class Acl extends Base
|
||||
'subtask' => '*',
|
||||
'task' => '*',
|
||||
'tasklink' => '*',
|
||||
'timer' => '*',
|
||||
'calendar' => array('show', 'project'),
|
||||
);
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class Budget extends Base
|
||||
->join(Task::TABLE, 'id', 'task_id', Subtask::TABLE)
|
||||
->join(User::TABLE, 'id', 'user_id')
|
||||
->eq(Task::TABLE.'.project_id', $project_id)
|
||||
->filter(array($this, 'applyUserRate'));
|
||||
->callback(array($this, 'applyUserRate'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -276,7 +276,7 @@ class Project extends Base
|
||||
return $this->db
|
||||
->table(Project::TABLE)
|
||||
->in('id', $project_ids)
|
||||
->filter(array($this, 'applyColumnStats'));
|
||||
->callback(array($this, 'applyColumnStats'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -78,6 +78,8 @@ class Subtask extends Base
|
||||
|
||||
foreach ($subtasks as &$subtask) {
|
||||
$subtask['status_name'] = $status[$subtask['status']];
|
||||
$subtask['timer_start_date'] = isset($subtask['timer_start_date']) ? $subtask['timer_start_date'] : 0;
|
||||
$subtask['is_timer_started'] = ! empty($subtask['timer_start_date']);
|
||||
}
|
||||
|
||||
return $subtasks;
|
||||
@@ -101,12 +103,13 @@ class Subtask extends Base
|
||||
Task::TABLE.'.title AS task_name',
|
||||
Project::TABLE.'.name AS project_name'
|
||||
)
|
||||
->subquery($this->subtaskTimeTracking->getTimerQuery($user_id), 'timer_start_date')
|
||||
->eq('user_id', $user_id)
|
||||
->eq(Project::TABLE.'.is_active', Project::ACTIVE)
|
||||
->in(Subtask::TABLE.'.status', $status)
|
||||
->join(Task::TABLE, 'id', 'task_id')
|
||||
->join(Project::TABLE, 'id', 'project_id', Task::TABLE)
|
||||
->filter(array($this, 'addStatusName'));
|
||||
->callback(array($this, 'addStatusName'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,10 +124,15 @@ class Subtask extends Base
|
||||
return $this->db
|
||||
->table(self::TABLE)
|
||||
->eq('task_id', $task_id)
|
||||
->columns(self::TABLE.'.*', User::TABLE.'.username', User::TABLE.'.name')
|
||||
->columns(
|
||||
self::TABLE.'.*',
|
||||
User::TABLE.'.username',
|
||||
User::TABLE.'.name'
|
||||
)
|
||||
->subquery($this->subtaskTimeTracking->getTimerQuery($this->userSession->getId()), 'timer_start_date')
|
||||
->join(User::TABLE, 'id', 'user_id')
|
||||
->asc(self::TABLE.'.position')
|
||||
->filter(array($this, 'addStatusName'))
|
||||
->callback(array($this, 'addStatusName'))
|
||||
->findAll();
|
||||
}
|
||||
|
||||
@@ -144,8 +152,9 @@ class Subtask extends Base
|
||||
->table(self::TABLE)
|
||||
->eq(self::TABLE.'.id', $subtask_id)
|
||||
->columns(self::TABLE.'.*', User::TABLE.'.username', User::TABLE.'.name')
|
||||
->subquery($this->subtaskTimeTracking->getTimerQuery($this->userSession->getId()), 'timer_start_date')
|
||||
->join(User::TABLE, 'id', 'user_id')
|
||||
->filter(array($this, 'addStatusName'))
|
||||
->callback(array($this, 'addStatusName'))
|
||||
->findOne();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,27 @@ class SubtaskTimeTracking extends Base
|
||||
*/
|
||||
const TABLE = 'subtask_time_tracking';
|
||||
|
||||
/**
|
||||
* Get query to check if a timer is started for the given user and subtask
|
||||
*
|
||||
* @access public
|
||||
* @param integer $user_id User id
|
||||
* @return string
|
||||
*/
|
||||
public function getTimerQuery($user_id)
|
||||
{
|
||||
return sprintf(
|
||||
"SELECT %s FROM %s WHERE %s='%d' AND %s='0' AND %s=%s",
|
||||
$this->db->escapeIdentifier('start'),
|
||||
$this->db->escapeIdentifier(self::TABLE),
|
||||
$this->db->escapeIdentifier('user_id'),
|
||||
$user_id,
|
||||
$this->db->escapeIdentifier('end'),
|
||||
$this->db->escapeIdentifier('subtask_id'),
|
||||
Subtask::TABLE.'.id'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get query for user timesheet (pagination)
|
||||
*
|
||||
@@ -217,7 +238,7 @@ class SubtaskTimeTracking extends Base
|
||||
{
|
||||
return $this->db
|
||||
->table(self::TABLE)
|
||||
->insert(array('subtask_id' => $subtask_id, 'user_id' => $user_id, 'start' => time()));
|
||||
->insert(array('subtask_id' => $subtask_id, 'user_id' => $user_id, 'start' => time(), 'end' => 0));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -301,7 +301,7 @@ class TaskFilter extends Base
|
||||
*/
|
||||
public function toAutoCompletion()
|
||||
{
|
||||
return $this->query->columns('id', 'title')->filter(function(array $results) {
|
||||
return $this->query->columns('id', 'title')->callback(function(array $results) {
|
||||
|
||||
foreach ($results as &$result) {
|
||||
$result['value'] = $result['title'];
|
||||
|
||||
@@ -316,7 +316,7 @@ class TaskFinder extends Base
|
||||
->table(Task::TABLE)
|
||||
->eq('project_id', $project_id)
|
||||
->eq('column_id', $column_id)
|
||||
->in('is_active', 1)
|
||||
->eq('is_active', 1)
|
||||
->count();
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ class TaskFinder extends Base
|
||||
->eq('project_id', $project_id)
|
||||
->eq('column_id', $column_id)
|
||||
->eq('swimlane_id', $swimlane_id)
|
||||
->in('is_active', 1)
|
||||
->eq('is_active', 1)
|
||||
->count();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user