Poprawka generatora QR i ukrycie imienia

This commit is contained in:
2026-05-27 15:06:53 +02:00
parent d54c93623f
commit f4fb540652
3 changed files with 104 additions and 36 deletions

View File

@@ -167,7 +167,7 @@
</div>
</div>
<!-- NAME DIALOG -->
<!-- NAME DIALOG (Tymczasowo wyłączone)
<div class="modal-overlay" id="nameModal">
<div class="modal-content" style="text-align: center;">
<div style="font-size: 48px; margin-bottom: 15px;">👋</div>
@@ -186,6 +186,7 @@
</div>
</div>
</div>
-->
<!-- BILL DIALOG -->
<div class="modal-overlay" id="billModal">

View File

@@ -28,6 +28,7 @@ const userProfileKey = "karczma_user_profile";
const USER_PROFILE_EXPIRE_MS = 180 * 24 * 60 * 60 * 1000; // ~6 months
function initUserProfile() {
return; // Funkcja tymczasowo wyłączona
try {
const raw = localStorage.getItem(userProfileKey);
let profile = null;
@@ -146,7 +147,7 @@ const msgInterval = setInterval(() => {
// Initial State
if (tableParam) {
tableLabel.textContent = `Stolik ${tableParam}`;
tableLabel.textContent = tableParam.toUpperCase().startsWith("STOLIK") ? tableParam : `Stolik ${tableParam}`;
}
function hideLoader() {
@@ -460,7 +461,7 @@ async function fetchOrders() {
if (result.status === 'success') {
if (result.tableName && result.tableName !== '') {
tableLabel.textContent = `Stolik ${result.tableName}`;
tableLabel.textContent = result.tableName.toUpperCase().startsWith("STOLIK") ? result.tableName : `Stolik ${result.tableName}`;
tableParam = result.tableName; // Aktualizacja do właściwej nazwy na poczet innych zapytań
}
@@ -758,7 +759,7 @@ window.selectDocument = function (docType) {
}
};
window.fetchGUS = function () {
window.fetchGUS = async function () {
const nip = document.getElementById("nipInput").value.replace(/[\s-]/g, '');
if (nip.length < 10) {
alert("Wprowadź poprawny numer NIP.");
@@ -768,34 +769,51 @@ window.fetchGUS = function () {
btn.textContent = "Szukam...";
btn.disabled = true;
// Symulacja pobrania z GUS
setTimeout(() => {
try {
const apiKey = "d8bdc252-e0f1-4863-97a1-826faddbc49c";
const response = await fetch(`https://api.magico.pro/v1/gus/${nip}?api_key=${apiKey}`);
const result = await response.json();
if (result.status && result.data) {
const data = result.data;
let fullStreet = data.street || '';
if (data.propertyNumber) fullStreet += ' ' + data.propertyNumber;
if (data.apartmentNumber) fullStreet += '/' + data.apartmentNumber;
billState.nip = nip;
billState.company = {
name: data.name,
street: fullStreet.trim(),
zip: data.zipCode,
city: data.city,
nip: data.nip
};
document.getElementById("cmpName").value = billState.company.name;
document.getElementById("cmpStreet").value = billState.company.street;
document.getElementById("cmpZip").value = billState.company.zip;
document.getElementById("cmpCity").value = billState.company.city;
document.getElementById("cmpNip").value = "NIP: " + billState.company.nip;
// reset do readonly
document.getElementById("cmpName").readOnly = true;
document.getElementById("cmpStreet").readOnly = true;
document.getElementById("cmpZip").readOnly = true;
document.getElementById("cmpCity").readOnly = true;
document.getElementById("btnEditCompany").textContent = "Popraw ręcznie";
goToStep("stepVerify");
} else {
alert("Nie udało się pobrać danych z GUS dla podanego NIP-u.");
}
} catch (error) {
console.error("Błąd pobierania danych z GUS:", error);
alert("Błąd połączenia z API GUS.");
} finally {
btn.textContent = "Pobierz z GUS";
btn.disabled = false;
billState.nip = nip;
billState.company = {
name: "Przykładowa Firma Sp. z o.o.",
street: "ul. Gastronomiczna 12/4",
zip: "00-120",
city: "Warszawa",
nip: nip
};
document.getElementById("cmpName").value = billState.company.name;
document.getElementById("cmpStreet").value = billState.company.street;
document.getElementById("cmpZip").value = billState.company.zip;
document.getElementById("cmpCity").value = billState.company.city;
document.getElementById("cmpNip").value = "NIP: " + billState.company.nip;
// reset do readonly
document.getElementById("cmpName").readOnly = true;
document.getElementById("cmpStreet").readOnly = true;
document.getElementById("cmpZip").readOnly = true;
document.getElementById("cmpCity").readOnly = true;
document.getElementById("btnEditCompany").textContent = "Popraw ręcznie";
goToStep("stepVerify");
}, 1200);
}
};
// --- DYNAMIC MENU LOADING ---
@@ -806,19 +824,19 @@ async function loadMenu() {
const menuData = await response.json();
const container = document.getElementById('menuContainer');
if (!container) return;
container.innerHTML = '';
menuData.forEach(category => {
const catId = category.items.length > 0 ? category.items[0].categoryId : '';
const catDiv = document.createElement('div');
catDiv.className = 'rm-category';
catDiv.setAttribute('data-cat-id', catId);
let html = `<div class="restaurant-menu-category">${category.categoryName}</div>
<div class="rmc-positions">`;
category.items.forEach(item => {
html += `
<div class="rmc-position" data-position="${item.position}" data-category-id="${item.categoryId}">
@@ -830,7 +848,7 @@ async function loadMenu() {
</div>
`;
});
html += `</div>`;
catDiv.innerHTML = html;
container.appendChild(catDiv);
@@ -945,7 +963,7 @@ window.initGeolocation = function () {
return;
}
geoMsg.innerHTML = "Pobieranie lokalizacji...";
geoMsg.innerHTML = "Sprawdzamy Twoją lokalizację...";
navigator.geolocation.getCurrentPosition(
(position) => {

View File

@@ -19,7 +19,14 @@ echo "<!DOCTYPE html>
th { background: #eee; }
a { color: #0066cc; 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: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; }
#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>
<h1>Linki do aplikacji (Kody QR)</h1>
@@ -29,6 +36,7 @@ echo "<!DOCTYPE html>
<th>Nazwa stolika</th>
<th>Hash (ID z bazy)</th>
<th>Bezpieczny Link (KOD QR)</th>
<th>Akcje</th>
</tr>";
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
@@ -39,10 +47,51 @@ while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
<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()'>&times;</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>
</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
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) {
var modal = document.getElementById('qrModal');
if (event.target == modal) {
closeQR();
}
}
</script>
</body>
</html>";