summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-02-10 22:10:32 -0500
committerFrederic Guillot <fred@kanboard.net>2015-02-10 22:10:32 -0500
commitefbf679385773e76cbb436691f63e931c17172d4 (patch)
treee2d15b3a0afa15e2a5532ad8f2d2c110665ffb98 /app
parent57613d18539a2cf5970dcc0c4f50e023df9eea73 (diff)
Add subtask time tracking in the task view
Diffstat (limited to 'app')
-rw-r--r--app/Controller/Task.php23
-rw-r--r--app/Locale/da_DK/translations.php2
-rw-r--r--app/Locale/de_DE/translations.php2
-rw-r--r--app/Locale/es_ES/translations.php2
-rw-r--r--app/Locale/fi_FI/translations.php2
-rw-r--r--app/Locale/fr_FR/translations.php6
-rw-r--r--app/Locale/hu_HU/translations.php2
-rw-r--r--app/Locale/it_IT/translations.php2
-rw-r--r--app/Locale/ja_JP/translations.php2
-rw-r--r--app/Locale/pl_PL/translations.php2
-rw-r--r--app/Locale/pt_BR/translations.php2
-rw-r--r--app/Locale/ru_RU/translations.php2
-rw-r--r--app/Locale/sv_SE/translations.php2
-rw-r--r--app/Locale/th_TH/translations.php2
-rw-r--r--app/Locale/zh_CN/translations.php2
-rw-r--r--app/Model/SubtaskTimeTracking.php29
-rw-r--r--app/Template/task/sidebar.php5
-rw-r--r--app/Template/task/time_tracking.php25
-rw-r--r--app/Template/user/timesheet.php4
19 files changed, 114 insertions, 4 deletions
diff --git a/app/Controller/Task.php b/app/Controller/Task.php
index 67dfe14f..fdd20b5e 100644
--- a/app/Controller/Task.php
+++ b/app/Controller/Task.php
@@ -488,4 +488,27 @@ class Task extends Base
'projects_list' => $projects_list,
)));
}
+
+ /**
+ * Display the time tracking details
+ *
+ * @access public
+ */
+ public function timesheet()
+ {
+ $task = $this->getTask();
+
+ $subtask_paginator = $this->paginator
+ ->setUrl('task', 'timesheet', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'pagination' => 'subtasks'))
+ ->setMax(15)
+ ->setOrder('start')
+ ->setDirection('DESC')
+ ->setQuery($this->subtaskTimeTracking->getTaskQuery($task['id']))
+ ->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks');
+
+ $this->response->html($this->taskLayout('task/time_tracking', array(
+ 'task' => $task,
+ 'subtask_paginator' => $subtask_paginator,
+ )));
+ }
}
diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php
index fbd7b3ab..3fd68fab 100644
--- a/app/Locale/da_DK/translations.php
+++ b/app/Locale/da_DK/translations.php
@@ -681,4 +681,6 @@ return array(
// 'Bitbucket commit received' => '',
// 'Bitbucket webhooks' => '',
// 'Help on Bitbucket webhooks' => '',
+ // 'Start' => '',
+ // 'End' => '',
);
diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php
index 5372e175..1efd9c99 100644
--- a/app/Locale/de_DE/translations.php
+++ b/app/Locale/de_DE/translations.php
@@ -681,4 +681,6 @@ return array(
'Bitbucket commit received' => 'Bitbucket commit erhalten',
'Bitbucket webhooks' => 'Bitbucket webhooks',
'Help on Bitbucket webhooks' => 'Hilfe für Bitbucket webhooks',
+ // 'Start' => '',
+ // 'End' => '',
);
diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php
index 8cfa91b8..da3c01c6 100644
--- a/app/Locale/es_ES/translations.php
+++ b/app/Locale/es_ES/translations.php
@@ -681,4 +681,6 @@ return array(
// 'Bitbucket commit received' => '',
// 'Bitbucket webhooks' => '',
// 'Help on Bitbucket webhooks' => '',
+ // 'Start' => '',
+ // 'End' => '',
);
diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php
index 39676bf1..7b329105 100644
--- a/app/Locale/fi_FI/translations.php
+++ b/app/Locale/fi_FI/translations.php
@@ -681,4 +681,6 @@ return array(
// 'Bitbucket commit received' => '',
// 'Bitbucket webhooks' => '',
// 'Help on Bitbucket webhooks' => '',
+ // 'Start' => '',
+ // 'End' => '',
);
diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php
index 5df39809..7b8c0a4a 100644
--- a/app/Locale/fr_FR/translations.php
+++ b/app/Locale/fr_FR/translations.php
@@ -341,7 +341,7 @@ return array(
'Add a comment' => 'Ajouter un commentaire',
'Edit a comment' => 'Modifier un commentaire',
'Summary' => 'Résumé',
- 'Time tracking' => 'Gestion du temps',
+ 'Time tracking' => 'Suivi du temps',
'Estimate:' => 'Estimation :',
'Spent:' => 'Passé :',
'Do you really want to remove this sub-task?' => 'Voulez-vous vraiment supprimer cette sous-tâche ?',
@@ -668,7 +668,7 @@ return array(
'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',
+ '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',
'Which parts of the project do you want to duplicate?' => 'Quelles parties du projet voulez-vous dupliquer ?',
@@ -683,4 +683,6 @@ return array(
'Bitbucket commit received' => '« Commit » reçu via Bitbucket',
'Bitbucket webhooks' => 'Webhook Bitbucket',
'Help on Bitbucket webhooks' => 'Aide sur les webhooks Bitbucket',
+ 'Start' => 'Début',
+ 'End' => 'Fin',
);
diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php
index b7fbd04e..ba6b18a0 100644
--- a/app/Locale/hu_HU/translations.php
+++ b/app/Locale/hu_HU/translations.php
@@ -681,4 +681,6 @@ return array(
// 'Bitbucket commit received' => '',
// 'Bitbucket webhooks' => '',
// 'Help on Bitbucket webhooks' => '',
+ // 'Start' => '',
+ // 'End' => '',
);
diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php
index 2a974629..9fdc2631 100644
--- a/app/Locale/it_IT/translations.php
+++ b/app/Locale/it_IT/translations.php
@@ -681,4 +681,6 @@ return array(
// 'Bitbucket commit received' => '',
// 'Bitbucket webhooks' => '',
// 'Help on Bitbucket webhooks' => '',
+ // 'Start' => '',
+ // 'End' => '',
);
diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php
index 2647f9fd..df12a789 100644
--- a/app/Locale/ja_JP/translations.php
+++ b/app/Locale/ja_JP/translations.php
@@ -681,4 +681,6 @@ return array(
// 'Bitbucket commit received' => '',
// 'Bitbucket webhooks' => '',
// 'Help on Bitbucket webhooks' => '',
+ // 'Start' => '',
+ // 'End' => '',
);
diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php
index c83e130a..b46bc0f1 100644
--- a/app/Locale/pl_PL/translations.php
+++ b/app/Locale/pl_PL/translations.php
@@ -681,4 +681,6 @@ return array(
// 'Bitbucket commit received' => '',
// 'Bitbucket webhooks' => '',
// 'Help on Bitbucket webhooks' => '',
+ // 'Start' => '',
+ // 'End' => '',
);
diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php
index 6db1753b..ca8ae3e9 100644
--- a/app/Locale/pt_BR/translations.php
+++ b/app/Locale/pt_BR/translations.php
@@ -681,4 +681,6 @@ return array(
'Bitbucket commit received' => '"Commit" recebido via Bitbucket',
'Bitbucket webhooks' => 'Webhook Bitbucket',
'Help on Bitbucket webhooks' => 'Ajuda sobre os webhooks Bitbucket',
+ // 'Start' => '',
+ // 'End' => '',
);
diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php
index ed68a447..f094b725 100644
--- a/app/Locale/ru_RU/translations.php
+++ b/app/Locale/ru_RU/translations.php
@@ -681,4 +681,6 @@ return array(
// 'Bitbucket commit received' => '',
// 'Bitbucket webhooks' => '',
// 'Help on Bitbucket webhooks' => '',
+ // 'Start' => '',
+ // 'End' => '',
);
diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php
index 1d793b35..3ebe8a34 100644
--- a/app/Locale/sv_SE/translations.php
+++ b/app/Locale/sv_SE/translations.php
@@ -681,4 +681,6 @@ return array(
// 'Bitbucket commit received' => '',
// 'Bitbucket webhooks' => '',
// 'Help on Bitbucket webhooks' => '',
+ // 'Start' => '',
+ // 'End' => '',
);
diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php
index cf5302f6..8cdab422 100644
--- a/app/Locale/th_TH/translations.php
+++ b/app/Locale/th_TH/translations.php
@@ -681,4 +681,6 @@ return array(
// 'Bitbucket commit received' => '',
// 'Bitbucket webhooks' => '',
// 'Help on Bitbucket webhooks' => '',
+ // 'Start' => '',
+ // 'End' => '',
);
diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php
index 6dbd1676..48d2b69b 100644
--- a/app/Locale/zh_CN/translations.php
+++ b/app/Locale/zh_CN/translations.php
@@ -681,4 +681,6 @@ return array(
// 'Bitbucket commit received' => '',
// 'Bitbucket webhooks' => '',
// 'Help on Bitbucket webhooks' => '',
+ // 'Start' => '',
+ // 'End' => '',
);
diff --git a/app/Model/SubtaskTimeTracking.php b/app/Model/SubtaskTimeTracking.php
index 5b58dfe2..8093cf80 100644
--- a/app/Model/SubtaskTimeTracking.php
+++ b/app/Model/SubtaskTimeTracking.php
@@ -44,6 +44,35 @@ class SubtaskTimeTracking extends Base
}
/**
+ * Get query for task (pagination)
+ *
+ * @access public
+ * @param integer $task_id Task id
+ * @return \PicoDb\Table
+ */
+ public function getTaskQuery($task_id)
+ {
+ return $this->db
+ ->table(self::TABLE)
+ ->columns(
+ self::TABLE.'.id',
+ self::TABLE.'.subtask_id',
+ self::TABLE.'.end',
+ self::TABLE.'.start',
+ self::TABLE.'.user_id',
+ Subtask::TABLE.'.task_id',
+ Subtask::TABLE.'.title AS subtask_title',
+ Task::TABLE.'.project_id',
+ User::TABLE.'.username',
+ User::TABLE.'.name AS user_fullname'
+ )
+ ->join(Subtask::TABLE, 'id', 'subtask_id')
+ ->join(Task::TABLE, 'id', 'task_id', Subtask::TABLE)
+ ->join(User::TABLE, 'id', 'user_id', self::TABLE)
+ ->eq(Task::TABLE.'.id', $task_id);
+ }
+
+ /**
* Get all recorded time slots for a given user
*
* @access public
diff --git a/app/Template/task/sidebar.php b/app/Template/task/sidebar.php
index acddd52f..e85a1671 100644
--- a/app/Template/task/sidebar.php
+++ b/app/Template/task/sidebar.php
@@ -4,6 +4,11 @@
<li>
<?= $this->a(t('Summary'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
</li>
+ <?php if ($task['time_estimated'] > 0 || $task['time_spent'] > 0): ?>
+ <li>
+ <?= $this->a(t('Time tracking'), 'task', 'timesheet', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
+ </li>
+ <?php endif ?>
<li>
<?= $this->a(t('Edit the task'), 'task', 'edit', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
</li>
diff --git a/app/Template/task/time_tracking.php b/app/Template/task/time_tracking.php
new file mode 100644
index 00000000..6e86df91
--- /dev/null
+++ b/app/Template/task/time_tracking.php
@@ -0,0 +1,25 @@
+<?= $this->render('task/timesheet', array('task' => $task)) ?>
+
+<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(t('User'), 'username') ?></th>
+ <th class="column-40"><?= $subtask_paginator->order(t('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['user_fullname'] ?: $record['username']), 'user', 'show', array('user_id' => $record['user_id'])) ?></td>
+ <td><?= t($record['subtask_title']) ?></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 ?> \ No newline at end of file
diff --git a/app/Template/user/timesheet.php b/app/Template/user/timesheet.php
index fb7e51f0..4f052006 100644
--- a/app/Template/user/timesheet.php
+++ b/app/Template/user/timesheet.php
@@ -8,8 +8,8 @@
<?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 class="column-20"><?= $subtask_paginator->order(t('Task'), 'task_title') ?></th>
+ <th class="column-20"><?= $subtask_paginator->order(t('Subtask'), 'subtask_title') ?></th>
<th><?= $subtask_paginator->order(t('Start'), 'start') ?></th>
<th><?= $subtask_paginator->order(t('End'), 'end') ?></th>
</tr>