diff --git a/README.md b/README.md index 17d470c..a2e0227 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ und wird später ausgebaut. Fokus dieser Version ist der Mitglieder-/Admin-Berei Mitglieder vergeben, mit Rangliste und Verlauf - Lagerhaus: Bestand der Legion mit Einlagerungen (wer hat was wann überreicht) und Entnahmen (wann, optional an wen), Gegenstandsliste aus dem Aion-2-Wiki mit rund 2.300 Einträgen +- Anwesenheitsliste pro Raid (anwesend, abwesend, entschuldigt), automatische Beitragspunkte + beim Archivieren und eine Discord-PN an die Raidleitung, sobald ein Raid beginnt - Raids-Seite: zeigt anstehende Raid-Termine, Anforderungen, Gruppen und Anmeldungen, bezogen von einer externen API (`config.php: raids_api`), Filter Aktiv/Archiviert/Alle - "Mein Profil"-Seite: Anzeigename ändern, Passwort ändern, Discord-Verknüpfung verwalten @@ -392,6 +394,70 @@ Berechtigung `map.manage` werden nicht mehr benutzt und können bei bestehenden gelöscht werden. Die alten Taktiken werden nicht übernommen: Sie lagen als Anteil eines selbst erstellten Kartenbildes vor, das mit den neuen Kacheln nicht übereinstimmt. +### Anwesenheit bei Raids + +Auf der Raid-Seite hat jeder Raid für Mitglieder mit `raids.manage` den Knopf **Anwesenheit** +(`raid_attendance.php`). Dort steht jede Anmeldung mit Gruppe und Klasse und bekommt einen der +Zustände **Anwesend**, **Abwesend** oder **Entschuldigt**. Knöpfe setzen alle in den Gruppen auf +anwesend, die Ersatzbank auf abwesend oder Abgemeldete auf entschuldigt. Wer dabei war, ohne +angemeldet zu sein, lässt sich als Mitglied nachtragen. **Speichern & als kontrolliert +markieren** hält fest, wer die Liste wann geprüft hat. Die Raid-Karte zeigt danach „kontrolliert“, +vorher nach Raidbeginn „noch nicht kontrolliert“. Wer kein Website-Konto mit Discord-Verknüpfung +hat, steht mit in der Liste, kann aber keine Beitragspunkte bekommen. + +Gespeichert wird in `raid_attendance` (je Raid und Discord-ID) und `raid_settings`. Die Raids +selbst liegen weiter beim Bot, zugeordnet ist alles über die `raid_id` (= Discord-Nachrichten-ID). +Postet die Raid-API eine gelöschte Nachricht neu und ändert sich dadurch die ID, ziehen +Einstellungen, Anwesenheit und Vergaben beim Bearbeiten mit um. + +**Punkte nach Anwesenheit:** Im Formular „Punkte vergeben“ wählt man beim Anlass Raid einen Raid. +Mit Anwesenheitsliste sind die Anwesenden vorausgewählt. Ein Knopf wechselt auf die Abwesenden, +dann wird die Punktzahl negativ, also ein Abzug. Ohne Liste sind wie bisher alle in einer Gruppe +Angemeldeten vorausgewählt. + +**Automatische Punkte beim Archivieren:** Beim Anlegen und Bearbeiten eines Raids gibt es die +Felder **Punkte für Anwesende** und **Abzug für Abwesende** (0 = keine Automatik). Wird der Raid +archiviert, vergibt die Website diese Punkte selbst: + +- Anwesenheitsliste geführt: die Anwesenden bekommen die Punkte, den Abwesenden wird der Abzug + abgezogen, Entschuldigte bleiben unberührt. +- Keine Liste: alle, die in einer Gruppe angemeldet waren, bekommen die Punkte, einen Abzug gibt + es dann nicht. +- Wurden für den Raid vorher schon Punkte vergeben (von Hand), entfällt die Automatik. + +Das gilt auch, wenn der Raid im Discord über den Knopf archiviert wurde. Davon erfährt die +Website nicht direkt, deshalb prüft sie beim Aufruf der Raid- und Punkteseiten, ob ein Raid mit +offener Automatik inzwischen archiviert ist. Jeder Raid wird nur einmal verarbeitet, das Ergebnis +steht an der Raid-Karte und in der Anwesenheitsliste. + +#### Discord-PN zum Raidbeginn + +Sobald die Uhrzeit eines Raids erreicht ist, bekommen alle Angemeldeten mit `raids.manage` eine +Discord-PN mit einem Knopf zur Anwesenheitsliste. War die Liste schon vorher als kontrolliert +markiert, entfällt die Nachricht. Das erledigt der Bot (Datei `cogs/attendance.py` im Bot-Repo +Aion2_RaidPlaner): Er prüft jede Minute, ob ein Raid begonnen hat, höchstens drei Stunden +rückwirkend, damit nach einer Pause keine Flut alter Erinnerungen kommt. Dann fragt er die +Website über `bot_api.php`, wer die Nachricht bekommen soll. Für jeden Raid geht die +Erinnerung einmal raus. Ist die Website nicht erreichbar, versucht er es später erneut. + +Einrichtung: + +1. In `config.php` der Website einen langen, zufälligen Schlüssel eintragen: + ```php + 'bot_callback' => [ + 'key' => 'mindestens-16-zeichen-zufaellig', + ], + ``` +2. In der `.env` des Bots: + ``` + WEBSITE_URL=https://lumina.maaxxs-coding.de + WEBSITE_BOT_KEY= + ``` +3. `cogs/attendance.py` in den Bot kopieren und den Bot neu starten. Die zusätzliche Spalte + `attendance_notified` in `raids` legt die Datei beim Start selbst an. + +Fehlt einer der Werte, bleibt die Erinnerung aus, alles andere funktioniert trotzdem. + ### Beitragspunkte Die Seite **Beitragspunkte** (`contributions.php`) vergibt Punkte an Mitglieder, für Raids, diff --git a/assets/css/style.css b/assets/css/style.css index 27dd8d3..6f8cd5e 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -2522,3 +2522,116 @@ button.contribution-chip-remove:hover { background: none; color: var(--danger); .contribution-own { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px dashed var(--border); } .contribution-own h3 { margin: 0 0 0.6rem; font-size: 1rem; } .contribution-limit-note { margin: 1rem 0 0; font-size: 0.85rem; } + +/* --- Raids: Anwesenheit und automatische Beitragspunkte --- */ + +.raid-points-fields { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 0.75rem; + margin-top: 0.75rem; +} + +.raid-points-fields label { display: flex; align-items: center; gap: 0.35rem; } +.raid-points-fields .field-hint { grid-column: 1 / -1; margin: 0; } + +.raid-attendance-line { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 0.5rem; + margin: 0.25rem 0 0.75rem; +} + +a.button-small:hover { text-decoration: none; } +.raid-auto-points { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.85rem; } + +.attendance-head { + display: flex; + align-items: flex-start; + justify-content: space-between; + flex-wrap: wrap; + gap: 0.5rem 1.5rem; +} + +.attendance-head h1 { margin-bottom: 0.2rem; } +.attendance-head p { margin-top: 0; } + +.attendance-status { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 0.5rem 1rem; + padding: 0.75rem 1rem; + border: 1px solid var(--border); + border-radius: 8px; + background: var(--bg-panel-alt); + font-size: 0.9rem; +} + +.attendance-auto { display: inline-flex; align-items: center; gap: 0.35rem; } + +.attendance-bulk { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 0.4rem; + font-size: 0.9rem; +} + +.attendance-list { display: flex; flex-direction: column; gap: 0.35rem; } + +.attendance-row { + display: flex; + align-items: center; + justify-content: space-between; + flex-wrap: wrap; + gap: 0.5rem 1rem; + padding: 0.55rem 0.8rem; + border: 1px solid var(--border); + border-radius: 8px; + background: rgba(35, 35, 35, 0.6); +} + +.attendance-person { display: flex; align-items: center; flex-wrap: wrap; gap: 0.3rem 0.6rem; } +.attendance-person .text-muted { font-size: 0.85rem; } + +.attendance-choice { display: flex; gap: 0.3rem; } + +.attendance-option { + display: inline-flex; + align-items: center; + padding: 0.3rem 0.7rem; + border: 1px solid var(--border); + border-radius: 999px; + font-size: 0.85rem; + font-weight: 500; + cursor: pointer; + user-select: none; +} + +.attendance-option input { position: absolute; opacity: 0; pointer-events: none; } +.attendance-option:hover { border-color: var(--text-muted); } +.attendance-present:has(input:checked) { border-color: var(--success); background: rgba(76, 175, 80, 0.2); color: #8fdc92; } +.attendance-absent:has(input:checked) { border-color: var(--danger); background: rgba(217, 83, 79, 0.2); color: #ff9b97; } +.attendance-excused:has(input:checked) { border-color: var(--gold); background: rgba(201, 162, 39, 0.18); color: var(--gold); } +.attendance-none:has(input:checked) { border-color: var(--text-muted); background: var(--bg-panel-alt); } +.attendance-option:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; } + +.attendance-add { display: flex; flex-direction: column; gap: 0.3rem; max-width: 420px; } + +@media (max-width: 600px) { + .raid-points-fields { grid-template-columns: 1fr; } +} + +.contribution-raid-mode { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 0.4rem; + margin-top: 0.5rem; + font-size: 0.9rem; +} + +.contribution-raid-mode[hidden] { display: none; } +.contribution-raid-mode .button-small.active { border-color: var(--gold); color: var(--gold); } diff --git a/assets/js/contributions.js b/assets/js/contributions.js index 446bebe..c31b06d 100644 --- a/assets/js/contributions.js +++ b/assets/js/contributions.js @@ -83,36 +83,72 @@ category.addEventListener('change', toggleRaidField); toggleRaidField(); + var raidMode = document.getElementById('raid-mode'); + var currentRaid = null; + + function selectUsers(ids) { + boxes.forEach(function (box) { + box.checked = ids.indexOf(parseInt(box.value, 10)) !== -1; + }); + } + + // mode: present = Anwesende mit Punkten, absent = Abwesende mit Abzug, + // participants = alle in einer Gruppe Angemeldeten (ohne Anwesenheitsliste). + function applyRaid(raid, mode) { + var ids = mode === 'present' ? raid.present : (mode === 'absent' ? raid.absent : raid.participants); + selectUsers(ids); + + // Grund nur ueberschreiben, wenn nichts Eigenes eingetragen wurde. + if (titleInput.value === '' || titleInput.value === autoTitle) { + autoTitle = (mode === 'absent' ? 'Abwesend: ' : '') + raid.title + (raid.date ? ' (' + raid.date + ')' : ''); + titleInput.value = autoTitle; + } + if (raid.time) timeInput.value = raid.time; + + // Abwesenden werden Punkte abgezogen, allen anderen gutgeschrieben. + var points = parseInt(pointsInput.value, 10); + if (points && ((mode === 'absent' && points > 0) || (mode !== 'absent' && points < 0))) { + pointsInput.value = -points; + } + + var info; + if (mode === 'present') { + info = ids.length + ' Anwesende ausgewählt (laut Anwesenheitsliste).'; + } else if (mode === 'absent') { + info = ids.length + ' Abwesende ausgewählt - die Punkte werden abgezogen.'; + } else { + info = ids.length + ' Teilnehmer ausgewählt (laut Anmeldung).'; + if (raid.bench.length) info += ' ' + raid.bench.length + ' auf der Ersatzbank (nicht ausgewählt).'; + } + if (!raid.attendance) { + info += ' Für diesen Raid wurde noch keine Anwesenheitsliste geführt.'; + } + if (raid.withoutAccount.length) { + info += ' Ohne Website-Konto, daher keine Punkte möglich: ' + raid.withoutAccount.join(', ') + '.'; + } + raidInfo.textContent = info; + raidInfo.hidden = false; + raidMode.querySelectorAll('[data-raid-mode]').forEach(function (button) { + button.classList.toggle('active', button.getAttribute('data-raid-mode') === mode); + }); + updateCount(); + } + if (raidSelect) { raidSelect.addEventListener('change', function () { - var raid = raids.filter(function (r) { return String(r.id) === raidSelect.value; })[0]; - if (!raid) { + currentRaid = raids.filter(function (r) { return r.id === raidSelect.value; })[0] || null; + raidMode.hidden = !(currentRaid && currentRaid.attendance); + if (!currentRaid) { raidInfo.hidden = true; return; } + applyRaid(currentRaid, currentRaid.attendance ? 'present' : 'participants'); + }); - // Teilnehmer des Raids auswaehlen, alle anderen abwaehlen. - boxes.forEach(function (box) { - box.checked = raid.participants.indexOf(parseInt(box.value, 10)) !== -1; + raidMode.querySelectorAll('[data-raid-mode]').forEach(function (button) { + button.addEventListener('click', function () { + if (currentRaid) applyRaid(currentRaid, button.getAttribute('data-raid-mode')); }); - - // Grund und Datum nur ueberschreiben, wenn nichts Eigenes eingetragen wurde. - if (titleInput.value === '' || titleInput.value === autoTitle) { - autoTitle = raid.title + (raid.date ? ' (' + raid.date + ')' : ''); - titleInput.value = autoTitle; - } - if (raid.time) timeInput.value = raid.time; - - var info = raid.participants.length + ' Teilnehmer ausgewählt.'; - if (raid.bench.length) { - info += ' ' + raid.bench.length + ' auf der Ersatzbank (nicht ausgewählt).'; - } - if (raid.withoutAccount.length) { - info += ' Ohne Website-Konto, daher keine Punkte möglich: ' + raid.withoutAccount.join(', ') + '.'; - } - raidInfo.textContent = info; - raidInfo.hidden = false; - updateCount(); }); } diff --git a/assets/js/raids.js b/assets/js/raids.js index a28116a..b35f4f2 100644 --- a/assets/js/raids.js +++ b/assets/js/raids.js @@ -190,7 +190,9 @@ gearscore: form.gearscore.value, group_names: groupNames.join(', '), max_slots: form.max_slots.value, - locked_groups: lockedGroups + locked_groups: lockedGroups, + points_present: form.points_present ? form.points_present.value : 0, + points_absent: form.points_absent ? form.points_absent.value : 0 }).then(function (result) { feedback.textContent = result.message || ''; if (result.status === 'success') { @@ -276,7 +278,9 @@ requirements: raidCreateForm.requirements.value, gearscore: raidCreateForm.gearscore.value, group_names: groupNames.join(', '), - max_slots: raidCreateForm.max_slots.value + max_slots: raidCreateForm.max_slots.value, + points_present: raidCreateForm.points_present.value, + points_absent: raidCreateForm.points_absent.value }).then(function (result) { feedback.textContent = result.message || ''; if (result.status === 'success') { diff --git a/bot_api.php b/bot_api.php new file mode 100644 index 0000000..64fb174 --- /dev/null +++ b/bot_api.php @@ -0,0 +1,72 @@ + + */ +require_once __DIR__ . '/includes/bootstrap.php'; +require_once __DIR__ . '/includes/raid_attendance.php'; + +header('Content-Type: application/json; charset=UTF-8'); + +function bot_api_reply(int $status, array $data): void +{ + http_response_code($status); + echo json_encode($data, JSON_UNESCAPED_UNICODE); + exit; +} + +$expectedKey = bot_callback_key(); +if ($expectedKey === null) { + bot_api_reply(503, ['status' => 'error', 'message' => 'bot_callback.key ist in config.php nicht eingetragen.']); +} +$givenKey = (string) ($_SERVER['HTTP_X_BOT_KEY'] ?? ''); +if (!hash_equals($expectedKey, $givenKey)) { + bot_api_reply(403, ['status' => 'error', 'message' => 'Ungültiger Schlüssel.']); +} + +$action = (string) ($_GET['action'] ?? ''); +if ($action !== 'attendance_recipients') { + bot_api_reply(400, ['status' => 'error', 'message' => 'Unbekannte Aktion.']); +} + +$raidId = (string) ($_GET['raid_id'] ?? ''); +if (!ctype_digit($raidId)) { + bot_api_reply(400, ['status' => 'error', 'message' => 'raid_id fehlt.']); +} + +$discordIds = array_values(array_filter( + array_map('trim', explode(',', (string) ($_GET['discord_ids'] ?? ''))), + static fn (string $id): bool => $id !== '' && ctype_digit($id) +)); + +$recipients = []; +if (!empty($discordIds)) { + $placeholders = implode(',', array_fill(0, count($discordIds), '?')); + $stmt = db()->prepare( + "SELECT DISTINCT u.discord_id FROM users u + JOIN user_roles ur ON ur.user_id = u.id + JOIN role_permissions rp ON rp.role_id = ur.role_id + JOIN permissions p ON p.id = rp.permission_id + WHERE u.status = 'active' AND p.`key` = 'raids.manage' AND u.discord_id IN ($placeholders)" + ); + $stmt->execute($discordIds); + $recipients = array_map('strval', $stmt->fetchAll(PDO::FETCH_COLUMN)); +} + +$settings = raid_settings_get((int) $raidId); +$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; +$host = (string) ($_SERVER['HTTP_HOST'] ?? ''); + +bot_api_reply(200, [ + 'status' => 'success', + 'recipients' => $recipients, + // Schon kontrolliert (z.B. vor Raidbeginn)? Dann braucht es keine Erinnerung mehr. + 'checked' => $settings['attendance_checked_at'] !== null, + 'url' => $scheme . '://' . $host . '/raid_attendance.php?raid=' . $raidId, +]); diff --git a/config.example.php b/config.example.php index fa57fbb..51734b5 100644 --- a/config.example.php +++ b/config.example.php @@ -21,6 +21,11 @@ return [ // dieses Servers. Ohne raid_channel-Konfiguration im Bot schlaegt das Erstellen fehl. 'guild_id' => 'deine-discord-server-id', ], + // Gemeinsamer Schluessel fuer den Rueckkanal vom Bot (bot_api.php): im Bot als + // WEBSITE_BOT_KEY in der .env eintragen. Mindestens 16 Zeichen, z.B. zufaellig erzeugt. + 'bot_callback' => [ + 'key' => 'langer-zufaelliger-schluessel', + ], 'discord' => [ 'client_id' => 'deine-discord-client-id', 'client_secret' => 'dein-discord-client-secret', diff --git a/contributions.php b/contributions.php index 536d907..f258822 100644 --- a/contributions.php +++ b/contributions.php @@ -1,8 +1,12 @@ query( @@ -27,6 +27,7 @@ $raids = []; $raidsError = null; try { $apiRaids = fetch_raids('all'); + raid_process_auto_points($apiRaids); usort($apiRaids, static fn (array $a, array $b): int => (int) ($b['timestamp'] ?? 0) <=> (int) ($a['timestamp'] ?? 0)); foreach (array_slice($apiRaids, 0, 40) as $raid) { $participants = []; @@ -46,9 +47,27 @@ try { $bench[] = $userId; } } + // Anwesenheitsliste: Anwesende bekommen Punkte, Abwesenden kann man abziehen. + $present = []; + $absent = []; + $raidIdValue = (int) ($raid['raid_id'] ?? 0); + $attendance = raid_attendance_get($raidIdValue); + foreach ($attendance as $discordId => $entry) { + $userId = $userIdByDiscord[$discordId] ?? null; + if ($userId !== null && $entry['status'] === 'present') { + $present[] = $userId; + } elseif ($userId !== null && $entry['status'] === 'absent') { + $absent[] = $userId; + } + } + $timestamp = (int) ($raid['timestamp'] ?? 0); $raids[] = [ - 'id' => (int) ($raid['raid_id'] ?? 0), + // Als Text: Discord-IDs sind 19-stellig und in JavaScript als Zahl nicht exakt. + 'id' => (string) $raidIdValue, + 'attendance' => !empty($attendance), + 'present' => $present, + 'absent' => $absent, 'title' => (string) ($raid['title'] ?? 'Raid'), 'date' => $timestamp ? date('d.m.Y H:i', $timestamp) : (string) ($raid['date'] ?? ''), 'time' => $timestamp ? date('Y-m-d\TH:i', $timestamp) : '', @@ -104,7 +123,7 @@ include __DIR__ . '/includes/header.php'; + +
+ Schnell setzen: + + + + +
+ + +

