Compare commits
5 Commits
94aa765186
...
30d242afb8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30d242afb8 | ||
|
|
0b4e4d6d89 | ||
|
|
dbb2151bf1 | ||
|
|
de77fac3e6 | ||
|
|
07413b7c46 |
173
admin/colors.php
173
admin/colors.php
@@ -1,173 +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_color = null;
|
|
||||||
|
|
||||||
// --- Löschen ---
|
|
||||||
if (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['id'])) {
|
|
||||||
$id = $_GET['id'];
|
|
||||||
$stmt = mysqli_prepare($conn, "DELETE FROM colors WHERE id = ?");
|
|
||||||
mysqli_stmt_bind_param($stmt, "i", $id);
|
|
||||||
if (mysqli_stmt_execute($stmt)) {
|
|
||||||
$message = "Farbe erfolgreich gelöscht!";
|
|
||||||
$message_type = 'success';
|
|
||||||
} else {
|
|
||||||
$message = "Fehler beim Löschen der Farbe.";
|
|
||||||
$message_type = 'danger';
|
|
||||||
}
|
|
||||||
mysqli_stmt_close($stmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Bearbeiten ---
|
|
||||||
if (isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['id'])) {
|
|
||||||
$id = $_GET['id'];
|
|
||||||
$stmt = mysqli_prepare($conn, "SELECT id, name, hex_code FROM colors WHERE id = ?");
|
|
||||||
mysqli_stmt_bind_param($stmt, "i", $id);
|
|
||||||
mysqli_stmt_execute($stmt);
|
|
||||||
$result = mysqli_stmt_get_result($stmt);
|
|
||||||
$edit_color = mysqli_fetch_assoc($result);
|
|
||||||
mysqli_stmt_close($stmt);
|
|
||||||
$edit_mode = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Hinzufügen / Aktualisieren ---
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
||||||
$name = $_POST['name'];
|
|
||||||
$hex_code = $_POST['hex_code'];
|
|
||||||
$id = $_POST['id'] ?? null;
|
|
||||||
|
|
||||||
if ($id) {
|
|
||||||
$stmt = mysqli_prepare($conn, "UPDATE colors SET name = ?, hex_code = ? WHERE id = ?");
|
|
||||||
mysqli_stmt_bind_param($stmt, "ssi", $name, $hex_code, $id);
|
|
||||||
if (mysqli_stmt_execute($stmt)) {
|
|
||||||
$message = "Farbe erfolgreich aktualisiert!";
|
|
||||||
$message_type = 'success';
|
|
||||||
} else {
|
|
||||||
$message = "Fehler beim Aktualisieren der Farbe.";
|
|
||||||
$message_type = 'danger';
|
|
||||||
}
|
|
||||||
mysqli_stmt_close($stmt);
|
|
||||||
} else {
|
|
||||||
$stmt = mysqli_prepare($conn, "INSERT INTO colors (name, hex_code) VALUES (?, ?)");
|
|
||||||
mysqli_stmt_bind_param($stmt, "ss", $name, $hex_code);
|
|
||||||
if (mysqli_stmt_execute($stmt)) {
|
|
||||||
$message = "Neue Farbe erfolgreich hinzugefügt!";
|
|
||||||
$message_type = 'success';
|
|
||||||
} else {
|
|
||||||
$message = "Fehler beim Hinzufügen der Farbe.";
|
|
||||||
$message_type = 'danger';
|
|
||||||
}
|
|
||||||
mysqli_stmt_close($stmt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Farben auslesen ---
|
|
||||||
$colors = [];
|
|
||||||
$result = mysqli_query($conn, "SELECT id, name, hex_code FROM colors ORDER BY name");
|
|
||||||
while ($row = mysqli_fetch_assoc($result)) {
|
|
||||||
$colors[] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once '../inc/header.php';
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div class="container mt-5">
|
|
||||||
|
|
||||||
<?php if ($message) : ?>
|
|
||||||
<div class="alert alert-<?= $message_type ?> alert-dismissible fade show" role="alert">
|
|
||||||
<?= 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">Farbverwaltung</h2>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="collapse <?= $edit_mode ? 'show' : '' ?>" id="colorFormCollapse">
|
|
||||||
<div class="card shadow mb-4">
|
|
||||||
<div class="card-header bg-primary-subtle text-secondary">
|
|
||||||
<h4 class="mb-0"><?= $edit_mode ? 'Farbe bearbeiten' : 'Neue Farbe hinzufügen'; ?></h4>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<form action="colors.php" method="post">
|
|
||||||
<?php if ($edit_mode): ?>
|
|
||||||
<input type="hidden" name="id" value="<?= htmlspecialchars($edit_color['id']); ?>">
|
|
||||||
<?php endif; ?>
|
|
||||||
<div class="row g-3">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<label for="name" class="form-label">Name der Farbe</label>
|
|
||||||
<input type="text" class="form-control" id="name" name="name"
|
|
||||||
value="<?= htmlspecialchars($edit_color['name'] ?? ''); ?>" required>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6">
|
|
||||||
<label for="hex_code" class="form-label">Hex-Code</label>
|
|
||||||
<input type="color" class="form-control form-control-color" id="hex_code" name="hex_code"
|
|
||||||
value="<?= htmlspecialchars($edit_color['hex_code'] ?? '#'); ?>">
|
|
||||||
</div>
|
|
||||||
<div class="col-12 d-flex justify-content-start mt-2">
|
|
||||||
<button type="submit" class="btn btn-sm btn-outline-<?= $edit_mode ? 'success' : 'primary'; ?> me-2">
|
|
||||||
<?= $edit_mode ? 'Speichern' : 'Hinzufügen'; ?>
|
|
||||||
</button>
|
|
||||||
<a href="colors.php" class="btn btn-sm btn-outline-secondary">Abbrechen</a>
|
|
||||||
</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">Aktuelle Farben</h4>
|
|
||||||
<a class="btn btn-sm d-flex align-items-center justify-content-center" data-bs-toggle="collapse" href="#colorFormCollapse" role="button" aria-expanded="false" aria-controls="colorFormCollapse">Add
|
|
||||||
<span class="material-symbols-outlined">add</span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<?php if (empty($colors)): ?>
|
|
||||||
<p class="text-muted text-center">Es sind noch keine Farben vorhanden.</p>
|
|
||||||
<?php else: ?>
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-striped table-hover">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Hex-Code</th>
|
|
||||||
<th>Farbe</th>
|
|
||||||
<th>Aktionen</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($colors as $color): ?>
|
|
||||||
<tr>
|
|
||||||
<td><?= htmlspecialchars($color['name']); ?></td>
|
|
||||||
<td><?= htmlspecialchars($color['hex_code']); ?></td>
|
|
||||||
<td>
|
|
||||||
<div style="background-color: <?= htmlspecialchars($color['hex_code']); ?>; width: 40px; height: 20px; border: 1px solid #ccc;"></div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="colors.php?action=edit&id=<?= htmlspecialchars($color['id']); ?>" class="text-dark me-1 text-decoration-none">
|
|
||||||
<span class="material-icons">mode_edit_outline</span>
|
|
||||||
</a>
|
|
||||||
<a href="colors.php?action=delete&id=<?= htmlspecialchars($color['id']); ?>" class="text-danger text-decoration-none" onclick="return confirm('Sind Sie sicher, dass Sie diese Farbe löschen möchten?');">
|
|
||||||
<span class="material-icons">delete_outline</span>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php include('../inc/footer.php'); ?>
|
|
||||||
@@ -7,11 +7,11 @@ include('../inc/check_login.php');
|
|||||||
include('../inc/db.php');
|
include('../inc/db.php');
|
||||||
require_once '../inc/helpers.php';
|
require_once '../inc/helpers.php';
|
||||||
|
|
||||||
// Nur Admin darf diese Seite nutzen
|
// Nur Admin darf diese Seite nutzen deaktiviert
|
||||||
if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'admin') {
|
// if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'admin') {
|
||||||
header("Location: ../index.php");
|
// header("Location: ../index.php");
|
||||||
exit;
|
// exit;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Meeting-ID prüfen
|
// Meeting-ID prüfen
|
||||||
if (!isset($_GET['id'])) {
|
if (!isset($_GET['id'])) {
|
||||||
|
|||||||
204
colors.php
Executable file
204
colors.php
Executable file
@@ -0,0 +1,204 @@
|
|||||||
|
<?php
|
||||||
|
session_start(); // Sicherstellen, dass Session läuft
|
||||||
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
header("Location: login.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once 'inc/db.php';
|
||||||
|
|
||||||
|
// Prüfen, ob der aktuelle Benutzer Admin ist
|
||||||
|
$is_admin = ($_SESSION['role'] === 'admin');
|
||||||
|
|
||||||
|
$message = '';
|
||||||
|
$message_type = '';
|
||||||
|
$edit_mode = false;
|
||||||
|
$edit_color = null;
|
||||||
|
|
||||||
|
// --- 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 colors WHERE id = ?");
|
||||||
|
mysqli_stmt_bind_param($stmt, "i", $id);
|
||||||
|
if (mysqli_stmt_execute($stmt)) {
|
||||||
|
$message = "Farbe erfolgreich gelöscht!";
|
||||||
|
$message_type = 'success';
|
||||||
|
} else {
|
||||||
|
$message = "Fehler beim Löschen der Farbe.";
|
||||||
|
$message_type = 'danger';
|
||||||
|
}
|
||||||
|
mysqli_stmt_close($stmt);
|
||||||
|
// Weiterleitung verhindert doppeltes Löschen beim Reload
|
||||||
|
header("Location: colors.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Nur Admins: Bearbeiten (Vorbereitung) ---
|
||||||
|
if ($is_admin && isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['id'])) {
|
||||||
|
$id = (int)$_GET['id'];
|
||||||
|
$stmt = mysqli_prepare($conn, "SELECT id, name, hex_code FROM colors WHERE id = ?");
|
||||||
|
mysqli_stmt_bind_param($stmt, "i", $id);
|
||||||
|
mysqli_stmt_execute($stmt);
|
||||||
|
$result = mysqli_stmt_get_result($stmt);
|
||||||
|
$edit_color = mysqli_fetch_assoc($result);
|
||||||
|
mysqli_stmt_close($stmt);
|
||||||
|
if ($edit_color) {
|
||||||
|
$edit_mode = true;
|
||||||
|
} else {
|
||||||
|
$message = "Farbe nicht gefunden.";
|
||||||
|
$message_type = 'warning';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Nur Admins: Hinzufügen / Aktualisieren ---
|
||||||
|
if ($is_admin && $_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$name = trim($_POST['name'] ?? '');
|
||||||
|
$hex_code = trim($_POST['hex_code'] ?? '');
|
||||||
|
$id = !empty($_POST['id']) ? (int)$_POST['id'] : null;
|
||||||
|
|
||||||
|
if (empty($name) || empty($hex_code)) {
|
||||||
|
$message = "Name und Farbcode sind erforderlich.";
|
||||||
|
$message_type = 'danger';
|
||||||
|
} else {
|
||||||
|
if ($id) {
|
||||||
|
$stmt = mysqli_prepare($conn, "UPDATE colors SET name = ?, hex_code = ? WHERE id = ?");
|
||||||
|
mysqli_stmt_bind_param($stmt, "ssi", $name, $hex_code, $id);
|
||||||
|
if (mysqli_stmt_execute($stmt)) {
|
||||||
|
$message = "Farbe erfolgreich aktualisiert!";
|
||||||
|
$message_type = 'success';
|
||||||
|
} else {
|
||||||
|
$message = "Fehler beim Aktualisieren der Farbe.";
|
||||||
|
$message_type = 'danger';
|
||||||
|
}
|
||||||
|
mysqli_stmt_close($stmt);
|
||||||
|
} else {
|
||||||
|
$stmt = mysqli_prepare($conn, "INSERT INTO colors (name, hex_code) VALUES (?, ?)");
|
||||||
|
mysqli_stmt_bind_param($stmt, "ss", $name, $hex_code);
|
||||||
|
if (mysqli_stmt_execute($stmt)) {
|
||||||
|
$message = "Neue Farbe erfolgreich hinzugefügt!";
|
||||||
|
$message_type = 'success';
|
||||||
|
} else {
|
||||||
|
$message = "Fehler beim Hinzufügen der Farbe.";
|
||||||
|
$message_type = 'danger';
|
||||||
|
}
|
||||||
|
mysqli_stmt_close($stmt);
|
||||||
|
}
|
||||||
|
// Nach POST: Weiterleitung zur Anzeige (Post-Redirect-Get)
|
||||||
|
header("Location: colors.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Farben für alle anzeigen ---
|
||||||
|
$colors = [];
|
||||||
|
$result = mysqli_query($conn, "SELECT id, name, hex_code FROM colors ORDER BY name");
|
||||||
|
while ($row = mysqli_fetch_assoc($result)) {
|
||||||
|
$colors[] = $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" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
|
<h2 class="mb-0">Farbverwaltung</h2>
|
||||||
|
<?php if ($is_admin): ?>
|
||||||
|
<a class="btn btn-sm btn-outline-primary d-flex align-items-center" data-bs-toggle="collapse" href="#colorFormCollapse" role="button">
|
||||||
|
<span class="material-symbols-outlined me-1">add</span> Farbe hinzufügen
|
||||||
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if ($is_admin): ?>
|
||||||
|
<div class="collapse <?= $edit_mode ? 'show' : '' ?>" id="colorFormCollapse">
|
||||||
|
<div class="card shadow mb-4">
|
||||||
|
<div class="card-header bg-primary-subtle text-secondary">
|
||||||
|
<h4 class="mb-0"><?= $edit_mode ? 'Farbe bearbeiten' : 'Neue Farbe hinzufügen'; ?></h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<form action="colors.php" method="post">
|
||||||
|
<?php if ($edit_mode): ?>
|
||||||
|
<input type="hidden" name="id" value="<?= htmlspecialchars($edit_color['id']); ?>">
|
||||||
|
<?php endif; ?>
|
||||||
|
<div class="row g-3">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label for="name" class="form-label">Name der Farbe</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name"
|
||||||
|
value="<?= htmlspecialchars($edit_color['name'] ?? ''); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label for="hex_code" class="form-label">Hex-Code</label>
|
||||||
|
<input type="color" class="form-control form-control-color" id="hex_code" name="hex_code"
|
||||||
|
value="<?= htmlspecialchars($edit_color['hex_code'] ?? '#000000'); ?>">
|
||||||
|
</div>
|
||||||
|
<div class="col-12 d-flex justify-content-start mt-2">
|
||||||
|
<button type="submit" class="btn btn-sm btn-outline-<?= $edit_mode ? 'success' : 'primary'; ?> me-2">
|
||||||
|
<?= $edit_mode ? 'Speichern' : 'Hinzufügen'; ?>
|
||||||
|
</button>
|
||||||
|
<a href="colors.php" class="btn btn-sm btn-outline-secondary">Abbrechen</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr class="mt-4 mb-4">
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="card shadow">
|
||||||
|
<div class="card-header bg-secondary bg-opacity-50 text-secondary">
|
||||||
|
<h4 class="mb-0">Aktuelle Farben</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if (empty($colors)): ?>
|
||||||
|
<p class="text-muted text-center">Es sind noch keine Farben vorhanden.</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Hex-Code</th>
|
||||||
|
<th>Farbe</th>
|
||||||
|
<?php if ($is_admin): ?>
|
||||||
|
<th>Aktionen</th>
|
||||||
|
<?php endif; ?>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($colors as $color): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?= htmlspecialchars($color['name']); ?></td>
|
||||||
|
<td><?= htmlspecialchars($color['hex_code']); ?></td>
|
||||||
|
<td>
|
||||||
|
<div style="background-color: <?= htmlspecialchars($color['hex_code']); ?>; width: 40px; height: 20px; border: 1px solid #ccc;"></div>
|
||||||
|
</td>
|
||||||
|
<?php if ($is_admin): ?>
|
||||||
|
<td>
|
||||||
|
<a href="colors.php?action=edit&id=<?= htmlspecialchars($color['id']); ?>" class="text-dark me-1 text-decoration-none">
|
||||||
|
<span class="material-icons">mode_edit_outline</span>
|
||||||
|
</a>
|
||||||
|
<a href="colors.php?action=delete&id=<?= htmlspecialchars($color['id']); ?>" class="text-danger text-decoration-none" onclick="return confirm('Sind Sie sicher, dass Sie diese Farbe löschen möchten?');">
|
||||||
|
<span class="material-icons">delete_outline</span>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<?php endif; ?>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php include('inc/footer.php'); ?>
|
||||||
@@ -27,14 +27,18 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link d-flex" href="#"><span class="material-icons md-18 me-1">message</span>Kontakt</a>
|
<a class="nav-link d-flex" href="#"><span class="material-icons md-18 me-1">message</span>Kontakt</a>
|
||||||
</li> -->
|
</li> -->
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<a class="nav-link d-flex align-items-center dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"><span class="material-icons md-18 me-1">settings</span>Settings</a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a class="dropdown-item" href="../colors.php">Farben</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
<?php
|
<?php
|
||||||
if (isset($_SESSION['role']) && $_SESSION['role'] == 'admin') {
|
if (isset($_SESSION['role']) && $_SESSION['role'] == 'admin') {
|
||||||
?>
|
?>
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link d-flex align-items-center dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"><span class="material-icons md-18 me-1">admin_panel_settings</span>Admin</a>
|
<a class="nav-link d-flex align-items-center dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"><span class="material-icons md-18 me-1">admin_panel_settings</span>Admin</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a class="dropdown-item" href="../admin/colors.php">Farben</a></li>
|
|
||||||
<li><a class="dropdown-item" href="../admin/planning.php">Terminplanung</a></li>
|
<li><a class="dropdown-item" href="../admin/planning.php">Terminplanung</a></li>
|
||||||
<li><a class="dropdown-item" href="../admin/users.php">Benutzer</a></li>
|
<li><a class="dropdown-item" href="../admin/users.php">Benutzer</a></li>
|
||||||
<li><a class="dropdown-item" href="../admin/check_session.php">Session prüfen</a></li>
|
<li><a class="dropdown-item" href="../admin/check_session.php">Session prüfen</a></li>
|
||||||
|
|||||||
49
index.php
49
index.php
@@ -216,10 +216,7 @@ if ($row) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --- TERMINVERSCHIEBUNG (ohne Änderung) ---
|
// --- TERMINVERSCHIEBUNG (ohne Änderung) ---
|
||||||
include('verschiebung.php'); // oder den gesamten Block hier lassen – optional
|
include('verschiebung.php');
|
||||||
// ... (hier kommt dein bestehender Verschiebungscode – unverändert)
|
|
||||||
// Da du ihn bereits modularisiert hast, kannst du auch `include('verschiebung.php');` nutzen
|
|
||||||
// Für diese Version lasse ich ihn aus Platzgründen weg – du kannst ihn wie gewohnt einfügen.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
include('inc/header.php');
|
include('inc/header.php');
|
||||||
@@ -239,7 +236,7 @@ $german_weekdays = [
|
|||||||
<!-- Optional: Hinweis bei automatischer Ablehnung -->
|
<!-- Optional: Hinweis bei automatischer Ablehnung -->
|
||||||
<?php if (isset($auto_declined) && $auto_declined === 'declined'): ?>
|
<?php if (isset($auto_declined) && $auto_declined === 'declined'): ?>
|
||||||
<div class="alert alert-info alert-dismissible fade show" role="alert">
|
<div class="alert alert-info alert-dismissible fade show" role="alert">
|
||||||
Du befindest dich im Abwesenheitsmodus → Teilnahme wurde automatisch abgelehnt.
|
Abwesenheitsmodus aktiv.
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@@ -287,7 +284,26 @@ $german_weekdays = [
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Verschiebungsformular (unverändert) -->
|
||||||
|
<div class="collapse" id="rescheduleForm">
|
||||||
|
<div class="card card-body bg-light mt-3 mx-auto" style="max-width: 90%;">
|
||||||
|
<h5>Anderen Termin vorschlagen</h5>
|
||||||
|
<form method="POST">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="new_date" class="form-label">Neuer Termin:</label>
|
||||||
|
<input type="datetime-local" class="form-control" id="new_date" name="new_date" value="<?= $row ? date('Y-m-d\TH:i', strtotime($row['meeting_date'])) : '' ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="reason" class="form-label">Grund/Bemerkung:</label>
|
||||||
|
<textarea class="form-control" id="reason" name="reason" rows="2" placeholder="Warum soll der Termin verschoben werden?"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex gap-2">
|
||||||
|
<button type="submit" name="propose_reschedule" class="btn btn-sm btn-outline-primary">Vorschlag einreichen</button>
|
||||||
|
<button type="button" class="btn btn-sm btn-outline-secondary" data-bs-toggle="collapse" data-bs-target="#rescheduleForm">Abbrechen</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="d-flex justify-content-center pt-2 pb-3" style="max-width: 500px; margin-left: auto; margin-right: auto; flex-direction: column; align-items: center;">
|
<div class="d-flex justify-content-center pt-2 pb-3" style="max-width: 500px; margin-left: auto; margin-right: auto; flex-direction: column; align-items: center;">
|
||||||
<?php if ($user_attendance_status === 'accepted'): ?>
|
<?php if ($user_attendance_status === 'accepted'): ?>
|
||||||
<p class="text-success fw-bold mb-4">Du hast zugesagt!</p>
|
<p class="text-success fw-bold mb-4">Du hast zugesagt!</p>
|
||||||
@@ -398,26 +414,7 @@ $german_weekdays = [
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Verschiebungsformular (unverändert) -->
|
|
||||||
<div class="collapse" id="rescheduleForm">
|
|
||||||
<div class="card card-body bg-light mt-3 mx-auto" style="max-width: 500px;">
|
|
||||||
<h5>Anderen Termin vorschlagen</h5>
|
|
||||||
<form method="POST">
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="new_date" class="form-label">Neuer Termin:</label>
|
|
||||||
<input type="datetime-local" class="form-control" id="new_date" name="new_date" value="<?= $row ? date('Y-m-d\TH:i', strtotime($row['meeting_date'])) : '' ?>" required>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="reason" class="form-label">Grund/Bemerkung:</label>
|
|
||||||
<textarea class="form-control" id="reason" name="reason" rows="2" placeholder="Warum soll der Termin verschoben werden?"></textarea>
|
|
||||||
</div>
|
|
||||||
<div class="d-flex gap-2">
|
|
||||||
<button type="submit" name="propose_reschedule" class="btn btn-sm btn-outline-primary">Vorschlag einreichen</button>
|
|
||||||
<button type="button" class="btn btn-sm btn-outline-secondary" data-bs-toggle="collapse" data-bs-target="#rescheduleForm">Abbrechen</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
|||||||
102
profil.php
102
profil.php
@@ -2,59 +2,78 @@
|
|||||||
require_once 'inc/check_login.php';
|
require_once 'inc/check_login.php';
|
||||||
require_once 'inc/db.php';
|
require_once 'inc/db.php';
|
||||||
|
|
||||||
// Variable zur Statusmeldung
|
|
||||||
$message = '';
|
$message = '';
|
||||||
$message_type = '';
|
$message_type = '';
|
||||||
|
|
||||||
// Überprüfen, ob das Formular per POST gesendet wurde
|
$user_id = (int)$_SESSION['user_id']; // Sicherheitshalber als Integer
|
||||||
|
|
||||||
|
// Aktuelle Benutzerdaten laden
|
||||||
|
$stmt_fetch = mysqli_prepare($conn, "SELECT username, email, role, birthday FROM users WHERE id = ?");
|
||||||
|
mysqli_stmt_bind_param($stmt_fetch, "i", $user_id);
|
||||||
|
mysqli_stmt_execute($stmt_fetch);
|
||||||
|
$result = mysqli_stmt_get_result($stmt_fetch);
|
||||||
|
$user_data = mysqli_fetch_assoc($result);
|
||||||
|
mysqli_stmt_close($stmt_fetch);
|
||||||
|
|
||||||
|
if (!$user_data) {
|
||||||
|
die("Benutzer nicht gefunden.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$current_username = $user_data['username'];
|
||||||
|
$current_email = $user_data['email'];
|
||||||
|
$current_role = $user_data['role'];
|
||||||
|
$current_birthday = $user_data['birthday'] ?? '';
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$new_username = trim($_POST['username'] ?? '');
|
||||||
|
$new_email = trim($_POST['email'] ?? '');
|
||||||
|
$new_birthday = trim($_POST['birthday'] ?? '');
|
||||||
|
|
||||||
// Eingaben aus dem Formular holen
|
|
||||||
$new_username = $_POST['username'];
|
|
||||||
$new_email = $_POST['email'];
|
|
||||||
$user_id = $_SESSION['user_id'];
|
|
||||||
|
|
||||||
// Validierung der Eingaben
|
|
||||||
if (empty($new_username)) {
|
if (empty($new_username)) {
|
||||||
$message = "Benutzername darf nicht leer sein.";
|
$message = "Benutzername darf nicht leer sein.";
|
||||||
$message_type = 'danger';
|
$message_type = 'danger';
|
||||||
} else {
|
} else {
|
||||||
// Datenbank-Abfrage vorbereiten
|
if (!empty($new_email) && !filter_var($new_email, FILTER_VALIDATE_EMAIL)) {
|
||||||
$stmt = mysqli_prepare($conn, "UPDATE users SET username = ?, email = ? WHERE id = ?");
|
$message = "Ungültige E-Mail-Adresse.";
|
||||||
|
$message_type = 'danger';
|
||||||
|
} else {
|
||||||
|
$stmt = mysqli_prepare($conn, "UPDATE users SET username = ?, email = ?, birthday = ? WHERE id = ?");
|
||||||
|
if ($stmt) {
|
||||||
|
$db_email = (!empty($new_email)) ? $new_email : null;
|
||||||
|
$db_birthday = (!empty($new_birthday)) ? $new_birthday : null;
|
||||||
|
mysqli_stmt_bind_param($stmt, "sssi", $new_username, $db_email, $db_birthday, $user_id);
|
||||||
|
if (mysqli_stmt_execute($stmt)) {
|
||||||
|
$_SESSION['username'] = $new_username;
|
||||||
|
$_SESSION['email'] = $new_email;
|
||||||
|
|
||||||
if ($stmt) {
|
$result_reload = mysqli_query($conn, "SELECT username, email, role, birthday FROM users WHERE id = " . (int)$user_id);
|
||||||
// Parameter binden
|
if ($result_reload) {
|
||||||
mysqli_stmt_bind_param($stmt, "ssi", $new_username, $new_email, $user_id);
|
$user_data = mysqli_fetch_assoc($result_reload);
|
||||||
|
$current_username = $user_data['username'];
|
||||||
|
$current_email = $user_data['email'];
|
||||||
|
$current_role = $user_data['role'];
|
||||||
|
$current_birthday = $user_data['birthday'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
// Statement ausführen
|
$message = "Profil erfolgreich aktualisiert!";
|
||||||
if (mysqli_stmt_execute($stmt)) {
|
$message_type = 'success';
|
||||||
// Session-Variablen aktualisieren
|
} else {
|
||||||
$_SESSION['username'] = $new_username;
|
$message = "Fehler beim Speichern der Daten.";
|
||||||
$_SESSION['email'] = $new_email;
|
$message_type = 'danger';
|
||||||
$message = "Profil erfolgreich aktualisiert!";
|
}
|
||||||
$message_type = 'success';
|
mysqli_stmt_close($stmt);
|
||||||
} else {
|
} else {
|
||||||
$message = "Fehler beim Speichern der Daten.";
|
$message = "Datenbankfehler: Statement konnte nicht vorbereitet werden.";
|
||||||
$message_type = 'danger';
|
$message_type = 'danger';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Statement schließen
|
|
||||||
mysqli_stmt_close($stmt);
|
|
||||||
} else {
|
|
||||||
$message = "Datenbankfehler: Statement konnte nicht vorbereitet werden.";
|
|
||||||
$message_type = 'danger';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Daten für die Anzeige aus der Session holen
|
|
||||||
$current_username = $_SESSION['username'];
|
|
||||||
$current_email = $_SESSION['email'];
|
|
||||||
$current_role = $_SESSION['role'];
|
|
||||||
|
|
||||||
require_once 'inc/header.php'; ?>
|
require_once 'inc/header.php';
|
||||||
|
?>
|
||||||
|
|
||||||
<div class="container mt-5">
|
<div class="container mt-5">
|
||||||
|
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-md-8 col-lg-6">
|
<div class="col-md-8 col-lg-6">
|
||||||
<h2 class="mb-4">Benutzerverwaltung</h2>
|
<h2 class="mb-4">Benutzerverwaltung</h2>
|
||||||
@@ -63,9 +82,9 @@ require_once 'inc/header.php'; ?>
|
|||||||
<h4 class="mb-0">Profil bearbeiten</h4>
|
<h4 class="mb-0">Profil bearbeiten</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<?php if ($message) : ?>
|
<?php if ($message): ?>
|
||||||
<div id="status-message" class="alert alert-<?php echo $message_type; ?> alert-dismissible fade show" role="alert">
|
<div id="status-message" class="alert alert-<?= htmlspecialchars($message_type) ?> alert-dismissible fade show" role="alert">
|
||||||
<?php echo htmlspecialchars($message); ?>
|
<?= htmlspecialchars($message) ?>
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@@ -73,15 +92,20 @@ require_once 'inc/header.php'; ?>
|
|||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="username" class="form-label fw-bold">Benutzername</label>
|
<label for="username" class="form-label fw-bold">Benutzername</label>
|
||||||
<input type="text" class="form-control" id="username" name="username" value="<?php echo htmlspecialchars($current_username); ?>" required>
|
<input type="text" class="form-control" id="username" name="username" value="<?= htmlspecialchars($current_username) ?>" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="email" class="form-label fw-bold">E-Mail-Adresse</label>
|
<label for="email" class="form-label fw-bold">E-Mail-Adresse</label>
|
||||||
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($current_email); ?>">
|
<input type="email" class="form-control" id="email" name="email" value="<?= htmlspecialchars($current_email) ?>">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="birthday" class="form-label fw-bold">Geburtstag</label>
|
||||||
|
<input type="date" class="form-control" id="birthday" name="birthday" value="<?= htmlspecialchars($current_birthday) ?>">
|
||||||
|
<small class="form-text text-muted">Für automatische Sonderzahlung.</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="role" class="form-label fw-bold">Rolle</label>
|
<label for="role" class="form-label fw-bold">Rolle</label>
|
||||||
<input type="text" class="form-control" id="role" name="role" value="<?php echo htmlspecialchars($current_role); ?>" disabled readonly>
|
<input type="text" class="form-control" id="role" name="role" value="<?= htmlspecialchars($current_role) ?>" disabled readonly>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="d-flex justify-content-between align-items-center mt-3">
|
<div class="d-flex justify-content-between align-items-center mt-3">
|
||||||
|
|||||||
Reference in New Issue
Block a user