112 lines
4.9 KiB
PHP
112 lines
4.9 KiB
PHP
<?php
|
|
require_once __DIR__ . '/auth.php';
|
|
requireAdminAuth(true);
|
|
require_once __DIR__ . '/../../config/database.php';
|
|
|
|
$tsql = "SELECT ID, Nazwa FROM dbo.NGastroStolik ORDER BY Nazwa";
|
|
$stmt = sqlsrv_query($conn, $tsql);
|
|
|
|
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
|
|
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
|
|
$scriptDir = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'] ?? '/public/staff'));
|
|
$publicDir = str_replace('\\', '/', dirname($scriptDir));
|
|
$basePath = rtrim($publicDir, '/') . '/app.html?h=';
|
|
$baseUrl = "{$scheme}://{$host}{$basePath}";
|
|
?>
|
|
<!doctype html>
|
|
<html lang="pl">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>Generator Linków QR - Stoliki</title>
|
|
<style>
|
|
body { font-family: Inter, Arial, sans-serif; padding: 20px; background: #0f172a; color: #e2e8f0; }
|
|
h1 { margin: 0 0 10px; }
|
|
p { color: #94a3b8; }
|
|
table { border-collapse: collapse; width: 100%; max-width: 1100px; background: #111827; border: 1px solid #334155; }
|
|
th, td { border: 1px solid #334155; padding: 10px; text-align: left; }
|
|
th { background: #0b1220; }
|
|
a { color: #93c5fd; text-decoration: none; }
|
|
a:hover { text-decoration: underline; }
|
|
.btn-qr { padding: 8px 10px; background: #3b82f6; color: #fff; border: none; border-radius: 8px; cursor: pointer; }
|
|
.btn-qr:hover { background: #2563eb; }
|
|
.btn-nav { display:inline-block; margin-right:8px; margin-bottom:14px; color:#cbd5e1; text-decoration:none; border:1px solid #334155; padding:8px 12px; border-radius:10px; }
|
|
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.7); align-items: center; justify-content: center; }
|
|
.modal-content { background: #111827; border:1px solid #334155; padding: 20px; border-radius: 8px; text-align: center; max-width: 420px; width: 90%; }
|
|
.close { float: right; font-size: 24px; font-weight: bold; cursor: pointer; line-height: 20px; color:#cbd5e1; }
|
|
#qrcode { margin-top: 20px; display: flex; justify-content: center; }
|
|
</style>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
|
|
</head>
|
|
<body>
|
|
<a class="btn-nav" href="index.php">Wróć do panelu admina</a>
|
|
<a class="btn-nav" href="logout.php">Wyloguj</a>
|
|
<h1>Linki do aplikacji (kody QR)</h1>
|
|
<p>Skopiuj poniższe linki lub wygeneruj z nich kody QR do umieszczenia na stolikach.</p>
|
|
<table>
|
|
<tr>
|
|
<th>Nazwa stolika</th>
|
|
<th>Hash (ID z bazy)</th>
|
|
<th>Bezpieczny link</th>
|
|
<th>Akcje</th>
|
|
</tr>
|
|
<?php while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)): ?>
|
|
<?php
|
|
$id = strtoupper((string)$row['ID']);
|
|
$nazwa = htmlspecialchars((string)$row['Nazwa'], ENT_QUOTES, 'UTF-8');
|
|
$link = $baseUrl . $id;
|
|
?>
|
|
<tr>
|
|
<td><strong><?= $nazwa ?></strong></td>
|
|
<td style="font-size:.85em;color:#94a3b8;"><?= $id ?></td>
|
|
<td><a href="<?= htmlspecialchars($link, ENT_QUOTES, 'UTF-8') ?>" target="_blank"><?= htmlspecialchars($link, ENT_QUOTES, 'UTF-8') ?></a></td>
|
|
<td><button class="btn-qr" onclick="openQR('<?= htmlspecialchars($link, ENT_QUOTES, 'UTF-8') ?>', '<?= $nazwa ?>')">Pokaż QR</button></td>
|
|
</tr>
|
|
<?php endwhile; ?>
|
|
</table>
|
|
|
|
<div id="qrModal" class="modal">
|
|
<div class="modal-content">
|
|
<span class="close" onclick="closeQR()">×</span>
|
|
<h2 id="qrTitle">Kod QR</h2>
|
|
<div id="qrcode"></div>
|
|
<p style="margin-top:20px;"><a id="qrLink" href="" target="_blank">Otwórz link w nowym oknie</a></p>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function openQR(link, nazwa) {
|
|
document.getElementById("qrModal").style.display = "flex";
|
|
document.getElementById("qrTitle").innerText = "Stolik: " + nazwa;
|
|
document.getElementById("qrLink").href = link;
|
|
|
|
const qrContainer = document.getElementById("qrcode");
|
|
qrContainer.innerHTML = "";
|
|
|
|
new QRCode(qrContainer, {
|
|
text: link,
|
|
width: 250,
|
|
height: 250,
|
|
colorDark: "#000000",
|
|
colorLight: "#ffffff",
|
|
correctLevel: QRCode.CorrectLevel.H
|
|
});
|
|
}
|
|
|
|
function closeQR() {
|
|
document.getElementById("qrModal").style.display = "none";
|
|
}
|
|
|
|
window.onclick = function (event) {
|
|
const modal = document.getElementById("qrModal");
|
|
if (event.target === modal) {
|
|
closeQR();
|
|
}
|
|
};
|
|
</script>
|
|
</body>
|
|
</html>
|
|
<?php
|
|
sqlsrv_free_stmt($stmt);
|
|
sqlsrv_close($conn);
|