LuminaWebsite/raid_attendance_action.php
Maaxxs 5dabbccbd7 Gear planner, dashboard polish, images on bug reports
Gear planner:
- Personal gear sets (18 slots) with enchant, exceed, soul imprint and manastones,
  stat totals by source and side-by-side comparison of 2-4 sets
- Sets can be shown on the own profile page (read-only for other members)
- Admin catalog: import items from aion2hub.com (Global client), compare stored
  values with the source one by one or all at once, at most one request per second
- New permissions gear.view (all with dashboard access) and gear.manage

Dashboard:
- Role badges ordered like the member list (roster_order)
- Stronger hover effect on "Rangliste & Verlauf" / "Zum Lumishop", no more blue
  hover on secondary buttons
- "Anstehende Raids" box links to the raids page, next raids link to the raid
  and to the calendar day
- Raid attendance only knows present/absent (old "excused" entries count as unset)

Bug reports:
- Up to 5 images per report, pasting copied images with Ctrl+V (also for the gallery)
- Images are only served to the reporter and bugs.manage via bug_image.php

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 09:27:09 +02:00

75 lines
2.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/raid_attendance.php';
require_permission('raids.manage');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
redirect('/raids.php');
}
verify_csrf();
$raidId = (int) ($_POST['raid_id'] ?? 0);
if ($raidId <= 0) {
redirect('/raids.php');
}
$userId = (int) current_user()['id'];
$statuses = (array) ($_POST['status'] ?? []);
$names = (array) ($_POST['names'] ?? []);
// Nachgetragenes Mitglied kommt als anwesend dazu.
$addDiscordId = trim((string) ($_POST['add_discord_id'] ?? ''));
if ($addDiscordId !== '' && ctype_digit($addDiscordId)) {
$stmt = db()->prepare("SELECT COALESCE(NULLIF(display_name, ''), username) FROM users WHERE discord_id = ?");
$stmt->execute([$addDiscordId]);
$name = $stmt->fetchColumn();
if ($name !== false) {
$statuses[$addDiscordId] = 'present';
$names[$addDiscordId] = (string) $name;
}
}
$pdo = db();
$pdo->beginTransaction();
$upsert = $pdo->prepare(
'INSERT INTO raid_attendance (raid_id, discord_id, name, status, updated_by, updated_at) VALUES (?, ?, ?, ?, ?, NOW())
ON DUPLICATE KEY UPDATE name = VALUES(name), status = VALUES(status), updated_by = VALUES(updated_by), updated_at = NOW()'
);
$delete = $pdo->prepare('DELETE FROM raid_attendance WHERE raid_id = ? AND discord_id = ?');
$counts = array_fill_keys(array_keys(RAID_ATTENDANCE_STATUSES), 0);
foreach ($statuses as $discordId => $status) {
$discordId = (string) $discordId;
if (!ctype_digit($discordId)) {
continue;
}
$status = (string) $status;
if (isset(RAID_ATTENDANCE_STATUSES[$status])) {
$upsert->execute([$raidId, $discordId, mb_substr((string) ($names[$discordId] ?? ''), 0, 100), $status, $userId]);
$counts[$status]++;
} else {
$delete->execute([$raidId, $discordId]); // "–" = nicht erfasst
}
}
if (!empty($_POST['mark_checked'])) {
$pdo->prepare(
'INSERT INTO raid_settings (raid_id, attendance_checked_at, attendance_checked_by) VALUES (?, NOW(), ?)
ON DUPLICATE KEY UPDATE attendance_checked_at = NOW(), attendance_checked_by = VALUES(attendance_checked_by)'
)->execute([$raidId, $userId]);
}
$pdo->commit();
admin_log('📋 Anwesenheit eingetragen', [
'Raid' => admin_log_raid($raidId),
'Anwesend' => $counts['present'],
'Abwesend' => $counts['absent'],
'Nachgetragen' => $addDiscordId !== '' && isset($names[$addDiscordId]) ? admin_log_discord($addDiscordId, (string) $names[$addDiscordId]) : '',
'Kontrolliert' => !empty($_POST['mark_checked']) ? 'ja, Liste abgeschlossen' : '',
], 'success');
set_flash('success', sprintf(
'Anwesenheit gespeichert: %d anwesend, %d abwesend%s.',
$counts['present'], $counts['absent'],
!empty($_POST['mark_checked']) ? ' - als kontrolliert markiert' : ''
));
redirect('/raid_attendance.php?raid=' . $raidId);