Asked for: "bei den Legionsbeiträgen soll der bot auch die leute drauf erinnern dass ihr beitrag fällig ist ...
die nachricht ist frei definierbar über die website (mit markierungen und erwähnungen) ... eine standardnachricht,
welche zur Legion passt" and "es soll wenn man die seite aufruft standardmäßig die von uns definierte reihenfolge
angezeigt werden".
Dues reminders (includes/dues_reminders.php, admin/dues.php "Erinnerungen per Discord"):
- Who: everyone still open in the running cycle with a linked Discord - not who paid, is exempt or sits in a
suspended cycle. Automatic (switch, off by default) at the start of the cycle and/or N days before its end, at
a set hour (settings dues_remind_*); a missed moment is caught up for 24 hours at most, so switching it on in the
middle of a cycle sends nothing. "Jetzt erinnern" for everyone open right now and "Testnachricht an mich" with
the text from the form, saved or not.
- The text is free: Discord formatting, placeholders {name}, {erwähnung}, {betrag}, {zyklus}, {bis}, mentions of
members and channels (channel list from the bot API), toolbar and live preview with the own values
(assets/js/dues-remind.js). The default text greets with "Arieluma" and is stored empty so improvements arrive.
- Flow: the bot (new cogs/dues_reminders.py, already deployed) asks bot_api.php?action=dues_reminders every minute;
the website queues due reminders in dues_reminders (at most once per member, cycle and kind) and hands out the
waiting ones with the finished text, the bot sends them without pings and reports back via
action=dues_reminders_done, then logs to the log channel. The text is dropped after sending, the log stays 90
days. The section lists the runs of the running cycle with delivered and not deliverable (with reason).
- Schema version 64 (table also in sql/schema.sql); privacy policy (what is stored, the bot, retention), data export
section, account deletion, data reset, audit log; patch notes and README.
Premades:
- The page opens in the order the leadership set: own premades are no longer pulled to the top. A chosen sort only
lives in the address (?sort=) - it survives a reload, not a new visit; the former browser entry
lumina_premades_sort is removed (and left the privacy policy). Patch notes of the sort and order entries adjusted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
523 lines
32 KiB
PHP
523 lines
32 KiB
PHP
<?php
|
||
/**
|
||
* Legionsbeitraege verwalten (includes/dues.php, nur dues.manage): Betrag und Rhythmus einstellen, je Zyklus abhaken,
|
||
* wer bezahlt hat, Mitglieder befreien und Zyklen fuer alle aussetzen. Aenderungen gehen an admin/dues_action.php, das
|
||
* Abhaken klappt mit JavaScript ohne Neuladen (assets/js/dues.js).
|
||
* /admin/dues.php die neuesten Zyklen (bis zum naechsten)
|
||
* /admin/dues.php?bis=ID aeltere: die Zyklen bis einschliesslich ID
|
||
*/
|
||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||
require_once __DIR__ . '/../includes/dues.php';
|
||
require_once __DIR__ . '/../includes/dues_reminders.php';
|
||
require_once __DIR__ . '/../includes/events_api.php';
|
||
require_permission('dues.manage');
|
||
|
||
$settings = dues_settings();
|
||
$configured = dues_configured($settings);
|
||
dues_sync($settings);
|
||
$cycles = dues_cycles();
|
||
['current' => $current, 'next' => $next] = dues_current($cycles);
|
||
$focus = $current ?? $next;
|
||
$hasData = dues_has_data();
|
||
$today = date('Y-m-d');
|
||
$currentEnd = dues_current_end($cycles);
|
||
|
||
// Sichtbare Zyklen: hoechstens DUES_VISIBLE_CYCLES bis zum gewaehlten (Standard: der neueste, also der naechste)
|
||
$cycleIds = array_keys($cycles);
|
||
$lastIndex = count($cycleIds) - 1;
|
||
$untilId = (int) ($_GET['bis'] ?? 0);
|
||
$untilIndex = isset($cycles[$untilId]) ? (int) array_search($untilId, $cycleIds, true) : $lastIndex;
|
||
$firstIndex = max(0, $untilIndex - DUES_VISIBLE_CYCLES + 1);
|
||
$visible = [];
|
||
foreach ($cycleIds ? array_slice($cycleIds, $firstIndex, $untilIndex - $firstIndex + 1) : [] as $id) {
|
||
$visible[$id] = $cycles[$id];
|
||
}
|
||
$olderUntil = $firstIndex > 0 ? $cycleIds[$firstIndex - 1] : null;
|
||
$newerUntil = $untilIndex < $lastIndex ? $cycleIds[min($lastIndex, $untilIndex + DUES_VISIBLE_CYCLES)] : null;
|
||
$bis = $untilIndex < $lastIndex ? (int) $cycleIds[$untilIndex] : 0;
|
||
|
||
$entries = dues_entries();
|
||
// Ehemalige Mitglieder nur, wenn sie in den gezeigten Zyklen (oder im laufenden) bezahlt haben
|
||
$formerIds = [];
|
||
foreach (array_merge(array_keys($visible), $focus !== null ? [$focus['id']] : []) as $id) {
|
||
array_push($formerIds, ...array_keys($entries[$id] ?? []));
|
||
}
|
||
$members = dues_members($formerIds);
|
||
$exemptions = dues_exemptions();
|
||
$arrears = dues_arrears($cycles, $members, $entries, $exemptions);
|
||
$totals = [];
|
||
foreach ($visible as $id => $cycle) {
|
||
$totals[$id] = dues_cycle_totals($cycle, $members, $entries, $exemptions);
|
||
}
|
||
$focusTotals = $focus !== null ? ($totals[$focus['id']] ?? dues_cycle_totals($focus, $members, $entries, $exemptions)) : null;
|
||
|
||
// Filter oben in der Tabelle: nach dem Stand im laufenden (sonst naechsten) Zyklus
|
||
$focusStatus = [];
|
||
foreach ($members as $member) {
|
||
$focusStatus[$member['id']] = $focus !== null ? dues_status($focus, $member, $entries, $exemptions) : '';
|
||
}
|
||
$activeMembers = array_filter($members, static fn (array $member): bool => $member['active']);
|
||
$filterCounts = [
|
||
'open' => count(array_filter($focusStatus, static fn (string $status): bool => $status === 'open')),
|
||
'paid' => count(array_filter($focusStatus, static fn (string $status): bool => $status === 'paid')),
|
||
'exempt' => count(array_filter($focusStatus, static fn (string $status): bool => $status === 'exempt')),
|
||
'arrears' => count(array_filter($arrears, static fn (array $row): bool => $row['count'] > 0)),
|
||
];
|
||
|
||
// Befreiungen: "Ab" - die letzten vergangenen Zyklen, der laufende, der naechste und weitere aus der Vorschau
|
||
$choices = dues_cycle_choices($cycles, $settings);
|
||
$choiceFocus = 0;
|
||
foreach ($choices as $index => $choice) {
|
||
if ($choice['ends_on'] >= $today) {
|
||
$choiceFocus = $index;
|
||
break;
|
||
}
|
||
}
|
||
$fromChoices = array_slice($choices, max(0, $choiceFocus - DUES_EXEMPT_PAST_CYCLES), DUES_EXEMPT_PAST_CYCLES + DUES_EXEMPT_MAX_CYCLES, true);
|
||
$exemptionRows = [];
|
||
foreach ($exemptions as $userId => $rows) {
|
||
foreach ($rows as $row) {
|
||
$row['member'] = $members[$userId]['name'] ?? ('Konto #' . $userId);
|
||
$row['is_active'] = isset($members[$userId]) && $members[$userId]['active'];
|
||
$exemptionRows[] = $row;
|
||
}
|
||
}
|
||
usort($exemptionRows, static fn (array $a, array $b): int => [$a['starts_on'], mb_strtolower($a['member'])] <=> [$b['starts_on'], mb_strtolower($b['member'])]);
|
||
$endsBefore = $focus['starts_on'] ?? $today;
|
||
$currentExemptions = array_filter($exemptionRows, static fn (array $row): bool => $row['ends_on'] === null || $row['ends_on'] >= $endsBefore);
|
||
$pastExemptions = array_reverse(array_filter($exemptionRows, static fn (array $row): bool => $row['ends_on'] !== null && $row['ends_on'] < $endsBefore));
|
||
|
||
$shortPeriod = static fn (array $cycle): string => (new DateTimeImmutable($cycle['starts_on']))->format('d.m.') . '–' . (new DateTimeImmutable($cycle['ends_on']))->format('d.m.');
|
||
$dateLabel = static fn (?string $date): string => $date !== null ? (new DateTimeImmutable($date))->format('d.m.Y') : '';
|
||
|
||
// Erinnerungen per Discord (includes/dues_reminders.php): wer im laufenden Zyklus noch offen ist, die bisherigen
|
||
// Durchgaenge und fuer den Editor die Erwaehnungen (Mitglieder mit Discord, Kanaele des Servers) samt Vorschau-Werten
|
||
$remind = dues_remind_settings();
|
||
$remindCycle = $current !== null && !$current['suspended'] ? $current : null;
|
||
$remindFound = $remindCycle !== null ? dues_remind_recipients($remindCycle) : null;
|
||
try {
|
||
$remindRuns = $current !== null ? dues_remind_runs($current['id']) : [];
|
||
} catch (PDOException $e) {
|
||
$remindRuns = []; // Tabelle kommt erst mit dem naechsten Schema-Abgleich
|
||
}
|
||
$remindUsers = [];
|
||
foreach (db()->query("SELECT discord_id, COALESCE(NULLIF(display_name, ''), username) AS name FROM users WHERE status = 'active' AND discord_id IS NOT NULL ORDER BY name")->fetchAll() as $row) {
|
||
$remindUsers[(string) $row['discord_id']] = (string) $row['name'];
|
||
}
|
||
$remindChannels = [];
|
||
try {
|
||
foreach (fetch_guild_channels() as $channel) {
|
||
$remindChannels[(string) $channel['channel_id']] = (string) $channel['name'];
|
||
}
|
||
} catch (Throwable $e) {
|
||
// Bot nicht erreichbar - dann ohne Kanaele zum Erwaehnen
|
||
}
|
||
$me = current_user();
|
||
$myName = (string) (($me['display_name'] ?? '') !== '' ? $me['display_name'] : $me['username']);
|
||
$sampleCycle = $current ?? $next;
|
||
$remindSample = [
|
||
'{name}' => $myName,
|
||
'{erwähnung}' => !empty($me['discord_id']) ? '<@' . $me['discord_id'] . '>' : $myName,
|
||
'{erwaehnung}' => !empty($me['discord_id']) ? '<@' . $me['discord_id'] . '>' : $myName,
|
||
'{betrag}' => dues_kina($sampleCycle['amount'] ?? $settings['amount']),
|
||
'{zyklus}' => $sampleCycle !== null ? dues_period_label($sampleCycle['starts_on'], $sampleCycle['ends_on']) : '…',
|
||
'{bis}' => $sampleCycle !== null ? $dateLabel($sampleCycle['ends_on']) : '…',
|
||
];
|
||
|
||
$pageTitle = 'Legionsbeiträge';
|
||
$containerWide = true;
|
||
include __DIR__ . '/../includes/header.php';
|
||
?>
|
||
|
||
<div class="panel dues-panel">
|
||
<div class="dues-head">
|
||
<div>
|
||
<h1>Legionsbeiträge</h1>
|
||
<?php if ($configured): ?>
|
||
<p class="text-muted">
|
||
<?= e(ucfirst(dues_rhythm_label($settings['unit'], $settings['every']))) ?> <?= e(dues_kina($settings['amount'])) ?> je Mitglied
|
||
· erster Zyklus ab <?= e($dateLabel($settings['start'])) ?>
|
||
· <a href="#einstellungen">Einstellungen</a>
|
||
</p>
|
||
<?php else: ?>
|
||
<p class="text-muted">Hier hältst du fest, wer seinen Beitrag in Kina bezahlt hat. Nur für die Verwaltung – die Mitglieder sehen diese Seite nicht.</p>
|
||
<?php endif; ?>
|
||
</div>
|
||
</div>
|
||
<?php if ($configured): ?>
|
||
<?= dues_summary_html($focus, $focusTotals, $arrears) ?>
|
||
<?php endif; ?>
|
||
</div>
|
||
|
||
<?php if ($configured && $visible): ?>
|
||
<div class="panel" id="zahlungen">
|
||
<div class="dues-section-head">
|
||
<h2>Wer hat bezahlt?</h2>
|
||
<nav class="dues-pager" aria-label="Zyklen blättern">
|
||
<?php if ($olderUntil !== null): ?>
|
||
<a class="button button-secondary button-small" href="/admin/dues.php?bis=<?= (int) $olderUntil ?>#zahlungen">← Ältere</a>
|
||
<?php endif; ?>
|
||
<?php if ($newerUntil !== null): ?>
|
||
<a class="button button-secondary button-small" href="/admin/dues.php<?= $newerUntil !== $cycleIds[$lastIndex] ? '?bis=' . (int) $newerUntil : '' ?>#zahlungen">Neuere →</a>
|
||
<?php endif; ?>
|
||
</nav>
|
||
</div>
|
||
<p class="text-muted dues-hint">
|
||
Ein Klick auf ein Feld hakt die Zahlung ab, ein zweiter nimmt sie zurück. Wer zu Beginn eines Zyklus noch nicht dabei war,
|
||
befreit ist oder wessen Zyklus ausgesetzt wurde, muss nichts zahlen – abhaken lässt sich trotzdem, falls doch jemand zahlt.
|
||
</p>
|
||
|
||
<div class="list-toolbar dues-toolbar">
|
||
<label class="search-field">
|
||
<?= icon('search') ?>
|
||
<input type="search" placeholder="Mitglied suchen …" autocomplete="off" aria-label="Mitglieder durchsuchen" data-dues-search>
|
||
</label>
|
||
<div class="members-chips" role="group" aria-label="Nach Stand filtern" data-dues-filters>
|
||
<button type="button" class="members-chip active" data-value="" aria-pressed="true">Alle <span class="chip-count"><?= count($members) ?></span></button>
|
||
<?php if ($focus !== null): ?>
|
||
<button type="button" class="members-chip" data-value="open" aria-pressed="false" title="Im <?= $current !== null ? 'laufenden' : 'nächsten' ?> Zyklus noch offen">Offen <span class="chip-count" data-dues-count="open"><?= $filterCounts['open'] ?></span></button>
|
||
<button type="button" class="members-chip" data-value="paid" aria-pressed="false" title="Im <?= $current !== null ? 'laufenden' : 'nächsten' ?> Zyklus bezahlt">Bezahlt <span class="chip-count" data-dues-count="paid"><?= $filterCounts['paid'] ?></span></button>
|
||
<button type="button" class="members-chip" data-value="exempt" aria-pressed="false" title="Im <?= $current !== null ? 'laufenden' : 'nächsten' ?> Zyklus befreit">Befreit <span class="chip-count" data-dues-count="exempt"><?= $filterCounts['exempt'] ?></span></button>
|
||
<?php endif; ?>
|
||
<button type="button" class="members-chip" data-value="arrears" aria-pressed="false" title="Offene Zahlungen aus früheren Zyklen">Rückstand <span class="chip-count" data-dues-count="arrears"><?= $filterCounts['arrears'] ?></span></button>
|
||
</div>
|
||
</div>
|
||
|
||
<?php // Aussetzen/Fortsetzen: Knoepfe im Kopf der Tabelle gehoeren zu diesem Formular (form="dues-cycle-form") ?>
|
||
<form method="post" action="/admin/dues_action.php" id="dues-cycle-form" class="dues-hidden-form">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="cycle">
|
||
<input type="hidden" name="bis" value="<?= $bis ?>">
|
||
<input type="hidden" name="note" value="">
|
||
</form>
|
||
<form method="post" action="/admin/dues_action.php" class="dues-form" data-dues-form>
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="toggle">
|
||
<input type="hidden" name="bis" value="<?= $bis ?>">
|
||
<div class="table-scroll dues-scroll">
|
||
<table class="dues-table">
|
||
<thead>
|
||
<tr>
|
||
<th scope="col" class="dues-member-col">Mitglied</th>
|
||
<?php foreach ($visible as $id => $cycle): ?>
|
||
<?php
|
||
$isCurrent = $current !== null && $current['id'] === $id;
|
||
$isNext = $next !== null && $next['id'] === $id;
|
||
$period = dues_period_label($cycle['starts_on'], $cycle['ends_on']);
|
||
?>
|
||
<th scope="col" class="dues-col<?= $isCurrent ? ' is-current' : '' ?><?= $isNext ? ' is-next' : '' ?><?= $cycle['suspended'] ? ' is-suspended' : '' ?>" title="<?= e($period . ($cycle['suspended'] && $cycle['note'] ? ' – ausgesetzt: ' . $cycle['note'] : '')) ?>">
|
||
<span class="dues-col-period"><?= e($shortPeriod($cycle)) ?></span>
|
||
<span class="dues-col-tag"><?= $cycle['suspended'] ? 'ausgesetzt' : ($isCurrent ? 'laufend' : ($isNext ? 'nächster' : (new DateTimeImmutable($cycle['starts_on']))->format('Y'))) ?></span>
|
||
<span class="dues-col-amount"><?= e(number_format($cycle['amount'], 0, ',', '.')) ?></span>
|
||
<?= dues_cycle_stats_html($cycle, $totals[$id]) ?>
|
||
<?php if ($cycle['suspended']): ?>
|
||
<button type="submit" form="dues-cycle-form" name="cycle" value="resume:<?= (int) $id ?>" class="icon-button dues-col-action"
|
||
title="Aussetzen zurücknehmen" aria-label="Aussetzen zurücknehmen: <?= e($period) ?>"
|
||
data-confirm="Im Zyklus <?= e($period) ?> müssen wieder alle zahlen, die nicht befreit sind." data-confirm-title="Zyklus fortsetzen?" data-confirm-ok="Fortsetzen"><?= icon('play') ?></button>
|
||
<?php else: ?>
|
||
<button type="submit" form="dues-cycle-form" name="cycle" value="suspend:<?= (int) $id ?>" class="icon-button dues-col-action"
|
||
title="Für alle aussetzen" aria-label="Für alle aussetzen: <?= e($period) ?>"
|
||
data-confirm="Im Zyklus <?= e($period) ?> muss niemand zahlen. Schon abgehakte Zahlungen bleiben stehen." data-confirm-title="Zyklus für alle aussetzen?"
|
||
data-confirm-ok="Aussetzen" data-confirm-input="note" data-confirm-placeholder="Grund (optional), z. B. Event-Woche"><?= icon('pause') ?></button>
|
||
<?php endif; ?>
|
||
</th>
|
||
<?php endforeach; ?>
|
||
<th scope="col" class="dues-arrears-col" title="Offene Zahlungen aus Zyklen, die schon vorbei sind">Rückstand</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php foreach ($members as $member): ?>
|
||
<tr data-dues-row="<?= (int) $member['id'] ?>" data-name="<?= e(mb_strtolower($member['name'])) ?>"
|
||
data-status="<?= e($focusStatus[$member['id']]) ?>" data-arrears="<?= (int) $arrears[$member['id']]['count'] ?>"<?= $member['active'] ? '' : ' class="is-former"' ?>>
|
||
<th scope="row" class="dues-member">
|
||
<span class="dues-member-inner">
|
||
<?= avatar_html($member, 26) ?>
|
||
<span class="dues-member-name"><?= e($member['name']) ?></span>
|
||
<?php if (!$member['active']): ?><span class="badge" title="Nicht mehr in der Legion">ehemalig</span><?php endif; ?>
|
||
</span>
|
||
</th>
|
||
<?php foreach ($visible as $id => $cycle): ?>
|
||
<td class="dues-cell-wrap<?= $current !== null && $current['id'] === $id ? ' is-current' : '' ?>">
|
||
<?= dues_cell_html($cycle, $member, dues_status($cycle, $member, $entries, $exemptions), $entries, $exemptions) ?>
|
||
</td>
|
||
<?php endforeach; ?>
|
||
<td class="dues-arrears-wrap"><?= dues_arrears_html($member['id'], $arrears[$member['id']]) ?></td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<p class="text-muted dues-no-match" data-dues-no-match hidden>Niemand passt zur Suche.</p>
|
||
</form>
|
||
<p class="dues-legend text-muted">
|
||
<span class="dues-cell is-paid" aria-hidden="true"><?= icon('check') ?></span> bezahlt
|
||
<span class="dues-cell is-open" aria-hidden="true"></span> offen
|
||
<span class="dues-cell is-exempt" aria-hidden="true"><span class="dues-cell-text">befreit</span></span>
|
||
<span class="dues-cell is-suspended" aria-hidden="true"><span class="dues-cell-text">–</span></span> ausgesetzt
|
||
<span class="dues-cell is-none" aria-hidden="true"><span class="dues-cell-text">·</span></span> noch nicht dabei
|
||
</p>
|
||
</div>
|
||
<?php elseif ($configured): ?>
|
||
<div class="panel"><p class="text-muted">Noch kein Zyklus angelegt.</p></div>
|
||
<?php endif; ?>
|
||
|
||
<?php if ($configured): ?>
|
||
<div class="panel" id="befreiungen">
|
||
<h2>Befreiungen</h2>
|
||
<p class="text-muted">
|
||
Befreite Mitglieder müssen in den gewählten Zyklen nichts zahlen – für einen Zyklus, mehrere oder bis auf Weiteres.
|
||
Einen ganzen Zyklus für alle setzt du oben in der Tabelle aus (<span class="dues-inline-icon"><?= icon('pause') ?></span>).
|
||
</p>
|
||
<form method="post" action="/admin/dues_action.php" class="dues-exempt-form">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="exempt_add">
|
||
<input type="hidden" name="bis" value="<?= $bis ?>">
|
||
<div class="dues-exempt-grid">
|
||
<fieldset class="dues-exempt-members">
|
||
<legend>Mitglieder</legend>
|
||
<label class="search-field">
|
||
<?= icon('search') ?>
|
||
<input type="search" placeholder="Mitglied suchen …" autocomplete="off" aria-label="Mitglieder für die Befreiung durchsuchen" data-dues-exempt-search>
|
||
</label>
|
||
<div class="checkbox-grid dues-member-picker" data-dues-exempt-list>
|
||
<?php foreach ($activeMembers as $member): ?>
|
||
<label data-name="<?= e(mb_strtolower($member['name'])) ?>">
|
||
<input type="checkbox" name="user_ids[]" value="<?= (int) $member['id'] ?>"> <?= e($member['name']) ?>
|
||
</label>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
</fieldset>
|
||
<div class="dues-exempt-options">
|
||
<label for="dues-exempt-from">Ab Zyklus</label>
|
||
<select id="dues-exempt-from" name="from">
|
||
<?php foreach ($fromChoices as $index => $choice): ?>
|
||
<option value="<?= e($choice['starts_on']) ?>"<?= $index === $choiceFocus ? ' selected' : '' ?>>
|
||
<?= e(dues_period_label($choice['starts_on'], $choice['ends_on'])) ?><?= $choice['starts_on'] <= $today && $choice['ends_on'] >= $today ? ' (laufend)' : ($choice['ends_on'] < $today ? ' (vorbei)' : '') ?>
|
||
</option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
<label for="dues-exempt-cycles">Für</label>
|
||
<select id="dues-exempt-cycles" name="cycles">
|
||
<?php for ($n = 1; $n <= DUES_EXEMPT_MAX_CYCLES; $n++): ?>
|
||
<option value="<?= $n ?>"><?= $n ?> <?= $n === 1 ? 'Zyklus' : 'Zyklen' ?></option>
|
||
<?php endfor; ?>
|
||
<option value="0">bis auf Weiteres</option>
|
||
</select>
|
||
<label for="dues-exempt-note">Grund <span class="text-muted">(optional)</span></label>
|
||
<input type="text" id="dues-exempt-note" name="note" maxlength="255" placeholder="z. B. Urlaub, neu dabei, Zweitaccount">
|
||
<button type="submit">Befreien</button>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
|
||
<?php if ($currentExemptions): ?>
|
||
<div class="table-scroll dues-exempt-table-wrap">
|
||
<table class="dues-exempt-table">
|
||
<thead><tr><th>Mitglied</th><th>Zeitraum</th><th>Grund</th><th>Eingetragen</th><th></th></tr></thead>
|
||
<tbody>
|
||
<?php foreach ($currentExemptions as $row): ?>
|
||
<?= dues_exemption_row_html($row, $bis, $currentEnd) ?>
|
||
<?php endforeach; ?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<?php else: ?>
|
||
<p class="text-muted">Gerade ist niemand befreit.</p>
|
||
<?php endif; ?>
|
||
<?php if ($pastExemptions): ?>
|
||
<details class="dues-past-exemptions">
|
||
<summary>Frühere Befreiungen (<?= count($pastExemptions) ?>)</summary>
|
||
<div class="table-scroll dues-exempt-table-wrap">
|
||
<table class="dues-exempt-table">
|
||
<thead><tr><th>Mitglied</th><th>Zeitraum</th><th>Grund</th><th>Eingetragen</th><th></th></tr></thead>
|
||
<tbody>
|
||
<?php foreach ($pastExemptions as $row): ?>
|
||
<?= dues_exemption_row_html($row, $bis, $currentEnd) ?>
|
||
<?php endforeach; ?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</details>
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<?php if ($configured): ?>
|
||
<div class="panel" id="erinnerungen">
|
||
<h2>Erinnerungen per Discord</h2>
|
||
<p class="text-muted">
|
||
Der Bot schreibt allen eine PN, die im laufenden Zyklus noch offen sind – wer bezahlt hat, befreit ist oder in einem
|
||
ausgesetzten Zyklus steckt, bekommt nichts. Ohne verknüpftes Discord kann der Bot niemanden erreichen.
|
||
</p>
|
||
|
||
<?php if ($current !== null): ?>
|
||
<div class="dues-remind-status">
|
||
<div class="dues-remind-now">
|
||
<div>
|
||
<strong>Laufender Zyklus <?= e(dues_period_label($current['starts_on'], $current['ends_on'])) ?>:</strong>
|
||
<?php if ($remindFound === null): ?>
|
||
ausgesetzt – niemand muss zahlen.
|
||
<?php elseif (!$remindFound['recipients'] && !$remindFound['without_discord']): ?>
|
||
niemand ist mehr offen.
|
||
<?php else: ?>
|
||
<?= count($remindFound['recipients']) + count($remindFound['without_discord']) ?> offen<?= $remindFound['without_discord']
|
||
? ', davon ohne Discord (keine PN): ' . e(implode(', ', $remindFound['without_discord'])) : '' ?>.
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php if ($remindFound !== null && $remindFound['recipients']): ?>
|
||
<form method="post" action="/admin/dues_action.php" class="inline-form"
|
||
data-confirm="<?= e(count($remindFound['recipients']) === 1 ? 'Ein Mitglied bekommt' : count($remindFound['recipients']) . ' Mitglieder bekommen') ?> in der nächsten Minute eine PN vom Bot – mit dem gespeicherten Text."
|
||
data-confirm-title="Jetzt erinnern?" data-confirm-ok="Erinnern">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="remind_now">
|
||
<button type="submit" class="button-secondary"><?= icon('bell') ?> Jetzt erinnern</button>
|
||
</form>
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php if ($remindRuns): ?>
|
||
<ul class="dues-remind-runs">
|
||
<?php foreach ($remindRuns as $run): ?>
|
||
<li>
|
||
<span class="text-muted"><?= e((new DateTimeImmutable($run['at']))->format('d.m. H:i')) ?> · <?= e(DUES_REMIND_KIND_LABELS[$run['kind']] ?? $run['kind']) ?>:</span>
|
||
<?= $run['sent'] ?> zugestellt<?= $run['waiting'] ? ', ' . $run['waiting'] . ' unterwegs' : '' ?>
|
||
<?php if ($run['failed']): ?>
|
||
· <span class="dues-remind-failed" title="<?= e(implode("\n", array_map(static fn (string $name, string $error): string => $name . ': ' . $error, array_keys($run['failed']), $run['failed']))) ?>">nicht zustellbar: <?= e(implode(', ', array_keys($run['failed']))) ?></span>
|
||
<?php endif; ?>
|
||
</li>
|
||
<?php endforeach; ?>
|
||
</ul>
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<form method="post" action="/admin/dues_action.php" class="dues-remind-form">
|
||
<?= csrf_field() ?>
|
||
<label class="checkbox-label"><input type="checkbox" name="enabled" value="1"<?= $remind['enabled'] ? ' checked' : '' ?>> Automatisch erinnern</label>
|
||
<div class="dues-remind-when">
|
||
<label class="checkbox-label"><input type="checkbox" name="remind_start" value="1"<?= $remind['start'] ? ' checked' : '' ?>> zu Beginn des Zyklus</label>
|
||
<label class="dues-remind-inline">und nochmal, wenn noch offen,
|
||
<input type="number" name="before" min="0" max="<?= DUES_REMIND_BEFORE_MAX ?>" value="<?= (int) $remind['before'] ?>" aria-label="Tage vor dem Ende"> Tag(e) vor dem Ende</label>
|
||
<label class="dues-remind-inline">um
|
||
<select name="hour" aria-label="Uhrzeit">
|
||
<?php for ($hour = 0; $hour <= 23; $hour++): ?>
|
||
<option value="<?= $hour ?>"<?= $remind['hour'] === $hour ? ' selected' : '' ?>><?= sprintf('%02d:00', $hour) ?></option>
|
||
<?php endfor; ?>
|
||
</select> Uhr</label>
|
||
</div>
|
||
<p class="field-hint">0 Tage = keine zweite Erinnerung. In kurzen Zyklen entfällt sie, wenn der Tag nicht nach dem Beginn liegt.</p>
|
||
|
||
<label for="dues-remind-message">Nachricht</label>
|
||
<div class="dues-remind-editor">
|
||
<div class="dues-remind-toolbar" role="toolbar" aria-label="Formatierung, Platzhalter und Erwähnungen">
|
||
<button type="button" class="dues-remind-tool" data-wrap="**" title="Fett"><strong>F</strong></button>
|
||
<button type="button" class="dues-remind-tool" data-wrap="*" title="Kursiv"><em>K</em></button>
|
||
<button type="button" class="dues-remind-tool" data-wrap="__" title="Unterstrichen"><u>U</u></button>
|
||
<button type="button" class="dues-remind-tool" data-wrap="~~" title="Durchgestrichen"><s>D</s></button>
|
||
<span class="dues-remind-sep" aria-hidden="true"></span>
|
||
<?php foreach (DUES_REMIND_PLACEHOLDERS as $placeholder => $hint): ?>
|
||
<button type="button" class="dues-remind-tool dues-remind-placeholder" data-insert="<?= e($placeholder) ?>" title="<?= e($hint) ?>"><?= e($placeholder) ?></button>
|
||
<?php endforeach; ?>
|
||
<span class="dues-remind-sep" aria-hidden="true"></span>
|
||
<select class="dues-remind-mention" data-insert-select aria-label="Mitglied erwähnen">
|
||
<option value="">@ Mitglied erwähnen …</option>
|
||
<?php foreach ($remindUsers as $discordId => $name): ?>
|
||
<option value="<@<?= e($discordId) ?>>"><?= e($name) ?></option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
<?php if ($remindChannels): ?>
|
||
<select class="dues-remind-mention" data-insert-select aria-label="Kanal erwähnen">
|
||
<option value=""># Kanal erwähnen …</option>
|
||
<?php foreach ($remindChannels as $channelId => $name): ?>
|
||
<option value="<#<?= e($channelId) ?>>">#<?= e($name) ?></option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
<?php endif; ?>
|
||
</div>
|
||
<textarea id="dues-remind-message" name="message" rows="11" maxlength="<?= DUES_REMIND_MESSAGE_MAX ?>" required
|
||
data-remind-message data-default="<?= e(DUES_REMIND_DEFAULT_MESSAGE) ?>"><?= e($remind['message']) ?></textarea>
|
||
<div class="field-hint dues-remind-hint">
|
||
Formatierung wie im Discord (**fett**, *kursiv*, __unterstrichen__, ~~durchgestrichen~~, > Zitat). Erwähnte Mitglieder und
|
||
Kanäle erscheinen in der PN als Name – pingen tut der Bot damit niemanden. <span data-remind-count></span>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="dues-remind-preview-wrap">
|
||
<span class="dues-remind-preview-label">Vorschau – so sähe deine eigene PN aus</span>
|
||
<div class="dues-remind-preview" data-remind-preview
|
||
data-sample="<?= e(json_encode($remindSample, JSON_UNESCAPED_UNICODE)) ?>"
|
||
data-users="<?= e(json_encode($remindUsers, JSON_UNESCAPED_UNICODE)) ?>"
|
||
data-channels="<?= e(json_encode($remindChannels, JSON_UNESCAPED_UNICODE)) ?>"></div>
|
||
</div>
|
||
|
||
<div class="actions dues-remind-actions">
|
||
<button type="submit" name="action" value="remind_settings">Erinnerungen speichern</button>
|
||
<button type="submit" name="action" value="remind_test" class="button-secondary"<?= empty($me['discord_id']) ? ' disabled title="Verknüpfe zuerst dein Discord im Profil"' : '' ?>>Testnachricht an mich</button>
|
||
<button type="button" class="button-secondary" data-remind-default>Standardtext</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<div class="panel" id="einstellungen">
|
||
<h2><?= $configured ? 'Einstellungen' : 'Beiträge einrichten' ?></h2>
|
||
<form method="post" action="/admin/dues_action.php" class="dues-settings-form">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="settings">
|
||
<div class="dues-settings-row">
|
||
<div>
|
||
<label for="dues-amount">Beitrag je Mitglied und Zyklus</label>
|
||
<div class="dues-amount-field">
|
||
<input type="text" id="dues-amount" name="amount" inputmode="numeric" required maxlength="20"
|
||
value="<?= $settings['amount'] > 0 ? e(number_format($settings['amount'], 0, ',', '.')) : '' ?>" placeholder="z. B. 500.000">
|
||
<span>Kina</span>
|
||
</div>
|
||
<div class="field-hint">Auch mit Kürzel wie im Spiel: 500k, 1,5kk, 2 Mio.</div>
|
||
</div>
|
||
<div>
|
||
<label for="dues-every">Rhythmus</label>
|
||
<div class="dues-rhythm-field">
|
||
<span>alle</span>
|
||
<input type="number" id="dues-every" name="every" min="1" max="<?= DUES_EVERY_MAX ?>" step="1" required value="<?= (int) $settings['every'] ?>">
|
||
<select name="unit" aria-label="Einheit">
|
||
<?php foreach (DUES_UNITS as $unit => [$one, $many]): ?>
|
||
<option value="<?= e($unit) ?>"<?= $settings['unit'] === $unit ? ' selected' : '' ?>><?= e($one) ?>(n)</option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
</div>
|
||
<div class="field-hint">z. B. alle 1 Woche = wöchentlich, alle 1 Monat = monatlich.</div>
|
||
</div>
|
||
<div>
|
||
<label for="dues-start">Erster Zyklus beginnt am</label>
|
||
<?php if ($hasData): ?>
|
||
<p class="dues-fixed"><?= e($dateLabel($settings['start'])) ?></p>
|
||
<div class="field-hint">Steht fest, sobald etwas abgehakt oder ausgesetzt ist.</div>
|
||
<?php else: ?>
|
||
<input type="date" id="dues-start" name="start" required value="<?= e($settings['start'] ?? $today) ?>"
|
||
min="<?= e(dues_day_shift($today, -366)) ?>" max="<?= e(dues_day_shift($today, 366)) ?>">
|
||
<div class="field-hint">Monatlich: an diesem Tag jeden Monat. Liegt er zurück, entstehen die Zyklen seitdem.</div>
|
||
<?php endif; ?>
|
||
</div>
|
||
</div>
|
||
<?php if ($hasData && $current !== null && !$current['suspended']): ?>
|
||
<label class="checkbox-label">
|
||
<input type="checkbox" name="apply_current" value="1">
|
||
Neuen Betrag schon für den laufenden Zyklus (<?= e(dues_period_label($current['starts_on'], $current['ends_on'])) ?>) übernehmen
|
||
</label>
|
||
<?php endif; ?>
|
||
<p class="field-hint">
|
||
<?php if ($hasData): ?>
|
||
Ein neuer Betrag gilt für alle kommenden Zyklen. Ein neuer Rhythmus beginnt nach dem laufenden Zyklus (bzw. nach dem letzten, in dem schon
|
||
etwas abgehakt oder der ausgesetzt ist); vergangene Zyklen bleiben, wie sie waren.
|
||
<?php else: ?>
|
||
Solange nichts abgehakt oder ausgesetzt ist, rechnet jede Änderung alle Zyklen neu – du kannst also gefahrlos ausprobieren.
|
||
<?php endif; ?>
|
||
</p>
|
||
<button type="submit"><?= $configured ? 'Einstellungen speichern' : 'Beiträge einrichten' ?></button>
|
||
</form>
|
||
</div>
|
||
|
||
<script src="<?= e(asset_url('/assets/js/dues.js')) ?>" defer></script>
|
||
<?php if ($configured): ?>
|
||
<script src="<?= e(asset_url('/assets/js/dues-remind.js')) ?>" defer></script>
|
||
<?php endif; ?>
|
||
<?php include __DIR__ . '/../includes/footer.php'; ?>
|