Add a page to display completed tasks and add the completion date column for tasks
This commit is contained in:
@@ -17,7 +17,7 @@ require __DIR__.'/schema.php';
|
||||
abstract class Base
|
||||
{
|
||||
const APP_VERSION = 'master';
|
||||
const DB_VERSION = 1;
|
||||
const DB_VERSION = 2;
|
||||
const DB_FILENAME = 'data/db.sqlite';
|
||||
|
||||
private static $dbInstance = null;
|
||||
|
||||
@@ -49,6 +49,7 @@ class Project extends Base
|
||||
|
||||
$project['columns'] = $columns;
|
||||
$project['nb_tasks'] = $taskModel->countByProjectId($project['id']);
|
||||
$project['nb_inactive_tasks'] = $project['nb_tasks'] - $project['nb_active_tasks'];
|
||||
}
|
||||
|
||||
$this->db->closeTransaction();
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
|
||||
namespace Schema;
|
||||
|
||||
function version_2($pdo)
|
||||
{
|
||||
$pdo->exec('ALTER TABLE tasks ADD column date_completed INTEGER');
|
||||
|
||||
// For all existing completed tasks, set the date of creation as a date of completion
|
||||
$pdo->exec('UPDATE tasks SET date_completed=date_creation WHERE is_active=0');
|
||||
}
|
||||
|
||||
function version_1($pdo)
|
||||
{
|
||||
$pdo->exec("
|
||||
|
||||
@@ -33,6 +33,7 @@ class Task extends Base
|
||||
self::TABLE.'.title',
|
||||
self::TABLE.'.description',
|
||||
self::TABLE.'.date_creation',
|
||||
self::TABLE.'.date_completed',
|
||||
self::TABLE.'.color_id',
|
||||
self::TABLE.'.project_id',
|
||||
self::TABLE.'.column_id',
|
||||
@@ -55,9 +56,30 @@ class Task extends Base
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllByProjectId($project_id)
|
||||
public function getAllByProjectId($project_id, array $status = array(1, 0))
|
||||
{
|
||||
return $this->db->table(self::TABLE)->eq('project_id', $project_id)->findAll();
|
||||
return $this->db->table(self::TABLE)
|
||||
->columns(
|
||||
self::TABLE.'.id',
|
||||
self::TABLE.'.title',
|
||||
self::TABLE.'.description',
|
||||
self::TABLE.'.date_creation',
|
||||
self::TABLE.'.date_completed',
|
||||
self::TABLE.'.color_id',
|
||||
self::TABLE.'.project_id',
|
||||
self::TABLE.'.column_id',
|
||||
self::TABLE.'.owner_id',
|
||||
self::TABLE.'.position',
|
||||
self::TABLE.'.is_active',
|
||||
\Model\Board::TABLE.'.title AS column_title',
|
||||
\Model\User::TABLE.'.username'
|
||||
)
|
||||
->join(\Model\Board::TABLE, 'id', 'column_id')
|
||||
->join(\Model\User::TABLE, 'id', 'owner_id')
|
||||
->eq(self::TABLE.'.project_id', $project_id)
|
||||
->in('is_active', $status)
|
||||
->desc('date_completed')
|
||||
->findAll();
|
||||
}
|
||||
|
||||
public function countByProjectId($project_id, $status = array(1, 0))
|
||||
@@ -117,12 +139,22 @@ class Task extends Base
|
||||
|
||||
public function close($task_id)
|
||||
{
|
||||
return $this->db->table(self::TABLE)->eq('id', $task_id)->update(array('is_active' => 0));
|
||||
return $this->db->table(self::TABLE)
|
||||
->eq('id', $task_id)
|
||||
->update(array(
|
||||
'is_active' => 0,
|
||||
'date_completed' => time()
|
||||
));
|
||||
}
|
||||
|
||||
public function open($task_id)
|
||||
{
|
||||
return $this->db->table(self::TABLE)->eq('id', $task_id)->update(array('is_active' => 1));
|
||||
return $this->db->table(self::TABLE)
|
||||
->eq('id', $task_id)
|
||||
->update(array(
|
||||
'is_active' => 1,
|
||||
'date_completed' => ''
|
||||
));
|
||||
}
|
||||
|
||||
public function remove($task_id)
|
||||
|
||||
Reference in New Issue
Block a user