67 lines
2.9 KiB
PHP
67 lines
2.9 KiB
PHP
<section class="dashboard-head">
|
|
<div>
|
|
<p class="eyebrow">Heute</p>
|
|
<h1>Deine Habits</h1>
|
|
</div>
|
|
<a class="button" href="index.php?route=habits/create">Habit erstellen</a>
|
|
</section>
|
|
|
|
<form method="get" action="index.php" class="filters">
|
|
<input type="hidden" name="route" value="dashboard">
|
|
|
|
<label for="category_id">Kategorie</label>
|
|
<select id="category_id" name="category_id">
|
|
<option value="">Alle Kategorien</option>
|
|
<?php foreach ($categories as $category): ?>
|
|
<option value="<?= (int) $category['id'] ?>" <?= (string) $filters['category_id'] === (string) $category['id'] ? 'selected' : '' ?>>
|
|
<?= e($category['name']) ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
|
|
<label for="status">Status</label>
|
|
<select id="status" name="status">
|
|
<option value="">Alle</option>
|
|
<option value="open" <?= $filters['status'] === 'open' ? 'selected' : '' ?>>Offen</option>
|
|
<option value="done" <?= $filters['status'] === 'done' ? 'selected' : '' ?>>Erledigt</option>
|
|
</select>
|
|
|
|
<button type="submit">Filtern</button>
|
|
</form>
|
|
|
|
<?php if (empty($habits)): ?>
|
|
<p class="empty">Noch keine Habits gefunden. Erstelle deinen ersten Habit.</p>
|
|
<?php endif; ?>
|
|
|
|
<section class="habit-list">
|
|
<?php foreach ($habits as $habit): ?>
|
|
<article class="habit-card <?= $habit['done_today'] ? 'done' : '' ?>">
|
|
<div class="habit-main">
|
|
<span class="category-dot" style="background-color: <?= e($habit['category_color'] ?? '#9ca3af') ?>"></span>
|
|
<div>
|
|
<h2><?= e($habit['title']) ?></h2>
|
|
<p><?= e($habit['description']) ?></p>
|
|
<small>
|
|
<?= e($habit['category_name'] ?? 'Ohne Kategorie') ?> |
|
|
Woche: <?= (int) $habit['completed_this_week'] ?> / <?= (int) $habit['target_per_week'] ?> erledigt
|
|
</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="habit-actions">
|
|
<form method="post" action="index.php?route=habits/toggle">
|
|
<?= csrf_field() ?>
|
|
<input type="hidden" name="id" value="<?= (int) $habit['id'] ?>">
|
|
<button type="submit"><?= $habit['done_today'] ? 'Heute erledigt' : 'Abhaken' ?></button>
|
|
</form>
|
|
<a href="index.php?route=habits/edit&id=<?= (int) $habit['id'] ?>">Bearbeiten</a>
|
|
<form method="post" action="index.php?route=habits/delete" onsubmit="return confirm('Diesen Habit wirklich loeschen?');">
|
|
<?= csrf_field() ?>
|
|
<input type="hidden" name="id" value="<?= (int) $habit['id'] ?>">
|
|
<button class="danger" type="submit">Loeschen</button>
|
|
</form>
|
|
</div>
|
|
</article>
|
|
<?php endforeach; ?>
|
|
</section>
|