145 lines
5.4 KiB
PHP
145 lines
5.4 KiB
PHP
<?php require __DIR__ . '/../partials/layout-top.php'; ?>
|
|
|
|
<section class="page-head">
|
|
<span class="eyebrow">RFID-Kaffeekasse</span>
|
|
<h1>Kartenleser einrichten</h1>
|
|
<p>Richten Sie Kartenleser ein und verbinden Sie Karten mit Mitgliedern. Eingelesene Karten erscheinen unten als Ereignisse.</p>
|
|
</section>
|
|
|
|
<div class="grid-three">
|
|
<form class="card form-card" method="post" action="<?= e(tenant_url($tenant['slug'], 'rfid')) ?>">
|
|
<?= csrf_field($csrf) ?>
|
|
<input type="hidden" name="action" value="create_device">
|
|
<label>
|
|
<span>Name für diesen Leser</span>
|
|
<input type="text" name="name" value="<?= e((string) old('name')) ?>" required>
|
|
</label>
|
|
<label>
|
|
<span>Ort am Standort</span>
|
|
<input type="text" name="location_label" value="<?= e((string) old('location_label')) ?>">
|
|
</label>
|
|
<button class="button button-primary" type="submit">Kartenleser anlegen</button>
|
|
</form>
|
|
|
|
<form class="card form-card" method="post" action="<?= e(tenant_url($tenant['slug'], 'rfid')) ?>">
|
|
<?= csrf_field($csrf) ?>
|
|
<input type="hidden" name="action" value="assign_tag">
|
|
<label>
|
|
<span>Mitglied</span>
|
|
<select name="member_id" required>
|
|
<?php foreach ($members as $member): ?>
|
|
<option value="<?= e((string) $member['id']) ?>"><?= e($member['display_name']) ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</label>
|
|
<label>
|
|
<span>Kartennummer</span>
|
|
<input type="text" name="uid" value="<?= e((string) old('uid')) ?>" required>
|
|
</label>
|
|
<label>
|
|
<span>Kartenlabel</span>
|
|
<input type="text" name="label" value="<?= e((string) old('label')) ?>">
|
|
</label>
|
|
<button class="button button-primary" type="submit">Karte mit Mitglied verbinden</button>
|
|
</form>
|
|
|
|
<section class="card">
|
|
<span class="eyebrow">Schnittstelle für den Leser</span>
|
|
<p class="muted">Der Leser sendet Ereignisse in diesem Format:</p>
|
|
<pre class="code-block">{
|
|
"device_token": "...",
|
|
"uid": "04AABBCCDD",
|
|
"event_id": "reader-0001",
|
|
"ts": "2026-06-15T09:30:00Z"
|
|
}</pre>
|
|
<p class="muted">Ein Ereignis ist noch keine Kaffeebuchung. Es zeigt zuerst, welche Karte an welchem Leser erkannt wurde.</p>
|
|
</section>
|
|
</div>
|
|
|
|
<div class="two-column">
|
|
<section class="table-card">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Kartenleser</th>
|
|
<th>Standort</th>
|
|
<th>Status</th>
|
|
<th>Geräte-Token</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if ($devices === []): ?>
|
|
<tr>
|
|
<td class="table-empty" colspan="4">Noch kein Kartenleser angelegt. Legen Sie oben den ersten Leser an.</td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
<?php foreach ($devices as $device): ?>
|
|
<tr>
|
|
<td><?= e($device['name']) ?></td>
|
|
<td><?= e((string) $device['location_label']) ?></td>
|
|
<td><?= e($device['status']) ?></td>
|
|
<td><code><?= e(substr($device['device_token'], 0, 16)) ?>...</code></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
<section class="table-card">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Karte</th>
|
|
<th>Mitglied</th>
|
|
<th>Status</th>
|
|
<th>Zuletzt</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if ($tags === []): ?>
|
|
<tr>
|
|
<td class="table-empty" colspan="4">Noch keine Karten mit Mitgliedern verbunden.</td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
<?php foreach ($tags as $tag): ?>
|
|
<tr>
|
|
<td><?= e((string) ($tag['label'] ?: 'ohne Label')) ?></td>
|
|
<td><?= e((string) $tag['member_name']) ?></td>
|
|
<td><?= e($tag['status']) ?></td>
|
|
<td><?= e((string) ($tag['last_seen_at'] ?? 'noch nie')) ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
</div>
|
|
|
|
<section class="table-card">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Zeit</th>
|
|
<th>Kartenleser</th>
|
|
<th>Status</th>
|
|
<th>Ereignis-ID</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if ($events === []): ?>
|
|
<tr>
|
|
<td class="table-empty" colspan="4">Noch keine Karte wurde von einem Leser gemeldet.</td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
<?php foreach ($events as $event): ?>
|
|
<tr>
|
|
<td><?= e($event['received_at']) ?></td>
|
|
<td><?= e((string) $event['device_name']) ?></td>
|
|
<td><?= e($event['status']) ?></td>
|
|
<td><?= e((string) $event['external_event_id']) ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
|
|
<?php require __DIR__ . '/../partials/layout-bottom.php'; ?>
|