Display-Seiten: Betriebszeiten, PIN, Gerätesperre, Sprache und Vorschau
All checks were successful
CI / PHP Lint (push) Successful in 34s
CI / PHP Lint-1 (push) Successful in 39s
CI / Unit Tests & Static Analysis (push) Successful in 38s
CI / PHP Lint (pull_request) Successful in 41s
CI / PHP Lint-1 (pull_request) Successful in 49s
CI / Unit Tests & Static Analysis (pull_request) Successful in 41s
All checks were successful
CI / PHP Lint (push) Successful in 34s
CI / PHP Lint-1 (push) Successful in 39s
CI / Unit Tests & Static Analysis (push) Successful in 38s
CI / PHP Lint (pull_request) Successful in 41s
CI / PHP Lint-1 (pull_request) Successful in 49s
CI / Unit Tests & Static Analysis (pull_request) Successful in 41s
Die Display-Seiten hängen an öffentlichen Links, deshalb bekommen sie Regler, mit denen sich der Missbrauch begrenzen lässt, und ein paar Komfortfunktionen für den Betrieb: - Betriebszeiten je Seite (auch über Mitternacht hinweg); außerhalb zeigt die Seite einen Hinweis statt des Buttons - Optionale PIN von der Rezeption, geprüft mit hash_equals - Wartezeit je Gerät über ein Cookie, zusätzlich zum globalen Cooldown - Feste Sprache je Seite, sonst Browsersprache; Gäste können unten umschalten - Reporting zeigt die Ausgabe pro Display-Seite - Vorschau der Seite direkt in der Administration - Backup exportiert und importiert die neuen Felder mit Migration 0007, 16 neue Sprachschlüssel, 7 zusätzliche Tests (69 Tests, 152 Assertions). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
88f40a3d21
commit
dd8e805e27
28 changed files with 478 additions and 26 deletions
|
|
@ -37,7 +37,8 @@ if (isset($_GET['export']) && isset($_GET['token']) && $auth->validateCsrfToken(
|
|||
'kiosks' => $db->fetchAll(
|
||||
"SELECT k.name, k.token, k.headline, k.subline, k.logo_url, k.background_url,
|
||||
k.bg_overlay, k.accent_color, k.card_style, k.daily_limit,
|
||||
k.cooldown_seconds, k.display_seconds, k.is_active,
|
||||
k.cooldown_seconds, k.display_seconds, k.active_from, k.active_to,
|
||||
k.device_cooldown_seconds, k.pin, k.language, k.is_active,
|
||||
s.name AS site_name, t.name AS template_name
|
||||
FROM kiosks k
|
||||
INNER JOIN sites s ON s.id = k.site_id
|
||||
|
|
@ -126,22 +127,28 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['import'])) {
|
|||
$k['logo_url'] ?? null, $k['background_url'] ?? null, (int)($k['bg_overlay'] ?? 45),
|
||||
$k['accent_color'] ?? null, ($k['card_style'] ?? 'light') === 'dark' ? 'dark' : 'light',
|
||||
(int)($k['daily_limit'] ?? 100), (int)($k['cooldown_seconds'] ?? 20),
|
||||
(int)($k['display_seconds'] ?? 90), (int)($k['is_active'] ?? 1),
|
||||
(int)($k['display_seconds'] ?? 90),
|
||||
$k['active_from'] ?? null, $k['active_to'] ?? null,
|
||||
(int)($k['device_cooldown_seconds'] ?? 0),
|
||||
$k['pin'] ?? null, $k['language'] ?? null,
|
||||
(int)($k['is_active'] ?? 1),
|
||||
];
|
||||
|
||||
if ($exists) {
|
||||
$db->query(
|
||||
"UPDATE kiosks SET site_id=?, template_id=?, name=?, headline=?, subline=?, logo_url=?,
|
||||
background_url=?, bg_overlay=?, accent_color=?, card_style=?, daily_limit=?,
|
||||
cooldown_seconds=?, display_seconds=?, is_active=? WHERE id=?",
|
||||
cooldown_seconds=?, display_seconds=?, active_from=?, active_to=?,
|
||||
device_cooldown_seconds=?, pin=?, language=?, is_active=? WHERE id=?",
|
||||
array_merge($values, [(int)$exists['id']])
|
||||
);
|
||||
} else {
|
||||
$db->query(
|
||||
"INSERT INTO kiosks (site_id, template_id, name, headline, subline, logo_url, background_url,
|
||||
bg_overlay, accent_color, card_style, daily_limit, cooldown_seconds, display_seconds,
|
||||
active_from, active_to, device_cooldown_seconds, pin, language,
|
||||
is_active, token, created_by)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||
array_merge($values, [$k['token'] ?? Kiosk::newToken(), $_SESSION['user_id'] ?? null])
|
||||
);
|
||||
}
|
||||
|
|
|
|||
117
admin/kiosks.php
117
admin/kiosks.php
|
|
@ -44,9 +44,22 @@ function kioskInput(): array
|
|||
'bg_overlay' => max(0, min(90, (int)($_POST['bg_overlay'] ?? 45))),
|
||||
'accent_color' => self_accent($_POST['accent_color'] ?? ''),
|
||||
'card_style' => ($_POST['card_style'] ?? 'light') === 'dark' ? 'dark' : 'light',
|
||||
'active_from' => self_time($_POST['active_from'] ?? ''),
|
||||
'active_to' => self_time($_POST['active_to'] ?? ''),
|
||||
'device_cooldown_seconds' => max(0, min(86400, (int)($_POST['device_cooldown_seconds'] ?? 0))),
|
||||
'pin' => preg_replace('/[^0-9A-Za-z]/', '', (string)($_POST['pin'] ?? '')) ?: null,
|
||||
'language' => in_array($_POST['language'] ?? '', ['de', 'en'], true) ? $_POST['language'] : null,
|
||||
];
|
||||
}
|
||||
|
||||
/** Uhrzeit im Format HH:MM oder nichts. */
|
||||
function self_time($value): ?string
|
||||
{
|
||||
$value = trim((string)$value);
|
||||
|
||||
return preg_match('/^([01]\d|2[0-3]):[0-5]\d$/', $value) ? $value : null;
|
||||
}
|
||||
|
||||
/** Nur echte Hex-Farben durchlassen – der Wert landet in einem style-Attribut. */
|
||||
function self_accent($value): ?string
|
||||
{
|
||||
|
|
@ -70,12 +83,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_kiosk'])) {
|
|||
$db->execute(
|
||||
"INSERT INTO kiosks (site_id, template_id, name, token, headline, subline,
|
||||
logo_url, background_url, bg_overlay, accent_color, card_style,
|
||||
daily_limit, cooldown_seconds, display_seconds, is_active, created_by)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?)",
|
||||
daily_limit, cooldown_seconds, display_seconds,
|
||||
active_from, active_to, device_cooldown_seconds, pin, language,
|
||||
is_active, created_by)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?)",
|
||||
[$in['site_id'], $in['template_id'], $in['name'], Kiosk::newToken(),
|
||||
$in['headline'], $in['subline'], $logo, $bg, $in['bg_overlay'],
|
||||
$in['accent_color'], $in['card_style'], $in['daily_limit'],
|
||||
$in['cooldown_seconds'], $in['display_seconds'], $_SESSION['user_id']]
|
||||
$in['cooldown_seconds'], $in['display_seconds'],
|
||||
$in['active_from'], $in['active_to'], $in['device_cooldown_seconds'],
|
||||
$in['pin'], $in['language'], $_SESSION['user_id']]
|
||||
);
|
||||
$auth->writeAuditLog($_SESSION['user_id'], 'kiosk_created', 'kiosk', null, $in['name']);
|
||||
$success = __('kiosks_added');
|
||||
|
|
@ -102,11 +119,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_kiosk'])) {
|
|||
$db->execute(
|
||||
"UPDATE kiosks SET site_id=?, template_id=?, name=?, headline=?, subline=?,
|
||||
logo_url=?, background_url=?, bg_overlay=?, accent_color=?, card_style=?,
|
||||
daily_limit=?, cooldown_seconds=?, display_seconds=?, is_active=?
|
||||
daily_limit=?, cooldown_seconds=?, display_seconds=?,
|
||||
active_from=?, active_to=?, device_cooldown_seconds=?, pin=?, language=?,
|
||||
is_active=?
|
||||
WHERE id=?",
|
||||
[$in['site_id'], $in['template_id'], $in['name'], $in['headline'], $in['subline'],
|
||||
$logo, $bg, $in['bg_overlay'], $in['accent_color'], $in['card_style'],
|
||||
$in['daily_limit'], $in['cooldown_seconds'], $in['display_seconds'], $in['is_active'], $id]
|
||||
$in['daily_limit'], $in['cooldown_seconds'], $in['display_seconds'],
|
||||
$in['active_from'], $in['active_to'], $in['device_cooldown_seconds'],
|
||||
$in['pin'], $in['language'], $in['is_active'], $id]
|
||||
);
|
||||
$auth->writeAuditLog($_SESSION['user_id'], 'kiosk_updated', 'kiosk', $id, $in['name']);
|
||||
$success = __('kiosks_updated');
|
||||
|
|
@ -227,6 +248,18 @@ $adminBase = '';
|
|||
<i class="fas fa-ticket" aria-hidden="true"></i>
|
||||
<?= (int)$k['total_vouchers'] ?> <?= __('kiosks_total') ?>
|
||||
</div>
|
||||
<?php if (!empty($k['active_from']) && !empty($k['active_to'])): ?>
|
||||
<div class="site-info-item">
|
||||
<i class="fas fa-clock" aria-hidden="true"></i>
|
||||
<?= htmlspecialchars(substr((string)$k['active_from'], 0, 5)) ?>–<?= htmlspecialchars(substr((string)$k['active_to'], 0, 5)) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($k['pin'])): ?>
|
||||
<div class="site-info-item">
|
||||
<i class="fas fa-lock" aria-hidden="true"></i>
|
||||
<?= __('kiosks_pin') ?>: <code><?= htmlspecialchars($k['pin']) ?></code>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<label class="muted" style="display:block;margin-bottom:6px;"><?= __('kiosks_link') ?></label>
|
||||
|
|
@ -248,6 +281,10 @@ $adminBase = '';
|
|||
onclick="showQr('<?= htmlspecialchars($url, ENT_QUOTES) ?>', '<?= htmlspecialchars($k['name'], ENT_QUOTES) ?>')">
|
||||
<i class="fas fa-qrcode" aria-hidden="true"></i> <?= __('kiosks_qr') ?>
|
||||
</button>
|
||||
<button class="btn btn-secondary btn-sm" type="button"
|
||||
onclick="showPreview('<?= htmlspecialchars($url, ENT_QUOTES) ?>', '<?= htmlspecialchars($k['name'], ENT_QUOTES) ?>')">
|
||||
<i class="fas fa-eye" aria-hidden="true"></i> <?= __('kiosks_preview') ?>
|
||||
</button>
|
||||
<button class="btn btn-secondary btn-sm" type="button"
|
||||
onclick='openEditModal(<?= json_encode([
|
||||
"id" => (int)$k["id"], "site_id" => (int)$k["site_id"],
|
||||
|
|
@ -256,6 +293,10 @@ $adminBase = '';
|
|||
"logo_url" => $k["logo_url"], "background_url" => $k["background_url"],
|
||||
"bg_overlay" => (int)$k["bg_overlay"], "accent_color" => $k["accent_color"],
|
||||
"card_style" => $k["card_style"],
|
||||
"active_from" => $k["active_from"] ? substr((string)$k["active_from"], 0, 5) : "",
|
||||
"active_to" => $k["active_to"] ? substr((string)$k["active_to"], 0, 5) : "",
|
||||
"device_cooldown_seconds" => (int)$k["device_cooldown_seconds"],
|
||||
"pin" => $k["pin"], "language" => $k["language"],
|
||||
"daily_limit" => (int)$k["daily_limit"],
|
||||
"cooldown_seconds" => (int)$k["cooldown_seconds"],
|
||||
"display_seconds" => (int)$k["display_seconds"],
|
||||
|
|
@ -384,6 +425,41 @@ $adminBase = '';
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label for="active_from"><?= __('kiosks_schedule') ?></label>
|
||||
<div style="display:flex;gap:8px;align-items:center;">
|
||||
<span class="muted"><?= __('kiosks_schedule_from') ?></span>
|
||||
<input type="time" id="active_from" name="active_from">
|
||||
<span class="muted"><?= __('kiosks_schedule_to') ?></span>
|
||||
<input type="time" id="active_to" name="active_to">
|
||||
</div>
|
||||
<div class="help-text"><?= __('kiosks_schedule_hint') ?></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="device_cooldown_seconds"><?= __('kiosks_device_cooldown') ?></label>
|
||||
<input type="number" id="device_cooldown_seconds" name="device_cooldown_seconds" min="0" max="86400" value="0">
|
||||
<div class="help-text"><?= __('kiosks_device_cooldown_hint') ?></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label for="pin"><?= __('kiosks_pin') ?></label>
|
||||
<input type="text" id="pin" name="pin" maxlength="12" autocomplete="off">
|
||||
<div class="help-text"><?= __('kiosks_pin_hint') ?></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="language"><?= __('kiosks_language') ?></label>
|
||||
<select id="language" name="language">
|
||||
<option value=""><?= __('kiosks_language_auto') ?></option>
|
||||
<?php foreach (I18n::getAvailable() as $code => $label): ?>
|
||||
<option value="<?= $code ?>"><?= htmlspecialchars($label) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="checkbox-group" id="activeRow" style="display:none;">
|
||||
<input type="checkbox" id="is_active" name="is_active" checked>
|
||||
<label for="is_active"><?= __('kiosks_active') ?></label>
|
||||
|
|
@ -402,6 +478,20 @@ $adminBase = '';
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Vorschau der Display-Seite -->
|
||||
<div class="modal" id="previewModal">
|
||||
<div class="modal-content" style="max-width:900px;" role="dialog" aria-modal="true">
|
||||
<div class="modal-header">
|
||||
<h2 class="modal-title" id="previewTitle"><?= __('kiosks_preview') ?></h2>
|
||||
<button class="modal-close" type="button" onclick="closePreview()" aria-label="<?= __('btn_cancel') ?>">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<iframe id="previewFrame" class="kiosk-preview-frame" title="<?= __('kiosks_preview') ?>" src="about:blank"></iframe>
|
||||
<p class="help-text" style="margin-top:12px;"><?= __('kiosks_preview_hint') ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- QR-Code des Links -->
|
||||
<div class="modal" id="qrModal">
|
||||
<div class="modal-content" style="max-width:420px;" role="dialog" aria-modal="true">
|
||||
|
|
@ -441,6 +531,11 @@ function openEditModal(data) {
|
|||
document.getElementById('template_id').value = data.template_id || 0;
|
||||
document.getElementById('headline').value = data.headline || '';
|
||||
document.getElementById('subline').value = data.subline || '';
|
||||
document.getElementById('active_from').value = data.active_from || '';
|
||||
document.getElementById('active_to').value = data.active_to || '';
|
||||
document.getElementById('device_cooldown_seconds').value = data.device_cooldown_seconds;
|
||||
document.getElementById('pin').value = data.pin || '';
|
||||
document.getElementById('language').value = data.language || '';
|
||||
document.getElementById('bg_overlay').value = data.bg_overlay;
|
||||
document.getElementById('accent_color').value = data.accent_color || '';
|
||||
document.getElementById('card_style').value = data.card_style || 'light';
|
||||
|
|
@ -487,6 +582,18 @@ function showQr(url, name) {
|
|||
|
||||
function closeQr() { document.getElementById('qrModal').classList.remove('active'); }
|
||||
|
||||
function showPreview(url, name) {
|
||||
document.getElementById('previewTitle').textContent = name;
|
||||
// cache-buster, damit Änderungen sofort sichtbar sind
|
||||
document.getElementById('previewFrame').src = url + '&preview=' + Date.now();
|
||||
document.getElementById('previewModal').classList.add('active');
|
||||
}
|
||||
|
||||
function closePreview() {
|
||||
document.getElementById('previewModal').classList.remove('active');
|
||||
document.getElementById('previewFrame').src = 'about:blank';
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (e.key === 'Escape') { closeModal(); closeQr(); }
|
||||
});
|
||||
|
|
|
|||
|
|
@ -88,6 +88,24 @@ $chartLabels = array_map(fn($r) => date('d.m', strtotime($r['d'])), $daily);
|
|||
$chartData = array_map(fn($r) => (int)$r['c'], $daily);
|
||||
|
||||
$csrf = $auth->getCsrfToken();
|
||||
// Auswertung der Display-Seiten: woher kommen die Codes?
|
||||
try {
|
||||
$perKiosk = $db->fetchAll(
|
||||
"SELECT k.name, s.name AS site_name,
|
||||
COUNT(v.id) AS total,
|
||||
SUM(CASE WHEN v.created_at >= DATE_SUB(NOW(), INTERVAL ? DAY) THEN 1 ELSE 0 END) AS in_period
|
||||
FROM kiosks k
|
||||
INNER JOIN sites s ON s.id = k.site_id
|
||||
LEFT JOIN vouchers v ON v.kiosk_id = k.id
|
||||
GROUP BY k.id, k.name, s.name
|
||||
HAVING total > 0
|
||||
ORDER BY in_period DESC, total DESC",
|
||||
[$days]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$perKiosk = []; // Tabelle fehlt auf alten Installationen
|
||||
}
|
||||
|
||||
$currentPage = 'reports';
|
||||
$adminBase = '';
|
||||
?>
|
||||
|
|
@ -142,6 +160,19 @@ $adminBase = '';
|
|||
</table>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2><?= __('rep_per_kiosk') ?></h2>
|
||||
<?php if (empty($perKiosk)): ?>
|
||||
<p class="muted"><?= __('rep_kiosk_none') ?></p>
|
||||
<?php else: ?>
|
||||
<table><tr><th><?= __('kiosks_name') ?></th><th><?= __('label_site') ?></th><th><?= str_replace('{days}', (string)$days, __('rep_in_period')) ?></th><th><?= __('label_total') ?></th></tr>
|
||||
<?php foreach ($perKiosk as $r): ?>
|
||||
<tr><td><?= htmlspecialchars($r['name']) ?></td><td><?= htmlspecialchars($r['site_name']) ?></td><td><?= (int)$r['in_period'] ?></td><td><?= (int)$r['total'] ?></td></tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2><?= __('rep_top_users') ?></h2>
|
||||
<table><tr><th><?= __('label_user') ?></th><th><?= __('rep_col_created') ?></th></tr>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue