1.3.0 Geburtstagslogik verbessert
This commit is contained in:
@@ -85,17 +85,15 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
}
|
||||
mysqli_stmt_close($stmt_insert);
|
||||
|
||||
// 🔹 GEBURTSTAGS-REGEL: last_birthday_year NUR setzen, wenn Geburtstag bereits war
|
||||
$current_year = (int)date('Y');
|
||||
$meeting_date_for_bday = $meeting['meeting_date'];
|
||||
|
||||
// 🔹 GEBURTSTAGS-ZAHLUNG BEHANDELN
|
||||
foreach ($_POST['user_id'] as $user_id) {
|
||||
$user_id = (int)$user_id;
|
||||
$paid = isset($_POST['paid'][$user_id]) && $_POST['paid'][$user_id] == 1;
|
||||
|
||||
if (!$paid) continue;
|
||||
|
||||
$user_stmt = mysqli_prepare($conn, "SELECT birthday FROM users WHERE id = ? AND birthday IS NOT NULL");
|
||||
// Hole aktuellen Status
|
||||
$user_stmt = mysqli_prepare($conn, "SELECT birthday_payer_pending FROM users WHERE id = ?");
|
||||
mysqli_stmt_bind_param($user_stmt, "i", $user_id);
|
||||
mysqli_stmt_execute($user_stmt);
|
||||
$user_row = mysqli_fetch_assoc(mysqli_stmt_get_result($user_stmt));
|
||||
@@ -103,20 +101,28 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
|
||||
if (!$user_row) continue;
|
||||
|
||||
$birthday = $user_row['birthday'];
|
||||
$birth_month = (int)date('m', strtotime($birthday));
|
||||
$birth_day = (int)date('d', strtotime($birthday));
|
||||
$birthday_this_year = "$current_year-$birth_month-$birth_day";
|
||||
$was_birthday_payer = (bool)$user_row['birthday_payer_pending'];
|
||||
|
||||
if (strtotime($birthday_this_year) <= strtotime($meeting_date_for_bday)) {
|
||||
$update_stmt = mysqli_prepare($conn, "
|
||||
if ($was_birthday_payer) {
|
||||
// 🎂 Geburtstags-Zahlung: NICHT zählen, aber Flag zurücksetzen
|
||||
$update = mysqli_prepare($conn, "
|
||||
UPDATE users
|
||||
SET last_birthday_year = ?
|
||||
SET birthday_payer_pending = 0
|
||||
WHERE id = ?
|
||||
");
|
||||
mysqli_stmt_bind_param($update_stmt, "ii", $current_year, $user_id);
|
||||
mysqli_stmt_execute($update_stmt);
|
||||
mysqli_stmt_close($update_stmt);
|
||||
mysqli_stmt_bind_param($update, "i", $user_id);
|
||||
mysqli_stmt_execute($update);
|
||||
mysqli_stmt_close($update);
|
||||
} else {
|
||||
// 🔢 Normale Zahlung: reguläre Anzahl erhöhen
|
||||
$update = mysqli_prepare($conn, "
|
||||
UPDATE users
|
||||
SET regular_paid_count = regular_paid_count + 1
|
||||
WHERE id = ?
|
||||
");
|
||||
mysqli_stmt_bind_param($update, "i", $user_id);
|
||||
mysqli_stmt_execute($update);
|
||||
mysqli_stmt_close($update);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user