Für diesen Raid gibt es keine Anmeldungen.

+ +
+ + +
+ +
+ + + + kein Website-Konto + +
+
+ $label): ?> + + + +
+
+ +
+ + + +
+ + +
+ + +
+ + +
+ + + + + diff --git a/raid_attendance_action.php b/raid_attendance_action.php new file mode 100644 index 0000000..c2b4f40 --- /dev/null +++ b/raid_attendance_action.php @@ -0,0 +1,67 @@ +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(); + +set_flash('success', sprintf( + 'Anwesenheit gespeichert: %d anwesend, %d abwesend, %d entschuldigt%s.', + $counts['present'], $counts['absent'], $counts['excused'], + !empty($_POST['mark_checked']) ? ' - als kontrolliert markiert' : '' +)); +redirect('/raid_attendance.php?raid=' . $raidId); diff --git a/raid_create_action.php b/raid_create_action.php index 062e3c4..6cfb9dd 100644 --- a/raid_create_action.php +++ b/raid_create_action.php @@ -1,6 +1,7 @@ $gearscore, 'max_slots' => $maxSlots, ]); + $newRaidId = (int) ($result['raid_id'] ?? 0); + // Beitragspunkte beim Archivieren kennt die Raid-API nicht - die merkt sich die Website. + if ($newRaidId > 0 && ($pointsPresent > 0 || $pointsAbsent > 0)) { + raid_settings_save_points($newRaidId, $pointsPresent, $pointsAbsent); + } json_response(true, 'Raid wurde erstellt.', ['raid_id' => $result['raid_id'] ?? null]); } catch (Throwable $e) { json_response(false, 'Erstellen fehlgeschlagen: ' . $e->getMessage()); diff --git a/raid_edit_action.php b/raid_edit_action.php index 47455ad..f955bda 100644 --- a/raid_edit_action.php +++ b/raid_edit_action.php @@ -1,6 +1,7 @@ getMessage(); } +// Automatische Beitragspunkte fuer inzwischen archivierte Raids (auch im Discord archivierte). +foreach (raid_process_auto_points($apiError ? null : $raids) as $autoMessage) { + if ($autoMessage !== '' && $canManageRaids) { + set_flash('info', $autoMessage); + } +} +try { + $raidSettings = raid_settings_all(); +} catch (PDOException $e) { + $raidSettings = []; +} + $premades = []; if ($canManageRaids) { try { @@ -117,6 +130,17 @@ include __DIR__ . '/includes/header.php'; +
+
+ + +
+
+ + +
+

