Verschiebung wieder korrekt implementiert
This commit is contained in:
@@ -63,3 +63,11 @@ pre {
|
||||
.collapse:not(.show) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.meeting-actions {
|
||||
max-width: 500px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
138
index.php
138
index.php
@@ -37,12 +37,10 @@ function auto_decline_if_on_vacation($conn, $meeting_id, $user_id, $meeting_date
|
||||
$existing = mysqli_fetch_assoc(mysqli_stmt_get_result($check_stmt));
|
||||
mysqli_stmt_close($check_stmt);
|
||||
|
||||
// Wenn bereits "accepted", nichts tun
|
||||
if ($existing && $existing['rsvp_status'] === 'accepted') {
|
||||
return 'accepted';
|
||||
}
|
||||
|
||||
// Sonst: ablehnen
|
||||
if ($existing) {
|
||||
$upd = mysqli_prepare($conn, "UPDATE meeting_teilnehmer SET rsvp_status = 'declined', attended = 0 WHERE meeting_id = ? AND user_id = ?");
|
||||
mysqli_stmt_bind_param($upd, "ii", $meeting_id, $user_id);
|
||||
@@ -72,10 +70,7 @@ function get_current_meeting($conn)
|
||||
|
||||
$row = get_current_meeting($conn);
|
||||
|
||||
// 🔴 Automatisches Abschließen bei vergangenem Termin wurde ENTFERNT
|
||||
// → Termin bleibt sichtbar, bis Admin in participant.php abschließt
|
||||
|
||||
// --- TEILNAHME-LOGIK ---
|
||||
// --- TEILNAHME-LOGIK & TERMINVERSCHIEBUNG ---
|
||||
if ($row) {
|
||||
$meeting_id = $row['id'];
|
||||
|
||||
@@ -132,7 +127,7 @@ if ($row) {
|
||||
// 🔥 Automatisch ablehnen, wenn im Abwesenheitsmodus
|
||||
$auto_declined = auto_decline_if_on_vacation($conn, $meeting_id, $logged_in_user_id, $row['meeting_date']);
|
||||
|
||||
// Status abrufen (kann jetzt "declined" sein)
|
||||
// Status abrufen
|
||||
$user_attendance_status = null;
|
||||
$user_status_sql = "SELECT rsvp_status FROM meeting_teilnehmer WHERE meeting_id = ? AND user_id = ?";
|
||||
$user_status_stmt = mysqli_prepare($conn, $user_status_sql);
|
||||
@@ -215,8 +210,14 @@ if ($row) {
|
||||
}
|
||||
}
|
||||
|
||||
// --- TERMINVERSCHIEBUNG (ohne Änderung) ---
|
||||
// --- TERMINVERSCHIEBUNG: Logik einbinden UND ausführen ---
|
||||
include('verschiebung.php');
|
||||
handle_reschedule_actions($conn, $meeting_id, $logged_in_user_id);
|
||||
$reschedule_data = load_reschedule_data($conn, $meeting_id, $logged_in_user_id);
|
||||
$active_proposals = $reschedule_data['active_proposals'];
|
||||
$user_votes = $reschedule_data['user_votes'];
|
||||
$yes_voters = $reschedule_data['yes_voters'];
|
||||
$no_voters = $reschedule_data['no_voters'];
|
||||
}
|
||||
|
||||
include('inc/header.php');
|
||||
@@ -233,7 +234,6 @@ $german_weekdays = [
|
||||
?>
|
||||
|
||||
<div class="container py-0">
|
||||
<!-- Optional: Hinweis bei automatischer Ablehnung -->
|
||||
<?php if (isset($auto_declined) && $auto_declined === 'declined'): ?>
|
||||
<div class="alert alert-info alert-dismissible fade show" role="alert">
|
||||
Abwesenheitsmodus aktiv.
|
||||
@@ -284,14 +284,15 @@ $german_weekdays = [
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Verschiebungsformular (unverändert) -->
|
||||
|
||||
<!-- Verschiebungsformular -->
|
||||
<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>
|
||||
<input type="datetime-local" class="form-control" id="new_date" name="new_date" value="<?= 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>
|
||||
@@ -304,8 +305,8 @@ $german_weekdays = [
|
||||
</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;">
|
||||
<?php if ($user_attendance_status === 'accepted'): ?>
|
||||
|
||||
<div class="d-flex justify-content-center pt-2 pb-3 meeting-actions"> <?php if ($user_attendance_status === 'accepted'): ?>
|
||||
<p class="text-success fw-bold mb-4">Du hast zugesagt!</p>
|
||||
<div class="d-flex justify-content-center">
|
||||
<a href="index.php?action=decline&meeting_id=<?= htmlspecialchars($meeting_id); ?>" class="btn btn-sm btn-outline-danger me-2">Absagen</a>
|
||||
@@ -344,7 +345,7 @@ $german_weekdays = [
|
||||
<a href="admin/participant.php?id=<?= htmlspecialchars($row['id']) ?>" class="btn btn-sm btn-outline-secondary">Teilnahme eintragen</a>
|
||||
</div>
|
||||
|
||||
<!-- Teilnehmerübersicht (unverändert) -->
|
||||
<!-- Teilnehmerübersicht -->
|
||||
<div class="card-footer text-center mt-3">
|
||||
<p class="text-muted mb-1">Teilnehmerübersicht:</p>
|
||||
<div class="d-flex justify-content-around">
|
||||
@@ -404,18 +405,119 @@ $german_weekdays = [
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 🔹 TERMINVERSCHIEBUNGS-VORSCHLÄGE -->
|
||||
<?php if (!empty($active_proposals)): ?>
|
||||
<div class="mt-4 pt-3 border-top">
|
||||
<h5 class="text-center mb-3">Aktive Verschiebungsvorschläge</h5>
|
||||
<?php foreach ($active_proposals as $p): ?>
|
||||
<div class="card mb-3 bg-light">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
<h6 class="mb-1">
|
||||
<?= date('d.m.Y H:i', strtotime($p['proposed_date'])) ?>
|
||||
<?php if (!empty($p['proposer_name'])): ?>
|
||||
<small class="text-muted">(von <?= htmlspecialchars($p['proposer_name']) ?>)</small>
|
||||
<?php endif; ?>
|
||||
</h6>
|
||||
<p class="mb-2"><?= htmlspecialchars($p['reason'] ?: 'Kein Grund angegeben') ?></p>
|
||||
</div>
|
||||
<?php if ($p['proposed_by_user_id'] == $logged_in_user_id): ?>
|
||||
<div class="dropdown ms-2">
|
||||
<button class="btn btn-sm btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">⋯</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item" href="#" data-bs-toggle="modal" data-bs-target="#editProposalModal<?= $p['id'] ?>">Bearbeiten</a>
|
||||
</li>
|
||||
<li>
|
||||
<form method="POST" class="d-inline" onsubmit="return confirm('Vorschlag wirklich löschen?')">
|
||||
<input type="hidden" name="proposal_id" value="<?= $p['id'] ?>">
|
||||
<button type="submit" name="delete_proposal" class="dropdown-item text-danger">Löschen</button>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Hier kommt dein bestehender Verschiebungs-HTML-Block – unverändert -->
|
||||
<!-- (Du kannst ihn aus deinem Originalcode kopieren) -->
|
||||
<div class="mt-2">
|
||||
<small class="text-success">✅ Ja: <?= $p['yes_votes'] ?>
|
||||
<?php if (!empty($yes_voters[$p['id']])): ?>
|
||||
(<?= implode(', ', $yes_voters[$p['id']]) ?>)
|
||||
<?php endif; ?>
|
||||
</small><br>
|
||||
<small class="text-danger">❌ Nein: <?= $p['no_votes'] ?>
|
||||
<?php if (!empty($no_voters[$p['id']])): ?>
|
||||
(<?= implode(', ', $no_voters[$p['id']]) ?>)
|
||||
<?php endif; ?>
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
<?php if (!isset($user_votes[$p['id']])): ?>
|
||||
<form method="POST" class="d-inline">
|
||||
<input type="hidden" name="proposal_id" value="<?= $p['id'] ?>">
|
||||
<button type="submit" name="vote_proposal" value="yes" class="btn btn-sm btn-success">✅ Ja</button>
|
||||
<button type="submit" name="vote_proposal" value="no" class="btn btn-sm btn-danger">❌ Nein</button>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<span class="badge bg-secondary">Bereits abgestimmt:
|
||||
<?= $user_votes[$p['id']] === 'yes' ? '✅ Ja' : '❌ Nein' ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (isset($_SESSION['role']) && $_SESSION['role'] === 'admin'): ?>
|
||||
<form method="POST" class="d-inline ms-2">
|
||||
<input type="hidden" name="proposal_id" value="<?= $p['id'] ?>">
|
||||
<button type="submit" name="accept_proposal" class="btn btn-sm btn-outline-success" onclick="return confirm('Vorschlag wirklich annehmen? Der Termin wird verschoben!')">Annehmen</button>
|
||||
<button type="submit" name="reject_proposal" class="btn btn-sm btn-outline-danger" onclick="return confirm('Vorschlag wirklich ablehnen?')">Ablehnen</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Bearbeiten-Modal -->
|
||||
<div class="modal fade" id="editProposalModal<?= $p['id'] ?>" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Vorschlag bearbeiten</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<form method="POST">
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="proposal_id" value="<?= $p['id'] ?>">
|
||||
<div class="mb-3">
|
||||
<label>Neuer Termin</label>
|
||||
<input type="datetime-local" name="new_date" class="form-control"
|
||||
value="<?= date('Y-m-d\TH:i', strtotime($p['proposed_date'])) ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label>Grund</label>
|
||||
<textarea name="reason" class="form-control"><?= htmlspecialchars($p['reason']) ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
|
||||
<button type="submit" name="edit_proposal" class="btn btn-primary">Speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php else: ?>
|
||||
<div class="alert alert-warning text-center">Keine anstehenden Termine gefunden.</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const links = document.querySelectorAll('.participant-toggle-collapse');
|
||||
|
||||
Reference in New Issue
Block a user