Baza danych i zapis akcji przywoływania kelnera. Czekam na endpointy lub coś z KDS
This commit is contained in:
@@ -1,99 +1,111 @@
|
||||
<?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';
|
||||
$baseUrl = "https://$host/app/public/app.html?h=";
|
||||
|
||||
echo "<!DOCTYPE html>
|
||||
<html lang='pl'>
|
||||
$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 charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Generator Linków QR - Stoliki</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; padding: 20px; }
|
||||
table { border-collapse: collapse; width: 100%; max-width: 800px; }
|
||||
th, td { border: 1px solid #ccc; padding: 10px; text-align: left; }
|
||||
th { background: #eee; }
|
||||
a { color: #0066cc; text-decoration: none; }
|
||||
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: 5px 10px; background: #3b82f6; color: #fff; border: none; border-radius: 4px; cursor: pointer; }
|
||||
.btn-qr { padding: 8px 10px; background: #3b82f6; color: #fff; border: none; border-radius: 8px; cursor: pointer; }
|
||||
.btn-qr:hover { background: #2563eb; }
|
||||
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); align-items: center; justify-content: center; }
|
||||
.modal-content { background: #fff; padding: 20px; border-radius: 8px; text-align: center; max-width: 400px; width: 90%; }
|
||||
.close { float: right; font-size: 24px; font-weight: bold; cursor: pointer; line-height: 20px; }
|
||||
.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>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Linki do aplikacji (Kody QR)</h1>
|
||||
<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 (KOD QR)</th>
|
||||
<th>Bezpieczny link</th>
|
||||
<th>Akcje</th>
|
||||
</tr>";
|
||||
</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>
|
||||
|
||||
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||
$id = strtoupper($row['ID']);
|
||||
$nazwa = htmlspecialchars($row['Nazwa']);
|
||||
$link = $baseUrl . $id;
|
||||
echo "<tr>
|
||||
<td><strong>$nazwa</strong></td>
|
||||
<td style='font-size: 0.8em; color: #666;'>$id</td>
|
||||
<td><a href='$link' target='_blank'>$link</a></td>
|
||||
<td><button class='btn-qr' onclick='openQR(\"$link\", \"$nazwa\")'>Pokaż QR</button></td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
echo " </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' style='color: #3b82f6;'>Otwórz link w nowym oknie</a></p>
|
||||
<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;
|
||||
|
||||
var qrContainer = document.getElementById('qrcode');
|
||||
qrContainer.innerHTML = ''; // Wyczyść poprzedni kod
|
||||
|
||||
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
|
||||
colorDark: "#000000",
|
||||
colorLight: "#ffffff",
|
||||
correctLevel: QRCode.CorrectLevel.H
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function closeQR() {
|
||||
document.getElementById('qrModal').style.display = 'none';
|
||||
document.getElementById("qrModal").style.display = "none";
|
||||
}
|
||||
|
||||
window.onclick = function(event) {
|
||||
var modal = document.getElementById('qrModal');
|
||||
if (event.target == modal) {
|
||||
|
||||
window.onclick = function (event) {
|
||||
const modal = document.getElementById("qrModal");
|
||||
if (event.target === modal) {
|
||||
closeQR();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>";
|
||||
|
||||
</html>
|
||||
<?php
|
||||
sqlsrv_free_stmt($stmt);
|
||||
sqlsrv_close($conn);
|
||||
|
||||
Reference in New Issue
Block a user