Files
kaffeekasse-saas/kaffeeliste.php
T
clemensandClaude Opus 4.8 eec7a2fef2 Legacy-Abbau Schritt 1: Dual-Write in die kl_*-Tabellen entfernt
Die Migration in participants/ledger_entries ist abgeschlossen: kein
Teilnehmer traegt noch eine legacy_mitarbeiter_id, kein Journaleintrag eine
legacy_table. Damit war der jeweils zweite Zweig ("Default-Mandant schreibt
zusaetzlich nach kl_Einzahlungen/kl_Kaffeeverbrauch/kl_Mitarbeiter") in
sechs Dateien nicht mehr erreichbar - er musste aber bei jeder Aenderung
mitgepflegt werden, zuletzt bei der Bemerkung fuer Einzahlungen.

Entfernt:
- Dual-Write beim Buchen: einzahlung.php, stricheintragen.php, index.php,
  jahresauswertung.php, app/imports.php, app/paypal-inbox.php
- Dual-Write in der Mitgliederverwaltung: ledger_create_participant,
  ledger_update_participant, ledger_set_participant_active,
  ledger_anonymize_participant
- die verwaisten Spiegelfunktionen ledger_mirror_legacy_payment,
  ledger_mirror_legacy_consumption und ledger_void_entry_by_legacy_id

Nebenbei behoben: kaffeeliste.php hat die Teilnehmer-Detailseite nur fuer
Mitglieder mit legacy_mitarbeiter_id verlinkt - die hat seit der Migration
niemand mehr, die Seite war also fuer alle unerreichbar. Verlinkt und
adressiert wird jetzt ueber participant_id; "user_id" bleibt als Alias
erhalten. Der Mandanten-Isolationstest prueft jetzt ledger_void_entry, also
den Pfad, den letzteneintraege.php tatsaechlich nutzt.

Pruefskripte unveraendert gegenueber der Baseline vor dem Umbau
(http-smoke 27/6, role-matrix 55/0); die Isolationspruefung steigt von
9 auf 11 PASS bei gleichem vorbestehendem Fehler.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-21 20:57:49 +02:00

108 lines
2.6 KiB
PHP

<?php
include "functions.php";
require_once __DIR__ . "/app/ledger.php";
$pdo = app_db_pdo();
$saasUser = saas_current_user($pdo);
$tenantId = 0;
$hasAccess = false;
function kaffeeliste_money(int $cents): string
{
return saas_format_money_cents($cents) . ' €';
}
if ($saasUser !== null && saas_user_has_role(['owner', 'admin', 'treasurer'], $saasUser)) {
$tenantId = (int)$saasUser['tenant_id'];
$hasAccess = true;
}
if (!$hasAccess && $saasUser === null && checkKaffeelisteAdmin($conn, $mailadress)) {
$tenant = ledger_fetch_default_tenant($pdo);
if ($tenant !== null) {
$tenantId = (int)$tenant['id'];
$hasAccess = true;
}
}
$participants = $hasAccess
? ledger_fetch_participant_summaries($pdo, $tenantId, ['active_only' => true])
: [];
include "header.php";
include "headerline.php";
include "nav.php";
?>
<section id="banner">
<div class="content">
<?php
if ($hasAccess) {
?>
<h2>Aktive Mitarbeiter mit Gesamtstand</h2>
<br>
<ul class="actions">
<li>
<form action="exportKaffeeliste.php" method="get">
<button type="submit">Kaffeeliste exportieren</button>
</form>
</li>
<li>
<form action="letzteneintraege.php" method="get">
<button type="submit">Letzten Einträge</button>
</form>
</li>
<li>
<form action="csvupload.php" method="get">
<button type="submit">CSV Upload</button>
</form>
</li>
</ul>
<br>
<table border="1" class="table table-striped table-bordered">
<tr>
<th>Name</th>
<th>E-Mail</th>
<th>Aktueller Stand</th>
<th>Gesamtausgabe (€)</th>
<th>Gesamtstriche</th>
<th>Gesamteinzahlungen</th>
</tr>
<?php
foreach ($participants as $participant) {
$participantId = (int)$participant['participant_id'];
$name = saas_html($participant['display_name']);
$email = saas_html((string)($participant['email'] ?? ''));
$balance = kaffeeliste_money((int)$participant['balance_cents']);
$totalCosts = kaffeeliste_money((int)$participant['total_costs_cents']);
$totalMarks = number_format((int)$participant['total_marks'], 0, ',', '.');
$totalPayments = kaffeeliste_money((int)$participant['total_payments_cents']);
echo "<tr>";
echo "<td><a href=\"teilnehmerauswertung.php?participant_id={$participantId}\">{$name}</a></td>";
echo "<td>{$email}</td>";
echo "<td>{$balance}</td>";
echo "<td>{$totalCosts}</td>";
echo "<td>{$totalMarks}</td>";
echo "<td>{$totalPayments}</td>";
echo "</tr>";
}
?>
</table>
<br><br>
<form action="mailversenden.php" method="get">
<button type="submit">Info-Mail versenden</button>
</form>
<?php
} else {
echo "<h2>Kein Zugriff</h2>";
}
?>
</div>
</section>
<?php include "footer.php"; ?>