Files
karczma-aplikacja-stoliki/public/qr.html
2026-04-30 20:21:29 +02:00

222 lines
6.8 KiB
HTML

<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<title>Generator QR - Stoliki</title>
<style>
/* Ustawienia strony A4 i druku */
@page {
size: A4;
margin: 10mm;
}
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background: #f0f0f0;
}
.container {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
background: white;
width: 210mm; /* Szerokość A4 */
margin: 0 auto;
min-height: 297mm;
}
/* Styl pojedynczego kafelka ze stolikiem */
.qr-card {
width: 48mm; /* ok. 4 kody w rzędzie */
height: 60mm;
border: 1px solid #eee;
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 5px;
text-align: center;
}
.label {
font-weight: bold;
font-size: 14pt;
margin-bottom: 10px;
}
img {
width: 35mm;
height: 35mm;
}
.footer-text {
font-size: 8pt;
color: #666;
margin-top: 5px;
}
/* Ukryj menu podczas drukowania */
@media print {
.no-print { display: none !important; }
body { background: white; }
.container { box-shadow: none; margin: 0; width: 100%; min-height: auto; }
.qr-card { page-break-inside: avoid; }
}
.no-print {
padding: 20px;
text-align: center;
background: #222;
color: white;
}
.no-print .controls-panel {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 15px;
margin-bottom: 15px;
}
.control-box {
background: #333;
padding: 15px;
border-radius: 8px;
display: flex;
flex-direction: column;
gap: 10px;
align-items: center;
}
.control-box p {
margin: 0;
font-weight: bold;
font-size: 14px;
}
.no-print input {
padding: 8px 12px;
font-size: 15px;
border: 1px solid #555;
border-radius: 4px;
background: #fff;
color: #000;
}
.no-print button {
padding: 8px 16px;
font-size: 15px;
cursor: pointer;
border: none;
border-radius: 4px;
background: #4a5568;
color: white;
font-weight: bold;
transition: 0.2s;
}
.no-print button:hover {
background: #2d3748;
}
.btn-print {
background: #e2b07e !important;
color: #000 !important;
}
.btn-print:hover {
background: #cc9f70 !important;
}
.btn-danger {
background: #e53e3e !important;
}
.btn-danger:hover {
background: #c53030 !important;
}
</style>
</head>
<body>
<div class="no-print">
<h1 style="margin-top:0;">Generator kodów QR dla stolików</h1>
<div class="controls-panel">
<div class="control-box">
<p>Dodaj pojedynczy stolik</p>
<div style="display:flex; gap:8px;">
<input type="text" id="customTableInput" placeholder="Np. 12A, VIP, 5..." style="width: 140px;">
<button onclick="addCustomTable()">Dodaj</button>
</div>
</div>
<div class="control-box">
<p>Wygeneruj zakres od 1 do...</p>
<div style="display:flex; gap:8px;">
<input type="number" id="bulkCountInput" value="20" style="width: 80px;">
<button onclick="generateBulk()">Generuj</button>
</div>
</div>
<div class="control-box">
<p>Adres bazowy URL aplikacji</p>
<div style="display:flex; gap:8px;">
<input type="text" id="baseUrlInput" value="http://192.168.20.84:3000/stolik2.html?table=" style="width: 320px;">
</div>
</div>
</div>
<div>
<button class="btn-print" onclick="window.print()">🖨️ Drukuj arkusz (Ctrl + P)</button>
<button class="btn-danger" onclick="clearGrid()" style="margin-left:10px;">🗑️ Wyczyść grid</button>
</div>
</div>
<div class="container" id="target">
<!-- Kody QR będą tutaj generowane -->
</div>
<script>
const target = document.getElementById('target');
function createQrCard(tableId) {
// Pobierz aktualny baseURL z inputa
const baseUrl = document.getElementById('baseUrlInput').value.trim();
const fullUrl = baseUrl + encodeURIComponent(tableId);
// Generowanie kodu przez zewnętrzne api
const qrApiUrl = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(fullUrl)}`;
const card = document.createElement('div');
card.className = 'qr-card';
card.innerHTML = `
<div class="label">STOLIK ${tableId}</div>
<img src="${qrApiUrl}" alt="QR ${tableId}">
<div class="footer-text">Zeskanuj, aby zamówić</div>
`;
target.appendChild(card);
}
function addCustomTable() {
const input = document.getElementById('customTableInput');
const val = input.value.trim();
if(!val) return;
createQrCard(val);
input.value = '';
input.focus();
}
function generateBulk() {
const count = parseInt(document.getElementById('bulkCountInput').value) || 0;
if (count > 0) {
// Jeśli chcesz przed każdą masówką wyczyścić: target.innerHTML = '';
for (let i = 1; i <= count; i++) {
createQrCard(i);
}
}
}
function clearGrid() {
target.innerHTML = '';
}
// Dodaj obsługę Entera na polu dodawania stolika
document.getElementById('customTableInput').addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
addCustomTable();
}
});
// Przy starcie wygeneruj kody tak jak było wcześniej
document.addEventListener('DOMContentLoaded', () => {
generateBulk();
});
</script>
</body>
</html>