Wird beim Archivieren automatisch vergeben - außer es wurden vorher schon Punkte für den Raid verteilt. Ohne Anwesenheitsliste bekommen alle in den Gruppen die Punkte, einen Abzug gibt es dann nicht. 0 = keine Automatik.

+
@@ -195,6 +219,11 @@ include __DIR__ . '/includes/header.php'; } } + $raidSetting = $raidSettings[(string) $raidId] ?? null; + $autoPresent = (int) ($raidSetting['points_present'] ?? 0); + $autoAbsent = (int) ($raidSetting['points_absent'] ?? 0); + $raidStarted = !empty($raid['timestamp']) && (int) $raid['timestamp'] <= time(); + $mySignupGroupNumber = $mySignup ? (int) ($mySignup['group'] ?? 0) : null; $mySignupGroupLabel = $mySignupGroupNumber === 0 ? 'Ersatzbank' : ($mySignupGroupNumber ? ($groupNames[$mySignupGroupNumber - 1] ?? ('#' . $mySignupGroupNumber)) : null); ?> @@ -242,6 +271,22 @@ include __DIR__ . '/includes/header.php';

+ +
+ Anwesenheit + + kontrolliert + + noch nicht kontrolliert + + 0 || $autoAbsent > 0): ?> + + + 0 ? ' / −' . $autoAbsent : '' ?> + + + +
+

