This commit is contained in:
Borgal
2025-11-16 21:13:04 +01:00
parent aeb2d87cf5
commit 1b9ba22bb5
11 changed files with 1104 additions and 234 deletions

View File

@@ -179,69 +179,14 @@ if ($row) {
mysqli_stmt_close($attendees_stmt);
}
// --- ZAHLENDE PERSON BESTIMMEN (MIT GEBURTSTAGS-REGEL) ---
// --- ZAHLENDE PERSON BESTIMMEN ---
$next_payer_username = null;
if ($total_accepted > 0) {
$current_year = date('Y');
$meeting_date = $row['meeting_date'];
// Kandidaten holen
$sql_candidates = "
SELECT
u.id,
u.username,
u.birthday,
u.last_birthday_year,
(SELECT COUNT(*) FROM meeting_teilnehmer WHERE user_id = u.id AND paid = 1) AS paid_count
FROM meeting_teilnehmer mt
JOIN users u ON mt.user_id = u.id
WHERE mt.meeting_id = ? AND mt.rsvp_status = 'accepted'
ORDER BY u.username
";
$stmt_candidates = mysqli_prepare($conn, $sql_candidates);
mysqli_stmt_bind_param($stmt_candidates, "i", $meeting_id);
mysqli_stmt_execute($stmt_candidates);
$candidates = mysqli_fetch_all(mysqli_stmt_get_result($stmt_candidates), MYSQLI_ASSOC);
mysqli_stmt_close($stmt_candidates);
$birthday_payers = [];
$regular_payers = [];
foreach ($candidates as $c) {
if (empty($c['birthday'])) {
$regular_payers[] = $c;
continue;
}
$birth_month = (int)date('m', strtotime($c['birthday']));
$birth_day = (int)date('d', strtotime($c['birthday']));
$birthday_this_year = "$current_year-$birth_month-$birth_day";
$already_paid_this_year = ($c['last_birthday_year'] == $current_year);
$birthday_passed = (strtotime($birthday_this_year) <= strtotime($meeting_date));
if (!$already_paid_this_year && $birthday_passed) {
$birthday_payers[] = $c;
} else {
$regular_payers[] = $c;
}
}
// Priorität: Geburtstagskinder zuerst
if (!empty($birthday_payers)) {
usort($birthday_payers, function ($a, $b) {
return $a['paid_count'] <=> $b['paid_count'];
});
$next_payer_username = $birthday_payers[0]['username'];
} elseif (!empty($regular_payers)) {
usort($regular_payers, function ($a, $b) {
return $a['paid_count'] <=> $b['paid_count'];
});
$next_payer_username = $regular_payers[0]['username'];
}
include_once('zahler.php');
$next_payer_username = get_next_payer_username($conn, $meeting_id);
}
// --- TERMINVERSCHIEBUNG: Logik einbinden UND ausführen ---
include('verschiebung.php');
handle_reschedule_actions($conn, $meeting_id, $logged_in_user_id);
@@ -266,6 +211,34 @@ $german_weekdays = [
?>
<div class="container pt-0">
<?php
// 🔹 Hinweis für fehlende Profildaten (E-Mail oder Geburtstag)
if (isset($_SESSION['user_id'])) {
$user_profile_check = mysqli_prepare($conn, "SELECT email, birthday FROM users WHERE id = ?");
mysqli_stmt_bind_param($user_profile_check, "i", $_SESSION['user_id']);
mysqli_stmt_execute($user_profile_check);
$profile_data = mysqli_fetch_assoc(mysqli_stmt_get_result($user_profile_check));
mysqli_stmt_close($user_profile_check);
$email_missing = empty($profile_data['email']);
$birthday_missing = empty($profile_data['birthday']) || $profile_data['birthday'] === '0000-00-00';
if ($email_missing || $birthday_missing) {
echo '<div class="alert alert-info alert-dismissible fade show" role="alert">';
echo '<strong>Fast fertig!</strong> ';
if ($email_missing && $birthday_missing) {
echo 'Bitte trage deine E-Mail-Adresse und deinen Geburtstag in deinem Profil ein, um alle Funktionen nutzen zu können.';
} elseif ($email_missing) {
echo 'Bitte trage deine E-Mail-Adresse in deinem Profil ein.';
} else {
echo 'Bitte trage deinen Geburtstag in deinem Profil ein, um bei Geburtstagen berücksichtigt zu werden.';
}
echo ' <a href="profil.php" class="alert-link">Zum Profil</a>';
echo '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>';
echo '</div>';
}
}
?>
<?php if (isset($auto_declined) && $auto_declined === 'declined'): ?>
<div class="alert alert-info alert-dismissible fade show" role="alert">
Abwesenheitsmodus aktiv.