diff --git a/docker/schema_family.sql b/docker/schema_family.sql index f2eb354..4fb9964 100644 --- a/docker/schema_family.sql +++ b/docker/schema_family.sql @@ -334,6 +334,7 @@ CREATE TABLE IF NOT EXISTS pf_todos ( title VARCHAR(500) NOT NULL, notes TEXT DEFAULT NULL, due_date DATE DEFAULT NULL, + due_time TIME DEFAULT NULL, priority ENUM('none','low','medium','high') DEFAULT 'none', done TINYINT(1) DEFAULT 0, done_at DATETIME DEFAULT NULL, diff --git a/modules/todo/api.php b/modules/todo/api.php index 9bfd1d7..6e27cbb 100644 --- a/modules/todo/api.php +++ b/modules/todo/api.php @@ -109,12 +109,13 @@ if ($action === 'todos') { if ($method === 'POST') { $d = tBody(); $title = trim($d['title'] ?? ''); if (!$title) tErr('Titre requis'); - $pdo->prepare("INSERT INTO pf_todos (list_id, title, notes, due_date, priority) VALUES (?,?,?,?,?)") + $pdo->prepare("INSERT INTO pf_todos (list_id, title, notes, due_date, due_time, priority) VALUES (?,?,?,?,?,?)") ->execute([ $d['list_id'] ?: null, $title, $d['notes'] ?? null, $d['due_date'] ?: null, + $d['due_time'] ?: null, $d['priority'] ?? 'none' ]); $id = (int)$pdo->lastInsertId(); @@ -144,8 +145,8 @@ if ($action === 'todos') { // Full update $title = trim($d['title'] ?? ''); if (!$title) tErr('Titre requis'); - $pdo->prepare("UPDATE pf_todos SET list_id=?, title=?, notes=?, due_date=?, priority=?, updated_at=NOW() WHERE id=?") - ->execute([$d['list_id'] ?: null, $title, $d['notes'] ?? null, $d['due_date'] ?: null, $d['priority'] ?? 'none', $id]); + $pdo->prepare("UPDATE pf_todos SET list_id=?, title=?, notes=?, due_date=?, due_time=?, priority=?, updated_at=NOW() WHERE id=?") + ->execute([$d['list_id'] ?: null, $title, $d['notes'] ?? null, $d['due_date'] ?: null, $d['due_time'] ?: null, $d['priority'] ?? 'none', $id]); tOk(['updated' => true]); } diff --git a/modules/todo/assets/todo.js b/modules/todo/assets/todo.js index a8a1b6f..a420384 100644 --- a/modules/todo/assets/todo.js +++ b/modules/todo/assets/todo.js @@ -4,6 +4,7 @@ const API = '/modules/todo/api.php'; // ─── Helpers ───────────────────────────────────────────────────────────────── function escHtml(s){const d=document.createElement('div');d.textContent=String(s??'');return d.innerHTML;} function fmtDate(d){if(!d)return null;const dt=new Date(d+'T00:00:00');return dt.toLocaleDateString('fr-FR',{day:'2-digit',month:'2-digit'});} +function fmtTime(t){if(!t)return null;return t.slice(0,5);} function isToday(d){if(!d)return false;return d===new Date().toISOString().slice(0,10);} function isOverdue(d){if(!d)return false;return d${t.priority==='high'?'Urgent':t.priority==='medium'?'Normal':'Bas'}`:''; const listBadge=t.list_name? @@ -219,6 +221,7 @@ function openAddTodo(){ document.getElementById('todo-form-title').value=''; document.getElementById('todo-form-notes').value=''; document.getElementById('todo-form-due').value=''; + document.getElementById('todo-form-time').value=''; document.getElementById('todo-delete-btn').style.display='none'; const sel=document.getElementById('todo-form-list'); sel.innerHTML=''+lists.map(l=>``).join(''); @@ -238,6 +241,7 @@ async function openEditTodo(id){ document.getElementById('todo-form-title').value=t.title; document.getElementById('todo-form-notes').value=t.notes||''; document.getElementById('todo-form-due').value=t.due_date||''; + document.getElementById('todo-form-time').value=t.due_time?t.due_time.slice(0,5):''; document.getElementById('todo-delete-btn').style.display=''; const sel=document.getElementById('todo-form-list'); sel.innerHTML=''+lists.map(l=>``).join(''); @@ -262,6 +266,7 @@ async function saveTodo(){ title, notes:document.getElementById('todo-form-notes').value||null, due_date:document.getElementById('todo-form-due').value||null, + due_time:document.getElementById('todo-form-time').value||null, list_id:document.getElementById('todo-form-list').value||null, priority:selectedPriority }; diff --git a/todo.php b/todo.php index 3a9e1c3..f4c7e97 100644 --- a/todo.php +++ b/todo.php @@ -78,13 +78,18 @@ require __DIR__ . '/header.php';
- - + +
+
+ + +
+