Anforderungen:

@@ -274,6 +319,16 @@ include __DIR__ . '/includes/header.php'; +
+
+ + +
+
+ + +
+
diff --git a/sql/schema.sql b/sql/schema.sql index 0e8ed91..e8d69bb 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -75,6 +75,37 @@ CREATE TABLE IF NOT EXISTS user_roles ( FOREIGN KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +-- -------------------------------------------------------------------------- +-- Raids: Einstellungen und Anwesenheit (die Raids selbst liegen beim Bot) +-- -------------------------------------------------------------------------- + +CREATE TABLE IF NOT EXISTS raid_settings ( + -- Discord-Nachrichten-ID des Raids (wie in der Raid-API), 19-stellig + raid_id BIGINT UNSIGNED NOT NULL PRIMARY KEY, + -- Automatische Beitragspunkte beim Archivieren: fuer Anwesende bzw. Abzug fuer Abwesende + points_present INT NOT NULL DEFAULT 0, + points_absent INT NOT NULL DEFAULT 0, + -- Wann die Automatik gelaufen ist (oder uebersprungen wurde, weil schon Punkte vergeben waren) + auto_processed_at DATETIME NULL, + auto_result VARCHAR(255) NULL, + -- Anwesenheitsliste als kontrolliert bestaetigt + attendance_checked_at DATETIME NULL, + attendance_checked_by INT UNSIGNED NULL, + FOREIGN KEY (attendance_checked_by) REFERENCES users(id) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS raid_attendance ( + raid_id BIGINT UNSIGNED NOT NULL, + -- Discord-ID wie in den Raid-Anmeldungen; zugeordnet zu Website-Konten ueber users.discord_id + discord_id BIGINT UNSIGNED NOT NULL, + name VARCHAR(100) NOT NULL DEFAULT '', + status ENUM('present', 'absent', 'excused') NOT NULL, + updated_by INT UNSIGNED NULL, + updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (raid_id, discord_id), + FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + -- -------------------------------------------------------------------------- -- Beitragspunkte -- -------------------------------------------------------------------------- @@ -87,7 +118,7 @@ CREATE TABLE IF NOT EXISTS contribution_awards ( title VARCHAR(150) NOT NULL, note VARCHAR(255) NULL, -- Raid aus der Raid-API, wenn die Punkte fuer einen Raid vergeben wurden - raid_id INT UNSIGNED NULL, + raid_id BIGINT UNSIGNED NULL, awarded_at DATETIME NOT NULL, created_by INT UNSIGNED NULL, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,