From e89ba5e9e692f33427fedb05a095255f27480a6b Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sun, 9 Nov 2014 17:59:02 -0500 Subject: Analytics: add the first graph (task repartition) --- app/Controller/Analytic.php | 56 +++++++++++++++++++++++++++++++++++ app/Controller/Base.php | 1 + app/Locale/da_DK/translations.php | 6 ++++ app/Locale/de_DE/translations.php | 6 ++++ app/Locale/es_ES/translations.php | 6 ++++ app/Locale/fi_FI/translations.php | 6 ++++ app/Locale/fr_FR/translations.php | 6 ++++ app/Locale/it_IT/translations.php | 6 ++++ app/Locale/ja_JP/translations.php | 6 ++++ app/Locale/pl_PL/translations.php | 6 ++++ app/Locale/pt_BR/translations.php | 6 ++++ app/Locale/ru_RU/translations.php | 6 ++++ app/Locale/sv_SE/translations.php | 6 ++++ app/Locale/th_TH/translations.php | 6 ++++ app/Locale/zh_CN/translations.php | 6 ++++ app/Model/Acl.php | 1 + app/Model/ProjectAnalytic.php | 43 +++++++++++++++++++++++++++ app/Template/analytic/layout.php | 18 +++++++++++ app/Template/analytic/repartition.php | 29 ++++++++++++++++++ app/Template/analytic/sidebar.php | 8 +++++ app/Template/app_notfound.php | 4 --- app/Template/board_index.php | 4 +++ 22 files changed, 238 insertions(+), 4 deletions(-) create mode 100644 app/Controller/Analytic.php create mode 100644 app/Model/ProjectAnalytic.php create mode 100644 app/Template/analytic/layout.php create mode 100644 app/Template/analytic/repartition.php create mode 100644 app/Template/analytic/sidebar.php (limited to 'app') diff --git a/app/Controller/Analytic.php b/app/Controller/Analytic.php new file mode 100644 index 00000000..68177c83 --- /dev/null +++ b/app/Controller/Analytic.php @@ -0,0 +1,56 @@ +projectPermission->getAllowedProjects($this->acl->getUserId()); + $params['analytic_content_for_layout'] = $this->template->load($template, $params); + + return $this->template->layout('analytic/layout', $params); + } + + /** + * Show task distribution graph + * + * @access public + */ + public function repartition() + { + $project = $this->getProject(); + $metrics = $this->projectAnalytic->getTaskRepartition($project['id']); + + if ($this->request->isAjax()) { + $this->response->json(array( + 'metrics' => $metrics, + 'labels' => array( + 'column_title' => t('Column'), + 'nb_tasks' => t('Number of tasks'), + ) + )); + } + else { + $this->response->html($this->layout('analytic/repartition', array( + 'project' => $project, + 'metrics' => $metrics, + 'title' => t('Task repartition for "%s"', $project['name']), + ))); + } + } +} diff --git a/app/Controller/Base.php b/app/Controller/Base.php index c0483aa1..7eb75b07 100644 --- a/app/Controller/Base.php +++ b/app/Controller/Base.php @@ -26,6 +26,7 @@ use Model\LastLogin; * @property \Model\Notification $notification * @property \Model\Project $project * @property \Model\ProjectPermission $projectPermission + * @property \Model\ProjectAnalytic $projectAnalytic * @property \Model\SubTask $subTask * @property \Model\Task $task * @property \Model\TaskHistory $taskHistory diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php index 8701cf3d..590f2512 100644 --- a/app/Locale/da_DK/translations.php +++ b/app/Locale/da_DK/translations.php @@ -565,4 +565,10 @@ return array( // 'Columns' => '', // 'Task' => '', // 'Your are not member of any project.' => '', + // 'Percentage' => '', + // 'Number of tasks' => '', + // 'Task distribution' => '', + // 'Reportings' => '', + // 'Task repartition for "%s"' => '', + // 'Analytics' => '', ); diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php index e47e55c1..807118d8 100644 --- a/app/Locale/de_DE/translations.php +++ b/app/Locale/de_DE/translations.php @@ -565,4 +565,10 @@ return array( // 'Columns' => '', // 'Task' => '', // 'Your are not member of any project.' => '', + // 'Percentage' => '', + // 'Number of tasks' => '', + // 'Task distribution' => '', + // 'Reportings' => '', + // 'Task repartition for "%s"' => '', + // 'Analytics' => '', ); diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php index 72c2e32f..25df8acf 100644 --- a/app/Locale/es_ES/translations.php +++ b/app/Locale/es_ES/translations.php @@ -565,4 +565,10 @@ return array( // 'Columns' => '', // 'Task' => '', // 'Your are not member of any project.' => '', + // 'Percentage' => '', + // 'Number of tasks' => '', + // 'Task distribution' => '', + // 'Reportings' => '', + // 'Task repartition for "%s"' => '', + // 'Analytics' => '', ); diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php index 7711773b..517430ea 100644 --- a/app/Locale/fi_FI/translations.php +++ b/app/Locale/fi_FI/translations.php @@ -565,4 +565,10 @@ return array( // 'Columns' => '', // 'Task' => '', // 'Your are not member of any project.' => '', + // 'Percentage' => '', + // 'Number of tasks' => '', + // 'Task distribution' => '', + // 'Reportings' => '', + // 'Task repartition for "%s"' => '', + // 'Analytics' => '', ); diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php index 05756a93..3afa53ce 100644 --- a/app/Locale/fr_FR/translations.php +++ b/app/Locale/fr_FR/translations.php @@ -565,4 +565,10 @@ return array( 'Columns' => 'Colonnes', 'Task' => 'Tâche', 'Your are not member of any project.' => 'Vous n\'êtes membre d\'aucun projet.', + 'Percentage' => 'Pourcentage', + 'Number of tasks' => 'Nombre de tâches', + 'Task distribution' => 'Répartition des tâches', + 'Reportings' => 'Rapports', + 'Task repartition for "%s"' => 'Répartition des tâches pour « %s »', + 'Analytics' => 'Analytique', ); diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php index 64beacab..81ccbd86 100644 --- a/app/Locale/it_IT/translations.php +++ b/app/Locale/it_IT/translations.php @@ -565,4 +565,10 @@ return array( // 'Columns' => '', // 'Task' => '', // 'Your are not member of any project.' => '', + // 'Percentage' => '', + // 'Number of tasks' => '', + // 'Task distribution' => '', + // 'Reportings' => '', + // 'Task repartition for "%s"' => '', + // 'Analytics' => '', ); diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php index 3d9c8440..2fdfb3d6 100644 --- a/app/Locale/ja_JP/translations.php +++ b/app/Locale/ja_JP/translations.php @@ -565,4 +565,10 @@ return array( // 'Columns' => '', // 'Task' => '', // 'Your are not member of any project.' => '', + // 'Percentage' => '', + // 'Number of tasks' => '', + // 'Task distribution' => '', + // 'Reportings' => '', + // 'Task repartition for "%s"' => '', + // 'Analytics' => '', ); diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php index 19befac7..45253fe1 100644 --- a/app/Locale/pl_PL/translations.php +++ b/app/Locale/pl_PL/translations.php @@ -565,4 +565,10 @@ return array( // 'Columns' => '', // 'Task' => '', // 'Your are not member of any project.' => '', + // 'Percentage' => '', + // 'Number of tasks' => '', + // 'Task distribution' => '', + // 'Reportings' => '', + // 'Task repartition for "%s"' => '', + // 'Analytics' => '', ); diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php index 62744783..778bfd3a 100644 --- a/app/Locale/pt_BR/translations.php +++ b/app/Locale/pt_BR/translations.php @@ -565,4 +565,10 @@ return array( // 'Columns' => '', // 'Task' => '', // 'Your are not member of any project.' => '', + // 'Percentage' => '', + // 'Number of tasks' => '', + // 'Task distribution' => '', + // 'Reportings' => '', + // 'Task repartition for "%s"' => '', + // 'Analytics' => '', ); diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php index b5c73a8f..f2eaca63 100644 --- a/app/Locale/ru_RU/translations.php +++ b/app/Locale/ru_RU/translations.php @@ -565,4 +565,10 @@ return array( // 'Columns' => '', // 'Task' => '', // 'Your are not member of any project.' => '', + // 'Percentage' => '', + // 'Number of tasks' => '', + // 'Task distribution' => '', + // 'Reportings' => '', + // 'Task repartition for "%s"' => '', + // 'Analytics' => '', ); diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php index 39cbff16..4f9d815a 100644 --- a/app/Locale/sv_SE/translations.php +++ b/app/Locale/sv_SE/translations.php @@ -565,4 +565,10 @@ return array( // 'Columns' => '', // 'Task' => '', // 'Your are not member of any project.' => '', + // 'Percentage' => '', + // 'Number of tasks' => '', + // 'Task distribution' => '', + // 'Reportings' => '', + // 'Task repartition for "%s"' => '', + // 'Analytics' => '', ); diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php index eefbdcf3..8a1c8b35 100644 --- a/app/Locale/th_TH/translations.php +++ b/app/Locale/th_TH/translations.php @@ -565,4 +565,10 @@ return array( // 'Columns' => '', // 'Task' => '', // 'Your are not member of any project.' => '', + // 'Percentage' => '', + // 'Number of tasks' => '', + // 'Task distribution' => '', + // 'Reportings' => '', + // 'Task repartition for "%s"' => '', + // 'Analytics' => '', ); diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php index 7db09c59..3d45532a 100644 --- a/app/Locale/zh_CN/translations.php +++ b/app/Locale/zh_CN/translations.php @@ -565,4 +565,10 @@ return array( // 'Columns' => '', // 'Task' => '', // 'Your are not member of any project.' => '', + // 'Percentage' => '', + // 'Number of tasks' => '', + // 'Task distribution' => '', + // 'Reportings' => '', + // 'Task repartition for "%s"' => '', + // 'Analytics' => '', ); diff --git a/app/Model/Acl.php b/app/Model/Acl.php index 9a6866d3..52957130 100644 --- a/app/Model/Acl.php +++ b/app/Model/Acl.php @@ -41,6 +41,7 @@ class Acl extends Base 'task' => array('show', 'create', 'save', 'edit', 'update', 'close', 'open', 'duplicate', 'remove', 'description', 'move', 'copy', 'time'), 'category' => array('index', 'save', 'edit', 'update', 'confirm', 'remove'), 'action' => array('index', 'event', 'params', 'create', 'confirm', 'remove'), + 'analytic' => array('repartition'), ); /** diff --git a/app/Model/ProjectAnalytic.php b/app/Model/ProjectAnalytic.php new file mode 100644 index 00000000..ccd2c4c9 --- /dev/null +++ b/app/Model/ProjectAnalytic.php @@ -0,0 +1,43 @@ +board->getColumns($project_id); + + foreach ($columns as $column) { + + $nb_tasks = $this->taskFinder->countByColumnId($project_id, $column['id']); + $total += $nb_tasks; + + $metrics[] = array( + 'column_title' => $column['title'], + 'nb_tasks' => $nb_tasks, + ); + } + + foreach ($metrics as &$metric) { + $metric['percentage'] = round(($metric['nb_tasks'] * 100) / $total, 2); + } + + return $metrics; + } +} diff --git a/app/Template/analytic/layout.php b/app/Template/analytic/layout.php new file mode 100644 index 00000000..2dd7a4f5 --- /dev/null +++ b/app/Template/analytic/layout.php @@ -0,0 +1,18 @@ + + + +
+ + +
\ No newline at end of file diff --git a/app/Template/analytic/repartition.php b/app/Template/analytic/repartition.php new file mode 100644 index 00000000..f20b6a0c --- /dev/null +++ b/app/Template/analytic/repartition.php @@ -0,0 +1,29 @@ + +
+ +
+ + + + + + + + + + + + + + +
+ + + + + % +
+ +
diff --git a/app/Template/analytic/sidebar.php b/app/Template/analytic/sidebar.php new file mode 100644 index 00000000..df6835ee --- /dev/null +++ b/app/Template/analytic/sidebar.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/app/Template/app_notfound.php b/app/Template/app_notfound.php index 734d16a4..686f1fa0 100644 --- a/app/Template/app_notfound.php +++ b/app/Template/app_notfound.php @@ -1,8 +1,4 @@
- -

diff --git a/app/Template/board_index.php b/app/Template/board_index.php index d15d455f..e478680f 100644 --- a/app/Template/board_index.php +++ b/app/Template/board_index.php @@ -24,6 +24,10 @@ $current_project_id)) ?> +
  • + + $current_project_id)) ?> +
  • $current_project_id)) ?> -- cgit v1.2.3