summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Controller/App.php132
-rw-r--r--app/Controller/Project.php8
-rw-r--r--app/Model/Project.php34
-rw-r--r--app/Model/ProjectAnalytic.php2
-rw-r--r--app/Model/ProjectPaginator.php49
-rw-r--r--app/Model/SubTask.php32
-rw-r--r--app/Model/SubtaskPaginator.php68
-rw-r--r--app/Model/TaskFinder.php94
-rw-r--r--app/Model/TaskPaginator.php139
-rw-r--r--app/Template/app/dashboard.php26
-rw-r--r--app/Template/app/index.php114
-rw-r--r--app/Template/app/projects.php33
-rw-r--r--app/Template/app/subtasks.php31
-rw-r--r--app/Template/app/tasks.php31
-rw-r--r--app/helpers.php6
-rw-r--r--assets/css/app.css7
-rw-r--r--assets/css/base.css1
-rw-r--r--assets/css/pagination.css6
-rwxr-xr-xscripts/create-random-projects.php18
-rwxr-xr-xscripts/create-random-tasks.php49
-rwxr-xr-xscripts/create-random-users.php2
21 files changed, 582 insertions, 300 deletions
diff --git a/app/Controller/App.php b/app/Controller/App.php
index 993149c5..2458800a 100644
--- a/app/Controller/App.php
+++ b/app/Controller/App.php
@@ -20,17 +20,137 @@ class App extends Base
*/
public function index()
{
+ $paginate = $this->request->getStringParam('paginate', 'userTasks');
+ $offset = $this->request->getIntegerParam('offset', 0);
+ $direction = $this->request->getStringParam('direction');
+ $order = $this->request->getStringParam('order');
+
$user_id = $this->acl->getUserId();
$projects = $this->projectPermission->getMemberProjects($user_id);
$project_ids = array_keys($projects);
- $this->response->html($this->template->layout('app/index', array(
+ $params = array(
+ 'title' => t('Dashboard'),
'board_selector' => $this->projectPermission->getAllowedProjects($user_id),
'events' => $this->projectActivity->getProjects($project_ids, 10),
- 'tasks' => $this->taskFinder->getAllTasksByUser($user_id),
- 'subtasks' => $this->subTask->getAllByUser($user_id, array(SubTask::STATUS_TODO, SubTask::STATUS_INPROGRESS)),
- 'projects' => $this->project->getSummary($project_ids),
- 'title' => t('Dashboard'),
- )));
+ );
+
+ $params += $this->getTaskPagination($user_id, $paginate, $offset, $order, $direction);
+ $params += $this->getSubtaskPagination($user_id, $paginate, $offset, $order, $direction);
+ $params += $this->getProjectPagination($project_ids, $paginate, $offset, $order, $direction);
+
+ $this->response->html($this->template->layout('app/dashboard', $params));
+ }
+
+ /**
+ * Get tasks pagination
+ *
+ * @access public
+ */
+ private function getTaskPagination($user_id, $paginate, $offset, $order, $direction)
+ {
+ $limit = 10;
+
+ if (! in_array($order, array('tasks.id', 'project_name', 'title'))) {
+ $order = 'tasks.id';
+ $direction = 'ASC';
+ }
+
+ if ($paginate === 'userTasks') {
+ $tasks = $this->taskPaginator->userTasks($user_id, $offset, $limit, $order, $direction);
+ }
+ else {
+ $offset = 0;
+ $tasks = $this->taskPaginator->userTasks($user_id, $offset, $limit);
+ }
+
+ return array(
+ 'tasks' => $tasks,
+ 'task_pagination' => array(
+ 'controller' => 'app',
+ 'action' => 'index',
+ 'params' => array('paginate' => 'userTasks'),
+ 'direction' => $direction,
+ 'order' => $order,
+ 'total' => $this->taskPaginator->countUserTasks($user_id),
+ 'offset' => $offset,
+ 'limit' => $limit,
+ )
+ );
+ }
+
+ /**
+ * Get subtasks pagination
+ *
+ * @access public
+ */
+ private function getSubtaskPagination($user_id, $paginate, $offset, $order, $direction)
+ {
+ $status = array(SubTask::STATUS_TODO, SubTask::STATUS_INPROGRESS);
+ $limit = 10;
+
+ if (! in_array($order, array('tasks.id', 'project_name', 'status', 'title'))) {
+ $order = 'tasks.id';
+ $direction = 'ASC';
+ }
+
+ if ($paginate === 'userSubtasks') {
+ $subtasks = $this->subtaskPaginator->userSubtasks($user_id, $status, $offset, $limit, $order, $direction);
+ }
+ else {
+ $offset = 0;
+ $subtasks = $this->subtaskPaginator->userSubtasks($user_id, $status, $offset, $limit);
+ }
+
+ return array(
+ 'subtasks' => $subtasks,
+ 'subtask_pagination' => array(
+ 'controller' => 'app',
+ 'action' => 'index',
+ 'params' => array('paginate' => 'userSubtasks'),
+ 'direction' => $direction,
+ 'order' => $order,
+ 'total' => $this->subtaskPaginator->countUserSubtasks($user_id, $status),
+ 'offset' => $offset,
+ 'limit' => $limit,
+ )
+ );
+ }
+
+ /**
+ * Get projects pagination
+ *
+ * @access public
+ */
+ private function getProjectPagination($project_ids, $paginate, $offset, $order, $direction)
+ {
+ $limit = 5;
+
+ if (! in_array($order, array('id', 'name'))) {
+ $order = 'name';
+ $direction = 'ASC';
+ }
+
+ if ($paginate === 'projectSummaries') {
+ $projects = $this->projectPaginator->projectSummaries($project_ids, $offset, $limit, $order, $direction);
+ }
+ else {
+ $offset = 0;
+ $projects = $this->projectPaginator->projectSummaries($project_ids, $offset, $limit);
+ }
+
+ return array(
+ 'projects' => $projects,
+ 'project_pagination' => array(
+ 'controller' => 'app',
+ 'action' => 'index',
+ 'params' => array('paginate' => 'projectSummaries'),
+ 'direction' => $direction,
+ 'order' => $order,
+ 'total' => count($project_ids),
+ 'offset' => $offset,
+ 'limit' => $limit,
+ )
+ );
}
}
diff --git a/app/Controller/Project.php b/app/Controller/Project.php
index a479b1d6..cac5e0b8 100644
--- a/app/Controller/Project.php
+++ b/app/Controller/Project.php
@@ -428,8 +428,8 @@ class Project extends Base
$limit = 25;
if ($search !== '') {
- $tasks = $this->taskFinder->search($project['id'], $search, $offset, $limit, $order, $direction);
- $nb_tasks = $this->taskFinder->countSearch($project['id'], $search);
+ $tasks = $this->taskPaginator->searchTasks($project['id'], $search, $offset, $limit, $order, $direction);
+ $nb_tasks = $this->taskPaginator->countSearchTasks($project['id'], $search);
}
$this->response->html($this->template->layout('project_search', array(
@@ -472,8 +472,8 @@ class Project extends Base
$offset = $this->request->getIntegerParam('offset', 0);
$limit = 25;
- $tasks = $this->taskFinder->getClosedTasks($project['id'], $offset, $limit, $order, $direction);
- $nb_tasks = $this->taskFinder->countByProjectId($project['id'], array(TaskModel::STATUS_CLOSED));
+ $tasks = $this->taskPaginator->closedTasks($project['id'], $offset, $limit, $order, $direction);
+ $nb_tasks = $this->taskPaginator->countClosedTasks($project['id']);
$this->response->html($this->template->layout('project_tasks', array(
'board_selector' => $this->projectPermission->getAllowedProjects($this->acl->getUserId()),
diff --git a/app/Model/Project.php b/app/Model/Project.php
index 2abee2aa..8b842519 100644
--- a/app/Model/Project.php
+++ b/app/Model/Project.php
@@ -96,40 +96,6 @@ class Project extends Base
}
/**
- * Get project summary for a list of project (number of tasks for each column)
- *
- * @access public
- * @param array $project_ids List of project id
- * @param integer $status Project status
- * @param string $order Sort on this column
- * @param string $direction Sorting direction
- * @return array Project properties
- */
- public function getSummary(array $project_ids, $status = self::ACTIVE, $order = 'name', $direction = 'asc')
- {
- if (empty($project_ids)) {
- return array();
- }
-
- $projects = $this->db->table(self::TABLE)
- ->in('id', $project_ids)
- ->eq('is_active', $status)
- ->orderby($order, $direction)
- ->findAll();
-
- foreach ($projects as &$project) {
-
- $project['columns'] = $this->board->getColumns($project['id']);
-
- foreach ($project['columns'] as &$column) {
- $column['nb_tasks'] = $this->taskFinder->countByColumnId($project['id'], $column['id']);
- }
- }
-
- return $projects;
- }
-
- /**
* Get all projects, optionaly fetch stats for each project and can check users permissions
*
* @access public
diff --git a/app/Model/ProjectAnalytic.php b/app/Model/ProjectAnalytic.php
index 8ecbf1f0..b62248eb 100644
--- a/app/Model/ProjectAnalytic.php
+++ b/app/Model/ProjectAnalytic.php
@@ -57,7 +57,7 @@ class ProjectAnalytic extends Base
foreach ($tasks as $task) {
- $user = $users[$task['owner_id']];
+ $user = isset($users[$task['owner_id']]) ? $users[$task['owner_id']] : $users[0];
$total++;
if (! isset($metrics[$user])) {
diff --git a/app/Model/ProjectPaginator.php b/app/Model/ProjectPaginator.php
new file mode 100644
index 00000000..9f1c39f0
--- /dev/null
+++ b/app/Model/ProjectPaginator.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace Model;
+
+/**
+ * Project Paginator
+ *
+ * @package model
+ * @author Frederic Guillot
+ */
+class ProjectPaginator extends Base
+{
+ /**
+ * Get project summary for a list of project (number of tasks for each column)
+ *
+ * @access public
+ * @param array $project_ids List of project id
+ * @param integer $offset Offset
+ * @param integer $limit Limit
+ * @param string $column Sorting column
+ * @param string $direction Sorting direction
+ * @return array
+ */
+ public function projectSummaries(array $project_ids, $offset = 0, $limit = 25, $column = 'name', $direction = 'asc')
+ {
+ if (empty($project_ids)) {
+ return array();
+ }
+
+ $projects = $this->db
+ ->table(Project::TABLE)
+ ->in('id', $project_ids)
+ ->offset($offset)
+ ->limit($limit)
+ ->orderBy($column, $direction)
+ ->findAll();
+
+ foreach ($projects as &$project) {
+
+ $project['columns'] = $this->board->getColumns($project['id']);
+
+ foreach ($project['columns'] as &$column) {
+ $column['nb_tasks'] = $this->taskFinder->countByColumnId($project['id'], $column['id']);
+ }
+ }
+
+ return $projects;
+ }
+}
diff --git a/app/Model/SubTask.php b/app/Model/SubTask.php
index f414da7f..886ad1f3 100644
--- a/app/Model/SubTask.php
+++ b/app/Model/SubTask.php
@@ -93,38 +93,6 @@ class SubTask extends Base
}
/**
- * Get all subtasks assigned to a user
- *
- * @access public
- * @param integer $user_id User id
- * @param array $status List of status
- * @return array
- */
- public function getAllByUser($user_id, array $status)
- {
- $status_list = $this->getStatusList();
- $subtasks = $this->db->table(self::TABLE)
- ->columns(
- self::TABLE.'.*',
- Task::TABLE.'.project_id',
- Task::TABLE.'.color_id',
- Project::TABLE.'.name AS project_name'
- )
- ->eq('user_id', $user_id)
- ->in(self::TABLE.'.status', $status)
- ->join(Task::TABLE, 'id', 'task_id')
- ->join(Project::TABLE, 'id', 'project_id', Task::TABLE)
- ->asc(Task::TABLE.'.id')
- ->findAll();
-
- foreach ($subtasks as &$subtask) {
- $subtask['status_name'] = $status_list[$subtask['status']];
- }
-
- return $subtasks;
- }
-
- /**
* Get a subtask by the id
*
* @access public
diff --git a/app/Model/SubtaskPaginator.php b/app/Model/SubtaskPaginator.php
new file mode 100644
index 00000000..8ccbd696
--- /dev/null
+++ b/app/Model/SubtaskPaginator.php
@@ -0,0 +1,68 @@
+<?php
+
+namespace Model;
+
+/**
+ * Subtask Paginator
+ *
+ * @package model
+ * @author Frederic Guillot
+ */
+class SubtaskPaginator extends Base
+{
+ /**
+ * Get all subtasks assigned to a user
+ *
+ * @access public
+ * @param integer $user_id User id
+ * @param array $status List of status
+ * @param integer $offset Offset
+ * @param integer $limit Limit
+ * @param string $column Sorting column
+ * @param string $direction Sorting direction
+ * @return array
+ */
+ public function userSubtasks($user_id, array $status, $offset = 0, $limit = 25, $column = 'tasks.id', $direction = 'asc')
+ {
+ $status_list = $this->subTask->getStatusList();
+
+ $subtasks = $this->db->table(SubTask::TABLE)
+ ->columns(
+ SubTask::TABLE.'.*',
+ Task::TABLE.'.project_id',
+ Task::TABLE.'.color_id',
+ Project::TABLE.'.name AS project_name'
+ )
+ ->eq('user_id', $user_id)
+ ->in(SubTask::TABLE.'.status', $status)
+ ->join(Task::TABLE, 'id', 'task_id')
+ ->join(Project::TABLE, 'id', 'project_id', Task::TABLE)
+ ->offset($offset)
+ ->limit($limit)
+ ->orderBy($column, $direction)
+ ->findAll();
+
+ foreach ($subtasks as &$subtask) {
+ $subtask['status_name'] = $status_list[$subtask['status']];
+ }
+
+ return $subtasks;
+ }
+
+ /**
+ * Count all subtasks assigned to the user
+ *
+ * @access public
+ * @param integer $user_id User id
+ * @param array $status List of status
+ * @return integer
+ */
+ public function countUserSubtasks($user_id, array $status)
+ {
+ return $this->db
+ ->table(SubTask::TABLE)
+ ->eq('user_id', $user_id)
+ ->in('status', $status)
+ ->count();
+ }
+}
diff --git a/app/Model/TaskFinder.php b/app/Model/TaskFinder.php
index 56795152..0e581025 100644
--- a/app/Model/TaskFinder.php
+++ b/app/Model/TaskFinder.php
@@ -15,10 +15,10 @@ class TaskFinder extends Base
/**
* Common request to fetch a list of tasks
*
- * @access private
+ * @access public
* @return \PicoDb\Table
*/
- private function prepareRequestList()
+ public function getQuery()
{
return $this->db
->table(Task::TABLE)
@@ -51,51 +51,6 @@ class TaskFinder extends Base
}
/**
- * Task search with pagination
- *
- * @access public
- * @param integer $project_id Project id
- * @param string $search Search terms
- * @param integer $offset Offset
- * @param integer $limit Limit
- * @param string $column Sorting column
- * @param string $direction Sorting direction
- * @return array
- */
- public function search($project_id, $search, $offset = 0, $limit = 25, $column = 'tasks.id', $direction = 'DESC')
- {
- return $this->prepareRequestList()
- ->eq('project_id', $project_id)
- ->like('title', '%'.$search.'%')
- ->offset($offset)
- ->limit($limit)
- ->orderBy($column, $direction)
- ->findAll();
- }
-
- /**
- * Get all completed tasks with pagination
- *
- * @access public
- * @param integer $project_id Project id
- * @param integer $offset Offset
- * @param integer $limit Limit
- * @param string $column Sorting column
- * @param string $direction Sorting direction
- * @return array
- */
- public function getClosedTasks($project_id, $offset = 0, $limit = 25, $column = 'tasks.date_completed', $direction = 'DESC')
- {
- return $this->prepareRequestList()
- ->eq('project_id', $project_id)
- ->eq('is_active', Task::STATUS_CLOSED)
- ->offset($offset)
- ->limit($limit)
- ->orderBy($column, $direction)
- ->findAll();
- }
-
- /**
* Get all tasks shown on the board (sorted by position)
*
* @access public
@@ -104,7 +59,7 @@ class TaskFinder extends Base
*/
public function getTasksOnBoard($project_id)
{
- return $this->prepareRequestList()
+ return $this->getQuery()
->eq('project_id', $project_id)
->eq('is_active', Task::STATUS_OPEN)
->asc('tasks.position')
@@ -112,33 +67,6 @@ class TaskFinder extends Base
}
/**
- * Get all open tasks for a given user
- *
- * @access public
- * @param integer $user_id User id
- * @return array
- */
- public function getAllTasksByUser($user_id)
- {
- return $this->db
- ->table(Task::TABLE)
- ->columns(
- 'tasks.id',
- 'tasks.title',
- 'tasks.date_due',
- 'tasks.date_creation',
- 'tasks.project_id',
- 'tasks.color_id',
- 'projects.name AS project_name'
- )
- ->join(Project::TABLE, 'id', 'project_id')
- ->eq('tasks.owner_id', $user_id)
- ->eq('tasks.is_active', Task::STATUS_OPEN)
- ->asc('tasks.id')
- ->findAll();
- }
-
- /**
* Get all tasks for a given project and status
*
* @access public
@@ -296,22 +224,6 @@ class TaskFinder extends Base
}
/**
- * Count the number of tasks for a custom search
- *
- * @access public
- * @param integer $project_id Project id
- * @param string $search Search terms
- * @return integer
- */
- public function countSearch($project_id, $search)
- {
- return $this->db->table(Task::TABLE)
- ->eq('project_id', $project_id)
- ->like('title', '%'.$search.'%')
- ->count();
- }
-
- /**
* Return true if the task exists
*
* @access public
diff --git a/app/Model/TaskPaginator.php b/app/Model/TaskPaginator.php
new file mode 100644
index 00000000..4ae3566c
--- /dev/null
+++ b/app/Model/TaskPaginator.php
@@ -0,0 +1,139 @@
+<?php
+
+namespace Model;
+
+/**
+ * Task Paginator model
+ *
+ * @package model
+ * @author Frederic Guillot
+ */
+class TaskPaginator extends Base
+{
+ /**
+ * Task search with pagination
+ *
+ * @access public
+ * @param integer $project_id Project id
+ * @param string $search Search terms
+ * @param integer $offset Offset
+ * @param integer $limit Limit
+ * @param string $column Sorting column
+ * @param string $direction Sorting direction
+ * @return array
+ */
+ public function searchTasks($project_id, $search, $offset = 0, $limit = 25, $column = 'tasks.id', $direction = 'DESC')
+ {
+ return $this->taskFinder->getQuery()
+ ->eq('project_id', $project_id)
+ ->like('title', '%'.$search.'%')
+ ->offset($offset)
+ ->limit($limit)
+ ->orderBy($column, $direction)
+ ->findAll();
+ }
+
+ /**
+ * Count the number of tasks for a custom search
+ *
+ * @access public
+ * @param integer $project_id Project id
+ * @param string $search Search terms
+ * @return integer
+ */
+ public function countSearchTasks($project_id, $search)
+ {
+ return $this->db->table(Task::TABLE)
+ ->eq('project_id', $project_id)
+ ->like('title', '%'.$search.'%')
+ ->count();
+ }
+
+ /**
+ * Get all completed tasks with pagination
+ *
+ * @access public
+ * @param integer $project_id Project id
+ * @param integer $offset Offset
+ * @param integer $limit Limit
+ * @param string $column Sorting column
+ * @param string $direction Sorting direction
+ * @return array
+ */
+ public function closedTasks($project_id, $offset = 0, $limit = 25, $column = 'tasks.date_completed', $direction = 'DESC')
+ {
+ return $this->taskFinder->getQuery()
+ ->eq('project_id', $project_id)
+ ->eq('is_active', Task::STATUS_CLOSED)
+ ->offset($offset)
+ ->limit($limit)
+ ->orderBy($column, $direction)
+ ->findAll();
+ }
+
+ /**
+ * Count all closed tasks
+ *
+ * @access public
+ * @param integer $project_id Project id
+ * @param array $status List of status id
+ * @return integer
+ */
+ public function countClosedTasks($project_id)
+ {
+ return $this->db
+ ->table(Task::TABLE)
+ ->eq('project_id', $project_id)
+ ->eq('is_active', Task::STATUS_CLOSED)
+ ->count();
+ }
+
+ /**
+ * Get all open tasks for a given user
+ *
+ * @access public
+ * @param integer $user_id User id
+ * @param integer $offset Offset
+ * @param integer $limit Limit
+ * @param string $column Sorting column
+ * @param string $direction Sorting direction
+ * @return array
+ */
+ public function userTasks($user_id, $offset = 0, $limit = 25, $column = 'tasks.id', $direction = 'ASC')
+ {
+ return $this->db
+ ->table(Task::TABLE)
+ ->columns(
+ 'tasks.id',
+ 'tasks.title',
+ 'tasks.date_due',
+ 'tasks.date_creation',
+ 'tasks.project_id',
+ 'tasks.color_id',
+ 'projects.name AS project_name'
+ )
+ ->join(Project::TABLE, 'id', 'project_id')
+ ->eq('tasks.owner_id', $user_id)
+ ->eq('tasks.is_active', Task::STATUS_OPEN)
+ ->offset($offset)
+ ->limit($limit)
+ ->orderBy($column, $direction)
+ ->findAll();
+ }
+
+ /**
+ * Count all tasks assigned to the user
+ *
+ * @access public
+ * @param integer $user_id User id
+ * @return integer
+ */
+ public function countUserTasks($user_id)
+ {
+ return $this->db
+ ->table(Task::TABLE)
+ ->eq('owner_id', $user_id)
+ ->eq('is_active', Task::STATUS_OPEN)
+ ->count();
+ }
+}
diff --git a/app/Template/app/dashboard.php b/app/Template/app/dashboard.php
new file mode 100644
index 00000000..9bcd69f6
--- /dev/null
+++ b/app/Template/app/dashboard.php
@@ -0,0 +1,26 @@
+<section id="main">
+ <div class="page-header">
+ <ul>
+ <?php if (Helper\is_admin()): ?>
+ <li><i class="fa fa-plus fa-fw"></i><?= Helper\a(t('New project'), 'project', 'create') ?></li>
+ <?php endif ?>
+ <li><i class="fa fa-lock fa-fw"></i><?= Helper\a(t('New private project'), 'project', 'create', array('private' => 1)) ?></li>
+ <li><i class="fa fa-folder fa-fw"></i><?= Helper\a(t('Project management'), 'project', 'index') ?></li>
+ <?php if (Helper\is_admin()): ?>
+ <li><i class="fa fa-user fa-fw"></i><?= Helper\a(t('User management'), 'user', 'index') ?></li>
+ <li><i class="fa fa-cog fa-fw"></i><?= Helper\a(t('Settings'), 'config', 'index') ?></li>
+ <?php endif ?>
+ </ul>
+ </div>
+ <section id="dashboard">
+ <div class="dashboard-left-column">
+ <?= Helper\Template('app/projects', array('projects' => $projects, 'pagination' => $project_pagination)) ?>
+ <?= Helper\Template('app/tasks', array('tasks' => $tasks, 'pagination' => $task_pagination)) ?>
+ <?= Helper\Template('app/subtasks', array('subtasks' => $subtasks, 'pagination' => $subtask_pagination)) ?>
+ </div>
+ <div class="dashboard-right-column">
+ <h2><?= t('Activity stream') ?></h2>
+ <?= Helper\template('project_events', array('events' => $events)) ?>
+ </div>
+ </section>
+</section> \ No newline at end of file
diff --git a/app/Template/app/index.php b/app/Template/app/index.php
deleted file mode 100644
index 637bc402..00000000
--- a/app/Template/app/index.php
+++ /dev/null
@@ -1,114 +0,0 @@
-<section id="main">
- <div class="page-header">
- <ul>
- <?php if (Helper\is_admin()): ?>
- <li><i class="fa fa-plus fa-fw"></i><?= Helper\a(t('New project'), 'project', 'create') ?></li>
- <?php endif ?>
- <li><i class="fa fa-lock fa-fw"></i><?= Helper\a(t('New private project'), 'project', 'create', array('private' => 1)) ?></li>
- <li><i class="fa fa-folder fa-fw"></i><?= Helper\a(t('Project management'), 'project', 'index') ?></li>
- <?php if (Helper\is_admin()): ?>
- <li><i class="fa fa-user fa-fw"></i><?= Helper\a(t('User management'), 'user', 'index') ?></li>
- <li><i class="fa fa-cog fa-fw"></i><?= Helper\a(t('Settings'), 'config', 'index') ?></li>
- <?php endif ?>
- </ul>
- </div>
- <section id="dashboard">
- <div class="dashboard-left-column">
- <h2><?= t('My projects') ?></h2>
- <?php if (empty($projects)): ?>
- <p class="alert"><?= t('Your are not member of any project.') ?></p>
- <?php else: ?>
- <table class="table-fixed">
- <tr>
- <th class="column-8">&nbsp;</th>
- <th class="column-20"><?= t('Project') ?></th>
- <th><?= t('Columns') ?></th>
- </tr>
- <?php foreach ($projects as $project): ?>
- <tr>
- <td>
- <?= Helper\a('#'.$project['id'], 'board', 'show', array('project_id' => $project['id']), false, 'dashboard-table-link') ?>
- </td>
- <td>
- <?php if (Helper\is_project_admin($project)): ?>
- <?= Helper\a('<i class="fa fa-cog"></i>', 'project', 'show', array('project_id' => $project['id']), false, 'dashboard-table-link', t('Settings')) ?>&nbsp;
- <?php endif ?>
- <?= Helper\a(Helper\escape($project['name']), 'board', 'show', array('project_id' => $project['id'])) ?>
- </td>
- <td class="dashboard-project-stats">
- <?php foreach ($project['columns'] as $column): ?>
- <strong title="<?= t('Task count') ?>"><?= $column['nb_tasks'] ?></strong>
- <span><?= Helper\escape($column['title']) ?></span>
- <?php endforeach ?>
- </td>
- </tr>
- <?php endforeach ?>
- </table>
- <?php endif ?>
-
- <h2><?= t('My tasks') ?></h2>
- <?php if (empty($tasks)): ?>
- <p class="alert"><?= t('There is nothing assigned to you.') ?></p>
- <?php else: ?>
- <table class="table-fixed">
- <tr>
- <th class="column-8">&nbsp;</th>
- <th class="column-20"><?= t('Project') ?></th>
- <th><?= t('Task') ?></th>
- <th class="column-20"><?= t('Due date') ?></th>
- </tr>
- <?php foreach ($tasks as $task): ?>
- <tr>
- <td class="task-table task-<?= $task['color_id'] ?>">
- <?= Helper\a('#'.$task['id'], 'task', 'show', array('task_id' => $task['id'])) ?>
- </td>
- <td>
- <?= Helper\a(Helper\escape($task['project_name']), 'board', 'show', array('project_id' => $task['project_id'])) ?>
- </td>
- <td>
- <?= Helper\a(Helper\escape($task['title']), 'task', 'show', array('task_id' => $task['id'])) ?>
- </td>
- <td>
- <?= dt('%B %e, %Y', $task['date_due']) ?>
- </td>
- </tr>
- <?php endforeach ?>
- </table>
- <?php endif ?>
-
- <h2><?= t('My subtasks') ?></h2>
- <?php if (empty($subtasks)): ?>
- <p class="alert"><?= t('There is nothing assigned to you.') ?></p>
- <?php else: ?>
- <table class="table-fixed">
- <tr>
- <th class="column-8">&nbsp;</th>
- <th class="column-20"><?= t('Project') ?></th>
- <th class="column-15"><?= t('Status') ?></th>
- <th><?= t('Subtask') ?></th>
- </tr>
- <?php foreach ($subtasks as $subtask): ?>
- <tr>
- <td class="task-table task-<?= $subtask['color_id'] ?>">
- <?= Helper\a('#'.$subtask['task_id'], 'task', 'show', array('task_id' => $subtask['task_id'])) ?>
- </td>
- <td>
- <?= Helper\a(Helper\escape($subtask['project_name']), 'board', 'show', array('project_id' => $subtask['project_id'])) ?>
- </td>
- <td>
- <?= Helper\escape($subtask['status_name']) ?>
- </td>
- <td>
- <?= Helper\a(Helper\escape($subtask['title']), 'task', 'show', array('task_id' => $subtask['task_id'])) ?>
- </td>
- </tr>
- <?php endforeach ?>
- </table>
- <?php endif ?>
-
- </div>
- <div class="dashboard-right-column">
- <h2><?= t('Activity stream') ?></h2>
- <?= Helper\template('project_events', array('events' => $events)) ?>
- </section>
-</section> \ No newline at end of file
diff --git a/app/Template/app/projects.php b/app/Template/app/projects.php
new file mode 100644
index 00000000..2c13a052
--- /dev/null
+++ b/app/Template/app/projects.php
@@ -0,0 +1,33 @@
+<h2><?= t('My projects') ?></h2>
+<?php if (empty($projects)): ?>
+ <p class="alert"><?= t('Your are not member of any project.') ?></p>
+<?php else: ?>
+ <table class="table-fixed">
+ <tr>
+ <th class="column-8"><?= Helper\order('Id', 'id', $pagination) ?></th>
+ <th class="column-20"><?= Helper\order(t('Project'), 'name', $pagination) ?></th>
+ <th><?= t('Columns') ?></th>
+ </tr>
+ <?php foreach ($projects as $project): ?>
+ <tr>
+ <td>
+ <?= Helper\a('#'.$project['id'], 'board', 'show', array('project_id' => $project['id']), false, 'dashboard-table-link') ?>
+ </td>
+ <td>
+ <?php if (Helper\is_project_admin($project)): ?>
+ <?= Helper\a('<i class="fa fa-cog"></i>', 'project', 'show', array('project_id' => $project['id']), false, 'dashboard-table-link', t('Settings')) ?>&nbsp;
+ <?php endif ?>
+ <?= Helper\a(Helper\escape($project['name']), 'board', 'show', array('project_id' => $project['id'])) ?>
+ </td>
+ <td class="dashboard-project-stats">
+ <?php foreach ($project['columns'] as $column): ?>
+ <strong title="<?= t('Task count') ?>"><?= $column['nb_tasks'] ?></strong>
+ <span><?= Helper\escape($column['title']) ?></span>
+ <?php endforeach ?>
+ </td>
+ </tr>
+ <?php endforeach ?>
+ </table>
+
+ <?= Helper\paginate($pagination) ?>
+<?php endif ?> \ No newline at end of file
diff --git a/app/Template/app/subtasks.php b/app/Template/app/subtasks.php
new file mode 100644
index 00000000..f51ef1db
--- /dev/null
+++ b/app/Template/app/subtasks.php
@@ -0,0 +1,31 @@
+<h2><?= t('My subtasks') ?></h2>
+<?php if (empty($subtasks)): ?>
+ <p class="alert"><?= t('There is nothing assigned to you.') ?></p>
+<?php else: ?>
+ <table class="table-fixed">
+ <tr>
+ <th class="column-10"><?= Helper\order(t('Task Id'), 'tasks.id', $pagination) ?></th>
+ <th class="column-20"><?= Helper\order(t('Project'), 'project_name', $pagination) ?></th>
+ <th class="column-15"><?= Helper\order(t('Status'), 'status', $pagination) ?></th>
+ <th><?= Helper\order(t('Subtask'), 'title', $pagination) ?></th>
+ </tr>
+ <?php foreach ($subtasks as $subtask): ?>
+ <tr>
+ <td class="task-table task-<?= $subtask['color_id'] ?>">
+ <?= Helper\a('#'.$subtask['task_id'], 'task', 'show', array('task_id' => $subtask['task_id'])) ?>
+ </td>
+ <td>
+ <?= Helper\a(Helper\escape($subtask['project_name']), 'board', 'show', array('project_id' => $subtask['project_id'])) ?>
+ </td>
+ <td>
+ <?= Helper\escape($subtask['status_name']) ?>
+ </td>
+ <td>
+ <?= Helper\a(Helper\escape($subtask['title']), 'task', 'show', array('task_id' => $subtask['task_id'])) ?>
+ </td>
+ </tr>
+ <?php endforeach ?>
+ </table>
+
+ <?= Helper\paginate($pagination) ?>
+<?php endif ?> \ No newline at end of file
diff --git a/app/Template/app/tasks.php b/app/Template/app/tasks.php
new file mode 100644
index 00000000..d1e1ed4e
--- /dev/null
+++ b/app/Template/app/tasks.php
@@ -0,0 +1,31 @@
+<h2><?= t('My tasks') ?></h2>
+<?php if (empty($tasks)): ?>
+ <p class="alert"><?= t('There is nothing assigned to you.') ?></p>
+<?php else: ?>
+ <table class="table-fixed">
+ <tr>
+ <th class="column-8"><?= Helper\order('Id', 'tasks.id', $pagination) ?></th>
+ <th class="column-20"><?= Helper\order(t('Project'), 'project_name', $pagination) ?></th>
+ <th><?= Helper\order(t('Task'), 'title', $pagination) ?></th>
+ <th class="column-20"><?= Helper\order(t('Due date'), 'date_due', $pagination) ?></th>
+ </tr>
+ <?php foreach ($tasks as $task): ?>
+ <tr>
+ <td class="task-table task-<?= $task['color_id'] ?>">
+ <?= Helper\a('#'.$task['id'], 'task', 'show', array('task_id' => $task['id'])) ?>
+ </td>
+ <td>
+ <?= Helper\a(Helper\escape($task['project_name']), 'board', 'show', array('project_id' => $task['project_id'])) ?>
+ </td>
+ <td>
+ <?= Helper\a(Helper\escape($task['title']), 'task', 'show', array('task_id' => $task['id'])) ?>
+ </td>
+ <td>
+ <?= dt('%B %e, %Y', $task['date_due']) ?>
+ </td>
+ </tr>
+ <?php endforeach ?>
+ </table>
+
+ <?= Helper\paginate($pagination) ?>
+<?php endif ?> \ No newline at end of file
diff --git a/app/helpers.php b/app/helpers.php
index 14d6a5ee..b53e59e7 100644
--- a/app/helpers.php
+++ b/app/helpers.php
@@ -618,8 +618,8 @@ function paginate(array $pagination)
{
extract($pagination);
- $html = '<div id="pagination">';
- $html .= '<span id="pagination-previous">';
+ $html = '<div class="pagination">';
+ $html .= '<span class="pagination-previous">';
if ($pagination['offset'] > 0) {
$offset = $pagination['offset'] - $limit;
@@ -630,7 +630,7 @@ function paginate(array $pagination)
}
$html .= '</span>';
- $html .= '<span id="pagination-next">';
+ $html .= '<span class="pagination-next">';
if (($total - $pagination['offset']) > $limit) {
$offset = $pagination['offset'] + $limit;
diff --git a/assets/css/app.css b/assets/css/app.css
index 0e031e28..e97a68c2 100644
--- a/assets/css/app.css
+++ b/assets/css/app.css
@@ -18,6 +18,7 @@ body {
body {
margin-left: 10px;
margin-right: 10px;
+ padding-bottom: 20px;
color: #333;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
@@ -1082,15 +1083,15 @@ tr td.task-orange,
}
/* pagination */
-#pagination {
+.pagination {
text-align: center;
}
-#pagination-next {
+.pagination-next {
margin-left: 5px;
}
-#pagination-previous {
+.pagination-previous {
margin-right: 5px;
}/* popover */
#popover-container {
diff --git a/assets/css/base.css b/assets/css/base.css
index 0ebf907d..4a80d5b6 100644
--- a/assets/css/base.css
+++ b/assets/css/base.css
@@ -17,6 +17,7 @@ body {
body {
margin-left: 10px;
margin-right: 10px;
+ padding-bottom: 20px;
color: #333;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
diff --git a/assets/css/pagination.css b/assets/css/pagination.css
index 3459507c..6809bc22 100644
--- a/assets/css/pagination.css
+++ b/assets/css/pagination.css
@@ -4,14 +4,14 @@
}
/* pagination */
-#pagination {
+.pagination {
text-align: center;
}
-#pagination-next {
+.pagination-next {
margin-left: 5px;
}
-#pagination-previous {
+.pagination-previous {
margin-right: 5px;
} \ No newline at end of file
diff --git a/scripts/create-random-projects.php b/scripts/create-random-projects.php
new file mode 100755
index 00000000..5cab1a25
--- /dev/null
+++ b/scripts/create-random-projects.php
@@ -0,0 +1,18 @@
+#!/usr/bin/env php
+<?php
+
+require __DIR__.'/../app/common.php';
+
+use Model\Project;
+use Model\ProjectPermission;
+
+$projectModel = new Project($container);
+$permissionModel = new ProjectPermission($container);
+
+for ($i = 0; $i < 100; $i++) {
+ $id = $projectModel->create(array(
+ 'name' => 'Project #'.$i
+ ));
+
+ $permissionModel->allowUser($id, 1);
+}
diff --git a/scripts/create-random-tasks.php b/scripts/create-random-tasks.php
index 9391c68c..08aa01dd 100755
--- a/scripts/create-random-tasks.php
+++ b/scripts/create-random-tasks.php
@@ -4,9 +4,35 @@
require __DIR__.'/../app/common.php';
use Model\Task;
+use Model\SubTask;
+use Model\Project;
+use Model\ProjectPermission;
+use Model\User;
-$task_per_column = 250;
-$taskModel = new Task($registry);
+$task_per_column = 50;
+
+$userModel = new User($container);
+$projectModel = new Project($container);
+$permissionModel = new ProjectPermission($container);
+$taskModel = new Task($container);
+$subtaskModel = new SubTask($container);
+
+for ($i = 0; $i <= 100; $i++) {
+ $id = $projectModel->create(array(
+ 'name' => 'Project #'.$i
+ ));
+
+ $permissionModel->allowUser($id, 1);
+}
+
+for ($i = 0; $i <= 500; $i++) {
+ $userModel->create(array(
+ 'username' => 'user'.$i,
+ 'password' => 'password'.$i,
+ 'name' => 'User #'.$i,
+ 'email' => 'user'.$i.'@localhost',
+ ));
+}
foreach (array(1, 2, 3, 4) as $column_id) {
@@ -14,14 +40,21 @@ foreach (array(1, 2, 3, 4) as $column_id) {
$task = array(
'title' => 'Task #'.$i.'-'.$column_id,
- 'project_id' => 1,
+ 'project_id' => mt_rand(1, 100),
'column_id' => $column_id,
- 'owner_id' => rand(0, 1),
- 'color_id' => rand(0, 1) === 0 ? 'green' : 'purple',
- 'score' => rand(0, 21),
- 'is_active' => rand(0, 1),
+ 'owner_id' => 1,
+ 'color_id' => mt_rand(0, 1) === 0 ? 'green' : 'purple',
+ 'score' => mt_rand(0, 21),
+ 'is_active' => mt_rand(0, 1),
);
- $taskModel->create($task);
+ $id = $taskModel->create($task);
+
+ $subtaskModel->create(array(
+ 'title' => 'Subtask of task #'.$id,
+ 'user_id' => 1,
+ 'status' => mt_rand(0, 2),
+ 'task_id' => $id,
+ ));
}
}
diff --git a/scripts/create-random-users.php b/scripts/create-random-users.php
index 47336c64..a8b7e4d3 100755
--- a/scripts/create-random-users.php
+++ b/scripts/create-random-users.php
@@ -5,7 +5,7 @@ require __DIR__.'/../app/common.php';
use Model\User;
-$userModel = new User($registry);
+$userModel = new User($container);
for ($i = 0; $i < 500; $i++) {
$userModel->create(array(