• R/O
  • SSH
  • HTTPS

pworg: Commit


Commit MetaInfo

Revision6 (tree)
Time2021-10-01 04:09:37
Authormateuszviste

Log Message

todo items have a checkbox to set them as done/undone

Change Summary

Incremental Difference

--- trunk/index.php (revision 5)
+++ trunk/index.php (revision 6)
@@ -234,6 +234,14 @@
234234 $db->close();
235235 }
236236
237+if ($a === 'todocheck') {
238+ $db = new SQLite3('agenda.sqlite3');
239+ $stmt = $db->prepare('UPDATE todos SET doneday = CASE WHEN doneday = 0 THEN :today ELSE 0 END WHERE id = :id');
240+ $stmt->bindvalue(':today', $today, SQLITE3_INTEGER);
241+ $stmt->bindvalue(':id', $id, SQLITE3_INTEGER);
242+ $stmt->execute();
243+ $db->close();
244+}
237245
238246 if ($a === 'jmp') {
239247 echo '<div class="column">' . "\n";
@@ -353,13 +361,18 @@
353361
354362 // display todos
355363 $todofound = 0;
356-$sqlres = $db->query("SELECT * FROM todos WHERE notbefore <= {$day} AND doneday <= {$day} ORDER BY notbefore, title;");
364+$sqlres = $db->query("SELECT * FROM todos WHERE notbefore <= {$day} AND (doneday = 0 OR doneday >= {$day}) ORDER BY notbefore, title;");
357365 while ($row = $sqlres->fetcharray()) {
358366 if ($todofound === 0) {
359367 $todofound = 1;
360368 echo '<div class="columnsectitle">pending tasks</div>' . "\n";
361369 }
362- echo ' <a href="?a=todo&amp;day=' . $day . '&amp;id=' . $row['id'] . '"><div class="todo">' . htmlspecialchars($row['title']) . "</div></a>\n";
370+ if ($row['doneday'] == 0) {
371+ $checkbox = '&#9744;';
372+ } else {
373+ $checkbox = '&#9745;';
374+ }
375+ echo ' <div class="todo"><a href="?day=' . $day . '&amp;a=todocheck&amp;id=' . $row['id'] . '">' . $checkbox . '</a> <a href="?a=todo&amp;day=' . $day . '&amp;id=' . $row['id'] . '">' . htmlspecialchars($row['title']) . "</a></div>\n";
363376 }
364377 $sqlres->finalize();
365378 echo "</div>\n";
Show on old repository browser