diff --git a/app/Controller/Task.php b/app/Controller/Task.php index ace40a01f..64017582f 100644 --- a/app/Controller/Task.php +++ b/app/Controller/Task.php @@ -526,4 +526,19 @@ class Task extends Base 'subtask_paginator' => $subtask_paginator, ))); } + + /** + * Display the task transitions + * + * @access public + */ + public function transitions() + { + $task = $this->getTask(); + + $this->response->html($this->taskLayout('task/transitions', array( + 'task' => $task, + 'transitions' => $this->transition->getAllByTask($task['id']), + ))); + } } diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php index f9fe1bab5..8263cbb9c 100644 --- a/app/Locale/da_DK/translations.php +++ b/app/Locale/da_DK/translations.php @@ -809,4 +809,7 @@ return array( // 'Move the task to another column when assignee is cleared' => '', // 'Source column' => '', // 'Show subtask estimates in the user calendar' => '', + // 'Transitions' => '', + // 'Executer' => '', + // 'Time spent in the column' => '', ); diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php index 9898e7f3e..6202cd1be 100644 --- a/app/Locale/de_DE/translations.php +++ b/app/Locale/de_DE/translations.php @@ -809,4 +809,7 @@ return array( // 'Move the task to another column when assignee is cleared' => '', // 'Source column' => '', // 'Show subtask estimates in the user calendar' => '', + // 'Transitions' => '', + // 'Executer' => '', + // 'Time spent in the column' => '', ); diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php index 0f576376b..edd49a335 100644 --- a/app/Locale/es_ES/translations.php +++ b/app/Locale/es_ES/translations.php @@ -809,4 +809,7 @@ return array( // 'Move the task to another column when assignee is cleared' => '', // 'Source column' => '', // 'Show subtask estimates in the user calendar' => '', + // 'Transitions' => '', + // 'Executer' => '', + // 'Time spent in the column' => '', ); diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php index a5c76cd12..9a62bf549 100644 --- a/app/Locale/fi_FI/translations.php +++ b/app/Locale/fi_FI/translations.php @@ -809,4 +809,7 @@ return array( // 'Move the task to another column when assignee is cleared' => '', // 'Source column' => '', // 'Show subtask estimates in the user calendar' => '', + // 'Transitions' => '', + // 'Executer' => '', + // 'Time spent in the column' => '', ); diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php index 7a88669c6..6baca123f 100644 --- a/app/Locale/fr_FR/translations.php +++ b/app/Locale/fr_FR/translations.php @@ -811,4 +811,7 @@ return array( 'Move the task to another column when assignee is cleared' => 'Déplacer la tâche dans une autre colonne lorsque celle-ci n\'est plus assignée', 'Source column' => 'Colonne d\'origine', 'Show subtask estimates in the user calendar' => 'Afficher le temps estimé des sous-tâches dans le calendrier utilisateur', + 'Transitions' => 'Transitions', + 'Executer' => 'Exécutant', + 'Time spent in the column' => 'Temps passé dans la colonne', ); diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php index c6bf929f5..42252f2b6 100644 --- a/app/Locale/hu_HU/translations.php +++ b/app/Locale/hu_HU/translations.php @@ -809,4 +809,7 @@ return array( 'Move the task to another column when assignee is cleared' => 'Feladat másik oszlopba helyezése felhasználóhoz rendélés törlésekor', 'Source column' => 'Forrás oszlop', // 'Show subtask estimates in the user calendar' => '', + // 'Transitions' => '', + // 'Executer' => '', + // 'Time spent in the column' => '', ); diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php index 08444549f..330729679 100644 --- a/app/Locale/it_IT/translations.php +++ b/app/Locale/it_IT/translations.php @@ -809,4 +809,7 @@ return array( // 'Move the task to another column when assignee is cleared' => '', // 'Source column' => '', // 'Show subtask estimates in the user calendar' => '', + // 'Transitions' => '', + // 'Executer' => '', + // 'Time spent in the column' => '', ); diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php index aa6c51f08..cbc402548 100644 --- a/app/Locale/ja_JP/translations.php +++ b/app/Locale/ja_JP/translations.php @@ -809,4 +809,7 @@ return array( // 'Move the task to another column when assignee is cleared' => '', // 'Source column' => '', // 'Show subtask estimates in the user calendar' => '', + // 'Transitions' => '', + // 'Executer' => '', + // 'Time spent in the column' => '', ); diff --git a/app/Locale/nl_NL/translations.php b/app/Locale/nl_NL/translations.php index 1a22bc30c..bf6c36658 100644 --- a/app/Locale/nl_NL/translations.php +++ b/app/Locale/nl_NL/translations.php @@ -809,4 +809,7 @@ return array( // 'Move the task to another column when assignee is cleared' => '', // 'Source column' => '', // 'Show subtask estimates in the user calendar' => '', + // 'Transitions' => '', + // 'Executer' => '', + // 'Time spent in the column' => '', ); diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php index 983b42a8a..da4bd8acf 100644 --- a/app/Locale/pl_PL/translations.php +++ b/app/Locale/pl_PL/translations.php @@ -809,4 +809,7 @@ return array( // 'Move the task to another column when assignee is cleared' => '', // 'Source column' => '', // 'Show subtask estimates in the user calendar' => '', + // 'Transitions' => '', + // 'Executer' => '', + // 'Time spent in the column' => '', ); diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php index 798569217..dae703eac 100644 --- a/app/Locale/pt_BR/translations.php +++ b/app/Locale/pt_BR/translations.php @@ -809,4 +809,7 @@ return array( // 'Move the task to another column when assignee is cleared' => '', // 'Source column' => '', // 'Show subtask estimates in the user calendar' => '', + // 'Transitions' => '', + // 'Executer' => '', + // 'Time spent in the column' => '', ); diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php index 181b035c5..bd26ea535 100644 --- a/app/Locale/ru_RU/translations.php +++ b/app/Locale/ru_RU/translations.php @@ -809,4 +809,7 @@ return array( // 'Move the task to another column when assignee is cleared' => '', // 'Source column' => '', // 'Show subtask estimates in the user calendar' => '', + // 'Transitions' => '', + // 'Executer' => '', + // 'Time spent in the column' => '', ); diff --git a/app/Locale/sr_Latn_RS/translations.php b/app/Locale/sr_Latn_RS/translations.php index 0f7df2333..bfd9352d4 100644 --- a/app/Locale/sr_Latn_RS/translations.php +++ b/app/Locale/sr_Latn_RS/translations.php @@ -809,4 +809,7 @@ return array( // 'Move the task to another column when assignee is cleared' => '', // 'Source column' => '', // 'Show subtask estimates in the user calendar' => '', + // 'Transitions' => '', + // 'Executer' => '', + // 'Time spent in the column' => '', ); diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php index 4da013bb9..31c5bf912 100644 --- a/app/Locale/sv_SE/translations.php +++ b/app/Locale/sv_SE/translations.php @@ -809,4 +809,7 @@ return array( // 'Move the task to another column when assignee is cleared' => '', // 'Source column' => '', // 'Show subtask estimates in the user calendar' => '', + // 'Transitions' => '', + // 'Executer' => '', + // 'Time spent in the column' => '', ); diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php index c478c9ba8..228b5e3c6 100644 --- a/app/Locale/th_TH/translations.php +++ b/app/Locale/th_TH/translations.php @@ -809,4 +809,7 @@ return array( // 'Move the task to another column when assignee is cleared' => '', // 'Source column' => '', // 'Show subtask estimates in the user calendar' => '', + // 'Transitions' => '', + // 'Executer' => '', + // 'Time spent in the column' => '', ); diff --git a/app/Locale/tr_TR/translations.php b/app/Locale/tr_TR/translations.php index 93638f89a..9d7cfdd20 100644 --- a/app/Locale/tr_TR/translations.php +++ b/app/Locale/tr_TR/translations.php @@ -809,4 +809,7 @@ return array( // 'Move the task to another column when assignee is cleared' => '', // 'Source column' => '', // 'Show subtask estimates in the user calendar' => '', + // 'Transitions' => '', + // 'Executer' => '', + // 'Time spent in the column' => '', ); diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php index aa6793272..8859cd172 100644 --- a/app/Locale/zh_CN/translations.php +++ b/app/Locale/zh_CN/translations.php @@ -809,4 +809,7 @@ return array( // 'Move the task to another column when assignee is cleared' => '', // 'Source column' => '', // 'Show subtask estimates in the user calendar' => '', + // 'Transitions' => '', + // 'Executer' => '', + // 'Time spent in the column' => '', ); diff --git a/app/Model/TaskPosition.php b/app/Model/TaskPosition.php index 6dd10b026..ab5fe43bc 100644 --- a/app/Model/TaskPosition.php +++ b/app/Model/TaskPosition.php @@ -143,6 +143,9 @@ class TaskPosition extends Base 'position' => $new_position, 'column_id' => $new_column_id, 'swimlane_id' => $new_swimlane_id, + 'src_column_id' => $task['column_id'], + 'dst_column_id' => $new_column_id, + 'date_moved' => $task['date_moved'], ); if ($task['swimlane_id'] != $new_swimlane_id) { diff --git a/app/Model/Transition.php b/app/Model/Transition.php new file mode 100644 index 000000000..583d3acab --- /dev/null +++ b/app/Model/Transition.php @@ -0,0 +1,67 @@ +db->table(self::TABLE)->insert(array( + 'user_id' => $user_id, + 'project_id' => $task['project_id'], + 'task_id' => $task['task_id'], + 'src_column_id' => $task['src_column_id'], + 'dst_column_id' => $task['dst_column_id'], + 'date' => time(), + 'time_spent' => time() - $task['date_moved'] + )); + } + + /** + * Get all transitions by task + * + * @access public + * @param integer $task_id + * @return array + */ + public function getAllByTask($task_id) + { + return $this->db->table(self::TABLE) + ->columns( + 'src.title as src_column', + 'dst.title as dst_column', + User::TABLE.'.name', + User::TABLE.'.username', + self::TABLE.'.user_id', + self::TABLE.'.date', + self::TABLE.'.time_spent' + ) + ->eq('task_id', $task_id) + ->desc('date') + ->join(User::TABLE, 'id', 'user_id') + ->join(Board::TABLE.' as src', 'id', 'src_column_id', self::TABLE, 'src') + ->join(Board::TABLE.' as dst', 'id', 'dst_column_id', self::TABLE, 'dst') + ->findAll(); + } +} diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php index 3669a6475..30fccbfa5 100644 --- a/app/Schema/Mysql.php +++ b/app/Schema/Mysql.php @@ -6,7 +6,31 @@ use PDO; use Core\Security; use Model\Link; -const VERSION = 55; +const VERSION = 56; + +function version_56($pdo) +{ + $pdo->exec('CREATE TABLE transitions ( + `id` INT NOT NULL AUTO_INCREMENT, + `user_id` INT NOT NULL, + `project_id` INT NOT NULL, + `task_id` INT NOT NULL, + `src_column_id` INT NOT NULL, + `dst_column_id` INT NOT NULL, + `date` INT NOT NULL, + `time_spent` INT DEFAULT 0, + FOREIGN KEY(src_column_id) REFERENCES columns(id) ON DELETE CASCADE, + FOREIGN KEY(dst_column_id) REFERENCES columns(id) ON DELETE CASCADE, + FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE, + FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE, + PRIMARY KEY(id) + ) ENGINE=InnoDB CHARSET=utf8'); + + $pdo->exec("CREATE INDEX transitions_task_index ON transitions(task_id)"); + $pdo->exec("CREATE INDEX transitions_project_index ON transitions(project_id)"); + $pdo->exec("CREATE INDEX transitions_user_index ON transitions(user_id)"); +} function version_55($pdo) { diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php index b60e441bb..ecf8664db 100644 --- a/app/Schema/Postgres.php +++ b/app/Schema/Postgres.php @@ -6,7 +6,30 @@ use PDO; use Core\Security; use Model\Link; -const VERSION = 36; +const VERSION = 37; + +function version_37($pdo) +{ + $pdo->exec('CREATE TABLE transitions ( + "id" SERIAL PRIMARY KEY, + "user_id" INTEGER NOT NULL, + "project_id" INTEGER NOT NULL, + "task_id" INTEGER NOT NULL, + "src_column_id" INTEGER NOT NULL, + "dst_column_id" INTEGER NOT NULL, + "date" INTEGER NOT NULL, + "time_spent" INTEGER DEFAULT 0, + FOREIGN KEY(src_column_id) REFERENCES columns(id) ON DELETE CASCADE, + FOREIGN KEY(dst_column_id) REFERENCES columns(id) ON DELETE CASCADE, + FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE, + FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE + )'); + + $pdo->exec("CREATE INDEX transitions_task_index ON transitions(task_id)"); + $pdo->exec("CREATE INDEX transitions_project_index ON transitions(project_id)"); + $pdo->exec("CREATE INDEX transitions_user_index ON transitions(user_id)"); +} function version_36($pdo) { diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php index 34ac2c6f1..19af5dd31 100644 --- a/app/Schema/Sqlite.php +++ b/app/Schema/Sqlite.php @@ -6,7 +6,30 @@ use Core\Security; use PDO; use Model\Link; -const VERSION = 54; +const VERSION = 55; + +function version_55($pdo) +{ + $pdo->exec('CREATE TABLE transitions ( + "id" INTEGER PRIMARY KEY, + "user_id" INTEGER NOT NULL, + "project_id" INTEGER NOT NULL, + "task_id" INTEGER NOT NULL, + "src_column_id" INTEGER NOT NULL, + "dst_column_id" INTEGER NOT NULL, + "date" INTEGER NOT NULL, + "time_spent" INTEGER DEFAULT 0, + FOREIGN KEY(src_column_id) REFERENCES columns(id) ON DELETE CASCADE, + FOREIGN KEY(dst_column_id) REFERENCES columns(id) ON DELETE CASCADE, + FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE, + FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE + )'); + + $pdo->exec("CREATE INDEX transitions_task_index ON transitions(task_id)"); + $pdo->exec("CREATE INDEX transitions_project_index ON transitions(project_id)"); + $pdo->exec("CREATE INDEX transitions_user_index ON transitions(user_id)"); +} function version_54($pdo) { diff --git a/app/ServiceProvider/ClassProvider.php b/app/ServiceProvider/ClassProvider.php index 2373ab016..c25ceb62e 100644 --- a/app/ServiceProvider/ClassProvider.php +++ b/app/ServiceProvider/ClassProvider.php @@ -56,6 +56,7 @@ class ClassProvider implements ServiceProviderInterface 'TimetableWeek', 'TimetableOff', 'TimetableExtra', + 'Transition', 'User', 'UserSession', 'Webhook', diff --git a/app/ServiceProvider/EventDispatcherProvider.php b/app/ServiceProvider/EventDispatcherProvider.php index ec3822065..f002db74b 100644 --- a/app/ServiceProvider/EventDispatcherProvider.php +++ b/app/ServiceProvider/EventDispatcherProvider.php @@ -14,6 +14,7 @@ use Subscriber\ProjectModificationDateSubscriber; use Subscriber\WebhookSubscriber; use Subscriber\SubtaskTimesheetSubscriber; use Subscriber\TaskMovedDateSubscriber; +use Subscriber\TransitionSubscriber; class EventDispatcherProvider implements ServiceProviderInterface { @@ -29,6 +30,7 @@ class EventDispatcherProvider implements ServiceProviderInterface $container['dispatcher']->addSubscriber(new NotificationSubscriber($container)); $container['dispatcher']->addSubscriber(new SubtaskTimesheetSubscriber($container)); $container['dispatcher']->addSubscriber(new TaskMovedDateSubscriber($container)); + $container['dispatcher']->addSubscriber(new TransitionSubscriber($container)); // Automatic actions $container['action']->attachEvents(); diff --git a/app/Subscriber/TransitionSubscriber.php b/app/Subscriber/TransitionSubscriber.php new file mode 100644 index 000000000..347dd37d4 --- /dev/null +++ b/app/Subscriber/TransitionSubscriber.php @@ -0,0 +1,26 @@ + array('execute', 0), + ); + } + + public function execute(TaskEvent $event) + { + $user_id = $this->userSession->getId(); + + if (! empty($user_id)) { + $this->transition->save($user_id, $event->getAll()); + } + } +} \ No newline at end of file diff --git a/app/Template/task/sidebar.php b/app/Template/task/sidebar.php index f41be14d2..cb3b3c694 100644 --- a/app/Template/task/sidebar.php +++ b/app/Template/task/sidebar.php @@ -4,6 +4,9 @@
= t('There is nothing to show.') ?>
+ +| = t('Date') ?> | += t('Source column') ?> | += t('Destination column') ?> | += t('Executer') ?> | += t('Time spent in the column') ?> | +
|---|---|---|---|---|
| = dt('%B %e, %Y at %k:%M %p', $transition['date']) ?> | += $this->e($transition['src_column']) ?> | += $this->e($transition['dst_column']) ?> | += $this->a($this->e($transition['name'] ?: $transition['username']), 'user', 'show', array('user_id' => $transition['user_id'])) ?> | += n(round($transition['time_spent'] / 3600, 2)).' '.t('hours') ?> | +