Add subtasks restrictions and time tracking
This commit is contained in:
@@ -167,6 +167,8 @@ abstract class Base
|
||||
if (! $this->acl->isPublicAction($controller, $action)) {
|
||||
$this->handleAuthentication();
|
||||
$this->handleAuthorization($controller, $action);
|
||||
|
||||
$this->session['has_subtask_inprogress'] = $this->subTask->hasSubtaskInProgress($this->userSession->getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -415,22 +415,6 @@ class Board extends Base
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the status of a subtask from the mouseover
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function toggleSubtask()
|
||||
{
|
||||
$task = $this->getTask();
|
||||
$this->subTask->toggleStatus($this->request->getIntegerParam('subtask_id'));
|
||||
|
||||
$this->response->html($this->template->render('board/subtasks', array(
|
||||
'subtasks' => $this->subTask->getAll($task['id']),
|
||||
'task' => $task,
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display all attachments during the task mouseover
|
||||
*
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Controller;
|
||||
|
||||
use Model\SubTask as SubtaskModel;
|
||||
|
||||
/**
|
||||
* SubTask controller
|
||||
*
|
||||
@@ -175,12 +177,86 @@ class Subtask extends Base
|
||||
public function toggleStatus()
|
||||
{
|
||||
$task = $this->getTask();
|
||||
$subtask_id = $this->request->getIntegerParam('subtask_id');
|
||||
$subtask = $this->getSubtask();
|
||||
$redirect = $this->request->getStringParam('redirect', 'task');
|
||||
|
||||
if (! $this->subTask->toggleStatus($subtask_id)) {
|
||||
$this->session->flashError(t('Unable to update your sub-task.'));
|
||||
$this->subTask->toggleStatus($subtask['id']);
|
||||
|
||||
if ($redirect === 'board') {
|
||||
|
||||
$this->session['has_subtask_inprogress'] = $this->subTask->hasSubtaskInProgress($this->userSession->getId());
|
||||
|
||||
$this->response->html($this->template->render('board/subtasks', array(
|
||||
'subtasks' => $this->subTask->getAll($task['id']),
|
||||
'task' => $task,
|
||||
)));
|
||||
}
|
||||
|
||||
$this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id'].'#subtasks');
|
||||
$this->toggleRedirect($task, $redirect);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle subtask restriction (popover)
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function subtaskRestriction()
|
||||
{
|
||||
$task = $this->getTask();
|
||||
$subtask = $this->getSubtask();
|
||||
|
||||
$this->response->html($this->template->render('subtask/restriction_change_status', array(
|
||||
'status_list' => array(
|
||||
SubtaskModel::STATUS_TODO => t('Todo'),
|
||||
SubtaskModel::STATUS_DONE => t('Done'),
|
||||
),
|
||||
'subtask_inprogress' => $this->subTask->getSubtaskInProgress($this->userSession->getId()),
|
||||
'subtask' => $subtask,
|
||||
'task' => $task,
|
||||
'redirect' => $this->request->getStringParam('redirect'),
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Change status of the in progress subtask and the other subtask
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function changeRestrictionStatus()
|
||||
{
|
||||
$task = $this->getTask();
|
||||
$subtask = $this->getSubtask();
|
||||
$values = $this->request->getValues();
|
||||
|
||||
// Change status of the previous in progress subtask
|
||||
$this->subTask->update(array(
|
||||
'id' => $values['id'],
|
||||
'status' => $values['status'],
|
||||
));
|
||||
|
||||
// Set the current subtask to in pogress
|
||||
$this->subTask->update(array(
|
||||
'id' => $subtask['id'],
|
||||
'status' => SubtaskModel::STATUS_INPROGRESS,
|
||||
));
|
||||
|
||||
$this->toggleRedirect($task, $values['redirect']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the right page
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function toggleRedirect(array $task, $redirect)
|
||||
{
|
||||
switch ($redirect) {
|
||||
case 'board':
|
||||
$this->response->redirect($this->helper->url('board', 'show', array('project_id' => $task['project_id'])));
|
||||
case 'dashboard':
|
||||
$this->response->redirect($this->helper->url('app', 'index'));
|
||||
default:
|
||||
$this->response->redirect($this->helper->url('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,6 +189,29 @@ class User extends Base
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display timesheet
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function timesheet()
|
||||
{
|
||||
$user = $this->getUser();
|
||||
|
||||
$subtask_paginator = $this->paginator
|
||||
->setUrl('user', 'timesheet', array('user_id' => $user['id'], 'pagination' => 'subtasks'))
|
||||
->setMax(20)
|
||||
->setOrder('start')
|
||||
->setDirection('DESC')
|
||||
->setQuery($this->subtaskTimeTracking->getUserQuery($user['id']))
|
||||
->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks');
|
||||
|
||||
$this->response->html($this->layout('user/timesheet', array(
|
||||
'subtask_paginator' => $subtask_paginator,
|
||||
'user' => $user,
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display last connections
|
||||
*
|
||||
@@ -450,7 +473,7 @@ class User extends Base
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function gitHub()
|
||||
public function github()
|
||||
{
|
||||
$code = $this->request->getStringParam('code');
|
||||
|
||||
@@ -494,7 +517,7 @@ class User extends Base
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function unlinkGitHub()
|
||||
public function unlinkGithub()
|
||||
{
|
||||
$this->checkCSRFParam();
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ class Helper
|
||||
*/
|
||||
public function formRadio($name, $label, $value, $selected = false, $class = '')
|
||||
{
|
||||
return '<label><input type="radio" name="'.$name.'" class="'.$class.'" value="'.$this->e($value).'" '.($selected ? 'selected="selected"' : '').'>'.$this->e($label).'</label>';
|
||||
return '<label><input type="radio" name="'.$name.'" class="'.$class.'" value="'.$this->e($value).'" '.($selected ? 'selected="selected"' : '').'> '.$this->e($label).'</label>';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -648,4 +648,26 @@ class Helper
|
||||
'Sat' => t('Sat'),
|
||||
));
|
||||
}
|
||||
|
||||
public function toggleSubtaskStatus(array $subtask, $redirect)
|
||||
{
|
||||
if ($subtask['status'] == 0 && isset($this->session['has_subtask_inprogress']) && $this->session['has_subtask_inprogress'] === true) {
|
||||
|
||||
return $this->a(
|
||||
trim($this->render('subtask/icons', array('subtask' => $subtask))) . $this->e($subtask['status_name']),
|
||||
'subtask',
|
||||
'subtaskRestriction',
|
||||
array('task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id'], 'redirect' => $redirect),
|
||||
false,
|
||||
'popover-subtask-restriction'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->a(
|
||||
trim($this->render('subtask/icons', array('subtask' => $subtask))) . $this->e($subtask['status_name']),
|
||||
'subtask',
|
||||
'toggleStatus',
|
||||
array('task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id'], 'redirect' => $redirect)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -701,4 +701,12 @@ return array(
|
||||
// 'Moved to column %s' => '',
|
||||
// 'Change description' => '',
|
||||
// 'User dashboard' => '',
|
||||
// 'Allow only one subtask in progress at the same time for a user' => '',
|
||||
// 'Edit column "%s"' => '',
|
||||
// 'Enable time tracking for subtasks' => '',
|
||||
// 'Select the new status of the subtask: "%s"' => '',
|
||||
// 'Subtask timesheet' => '',
|
||||
// 'There is nothing to show.' => '',
|
||||
// 'Time Tracking' => '',
|
||||
// 'You already have one subtask in progress' => '',
|
||||
);
|
||||
|
||||
@@ -701,4 +701,12 @@ return array(
|
||||
// 'Moved to column %s' => '',
|
||||
// 'Change description' => '',
|
||||
// 'User dashboard' => '',
|
||||
// 'Allow only one subtask in progress at the same time for a user' => '',
|
||||
// 'Edit column "%s"' => '',
|
||||
// 'Enable time tracking for subtasks' => '',
|
||||
// 'Select the new status of the subtask: "%s"' => '',
|
||||
// 'Subtask timesheet' => '',
|
||||
// 'There is nothing to show.' => '',
|
||||
// 'Time Tracking' => '',
|
||||
// 'You already have one subtask in progress' => '',
|
||||
);
|
||||
|
||||
@@ -701,4 +701,12 @@ return array(
|
||||
'Moved to column %s' => 'Movido a columna %s',
|
||||
// 'Change description' => '',
|
||||
// 'User dashboard' => '',
|
||||
// 'Allow only one subtask in progress at the same time for a user' => '',
|
||||
// 'Edit column "%s"' => '',
|
||||
// 'Enable time tracking for subtasks' => '',
|
||||
// 'Select the new status of the subtask: "%s"' => '',
|
||||
// 'Subtask timesheet' => '',
|
||||
// 'There is nothing to show.' => '',
|
||||
// 'Time Tracking' => '',
|
||||
// 'You already have one subtask in progress' => '',
|
||||
);
|
||||
|
||||
@@ -701,4 +701,12 @@ return array(
|
||||
// 'Moved to column %s' => '',
|
||||
// 'Change description' => '',
|
||||
// 'User dashboard' => '',
|
||||
// 'Allow only one subtask in progress at the same time for a user' => '',
|
||||
// 'Edit column "%s"' => '',
|
||||
// 'Enable time tracking for subtasks' => '',
|
||||
// 'Select the new status of the subtask: "%s"' => '',
|
||||
// 'Subtask timesheet' => '',
|
||||
// 'There is nothing to show.' => '',
|
||||
// 'Time Tracking' => '',
|
||||
// 'You already have one subtask in progress' => '',
|
||||
);
|
||||
|
||||
@@ -701,4 +701,12 @@ return array(
|
||||
'Moved to column %s' => 'Tâche déplacée à la colonne %s',
|
||||
'Change description' => 'Changer la description',
|
||||
'User dashboard' => 'Tableau de bord de l\'utilisateur',
|
||||
'Allow only one subtask in progress at the same time for a user' => 'Autoriser une seule sous-tâche en progrès en même temps pour un utilisateur',
|
||||
'Edit column "%s"' => 'Modifier la colonne « %s »',
|
||||
'Enable time tracking for subtasks' => 'Activer la feuille de temps pour les sous-tâches',
|
||||
'Select the new status of the subtask: "%s"' => 'Selectionnez le nouveau statut de la sous-tâche : « %s »',
|
||||
'Subtask timesheet' => 'Feuille de temps des sous-tâches',
|
||||
'There is nothing to show.' => 'Il n\'y a rien à montrer',
|
||||
'Time Tracking' => 'Feuille de temps',
|
||||
'You already have one subtask in progress' => 'Vous avez déjà une sous-tâche en progrès',
|
||||
);
|
||||
|
||||
@@ -701,4 +701,12 @@ return array(
|
||||
// 'Moved to column %s' => '',
|
||||
// 'Change description' => '',
|
||||
// 'User dashboard' => '',
|
||||
// 'Allow only one subtask in progress at the same time for a user' => '',
|
||||
// 'Edit column "%s"' => '',
|
||||
// 'Enable time tracking for subtasks' => '',
|
||||
// 'Select the new status of the subtask: "%s"' => '',
|
||||
// 'Subtask timesheet' => '',
|
||||
// 'There is nothing to show.' => '',
|
||||
// 'Time Tracking' => '',
|
||||
// 'You already have one subtask in progress' => '',
|
||||
);
|
||||
|
||||
@@ -701,4 +701,12 @@ return array(
|
||||
// 'Moved to column %s' => '',
|
||||
// 'Change description' => '',
|
||||
// 'User dashboard' => '',
|
||||
// 'Allow only one subtask in progress at the same time for a user' => '',
|
||||
// 'Edit column "%s"' => '',
|
||||
// 'Enable time tracking for subtasks' => '',
|
||||
// 'Select the new status of the subtask: "%s"' => '',
|
||||
// 'Subtask timesheet' => '',
|
||||
// 'There is nothing to show.' => '',
|
||||
// 'Time Tracking' => '',
|
||||
// 'You already have one subtask in progress' => '',
|
||||
);
|
||||
|
||||
@@ -701,4 +701,12 @@ return array(
|
||||
// 'Moved to column %s' => '',
|
||||
// 'Change description' => '',
|
||||
// 'User dashboard' => '',
|
||||
// 'Allow only one subtask in progress at the same time for a user' => '',
|
||||
// 'Edit column "%s"' => '',
|
||||
// 'Enable time tracking for subtasks' => '',
|
||||
// 'Select the new status of the subtask: "%s"' => '',
|
||||
// 'Subtask timesheet' => '',
|
||||
// 'There is nothing to show.' => '',
|
||||
// 'Time Tracking' => '',
|
||||
// 'You already have one subtask in progress' => '',
|
||||
);
|
||||
|
||||
@@ -701,4 +701,12 @@ return array(
|
||||
'Moved to column %s' => 'Przeniosiono do kolumny %s',
|
||||
// 'Change description' => '',
|
||||
// 'User dashboard' => '',
|
||||
// 'Allow only one subtask in progress at the same time for a user' => '',
|
||||
// 'Edit column "%s"' => '',
|
||||
// 'Enable time tracking for subtasks' => '',
|
||||
// 'Select the new status of the subtask: "%s"' => '',
|
||||
// 'Subtask timesheet' => '',
|
||||
// 'There is nothing to show.' => '',
|
||||
// 'Time Tracking' => '',
|
||||
// 'You already have one subtask in progress' => '',
|
||||
);
|
||||
|
||||
@@ -701,4 +701,12 @@ return array(
|
||||
'Moved to column %s' => 'Mover para a coluna %s',
|
||||
// 'Change description' => '',
|
||||
// 'User dashboard' => '',
|
||||
// 'Allow only one subtask in progress at the same time for a user' => '',
|
||||
// 'Edit column "%s"' => '',
|
||||
// 'Enable time tracking for subtasks' => '',
|
||||
// 'Select the new status of the subtask: "%s"' => '',
|
||||
// 'Subtask timesheet' => '',
|
||||
// 'There is nothing to show.' => '',
|
||||
// 'Time Tracking' => '',
|
||||
// 'You already have one subtask in progress' => '',
|
||||
);
|
||||
|
||||
@@ -701,4 +701,12 @@ return array(
|
||||
// 'Moved to column %s' => '',
|
||||
// 'Change description' => '',
|
||||
// 'User dashboard' => '',
|
||||
// 'Allow only one subtask in progress at the same time for a user' => '',
|
||||
// 'Edit column "%s"' => '',
|
||||
// 'Enable time tracking for subtasks' => '',
|
||||
// 'Select the new status of the subtask: "%s"' => '',
|
||||
// 'Subtask timesheet' => '',
|
||||
// 'There is nothing to show.' => '',
|
||||
// 'Time Tracking' => '',
|
||||
// 'You already have one subtask in progress' => '',
|
||||
);
|
||||
|
||||
@@ -701,4 +701,12 @@ return array(
|
||||
// 'Moved to column %s' => '',
|
||||
// 'Change description' => '',
|
||||
// 'User dashboard' => '',
|
||||
// 'Allow only one subtask in progress at the same time for a user' => '',
|
||||
// 'Edit column "%s"' => '',
|
||||
// 'Enable time tracking for subtasks' => '',
|
||||
// 'Select the new status of the subtask: "%s"' => '',
|
||||
// 'Subtask timesheet' => '',
|
||||
// 'There is nothing to show.' => '',
|
||||
// 'Time Tracking' => '',
|
||||
// 'You already have one subtask in progress' => '',
|
||||
);
|
||||
|
||||
@@ -701,4 +701,12 @@ return array(
|
||||
// 'Moved to column %s' => '',
|
||||
// 'Change description' => '',
|
||||
// 'User dashboard' => '',
|
||||
// 'Allow only one subtask in progress at the same time for a user' => '',
|
||||
// 'Edit column "%s"' => '',
|
||||
// 'Enable time tracking for subtasks' => '',
|
||||
// 'Select the new status of the subtask: "%s"' => '',
|
||||
// 'Subtask timesheet' => '',
|
||||
// 'There is nothing to show.' => '',
|
||||
// 'Time Tracking' => '',
|
||||
// 'You already have one subtask in progress' => '',
|
||||
);
|
||||
|
||||
@@ -701,4 +701,12 @@ return array(
|
||||
// 'Moved to column %s' => '',
|
||||
// 'Change description' => '',
|
||||
// 'User dashboard' => '',
|
||||
// 'Allow only one subtask in progress at the same time for a user' => '',
|
||||
// 'Edit column "%s"' => '',
|
||||
// 'Enable time tracking for subtasks' => '',
|
||||
// 'Select the new status of the subtask: "%s"' => '',
|
||||
// 'Subtask timesheet' => '',
|
||||
// 'There is nothing to show.' => '',
|
||||
// 'Time Tracking' => '',
|
||||
// 'You already have one subtask in progress' => '',
|
||||
);
|
||||
|
||||
@@ -223,12 +223,42 @@ class SubTask extends Base
|
||||
$values = array(
|
||||
'id' => $subtask['id'],
|
||||
'status' => ($subtask['status'] + 1) % 3,
|
||||
'task_id' => $subtask['task_id'],
|
||||
);
|
||||
|
||||
return $this->update($values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the subtask in progress for this user
|
||||
*
|
||||
* @access public
|
||||
* @param integer $user_id
|
||||
* @return array
|
||||
*/
|
||||
public function getSubtaskInProgress($user_id)
|
||||
{
|
||||
return $this->db->table(self::TABLE)
|
||||
->eq('status', self::STATUS_INPROGRESS)
|
||||
->eq('user_id', $user_id)
|
||||
->findOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the user have a subtask in progress
|
||||
*
|
||||
* @access public
|
||||
* @param integer $user_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasSubtaskInProgress($user_id)
|
||||
{
|
||||
return $this->config->get('subtask_restriction') == 1 &&
|
||||
$this->db->table(self::TABLE)
|
||||
->eq('status', self::STATUS_INPROGRESS)
|
||||
->eq('user_id', $user_id)
|
||||
->count() === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove
|
||||
*
|
||||
|
||||
80
app/Model/SubtaskTimeTracking.php
Normal file
80
app/Model/SubtaskTimeTracking.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Model;
|
||||
|
||||
/**
|
||||
* Subtask timesheet
|
||||
*
|
||||
* @package model
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class SubtaskTimeTracking extends Base
|
||||
{
|
||||
/**
|
||||
* SQL table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TABLE = 'subtask_time_tracking';
|
||||
|
||||
/**
|
||||
* Get query for user timesheet (pagination)
|
||||
*
|
||||
* @access public
|
||||
* @param integer $user_id User id
|
||||
* @return \PicoDb\Table
|
||||
*/
|
||||
public function getUserQuery($user_id)
|
||||
{
|
||||
return $this->db
|
||||
->table(self::TABLE)
|
||||
->columns(
|
||||
self::TABLE.'.id',
|
||||
self::TABLE.'.subtask_id',
|
||||
self::TABLE.'.end',
|
||||
self::TABLE.'.start',
|
||||
SubTask::TABLE.'.task_id',
|
||||
SubTask::TABLE.'.title AS subtask_title',
|
||||
Task::TABLE.'.title AS task_title',
|
||||
Task::TABLE.'.project_id'
|
||||
)
|
||||
->join(SubTask::TABLE, 'id', 'subtask_id')
|
||||
->join(Task::TABLE, 'id', 'task_id', SubTask::TABLE)
|
||||
->eq(self::TABLE.'.user_id', $user_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log start time
|
||||
*
|
||||
* @access public
|
||||
* @param integer $subtask_id
|
||||
* @param integer $user_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function logStartTime($subtask_id, $user_id)
|
||||
{
|
||||
return $this->db
|
||||
->table(self::TABLE)
|
||||
->insert(array('subtask_id' => $subtask_id, 'user_id' => $user_id, 'start' => time()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Log end time
|
||||
*
|
||||
* @access public
|
||||
* @param integer $subtask_id
|
||||
* @param integer $user_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function logEndTime($subtask_id, $user_id)
|
||||
{
|
||||
return $this->db
|
||||
->table(self::TABLE)
|
||||
->eq('subtask_id', $subtask_id)
|
||||
->eq('user_id', $user_id)
|
||||
->eq('end', 0)
|
||||
->update(array(
|
||||
'end' => time()
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,27 @@ namespace Schema;
|
||||
use PDO;
|
||||
use Core\Security;
|
||||
|
||||
const VERSION = 42;
|
||||
const VERSION = 43;
|
||||
|
||||
function version_43($pdo)
|
||||
{
|
||||
$rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
|
||||
$rq->execute(array('subtask_restriction', '0'));
|
||||
$rq->execute(array('subtask_time_tracking', '0'));
|
||||
|
||||
$pdo->exec("
|
||||
CREATE TABLE subtask_time_tracking (
|
||||
id INT NOT NULL AUTO_INCREMENT,
|
||||
user_id INT NOT NULL,
|
||||
subtask_id INT NOT NULL,
|
||||
start INT DEFAULT 0,
|
||||
end INT DEFAULT 0,
|
||||
PRIMARY KEY(id),
|
||||
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(subtask_id) REFERENCES task_has_subtasks(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB CHARSET=utf8
|
||||
");
|
||||
}
|
||||
|
||||
function version_42($pdo)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,26 @@ namespace Schema;
|
||||
use PDO;
|
||||
use Core\Security;
|
||||
|
||||
const VERSION = 23;
|
||||
const VERSION = 24;
|
||||
|
||||
function version_24($pdo)
|
||||
{
|
||||
$rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
|
||||
$rq->execute(array('subtask_restriction', '0'));
|
||||
$rq->execute(array('subtask_time_tracking', '0'));
|
||||
|
||||
$pdo->exec("
|
||||
CREATE TABLE subtask_time_tracking (
|
||||
id SERIAL PRIMARY KEY,
|
||||
user_id INTEGER NOT NULL,
|
||||
subtask_id INTEGER NOT NULL,
|
||||
start INTEGER DEFAULT 0,
|
||||
end INTEGER DEFAULT 0,
|
||||
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(subtask_id) REFERENCES task_has_subtasks(id) ON DELETE CASCADE
|
||||
)
|
||||
");
|
||||
}
|
||||
|
||||
function version_23($pdo)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,26 @@ namespace Schema;
|
||||
use Core\Security;
|
||||
use PDO;
|
||||
|
||||
const VERSION = 41;
|
||||
const VERSION = 42;
|
||||
|
||||
function version_42($pdo)
|
||||
{
|
||||
$rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
|
||||
$rq->execute(array('subtask_restriction', '0'));
|
||||
$rq->execute(array('subtask_time_tracking', '0'));
|
||||
|
||||
$pdo->exec("
|
||||
CREATE TABLE subtask_time_tracking (
|
||||
id INTEGER PRIMARY KEY,
|
||||
user_id INTEGER NOT NULL,
|
||||
subtask_id INTEGER NOT NULL,
|
||||
start INTEGER DEFAULT 0,
|
||||
end INTEGER DEFAULT 0,
|
||||
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(subtask_id) REFERENCES task_has_subtasks(id) ON DELETE CASCADE
|
||||
)
|
||||
");
|
||||
}
|
||||
|
||||
function version_41($pdo)
|
||||
{
|
||||
|
||||
@@ -33,6 +33,7 @@ class ClassProvider implements ServiceProviderInterface
|
||||
'ProjectPermission',
|
||||
'SubTask',
|
||||
'SubtaskExport',
|
||||
'SubtaskTimeTracking',
|
||||
'Swimlane',
|
||||
'Task',
|
||||
'TaskCreation',
|
||||
|
||||
@@ -12,6 +12,7 @@ use Subscriber\ProjectActivitySubscriber;
|
||||
use Subscriber\ProjectDailySummarySubscriber;
|
||||
use Subscriber\ProjectModificationDateSubscriber;
|
||||
use Subscriber\WebhookSubscriber;
|
||||
use Subscriber\SubtaskTimesheetSubscriber;
|
||||
|
||||
class EventDispatcherProvider implements ServiceProviderInterface
|
||||
{
|
||||
@@ -25,6 +26,7 @@ class EventDispatcherProvider implements ServiceProviderInterface
|
||||
$container['dispatcher']->addSubscriber(new ProjectModificationDateSubscriber($container));
|
||||
$container['dispatcher']->addSubscriber(new WebhookSubscriber($container));
|
||||
$container['dispatcher']->addSubscriber(new NotificationSubscriber($container));
|
||||
$container['dispatcher']->addSubscriber(new SubtaskTimesheetSubscriber($container));
|
||||
|
||||
// Automatic actions
|
||||
$container['action']->attachEvents();
|
||||
|
||||
32
app/Subscriber/SubtaskTimesheetSubscriber.php
Normal file
32
app/Subscriber/SubtaskTimesheetSubscriber.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Subscriber;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Model\SubTask;
|
||||
use Event\SubtaskEvent;
|
||||
|
||||
class SubtaskTimesheetSubscriber extends Base implements EventSubscriberInterface
|
||||
{
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
SubTask::EVENT_UPDATE => array('log', 0),
|
||||
);
|
||||
}
|
||||
|
||||
public function log(SubtaskEvent $event)
|
||||
{
|
||||
if (isset($event['status'])) {
|
||||
|
||||
$subtask = $this->subTask->getById($event['id']);
|
||||
|
||||
if ($subtask['status'] == SubTask::STATUS_INPROGRESS) {
|
||||
$this->subtaskTimeTracking->logStartTime($subtask['id'], $subtask['user_id']);
|
||||
}
|
||||
else {
|
||||
$this->subtaskTimeTracking->logEndTime($subtask['id'], $subtask['user_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
<?= $this->a($this->e($subtask['project_name']), 'board', 'show', array('project_id' => $subtask['project_id'])) ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= $this->e($subtask['status_name']) ?>
|
||||
<?= $this->toggleSubtaskStatus($subtask, 'dashboard') ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= $this->a($this->e($subtask['title']), 'task', 'show', array('task_id' => $subtask['task_id'], 'project_id' => $subtask['project_id'])) ?>
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
<section id="tooltip-subtasks">
|
||||
<?php foreach ($subtasks as $subtask): ?>
|
||||
<?= $this->a(
|
||||
trim($this->render('subtask/icons', array('subtask' => $subtask))) . $this->e($subtask['title']),
|
||||
'board',
|
||||
'toggleSubtask',
|
||||
array('task_id' => $subtask['task_id'], 'project_id' => $task['project_id'], 'subtask_id' => $subtask['id'])
|
||||
) ?>
|
||||
|
||||
<?= $this->toggleSubtaskStatus($subtask, 'board') ?>
|
||||
<?= $this->e(empty($subtask['username']) ? '' : ' ['.$this->getFullname($subtask).']') ?>
|
||||
|
||||
<br/>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
<?= $this->formText('project_categories', $values, $errors) ?><br/>
|
||||
<p class="form-help"><?= t('Example: "Bug, Feature Request, Improvement"') ?></p>
|
||||
|
||||
<?= $this->formCheckbox('subtask_restriction', t('Allow only one subtask in progress at the same time for a user'), 1, $values['subtask_restriction'] == 1) ?>
|
||||
<?= $this->formCheckbox('subtask_time_tracking', t('Enable time tracking for subtasks'), 1, $values['subtask_time_tracking'] == 1) ?>
|
||||
|
||||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||
</div>
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
<?= $this->formLabel(t('Title'), 'title') ?>
|
||||
<?= $this->formText('title', $values, $errors, array('required', 'autofocus', 'maxlength="50"')) ?><br/>
|
||||
|
||||
<?= $this->formLabel(t('Status'), 'status') ?>
|
||||
<?= $this->formSelect('status', $status_list, $values, $errors) ?><br/>
|
||||
|
||||
<?= $this->formLabel(t('Assignee'), 'user_id') ?>
|
||||
<?= $this->formSelect('user_id', $users_list, $values, $errors) ?><br/>
|
||||
|
||||
|
||||
19
app/Template/subtask/restriction_change_status.php
Normal file
19
app/Template/subtask/restriction_change_status.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<div class="page-header">
|
||||
<h2><?= t('You already have one subtask in progress') ?></h2>
|
||||
</div>
|
||||
|
||||
<form action="<?= $this->u('subtask', 'changeRestrictionStatus', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'subtask_id' => $subtask['id'])) ?>" method="post">
|
||||
|
||||
<?= $this->formCsrf() ?>
|
||||
<?= $this->formHidden('redirect', array('redirect' => $redirect)) ?>
|
||||
|
||||
<p><?= t('Select the new status of the subtask: "%s"', $subtask_inprogress['title']) ?></p>
|
||||
<?= $this->formRadios('status', $status_list) ?>
|
||||
<?= $this->formHidden('id', $subtask_inprogress) ?>
|
||||
|
||||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-red"/>
|
||||
<?= t('or') ?>
|
||||
<a href="#" class="close-popover"><?= t('cancel') ?></a>
|
||||
</div>
|
||||
</form>
|
||||
@@ -20,15 +20,14 @@
|
||||
<td><?= $this->e($subtask['title']) ?></td>
|
||||
<td>
|
||||
<?php if (! isset($not_editable)): ?>
|
||||
<?= $this->a(trim($this->render('subtask/icons', array('subtask' => $subtask))) . $this->e($subtask['status_name']),
|
||||
'subtask', 'toggleStatus', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'subtask_id' => $subtask['id'])) ?>
|
||||
<?= $this->toggleSubtaskStatus($subtask, 'task') ?>
|
||||
<?php else: ?>
|
||||
<?= $this->render('subtask/icons', array('subtask' => $subtask)) . $this->e($subtask['status_name']) ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if (! empty($subtask['username'])): ?>
|
||||
<?= $this->e($subtask['name'] ?: $subtask['username']) ?>
|
||||
<?= $this->a($this->e($subtask['name'] ?: $subtask['username']), 'user', 'show', array('user_id' => $subtask['user_id'])) ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
<li>
|
||||
<?= $this->a(t('Persistent connections'), 'user', 'sessions', array('user_id' => $user['id'])) ?>
|
||||
</li>
|
||||
<li>
|
||||
<?= $this->a(t('Time tracking'), 'user', 'timesheet', array('user_id' => $user['id'])) ?>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($this->userSession->isAdmin()): ?>
|
||||
|
||||
27
app/Template/user/timesheet.php
Normal file
27
app/Template/user/timesheet.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<div class="page-header">
|
||||
<h2><?= t('Time Tracking') ?></h2>
|
||||
</div>
|
||||
|
||||
<h3><?= t('Subtask timesheet') ?></h3>
|
||||
<?php if ($subtask_paginator->isEmpty()): ?>
|
||||
<p class="alert"><?= t('There is nothing to show.') ?></p>
|
||||
<?php else: ?>
|
||||
<table class="table-fixed">
|
||||
<tr>
|
||||
<th class="column-20"><?= $subtask_paginator->order('Task', 'task_title') ?></th>
|
||||
<th class="column-20"><?= $subtask_paginator->order('Subtask', 'subtask_title') ?></th>
|
||||
<th><?= $subtask_paginator->order(t('Start'), 'start') ?></th>
|
||||
<th><?= $subtask_paginator->order(t('End'), 'end') ?></th>
|
||||
</tr>
|
||||
<?php foreach ($subtask_paginator->getCollection() as $record): ?>
|
||||
<tr>
|
||||
<td><?= $this->a($this->e($record['task_title']), 'task', 'show', array('project_id' => $record['project_id'], 'task_id' => $record['task_id'])) ?></td>
|
||||
<td><?= $this->a($this->e($record['subtask_title']), 'task', 'show', array('project_id' => $record['project_id'], 'task_id' => $record['task_id'])) ?></td>
|
||||
<td><?= dt('%B %e, %Y at %k:%M %p', $record['start']) ?></td>
|
||||
<td><?= dt('%B %e, %Y at %k:%M %p', $record['end']) ?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</table>
|
||||
|
||||
<?= $subtask_paginator ?>
|
||||
<?php endif ?>
|
||||
Reference in New Issue
Block a user