Files
vintagecoding.net/functions/todo.php
T
2025-06-10 10:46:22 -06:00

49 lines
1.2 KiB
PHP

<?php
class Todo
{
private int $id;
private int $space;
private string $title;
private ?string $description;
private ?DateTime $due;
private ?int $priority;
private ?string $link;
private DateTime $createdAt;
public function __construct(int $id, int $space, string $title, ?string $description, ?DateTime $due, ?int $priority, ?string $link, ?DateTime $createdAt)
{
if ($space < 0) {
error_log('Tried creating a new space and todo at the same time.');
return;
}
$this->title = $title;
$this->description = $description;
$this->due = $due;
$this->priority = $priority;
$this->link = $link;
$this->createdAt = $createdAt;
if ($id < 0) {
$this->id = $id * -1;
$stmt = 'INSERT INTO todo (id, space, title, description, due, priority, link) VALUES (?, ?, ?, ?, ?, ?, ?)';
exec_stmt($stmt, 'iisssiss', $this->id, $space, $title, $description, $due, $priority, $link);
} else
$this->id = $id;
}
public function getHTML()
{
$html = '
<div class="row">
<label class="form_checkbox_container">' . $this->title . '
<span class="checkmark"></span>
</label>
</div>
';
return $html;
}
}