Porządki
This commit is contained in:
@@ -7,20 +7,22 @@ window.kitchenAnimations = [
|
||||
];
|
||||
window.selectedAnimationHtml = null;
|
||||
|
||||
const params = new URLSearchParams(location.search);
|
||||
let tableParam = (params.get("table") || "").trim();
|
||||
const params = new URLSearchParams(location.search);
|
||||
let hashParam = (params.get("h") || "").trim();
|
||||
|
||||
// Jeśli brak numeru stolika w URL – zapytaj użytkownika
|
||||
if (!tableParam) {
|
||||
const input = prompt("Podaj numer stolika:");
|
||||
// Jeśli brak hasha w URL – zapytaj użytkownika (np. do testów)
|
||||
if (!hashParam) {
|
||||
const input = prompt("Podaj bezpieczny hash stolika (wymagane):");
|
||||
const trimmed = (input || "").trim();
|
||||
if (trimmed) {
|
||||
const newUrl = new URL(location.href);
|
||||
newUrl.searchParams.set("table", trimmed);
|
||||
newUrl.searchParams.set("h", trimmed);
|
||||
location.replace(newUrl.toString());
|
||||
}
|
||||
}
|
||||
|
||||
let tableParam = ""; // Puste, zostanie uzupełnione przez backend
|
||||
|
||||
// UI Elements
|
||||
const loadingScreen = document.getElementById("loadingScreen");
|
||||
const loaderMsg = document.getElementById("loaderMsg");
|
||||
@@ -338,15 +340,20 @@ const params = new URLSearchParams(location.search);
|
||||
// API Fetch Logic
|
||||
async function fetchOrders() {
|
||||
try {
|
||||
if (!tableParam) {
|
||||
if (!hashParam) {
|
||||
updateUI([]);
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await fetch(`../api_kds.php?table=${encodeURIComponent(tableParam)}`);
|
||||
const response = await fetch(`../api/kds.php?h=${encodeURIComponent(hashParam)}`);
|
||||
const result = await response.json();
|
||||
|
||||
if (result.status === 'success') {
|
||||
if (result.tableName && result.tableName !== '') {
|
||||
tableLabel.textContent = `Stolik ${result.tableName}`;
|
||||
tableParam = result.tableName; // Aktualizacja do właściwej nazwy na poczet innych zapytań
|
||||
}
|
||||
|
||||
// API teraz samo filtruje i zwraca tylko to co nas interesuje (za pomocą mocnego wyrażenia regularnego)
|
||||
const matches = result.data;
|
||||
|
||||
@@ -434,7 +441,7 @@ const params = new URLSearchParams(location.search);
|
||||
goToStep("stepBillList");
|
||||
|
||||
try {
|
||||
const res = await fetch(`../api_bills.php?table=${encodeURIComponent(tableParam)}`);
|
||||
const res = await fetch(`../api/bills.php?h=${encodeURIComponent(hashParam)}`);
|
||||
const result = await res.json();
|
||||
|
||||
if (result.status === 'success' && result.data.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user