Files
domili/index.php
2025-08-20 17:55:25 +02:00

88 lines
3.4 KiB
PHP
Executable File

<?php
include('inc/check_login.php');
include('inc/db.php');
include('inc/helpers.php');
// Funktion, um den nächsten Termin zu holen
function get_next_meeting($conn)
{
$sql = "SELECT id, meeting_date, color_id, reason
FROM meetings
WHERE meeting_date > NOW()
ORDER BY meeting_date ASC
LIMIT 1";
$result = mysqli_query($conn, $sql);
if ($result && mysqli_num_rows($result) > 0) {
return mysqli_fetch_assoc($result);
}
return null;
}
// Den nächsten Termin holen
$row = get_next_meeting($conn);
// Die Funktion get_readable_text_color() ist jetzt in helpers.php und kann hier direkt aufgerufen werden.
include('inc/header.php');
// Wochentags-Übersetzung
$german_weekdays = [
'Mon' => 'Mo.',
'Tue' => 'Di.',
'Wed' => 'Mi.',
'Thu' => 'Do.',
'Fri' => 'Fr.',
'Sat' => 'Sa.',
'Sun' => 'So.',
];
?>
<div class="container py-5">
<div class="text-center mb-5">
<h1 class="display-4 fw-bold">DoMiLi</h1>
</div>
<?php if ($row): ?>
<?php
$english_weekday = date('D', strtotime($row['meeting_date']));
$german_weekday = $german_weekdays[$english_weekday] ?? '';
// Hole die Farbdetails, da sie nicht mehr im ursprünglichen JOIN sind
$color_sql = "SELECT * FROM colors WHERE id = ?";
$color_stmt = mysqli_prepare($conn, $color_sql);
mysqli_stmt_bind_param($color_stmt, "i", $row['color_id']);
mysqli_stmt_execute($color_stmt);
$color_result = mysqli_stmt_get_result($color_stmt);
$color_row = mysqli_fetch_assoc($color_result);
?>
<div class="card mx-auto bg-light shadow" style="max-width: 400px;">
<div class="card-body text-center">
<h5 class="card-title mb-3">Farbe des nächsten Treffens</h5>
<div class="rounded-4 mb-3 mx-auto d-flex flex-column justify-content-center align-items-center color-box" style="background-image: linear-gradient(135deg, <?= htmlspecialchars($color_row['hex_code']) ?>, <?= darken_color($color_row['hex_code']) ?>);">
<p class="fs-5 fw-semibold m-0" style="color: <?= get_readable_text_color($color_row['hex_code']) ?>;"><?= htmlspecialchars($color_row['name']) ?></p>
<p class="fs-6 fw-normal m-0" style="color: <?= get_readable_text_color($color_row['hex_code']) ?>;"><?= htmlspecialchars($row['reason']) ?></p>
</div>
<p class="text-muted">nächster Termin:</p>
<p class="text-muted fw-bold"><?= $german_weekday . ' ' . date('d.m.Y H:i', strtotime($row['meeting_date'])) ?></p>
</div>
<div class="d-flex justify-content-center my-3" style="max-width: 400px; margin-left: auto; margin-right: auto;">
<a href="#" class="btn btn-sm btn-outline-danger me-2">Absagen</a>
<a href="#" class="btn btn-sm btn-outline-secondary">Verschiebung beantragen</a>
</div>
<div class="d-flex justify-content-center my-3" style="max-width: 400px; margin-left: auto; margin-right: auto;">
<a href="admin/participant.php?id=<?= htmlspecialchars($row['id']) ?>" class="btn btn-sm btn-outline-primary">Teilnahme eintragen</a>
</div>
</div>
<?php else: ?>
<div class="alert alert-warning text-center">
Keine anstehenden Termine gefunden.
</div>
<?php endif; ?>
</div>
<?php include('inc/footer.php'); ?>