• R/O
  • SSH
  • HTTPS

pworg: Commit


Commit MetaInfo

Revision9 (tree)
Time2021-10-01 20:43:39
Authormateuszviste

Log Message

todo is being checked at the selected day + refreshing the page does not lead to unchecking a previously checked item

Change Summary

Incremental Difference

--- trunk/index.php (revision 8)
+++ trunk/index.php (revision 9)
@@ -244,10 +244,14 @@
244244 $db->close();
245245 }
246246
247-if ($a === 'todocheck') {
247+if (($a === 'todocheck') || ($a === 'todouncheck')) {
248248 $db = new SQLite3('agenda.sqlite3');
249- $stmt = $db->prepare('UPDATE todos SET doneday = CASE WHEN doneday = 0 THEN :today ELSE 0 END WHERE id = :id');
250- $stmt->bindvalue(':today', $today, SQLITE3_INTEGER);
249+ $stmt = $db->prepare('UPDATE todos SET doneday = :day WHERE id = :id');
250+ if ($a === 'todocheck') {
251+ $stmt->bindvalue(':day', $day, SQLITE3_INTEGER);
252+ } else {
253+ $stmt->bindvalue(':day', 0, SQLITE3_INTEGER);
254+ }
251255 $stmt->bindvalue(':id', $id, SQLITE3_INTEGER);
252256 $stmt->execute();
253257 $db->close();
@@ -380,11 +384,13 @@
380384 if ($row['doneday'] == 0) {
381385 $checkbox = '☐';
382386 $classname = 'todo';
387+ $linkaction = 'todocheck';
383388 } else {
384389 $checkbox = '☑';
385390 $classname = 'tododone';
391+ $linkaction = 'todouncheck';
386392 }
387- echo ' <div class="' . $classname . '"><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";
393+ echo ' <div class="' . $classname . '"><a href="?day=' . $day . '&amp;a=' . $linkaction . '&amp;id=' . $row['id'] . '">' . $checkbox . '</a> <a href="?a=todo&amp;day=' . $day . '&amp;id=' . $row['id'] . '">' . htmlspecialchars($row['title']) . "</a></div>\n";
388394 }
389395 $sqlres->finalize();
390396 echo "</div>\n";
Show on old repository browser