menü angepasst und Terminplaunung überarbeitet
This commit is contained in:
@@ -1,276 +0,0 @@
|
||||
<?php
|
||||
include('../inc/check_login.php');
|
||||
include('../inc/check_admin.php');
|
||||
require_once('../inc/db.php');
|
||||
|
||||
$message = '';
|
||||
$message_type = '';
|
||||
$edit_mode = false;
|
||||
$edit_meeting = null;
|
||||
|
||||
// --- Funktion zur gewichteten zufälligen Farbauswahl ---
|
||||
function get_weighted_random_color($conn)
|
||||
{
|
||||
// 1. Alle Farben abrufen
|
||||
$all_colors = [];
|
||||
$result_all = mysqli_query($conn, "SELECT id FROM colors");
|
||||
while ($row = mysqli_fetch_assoc($result_all)) {
|
||||
$all_colors[] = $row['id'];
|
||||
}
|
||||
|
||||
if (empty($all_colors)) {
|
||||
return null; // Keine Farben vorhanden
|
||||
}
|
||||
|
||||
// 2. Anzahl der Farben als "Sperrzeit"
|
||||
$color_count = count($all_colors);
|
||||
|
||||
// 3. Kürzlich verwendete Farben abrufen
|
||||
$used_colors_id = [];
|
||||
$stmt = mysqli_prepare($conn, "SELECT color_id FROM meetings ORDER BY meeting_date DESC LIMIT ?");
|
||||
mysqli_stmt_bind_param($stmt, "i", $color_count);
|
||||
mysqli_stmt_execute($stmt);
|
||||
$result_used = mysqli_stmt_get_result($stmt);
|
||||
while ($row = mysqli_fetch_assoc($result_used)) {
|
||||
$used_colors_id[] = $row['color_id'];
|
||||
}
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
// 4. Farben-Pool erstellen
|
||||
$color_pool = [];
|
||||
foreach ($all_colors as $color_id) {
|
||||
if (in_array($color_id, $used_colors_id)) {
|
||||
// Kürzlich verwendete Farben haben 1x Chance
|
||||
$color_pool[] = $color_id;
|
||||
} else {
|
||||
// Andere Farben haben 3x Chance
|
||||
$color_pool[] = $color_id;
|
||||
$color_pool[] = $color_id;
|
||||
$color_pool[] = $color_id;
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Zufällige Farbe aus dem Pool auswählen
|
||||
shuffle($color_pool);
|
||||
return $color_pool[0];
|
||||
}
|
||||
|
||||
// --- Logik zum Löschen und Bearbeiten von Terminen ---
|
||||
|
||||
// Aktion Löschen
|
||||
if (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['id'])) {
|
||||
$id = $_GET['id'];
|
||||
$stmt = mysqli_prepare($conn, "DELETE FROM meetings WHERE id = ?");
|
||||
mysqli_stmt_bind_param($stmt, "i", $id);
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
$message = "Termin erfolgreich gelöscht!";
|
||||
$message_type = 'success';
|
||||
} else {
|
||||
$message = "Fehler beim Löschen des Termins.";
|
||||
$message_type = 'danger';
|
||||
}
|
||||
mysqli_stmt_close($stmt);
|
||||
}
|
||||
|
||||
// Aktion Bearbeiten (Formular laden)
|
||||
if (isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['id'])) {
|
||||
$id = $_GET['id'];
|
||||
$stmt = mysqli_prepare($conn, "SELECT id, meeting_date, color_id, reason FROM meetings WHERE id = ?");
|
||||
mysqli_stmt_bind_param($stmt, "i", $id);
|
||||
mysqli_stmt_execute($stmt);
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
$edit_meeting = mysqli_fetch_assoc($result);
|
||||
mysqli_stmt_close($stmt);
|
||||
$edit_mode = true;
|
||||
|
||||
// Datum und Uhrzeit für die Formularfelder aufteilen
|
||||
$edit_date_time = new DateTime($edit_meeting['meeting_date']);
|
||||
$edit_meeting['meeting_date_only'] = $edit_date_time->format('Y-m-d');
|
||||
$edit_meeting['meeting_time_only'] = $edit_date_time->format('H:i');
|
||||
}
|
||||
|
||||
// --- Logik zum Hinzufügen oder Speichern von Terminen (POST) ---
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$meeting_date_only = $_POST['meeting_date'];
|
||||
$meeting_time_only = $_POST['meeting_time'] ?? '12:00';
|
||||
$meeting_date = $meeting_date_only . ' ' . $meeting_time_only;
|
||||
$color_id = $_POST['color_id'];
|
||||
$reason = $_POST['reason'] ?? 'Zufallsfarbe';
|
||||
$id = $_POST['id'] ?? null;
|
||||
|
||||
if ($id) { // Update-Logik
|
||||
$stmt = mysqli_prepare($conn, "UPDATE meetings SET meeting_date = ?, color_id = ?, reason = ? WHERE id = ?");
|
||||
mysqli_stmt_bind_param($stmt, "sisi", $meeting_date, $color_id, $reason, $id);
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
$message = "Termin erfolgreich aktualisiert!";
|
||||
$message_type = 'success';
|
||||
} else {
|
||||
$message = "Fehler beim Aktualisieren des Termins.";
|
||||
$message_type = 'danger';
|
||||
}
|
||||
mysqli_stmt_close($stmt);
|
||||
} else { // Insert-Logik
|
||||
$stmt = mysqli_prepare($conn, "INSERT INTO meetings (meeting_date, color_id, reason) VALUES (?, ?, ?)");
|
||||
mysqli_stmt_bind_param($stmt, "sis", $meeting_date, $color_id, $reason);
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
$message = "Neuer Termin erfolgreich hinzugefügt!";
|
||||
$message_type = 'success';
|
||||
} else {
|
||||
$message = "Fehler beim Hinzufügen des Termins.";
|
||||
$message_type = 'danger';
|
||||
}
|
||||
mysqli_stmt_close($stmt);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Nächste 2 Donnerstage automatisch hinzufügen (mit 12:00 Uhr) ---
|
||||
$date = new DateTime('now');
|
||||
$date->modify('next thursday');
|
||||
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
$next_thursday = $date->format('Y-m-d') . ' 12:00:00';
|
||||
|
||||
$stmt = mysqli_prepare($conn, "SELECT id FROM meetings WHERE meeting_date = ?");
|
||||
mysqli_stmt_bind_param($stmt, "s", $next_thursday);
|
||||
mysqli_stmt_execute($stmt);
|
||||
mysqli_stmt_store_result($stmt);
|
||||
|
||||
if (mysqli_stmt_num_rows($stmt) == 0) {
|
||||
$color_id = get_weighted_random_color($conn);
|
||||
if ($color_id) {
|
||||
$stmt_insert = mysqli_prepare($conn, "INSERT INTO meetings (meeting_date, color_id, reason) VALUES (?, ?, ?)");
|
||||
$default_reason = "Zufallsfarbe";
|
||||
mysqli_stmt_bind_param($stmt_insert, "sis", $next_thursday, $color_id, $default_reason);
|
||||
mysqli_stmt_execute($stmt_insert);
|
||||
mysqli_stmt_close($stmt_insert);
|
||||
}
|
||||
}
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
$date->modify('+1 week');
|
||||
}
|
||||
|
||||
// --- Termine und alle Farben abrufen (für Übersicht und Formular) ---
|
||||
$all_colors = [];
|
||||
$result = mysqli_query($conn, "SELECT id, name, hex_code FROM colors ORDER BY name");
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
$all_colors[] = $row;
|
||||
}
|
||||
|
||||
$meetings = [];
|
||||
// Aktualisierte Abfrage: Zeigt nur Meetings an, die nicht abgeschlossen sind (is_completed = 0)
|
||||
$result = mysqli_query($conn, "SELECT m.id, m.meeting_date, m.created_at, m.reason, c.name AS color_name, c.hex_code FROM meetings m JOIN colors c ON m.color_id = c.id WHERE m.is_completed = 0 ORDER BY m.meeting_date");
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
$meetings[] = $row;
|
||||
}
|
||||
|
||||
require_once '../inc/header.php';
|
||||
?>
|
||||
|
||||
<div class="container mt-5">
|
||||
|
||||
<?php if ($message) : ?>
|
||||
<div id="status-message" class="alert alert-<?php echo $message_type; ?> alert-dismissible fade show" role="alert">
|
||||
<?php echo htmlspecialchars($message); ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2 class="mb-0">Terminverwaltung</h2>
|
||||
</div>
|
||||
|
||||
<div class="collapse <?= $edit_mode ? 'show' : '' ?>" id="planningFormCollapse">
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header bg-primary-subtle text-secondary">
|
||||
<h4 class="mb-0"><?= $edit_mode ? 'Termin bearbeiten' : 'Neuen Termin hinzufügen'; ?></h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="planning.php" method="post">
|
||||
<?php if ($edit_mode): ?>
|
||||
<input type="hidden" name="id" value="<?= htmlspecialchars($edit_meeting['id']); ?>">
|
||||
<?php endif; ?>
|
||||
<div class="row g-1 align-items-end">
|
||||
<div class="col-md-4">
|
||||
<label for="meeting_date" class="form-label">Datum</label>
|
||||
<input type="date" class="form-control" id="meeting_date" name="meeting_date" value="<?= htmlspecialchars($edit_meeting['meeting_date_only'] ?? ''); ?>" required>
|
||||
<div class="form-text" style="visibility: hidden;"> </div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="meeting_time" class="form-label">Uhrzeit</label>
|
||||
<input type="time" class="form-control" id="meeting_time" name="meeting_time" value="<?= htmlspecialchars($edit_meeting['meeting_time_only'] ?? '12:00'); ?>" required>
|
||||
<div class="form-text" style="visibility: hidden;"> </div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="color_id" class="form-label">Farbe</label>
|
||||
<select class="form-select" id="color_id" name="color_id" required>
|
||||
<?php foreach ($all_colors as $color): ?>
|
||||
<option value="<?= htmlspecialchars($color['id']); ?>" <?= (($edit_meeting['color_id'] ?? '') == $color['id']) ? 'selected' : ''; ?>>
|
||||
<?= htmlspecialchars($color['name']); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<div class="form-text" style="visibility: hidden;"> </div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="reason" class="form-label">Grund für die Farbe (optional)</label>
|
||||
<input type="text" class="form-control" id="reason" name="reason" value="<?= htmlspecialchars($edit_meeting['reason'] ?? ''); ?>">
|
||||
<div class="form-text">wenn leer, wird automatisch "Zufallsfarbe" eingetragen</div>
|
||||
</div>
|
||||
<div class="col-12 d-flex justify-content-start">
|
||||
<div class="d-flex w-100">
|
||||
<button type="submit" class="btn btn-sm btn-outline-<?= $edit_mode ? 'success' : 'primary'; ?> w-auto me-2">
|
||||
<?= $edit_mode ? 'Speichern' : 'Hinzufügen'; ?>
|
||||
</button>
|
||||
<a href="planning.php" class="btn btn-sm btn-outline-secondary w-auto">Abbrechen</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="mt-4 mb-4">
|
||||
</div>
|
||||
|
||||
<div class="card shadow">
|
||||
<div class="card-header bg-secondary bg-opacity-50 text-secondary d-flex justify-content-between align-items-center mb-4">
|
||||
<h4 class="mb-0">Übersicht der nächsten Termine</h4>
|
||||
<a class="btn btn-sm d-flex align-items-center justify-content-center" data-bs-toggle="collapse" href="#planningFormCollapse" role="button" aria-expanded="false" aria-controls="planningFormCollapse">Add
|
||||
<span class="material-symbols-outlined">add</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php if (empty($meetings)): ?>
|
||||
<p class="text-muted text-center">Es sind noch keine Termine vorhanden.</p>
|
||||
<?php else: ?>
|
||||
<div class="list-group list-group-flush">
|
||||
<?php foreach ($meetings as $meeting): ?>
|
||||
<div class="list-group-item">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<p class="mb-1 fw-bold"><?= date('d.m.y H:i', strtotime($meeting['meeting_date'])); ?></p>
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="color-preview rounded me-2" style="background-color: <?= htmlspecialchars($meeting['hex_code']); ?>; width: 20px; height: 20px;"></div>
|
||||
<p class="mb-1"><?= htmlspecialchars($meeting['color_name']); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<a href="planning.php?action=edit&id=<?= htmlspecialchars($meeting['id']); ?>" class="text-dark me-1 text-decoration-none" data-bs-toggle="tooltip" data-bs-placement="top" title="Bearbeiten">
|
||||
<span class="material-icons">mode_edit_outline</span>
|
||||
</a>
|
||||
<a href="planning.php?action=delete&id=<?= htmlspecialchars($meeting['id']); ?>" class="text-danger text-decoration-none" onclick="return confirm('Sind Sie sicher, dass Sie diesen Termin löschen möchten?');" data-bs-toggle="tooltip" data-bs-placement="top" title="Löschen">
|
||||
<span class="material-icons">delete_outline</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<p class="small text-muted mb-0 mt-2">Grund: <?= htmlspecialchars($meeting['reason']); ?></p>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include('../inc/footer.php'); ?>
|
||||
307
planning.php
Executable file
307
planning.php
Executable file
@@ -0,0 +1,307 @@
|
||||
<?php
|
||||
include('inc/check_login.php');
|
||||
require_once('inc/db.php');
|
||||
|
||||
$is_admin = ($_SESSION['role'] === 'admin');
|
||||
|
||||
$message = '';
|
||||
$message_type = '';
|
||||
$edit_mode = false;
|
||||
$edit_meeting = null;
|
||||
|
||||
// --- Funktion: Zufallsfarbe mit inverser Gewichtung (alle Termine, keine Sonderfarben) ---
|
||||
function get_weighted_random_color($conn)
|
||||
{
|
||||
// Zählt ALLE Termine (vergangen + geplant) für jede reguläre Farbe
|
||||
$colors = [];
|
||||
$result = mysqli_query($conn, "
|
||||
SELECT
|
||||
c.id,
|
||||
c.name,
|
||||
COUNT(m.id) AS usage_count
|
||||
FROM colors c
|
||||
LEFT JOIN meetings m ON c.id = m.color_id
|
||||
WHERE c.is_special = 0
|
||||
GROUP BY c.id, c.name
|
||||
");
|
||||
|
||||
if (!$result || mysqli_num_rows($result) === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
$colors[] = [
|
||||
'id' => (int)$row['id'],
|
||||
'usage' => (int)$row['usage_count']
|
||||
];
|
||||
}
|
||||
|
||||
$max_usage = max(array_column($colors, 'usage'));
|
||||
$color_pool = [];
|
||||
|
||||
foreach ($colors as $color) {
|
||||
$weight = $max_usage - $color['usage'] + 1; // Mindestgewicht = 1
|
||||
for ($i = 0; $i < $weight; $i++) {
|
||||
$color_pool[] = $color['id'];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($color_pool)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $color_pool[array_rand($color_pool)];
|
||||
}
|
||||
|
||||
// --- Nur Admins: Löschen ---
|
||||
if ($is_admin && isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['id'])) {
|
||||
$id = (int)$_GET['id'];
|
||||
$stmt = mysqli_prepare($conn, "DELETE FROM meetings WHERE id = ?");
|
||||
mysqli_stmt_bind_param($stmt, "i", $id);
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
$message = "Termin erfolgreich gelöscht!";
|
||||
$message_type = 'success';
|
||||
} else {
|
||||
$message = "Fehler beim Löschen des Termins.";
|
||||
$message_type = 'danger';
|
||||
}
|
||||
mysqli_stmt_close($stmt);
|
||||
header("Location: planning.php");
|
||||
exit();
|
||||
}
|
||||
|
||||
// --- Nur Admins: Bearbeiten ---
|
||||
if ($is_admin && isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['id'])) {
|
||||
$id = (int)$_GET['id'];
|
||||
$stmt = mysqli_prepare($conn, "SELECT id, meeting_date, color_id, reason FROM meetings WHERE id = ?");
|
||||
mysqli_stmt_bind_param($stmt, "i", $id);
|
||||
mysqli_stmt_execute($stmt);
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
$edit_meeting = mysqli_fetch_assoc($result);
|
||||
mysqli_stmt_close($stmt);
|
||||
$edit_mode = true;
|
||||
|
||||
if ($edit_meeting) {
|
||||
$edit_dt = new DateTime($edit_meeting['meeting_date']);
|
||||
$edit_meeting['meeting_date_only'] = $edit_dt->format('Y-m-d');
|
||||
$edit_meeting['meeting_time_only'] = $edit_dt->format('H:i');
|
||||
} else {
|
||||
$message = "Termin nicht gefunden.";
|
||||
$message_type = 'warning';
|
||||
}
|
||||
}
|
||||
|
||||
// --- Nur Admins: Speichern (POST) ---
|
||||
if ($is_admin && $_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$meeting_date_only = $_POST['meeting_date'] ?? '';
|
||||
$meeting_time_only = $_POST['meeting_time'] ?? '12:00';
|
||||
$color_id = (int)($_POST['color_id'] ?? 0);
|
||||
$reason = trim($_POST['reason'] ?? 'Zufallsfarbe');
|
||||
$id = !empty($_POST['id']) ? (int)$_POST['id'] : null;
|
||||
|
||||
if (empty($meeting_date_only) || !$color_id) {
|
||||
$message = "Datum und Farbe sind erforderlich.";
|
||||
$message_type = 'danger';
|
||||
} else {
|
||||
$meeting_date = $meeting_date_only . ' ' . $meeting_time_only;
|
||||
if ($id) {
|
||||
$stmt = mysqli_prepare($conn, "UPDATE meetings SET meeting_date = ?, color_id = ?, reason = ? WHERE id = ?");
|
||||
mysqli_stmt_bind_param($stmt, "sisi", $meeting_date, $color_id, $reason, $id);
|
||||
} else {
|
||||
$stmt = mysqli_prepare($conn, "INSERT INTO meetings (meeting_date, color_id, reason) VALUES (?, ?, ?)");
|
||||
mysqli_stmt_bind_param($stmt, "sis", $meeting_date, $color_id, $reason);
|
||||
}
|
||||
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
$message = $id ? "Termin aktualisiert!" : "Neuer Termin hinzugefügt!";
|
||||
$message_type = 'success';
|
||||
} else {
|
||||
$message = "Fehler beim Speichern.";
|
||||
$message_type = 'danger';
|
||||
}
|
||||
mysqli_stmt_close($stmt);
|
||||
header("Location: planning.php");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
// --- 🔁 Automatische Planung: 4 Donnerstage, max. 1 pro Woche ---
|
||||
if ($is_admin) {
|
||||
$today = new DateTime('today');
|
||||
$existing_weeks = [];
|
||||
$result_existing = mysqli_query($conn, "SELECT meeting_date FROM meetings");
|
||||
while ($row = mysqli_fetch_assoc($result_existing)) {
|
||||
$dt = new DateTime($row['meeting_date']);
|
||||
$year = $dt->format('o');
|
||||
$week = $dt->format('W');
|
||||
$existing_weeks["$year-$week"] = true;
|
||||
}
|
||||
|
||||
$date = clone $today;
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
$date->modify($i === 0 ? 'next thursday' : 'next thursday');
|
||||
$year = $date->format('o');
|
||||
$week = $date->format('W');
|
||||
$week_key = "$year-$week";
|
||||
|
||||
if (!isset($existing_weeks[$week_key])) {
|
||||
$new_date = $date->format('Y-m-d') . ' 12:00:00';
|
||||
$color_id = get_weighted_random_color($conn);
|
||||
if ($color_id) {
|
||||
$check = mysqli_prepare($conn, "SELECT id FROM meetings WHERE meeting_date = ?");
|
||||
mysqli_stmt_bind_param($check, "s", $new_date);
|
||||
mysqli_stmt_execute($check);
|
||||
$exists = mysqli_fetch_assoc(mysqli_stmt_get_result($check));
|
||||
mysqli_stmt_close($check);
|
||||
|
||||
if (!$exists) {
|
||||
$default_reason = "Zufallsfarbe";
|
||||
$ins = mysqli_prepare($conn, "INSERT INTO meetings (meeting_date, color_id, reason) VALUES (?, ?, ?)");
|
||||
mysqli_stmt_bind_param($ins, "sis", $new_date, $color_id, $default_reason);
|
||||
mysqli_stmt_execute($ins);
|
||||
mysqli_stmt_close($ins);
|
||||
$existing_weeks[$week_key] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Daten für Anzeige laden ---
|
||||
$all_colors = [];
|
||||
if ($is_admin) {
|
||||
$result_colors = mysqli_query($conn, "SELECT id, name, hex_code FROM colors ORDER BY name");
|
||||
while ($row = mysqli_fetch_assoc($result_colors)) {
|
||||
$all_colors[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
$meetings = [];
|
||||
$result_meetings = mysqli_query($conn, "
|
||||
SELECT m.id, m.meeting_date, m.reason, c.name AS color_name, c.hex_code
|
||||
FROM meetings m
|
||||
JOIN colors c ON m.color_id = c.id
|
||||
WHERE m.is_completed = 0
|
||||
ORDER BY m.meeting_date
|
||||
");
|
||||
while ($row = mysqli_fetch_assoc($result_meetings)) {
|
||||
$meetings[] = $row;
|
||||
}
|
||||
|
||||
require_once 'inc/header.php';
|
||||
?>
|
||||
|
||||
<div class="container mt-5">
|
||||
<?php if ($message): ?>
|
||||
<div class="alert alert-<?= htmlspecialchars($message_type) ?> alert-dismissible fade show" role="alert">
|
||||
<?= htmlspecialchars($message) ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2 class="mb-0">Terminübersicht</h2>
|
||||
</div>
|
||||
|
||||
<?php if ($is_admin): ?>
|
||||
<div class="collapse <?= $edit_mode ? 'show' : '' ?>" id="planningFormCollapse">
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header bg-primary-subtle text-secondary">
|
||||
<h4 class="mb-0"><?= $edit_mode ? 'Termin bearbeiten' : 'Neuen Termin hinzufügen'; ?></h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="planning.php" method="post">
|
||||
<?php if ($edit_mode): ?>
|
||||
<input type="hidden" name="id" value="<?= htmlspecialchars($edit_meeting['id']); ?>">
|
||||
<?php endif; ?>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Datum</label>
|
||||
<input type="date" class="form-control" name="meeting_date" value="<?= htmlspecialchars($edit_meeting['meeting_date_only'] ?? ''); ?>" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Uhrzeit</label>
|
||||
<input type="time" class="form-control" name="meeting_time" value="<?= htmlspecialchars($edit_meeting['meeting_time_only'] ?? '12:00'); ?>" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Farbe</label>
|
||||
<select class="form-select" name="color_id" required>
|
||||
<?php foreach ($all_colors as $color): ?>
|
||||
<option value="<?= $color['id'] ?>" <?= (($edit_meeting['color_id'] ?? 0) == $color['id']) ? 'selected' : '' ?>>
|
||||
<?= htmlspecialchars($color['name']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label">Grund für die Farbe (optional)</label>
|
||||
<input type="text" class="form-control" name="reason" value="<?= htmlspecialchars($edit_meeting['reason'] ?? ''); ?>">
|
||||
<div class="form-text">Wenn leer, wird „Zufallsfarbe“ eingetragen.</div>
|
||||
</div>
|
||||
<div class="col-12 d-flex justify-content-start">
|
||||
<button type="submit" class="btn btn-sm btn-outline-<?= $edit_mode ? 'success' : 'primary' ?> me-2">
|
||||
<?= $edit_mode ? 'Speichern' : 'Hinzufügen' ?>
|
||||
</button>
|
||||
<a href="planning.php" class="btn btn-sm btn-outline-secondary">Abbrechen</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card shadow">
|
||||
<div class="card-header bg-secondary bg-opacity-50 text-secondary d-flex justify-content-between align-items-center">
|
||||
<h4 class="mb-0">Anstehende Termine</h4>
|
||||
<?php if ($is_admin): ?>
|
||||
<a class="btn btn-sm d-flex align-items-center justify-content-center" data-bs-toggle="collapse" href="#planningFormCollapse" role="button" aria-expanded="false" aria-controls="planningFormCollapse">Add
|
||||
<span class="material-symbols-outlined">add</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php if (empty($meetings)): ?>
|
||||
<p class="text-muted text-center">Keine anstehenden Termine.</p>
|
||||
<?php else: ?>
|
||||
<div class="list-group list-group-flush">
|
||||
<?php foreach ($meetings as $m): ?>
|
||||
<div class="list-group-item">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
<p class="fw-bold mb-1"><?= date('d.m.Y H:i', strtotime($m['meeting_date'])) ?></p>
|
||||
<div class="d-flex align-items-center mb-1">
|
||||
<div class="rounded me-2" style="background-color: <?= htmlspecialchars($m['hex_code']); ?>; width: 20px; height: 20px;"></div>
|
||||
<span><?= htmlspecialchars($m['color_name']); ?></span>
|
||||
</div>
|
||||
<p class="text-muted small mb-0">Grund: <?= htmlspecialchars($m['reason']); ?></p>
|
||||
</div>
|
||||
<?php if ($is_admin): ?>
|
||||
<div class="dropdown ms-2">
|
||||
<a href="#" class="text-secondary" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<span class="material-icons">more_vert</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li>
|
||||
<a class="dropdown-item d-flex align-items-center" href="planning.php?action=edit&id=<?= $m['id'] ?>">
|
||||
<span class="material-icons me-2">mode_edit_outline</span> Bearbeiten
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item d-flex align-items-center text-danger" href="planning.php?action=delete&id=<?= $m['id'] ?>" onclick="return confirm('Wirklich löschen?')">
|
||||
<span class="material-icons me-2">delete_outline</span> Löschen
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include('inc/footer.php'); ?>
|
||||
Reference in New Issue
Block a user