1.3.0
This commit is contained in:
@@ -85,20 +85,38 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
}
|
||||
mysqli_stmt_close($stmt_insert);
|
||||
|
||||
// 🔹 GEBURTSTAGS-REGEL: last_birthday_year setzen
|
||||
// 🔹 GEBURTSTAGS-REGEL: last_birthday_year NUR setzen, wenn Geburtstag bereits war
|
||||
$current_year = (int)date('Y');
|
||||
$meeting_date_for_bday = $meeting['meeting_date'];
|
||||
|
||||
foreach ($_POST['user_id'] as $user_id) {
|
||||
$user_id = (int)$user_id;
|
||||
$paid = isset($_POST['paid'][$user_id]) ? 1 : 0;
|
||||
$paid = isset($_POST['paid'][$user_id]) && $_POST['paid'][$user_id] == 1;
|
||||
|
||||
if ($paid) {
|
||||
$stmt_bday = mysqli_prepare($conn, "
|
||||
if (!$paid) continue;
|
||||
|
||||
$user_stmt = mysqli_prepare($conn, "SELECT birthday FROM users WHERE id = ? AND birthday IS NOT NULL");
|
||||
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));
|
||||
mysqli_stmt_close($user_stmt);
|
||||
|
||||
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";
|
||||
|
||||
if (strtotime($birthday_this_year) <= strtotime($meeting_date_for_bday)) {
|
||||
$update_stmt = mysqli_prepare($conn, "
|
||||
UPDATE users
|
||||
SET last_birthday_year = YEAR(CURDATE())
|
||||
WHERE id = ? AND birthday IS NOT NULL
|
||||
SET last_birthday_year = ?
|
||||
WHERE id = ?
|
||||
");
|
||||
mysqli_stmt_bind_param($stmt_bday, "i", $user_id);
|
||||
mysqli_stmt_execute($stmt_bday);
|
||||
mysqli_stmt_close($stmt_bday);
|
||||
mysqli_stmt_bind_param($update_stmt, "ii", $current_year, $user_id);
|
||||
mysqli_stmt_execute($update_stmt);
|
||||
mysqli_stmt_close($update_stmt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user