Teilnahme Eintragung hinzugefügt
This commit is contained in:
50
index.php
50
index.php
@@ -1,22 +1,27 @@
|
||||
<?php
|
||||
include('inc/check_login.php');
|
||||
include('inc/db.php');
|
||||
include('inc/helpers.php');
|
||||
|
||||
// Aktuelle Kalenderwoche berechnen
|
||||
$current_week = date('W');
|
||||
// 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";
|
||||
|
||||
// SQL-Abfrage mit JOIN zwischen meetings und colors
|
||||
$sql = "SELECT * FROM meetings
|
||||
JOIN colors ON meetings.color_id = colors.id
|
||||
WHERE WEEK(meeting_date, 1) = $current_week
|
||||
ORDER BY meeting_date DESC LIMIT 1";
|
||||
$result = mysqli_query($conn, $sql);
|
||||
|
||||
$result = mysqli_query($conn, $sql);
|
||||
if (!$result) {
|
||||
die("Fehler in der SQL-Abfrage: " . mysqli_error($conn));
|
||||
if ($result && mysqli_num_rows($result) > 0) {
|
||||
return mysqli_fetch_assoc($result);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
// Den nächsten Termin holen
|
||||
$row = get_next_meeting($conn);
|
||||
|
||||
// Funktion, die basierend auf der Hintergrundfarbe die optimale Textfarbe zurückgibt
|
||||
function get_readable_text_color($hex_code)
|
||||
@@ -59,34 +64,45 @@ $german_weekdays = [
|
||||
<div class="container py-5">
|
||||
<div class="text-center mb-5">
|
||||
<h1 class="display-4 fw-bold">DoMiLi</h1>
|
||||
<p class="lead">Farbe für Kalenderwoche <strong><?= $current_week ?></strong></p>
|
||||
</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 der Woche</h5>
|
||||
<div class="rounded mb-3 mx-auto d-flex justify-content-center align-items-center" style="height: min(100px, 25vw); background-color: <?= htmlspecialchars($row['hex_code']) ?>; text-shadow: 1px 1px 2px rgba(0,0,0,0.5);">
|
||||
<p class="fs-5 fw-semibold m-0" style="color: <?= get_readable_text_color($row['hex_code']) ?>;"><?= htmlspecialchars($row['name']) ?></p>
|
||||
<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-4">Absagen</a>
|
||||
<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 Farbe für diese Woche festgelegt.
|
||||
Keine anstehenden Termine gefunden.
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user