Compare commits
3 Commits
8de221ba79
...
99bb83702a
| Author | SHA1 | Date | |
|---|---|---|---|
| 99bb83702a | |||
| 79a83d4d73 | |||
| 04aaa6e321 |
5
.htaccess
Normal file
5
.htaccess
Normal file
@@ -0,0 +1,5 @@
|
||||
# Gdy ten plik leży w public_html/biesiada.menu/ (nad katalogiem app/)
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteRule ^app/public/app\.html$ app/public/app.php [L,QSA]
|
||||
</IfModule>
|
||||
@@ -24,6 +24,16 @@ if (!is_array($data)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$payload = isset($data['payload']) && is_array($data['payload']) ? $data['payload'] : [];
|
||||
|
||||
if (
|
||||
(isset($data['skipAnalytics']) && $data['skipAnalytics'] === true)
|
||||
|| (isset($payload['staffPreview']) && $payload['staffPreview'] === true)
|
||||
) {
|
||||
echo json_encode(['status' => 'success', 'skipped' => true], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
$eventName = isset($data['eventName']) ? trim((string)$data['eventName']) : '';
|
||||
$sessionId = isset($data['sessionId']) ? trim((string)$data['sessionId']) : '';
|
||||
$tableId = isset($data['tableId']) ? trim((string)$data['tableId']) : null;
|
||||
@@ -31,7 +41,6 @@ $zone = isset($data['zone']) ? trim((string)$data['zone']) : null;
|
||||
$qrHash = isset($data['qrHash']) ? trim((string)$data['qrHash']) : null;
|
||||
$deviceType = isset($data['deviceType']) ? trim((string)$data['deviceType']) : null;
|
||||
$browser = isset($data['browser']) ? trim((string)$data['browser']) : null;
|
||||
$payload = isset($data['payload']) && is_array($data['payload']) ? $data['payload'] : null;
|
||||
|
||||
$allowedEvents = [
|
||||
'qr_scan',
|
||||
@@ -46,6 +55,9 @@ $allowedEvents = [
|
||||
'menu_search',
|
||||
'bill_dialog_opened',
|
||||
'bill_request_sent',
|
||||
'menu_only_entered',
|
||||
'geo_gate_prompted',
|
||||
'geo_retry_from_menu',
|
||||
];
|
||||
|
||||
if ($eventName === '' || !in_array($eventName, $allowedEvents, true)) {
|
||||
|
||||
@@ -24,7 +24,7 @@ if (!isAdminLoggedIn()) {
|
||||
}
|
||||
|
||||
$range = isset($_GET['days']) ? trim((string)$_GET['days']) : '7';
|
||||
$allowedRanges = ['7', '30', '90', 'all', 'this_year', 'last_year'];
|
||||
$allowedRanges = ['today', '7', '30', '90', 'all', 'this_year', 'last_year'];
|
||||
if (!in_array($range, $allowedRanges, true)) {
|
||||
$range = '7';
|
||||
}
|
||||
@@ -36,6 +36,15 @@ $now = new DateTimeImmutable('now');
|
||||
switch ($range) {
|
||||
case 'all':
|
||||
break;
|
||||
case 'today':
|
||||
$start = new DateTimeImmutable('today');
|
||||
$end = $start->modify('+1 day');
|
||||
$whereWindow = ' AND created_at >= :start_at AND created_at < :end_at';
|
||||
$baseParams = [
|
||||
':start_at' => $start->format('Y-m-d H:i:s'),
|
||||
':end_at' => $end->format('Y-m-d H:i:s'),
|
||||
];
|
||||
break;
|
||||
case 'this_year':
|
||||
$start = new DateTimeImmutable(date('Y-01-01 00:00:00'));
|
||||
$end = $start->modify('+1 year');
|
||||
@@ -108,7 +117,7 @@ try {
|
||||
COUNT(*) AS total
|
||||
FROM analytics_events
|
||||
WHERE 1=1 {$whereWindow}
|
||||
AND event_name IN ('qr_scan','session_start','view_menu','bill_dialog_opened','bill_request_sent','waiter_call_requested')
|
||||
AND event_name IN ('qr_scan','session_start','view_menu','bill_dialog_opened','bill_request_sent','waiter_call_requested','menu_only_entered','geo_gate_prompted','geo_retry_from_menu')
|
||||
GROUP BY event_name
|
||||
";
|
||||
$stmtFunnel = $pdo->prepare($sqlFunnel);
|
||||
@@ -157,7 +166,6 @@ try {
|
||||
created_at,
|
||||
session_id,
|
||||
table_id,
|
||||
zone,
|
||||
device_type,
|
||||
browser,
|
||||
JSON_UNQUOTE(JSON_EXTRACT(payload_json, '$.ipAddress')) AS ip_address
|
||||
@@ -186,6 +194,7 @@ try {
|
||||
SELECT
|
||||
session_id,
|
||||
MAX(CASE WHEN event_name = 'session_start' THEN 1 ELSE 0 END) AS reached_app,
|
||||
MAX(CASE WHEN event_name = 'menu_only_entered' THEN 1 ELSE 0 END) AS menu_only,
|
||||
MAX(CASE WHEN event_name = 'view_menu' THEN 1 ELSE 0 END) AS entered_menu
|
||||
FROM analytics_events
|
||||
WHERE session_id IN ({$placeholders})
|
||||
@@ -196,22 +205,87 @@ try {
|
||||
while ($flagRow = $stmtSessionFlags->fetch()) {
|
||||
$sessionOutcomes[$flagRow['session_id']] = [
|
||||
'reached_app' => (int) $flagRow['reached_app'],
|
||||
'menu_only' => (int) $flagRow['menu_only'],
|
||||
'entered_menu' => (int) $flagRow['entered_menu'],
|
||||
];
|
||||
}
|
||||
|
||||
$sqlVisitHistory = "
|
||||
SELECT session_id, created_at
|
||||
FROM analytics_events
|
||||
WHERE event_name = 'qr_scan'
|
||||
AND session_id IN ({$placeholders})
|
||||
ORDER BY session_id ASC, created_at ASC
|
||||
";
|
||||
$stmtVisitHistory = $pdo->prepare($sqlVisitHistory);
|
||||
$stmtVisitHistory->execute($sessionIds);
|
||||
$visitHistoryBySession = [];
|
||||
while ($visitRow = $stmtVisitHistory->fetch()) {
|
||||
$sid = trim((string) ($visitRow['session_id'] ?? ''));
|
||||
if ($sid === '') {
|
||||
continue;
|
||||
}
|
||||
if (!isset($visitHistoryBySession[$sid])) {
|
||||
$visitHistoryBySession[$sid] = [];
|
||||
}
|
||||
$visitHistoryBySession[$sid][] = (string) $visitRow['created_at'];
|
||||
}
|
||||
} else {
|
||||
$visitHistoryBySession = [];
|
||||
}
|
||||
|
||||
foreach ($recentOpens as &$openRow) {
|
||||
$sid = trim((string) ($openRow['session_id'] ?? ''));
|
||||
$flags = $sessionOutcomes[$sid] ?? ['reached_app' => 0, 'entered_menu' => 0];
|
||||
$flags = $sessionOutcomes[$sid] ?? ['reached_app' => 0, 'menu_only' => 0, 'entered_menu' => 0];
|
||||
$openRow['reached_app'] = $flags['reached_app'];
|
||||
$openRow['menu_only'] = $flags['menu_only'];
|
||||
$openRow['entered_menu'] = $flags['entered_menu'];
|
||||
|
||||
$visitTimes = $visitHistoryBySession[$sid] ?? [];
|
||||
$openAt = (string) ($openRow['created_at'] ?? '');
|
||||
$visitNumber = 0;
|
||||
foreach ($visitTimes as $visitAt) {
|
||||
if ($visitAt <= $openAt) {
|
||||
$visitNumber++;
|
||||
}
|
||||
}
|
||||
if ($visitNumber < 1 && $openAt !== '') {
|
||||
$visitNumber = 1;
|
||||
}
|
||||
|
||||
$openRow['visitor_id_short'] = $sid !== '' ? substr($sid, 0, 8) : null;
|
||||
$openRow['visitor_visit_number'] = $visitNumber;
|
||||
$openRow['visitor_total_visits'] = count($visitTimes);
|
||||
$openRow['visitor_first_seen_at'] = $visitTimes[0] ?? null;
|
||||
$openRow['visitor_is_returning'] = $visitNumber > 1 ? 1 : 0;
|
||||
}
|
||||
unset($openRow);
|
||||
|
||||
$sqlVisitorSummary = "
|
||||
SELECT
|
||||
COUNT(DISTINCT session_id) AS unique_visitors,
|
||||
SUM(CASE WHEN scan_count > 1 THEN 1 ELSE 0 END) AS returning_visitors
|
||||
FROM (
|
||||
SELECT session_id, COUNT(*) AS scan_count
|
||||
FROM analytics_events
|
||||
WHERE event_name = 'qr_scan' {$whereWindow}
|
||||
GROUP BY session_id
|
||||
) visitor_counts
|
||||
";
|
||||
$stmtVisitorSummary = $pdo->prepare($sqlVisitorSummary);
|
||||
$stmtVisitorSummary->execute($baseParams);
|
||||
$visitorSummaryRow = $stmtVisitorSummary->fetch() ?: [
|
||||
'unique_visitors' => 0,
|
||||
'returning_visitors' => 0,
|
||||
];
|
||||
$uniqueVisitors = (int) $visitorSummaryRow['unique_visitors'];
|
||||
$returningVisitors = (int) $visitorSummaryRow['returning_visitors'];
|
||||
|
||||
$sqlQueueSummary = "
|
||||
SELECT
|
||||
COUNT(*) AS total_actions,
|
||||
SUM(CASE WHEN message_type = 'waiter_call' THEN 1 ELSE 0 END) AS waiter_calls,
|
||||
SUM(CASE WHEN message_type = 'bill_request' THEN 1 ELSE 0 END) AS bill_requests,
|
||||
SUM(CASE WHEN api_sent = 0 THEN 1 ELSE 0 END) AS pending_api,
|
||||
SUM(CASE WHEN status_kds = 0 THEN 1 ELSE 0 END) AS pending_kds,
|
||||
SUM(CASE WHEN status_kds = 1 THEN 1 ELSE 0 END) AS done_kds
|
||||
@@ -222,6 +296,8 @@ try {
|
||||
$stmtQueueSummary->execute($baseParams);
|
||||
$queueSummary = $stmtQueueSummary->fetch() ?: [
|
||||
'total_actions' => 0,
|
||||
'waiter_calls' => 0,
|
||||
'bill_requests' => 0,
|
||||
'pending_api' => 0,
|
||||
'pending_kds' => 0,
|
||||
'done_kds' => 0,
|
||||
@@ -263,6 +339,9 @@ try {
|
||||
'bill_dialog_opened' => (int)($funnelMap['bill_dialog_opened'] ?? 0),
|
||||
'bill_request_sent' => (int)($funnelMap['bill_request_sent'] ?? 0),
|
||||
'waiter_call_requested' => (int)($funnelMap['waiter_call_requested'] ?? 0),
|
||||
'menu_only_entered' => (int)($funnelMap['menu_only_entered'] ?? 0),
|
||||
'geo_gate_prompted' => (int)($funnelMap['geo_gate_prompted'] ?? 0),
|
||||
'geo_retry_from_menu' => (int)($funnelMap['geo_retry_from_menu'] ?? 0),
|
||||
],
|
||||
'geolocation' => [
|
||||
'passed' => (int)$geo['geo_passed'],
|
||||
@@ -270,9 +349,15 @@ try {
|
||||
'bypass' => (int)$geo['geo_bypass'],
|
||||
],
|
||||
'deviceStats' => $deviceStats,
|
||||
'visitorSummary' => [
|
||||
'uniqueVisitors' => $uniqueVisitors,
|
||||
'returningVisitors' => $returningVisitors,
|
||||
],
|
||||
'recentOpens' => $recentOpens,
|
||||
'guestQueueSummary' => [
|
||||
'total' => (int)$queueSummary['total_actions'],
|
||||
'waiterCalls' => (int)$queueSummary['waiter_calls'],
|
||||
'billRequests' => (int)$queueSummary['bill_requests'],
|
||||
'pendingApi' => (int)$queueSummary['pending_api'],
|
||||
'pendingKds' => (int)$queueSummary['pending_kds'],
|
||||
'doneKds' => (int)$queueSummary['done_kds'],
|
||||
|
||||
22
api/geo_bypass.php
Normal file
22
api/geo_bypass.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
require_once __DIR__ . '/request_ip.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
|
||||
http_response_code(405);
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'Method not allowed',
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
$clientIp = getRequestClientIp();
|
||||
$bypass = isGeoBypassTrustedIp($clientIp);
|
||||
|
||||
echo json_encode([
|
||||
'status' => 'success',
|
||||
'bypassGeo' => $bypass,
|
||||
'clientIp' => $clientIp,
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
94
api/request_ip.php
Normal file
94
api/request_ip.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Adres IP klienta (pierwszy z X-Forwarded-For lub REMOTE_ADDR).
|
||||
*/
|
||||
function getRequestClientIp(): string
|
||||
{
|
||||
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$parts = explode(',', (string) $_SERVER['HTTP_X_FORWARDED_FOR']);
|
||||
|
||||
return trim($parts[0]);
|
||||
}
|
||||
|
||||
return trim((string) ($_SERVER['REMOTE_ADDR'] ?? ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* Pojedyncze IP z pominięciem geo (zewnętrzne, dev, przykładowe hosty LAN).
|
||||
*/
|
||||
function getGeoBypassTrustedIps(): array
|
||||
{
|
||||
return [
|
||||
'82.160.190.247',
|
||||
'127.0.0.1',
|
||||
'::1',
|
||||
'192.168.20.84',
|
||||
'10.0.0.3',
|
||||
'10.0.0.7',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Pule wewnętrznych sieci — goście widziani przez lokalny serwer (REMOTE_ADDR z LAN).
|
||||
*/
|
||||
function getGeoBypassTrustedCidrs(): array
|
||||
{
|
||||
return [
|
||||
'10.0.0.0/24',
|
||||
];
|
||||
}
|
||||
|
||||
function normalizeClientIp(string $ip): string
|
||||
{
|
||||
if (strpos($ip, '::ffff:') === 0) {
|
||||
return substr($ip, 7);
|
||||
}
|
||||
|
||||
return $ip;
|
||||
}
|
||||
|
||||
function ipv4InCidr(string $ip, string $cidr): bool
|
||||
{
|
||||
if (!str_contains($cidr, '/')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
[$subnet, $bits] = explode('/', $cidr, 2);
|
||||
$bits = (int) $bits;
|
||||
if ($bits < 0 || $bits > 32) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$ipLong = ip2long($ip);
|
||||
$subnetLong = ip2long($subnet);
|
||||
if ($ipLong === false || $subnetLong === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$mask = $bits === 0 ? 0 : (-1 << (32 - $bits)) & 0xFFFFFFFF;
|
||||
|
||||
return ($ipLong & $mask) === ($subnetLong & $mask);
|
||||
}
|
||||
|
||||
function isGeoBypassTrustedIp(string $ip): bool
|
||||
{
|
||||
$ip = normalizeClientIp($ip);
|
||||
if ($ip === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (in_array($ip, getGeoBypassTrustedIps(), true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||
foreach (getGeoBypassTrustedCidrs() as $cidr) {
|
||||
if (ipv4InCidr($ip, $cidr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
77
api/waiter_feed.php
Normal file
77
api/waiter_feed.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
require_once __DIR__ . '/../config/database.php';
|
||||
require_once __DIR__ . '/message_text_helper.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
|
||||
http_response_code(405);
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'Method not allowed',
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$pdo = getAnalyticsPdo();
|
||||
$stmt = $pdo->query("
|
||||
SELECT
|
||||
id,
|
||||
table_id,
|
||||
message_type,
|
||||
message_text,
|
||||
otwierajacy_imie,
|
||||
otwierajacy_nazwisko,
|
||||
status_kds,
|
||||
api_sent,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM guest_action_queue
|
||||
WHERE DATE(created_at) = CURDATE()
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 500
|
||||
");
|
||||
$rows = $stmt->fetchAll();
|
||||
|
||||
$pending = 0;
|
||||
$waiterCalls = 0;
|
||||
$billRequests = 0;
|
||||
|
||||
foreach ($rows as &$row) {
|
||||
$row['id'] = (int) $row['id'];
|
||||
$row['status_kds'] = (int) $row['status_kds'];
|
||||
$row['api_sent'] = (int) $row['api_sent'];
|
||||
$row['message_text'] = normalizeQueueMessageText((string) ($row['message_text'] ?? ''));
|
||||
|
||||
if ($row['status_kds'] === 0) {
|
||||
$pending++;
|
||||
}
|
||||
if ($row['message_type'] === 'waiter_call') {
|
||||
$waiterCalls++;
|
||||
} elseif ($row['message_type'] === 'bill_request') {
|
||||
$billRequests++;
|
||||
}
|
||||
}
|
||||
unset($row);
|
||||
|
||||
echo json_encode([
|
||||
'status' => 'success',
|
||||
'date' => date('Y-m-d'),
|
||||
'count' => count($rows),
|
||||
'summary' => [
|
||||
'pending' => $pending,
|
||||
'waiter_calls' => $waiterCalls,
|
||||
'bill_requests' => $billRequests,
|
||||
],
|
||||
'polled_at' => date('Y-m-d H:i:s'),
|
||||
'poll_interval_seconds' => 15,
|
||||
'data' => $rows,
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
} catch (Throwable $e) {
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'Waiter feed fetch failed',
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
5
app/.htaccess
Normal file
5
app/.htaccess
Normal file
@@ -0,0 +1,5 @@
|
||||
# Gdy document root wskazuje na katalog app/ (URL: /public/app.html)
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteRule ^public/app\.html$ public/app.php [L,QSA]
|
||||
</IfModule>
|
||||
@@ -74,6 +74,9 @@
|
||||
<a href="public/staff/kds.php" class="dev-link kds">
|
||||
🍳 Ekran KDS (Kuchnia)
|
||||
</a>
|
||||
<a href="public/waiter/index.php" class="dev-link client">
|
||||
🛎️ Panel Kelnera (wezwania)
|
||||
</a>
|
||||
<a href="public/app.html" class="dev-link client">
|
||||
📱 Aplikacja dla Gościa (Poprosi o Hash)
|
||||
</a>
|
||||
|
||||
17
public/.htaccess
Normal file
17
public/.htaccess
Normal file
@@ -0,0 +1,17 @@
|
||||
# Aplikacja gościa: świeży HTML/PHP (w app.php dynamiczne ?v= z filemtime)
|
||||
<IfModule mod_headers.c>
|
||||
<FilesMatch "^app\.(html|php)$">
|
||||
Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
|
||||
Header set Pragma "no-cache"
|
||||
Header set Expires "0"
|
||||
</FilesMatch>
|
||||
</IfModule>
|
||||
|
||||
# Nie serwuj app.html zamiast reguły rewrite / app.php
|
||||
Options -MultiViews
|
||||
|
||||
# QR: app.html → app.php (gdy mod_rewrite działa; inaczej app.html robi redirect w JS)
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteRule ^app\.html$ app.php [L,QSA]
|
||||
</IfModule>
|
||||
348
public/app.html
348
public/app.html
@@ -1,332 +1,24 @@
|
||||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Karczma Biesiada – Twoje Zamówienie</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;600;700&family=Playfair+Display:wght@700&display=swap"
|
||||
rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/app.css">
|
||||
</head>
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Expires" content="0">
|
||||
<title>Karczma Biesiada – przekierowanie</title>
|
||||
<script>
|
||||
(function () {
|
||||
var target = "app.php" + window.location.search + window.location.hash;
|
||||
window.location.replace(target);
|
||||
})();
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="loadingScreen">
|
||||
<div class="loader-icon"></div>
|
||||
<div class="loader-text">
|
||||
<h2>Karczma Biesiada</h2>
|
||||
<div class="loader-msg" id="loaderMsg">Łączenie z kuchnią...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="geoScreen" class="hidden">
|
||||
<div class="geo-icon">📍</div>
|
||||
<div class="geo-text">
|
||||
<h2>Prywatność i Lokalizacja</h2>
|
||||
<div class="geo-msg" id="geoMsg">
|
||||
Aby zapewnić bezpieczeństwo Twojego zamówienia, musimy upewnić się, że znajdujesz się na terenie
|
||||
restauracji.<br><br>Prosimy o udzielenie zgody na dostęp do lokalizacji w przeglądarce.
|
||||
</div>
|
||||
<button id="geoActionBtn" class="btn btn-primary" style="margin-top: 24px; max-width: 250px; margin-left: auto; margin-right: auto;"
|
||||
onclick="initGeolocation()">Udziel zgody / Sprawdź</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<header id="mainHeader">
|
||||
<h1 class="logo-text">Karczma Biesiada</h1>
|
||||
<div id="tableLabel" class="table-badge">Wybierz stolik</div>
|
||||
</header>
|
||||
<!-- <div id="greetingBanner"
|
||||
style="display:none; text-align:center; padding: 10px; font-weight:600; color:var(--primary); font-family:'Playfair Display', serif; font-size:18px;">
|
||||
</div> -->
|
||||
|
||||
<main id="mainContent">
|
||||
<div id="statusView" class="view-section active">
|
||||
|
||||
<section class="status-card">
|
||||
<div class="status-header">
|
||||
<div>
|
||||
<span class="status-title">Aktualny status</span>
|
||||
<div id="prepStatus" class="status-value">Oczekiwanie...</div>
|
||||
</div>
|
||||
<div id="statusIcon" style="font-size: 28px;">⏳</div>
|
||||
</div>
|
||||
|
||||
<div class="progress-container">
|
||||
<div id="progressBar" class="progress-bar"></div>
|
||||
</div>
|
||||
|
||||
<div id="statusMeta" style="font-size: 12px; color: var(--text-muted);">
|
||||
Sprawdzamy co pysznego się przygotowuje...
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="items-container" id="ordersContainer">
|
||||
<h3 id="ordersTitle">Twoje zamówione dania</h3>
|
||||
<div id="emptyState" class="empty-state hidden">
|
||||
<div class="empty-icon">📖</div>
|
||||
<p style="color: var(--text-muted)">Jeśli właśnie złożyłeś zamówienie, daj nam chwilkę na jego
|
||||
przetworzenie.</p>
|
||||
<button class="btn btn-primary" style="margin-top: 15px; padding: 12px 20px; font-size: 15px;"
|
||||
onclick="switchTab('menu')">Przeglądaj menu</button>
|
||||
</div>
|
||||
<div id="itemsList"></div>
|
||||
</section>
|
||||
|
||||
<section id="historySection" class="items-container history-section hidden">
|
||||
<h3>Twoje poprzednie zamówienia</h3>
|
||||
<p class="history-note">To są pozycje z innych wizyt, które były widoczne na tym telefonie po zeskanowaniu
|
||||
kodów QR. Jeśli kiedyś byłeś w restauracji bez skanowania kodu, tych pozycji tu nie będzie 🙂</p>
|
||||
<div id="historyList"></div>
|
||||
<div style="text-align: center; margin-top: 15px;">
|
||||
<a href="#" onclick="clearGlobalHistory(event)"
|
||||
style="font-size: 12px; color: var(--text-muted); text-decoration: underline;">Usuń historię</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div id="metaFooter" class="meta-footer"></div>
|
||||
</div> <!-- Koniec statusView -->
|
||||
|
||||
<div id="menuView" class="view-section hidden">
|
||||
<div class="menu-search-container">
|
||||
<input type="text" id="menuSearchInput" placeholder="Szukaj dania..." oninput="filterMenu()" />
|
||||
</div>
|
||||
|
||||
<div class="restaurant-menu-container">
|
||||
<nav class="menu-categories-nav">
|
||||
<ul>
|
||||
<li><a href="#" class="active" data-category-badge="0" onclick="showCategory(0)">Wszystko</a></li>
|
||||
<li><a href="#" onclick="showCategory(1)" data-category-badge="1">Przystawki</a></li>
|
||||
<li><a href="#" onclick="showCategory(2)" data-category-badge="2">Zupy</a></li>
|
||||
<li><a href="#" onclick="showCategory(3)" data-category-badge="3">Dania główne</a></li>
|
||||
<li><a href="#" onclick="showCategory(4)" data-category-badge="4">Dania swojskie</a></li>
|
||||
<li><a href="#" onclick="showCategory(5)" data-category-badge="5">Ryby</a></li>
|
||||
<li><a href="#" onclick="showCategory(7)" data-category-badge="7">Sałatki</a></li>
|
||||
<li><a href="#" onclick="showCategory(6)" data-category-badge="6">Makarony</a></li>
|
||||
<li><a href="#" onclick="showCategory(9)" data-category-badge="9">Dla dzieci</a></li>
|
||||
<li><a href="#" onclick="showCategory(8)" data-category-badge="8">Dodatki</a></li>
|
||||
<li><a href="#" onclick="showCategory(10)" data-category-badge="10">Desery</a></li>
|
||||
<li><a href="#" onclick="showCategory(11)" data-category-badge="11">Napoje</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<div class="restaurant-menu-scroll" id="menuContainer">
|
||||
<!-- Dynamiczne menu załaduje się tutaj -->
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- Koniec menuView -->
|
||||
|
||||
</main>
|
||||
|
||||
<footer style="text-align: center; padding: 10px 0 20px; margin-top: 5px;">
|
||||
<a href="https://magico.pl" target="_blank"
|
||||
style="font-size: 12px; color: var(--text-muted); text-decoration: none;">
|
||||
© Magico Software
|
||||
</a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<!-- Bottom Navigation Bar -->
|
||||
<nav class="bottom-nav" id="bottomNav" style="display: none;">
|
||||
<div class="nav-item active" onclick="switchTab('status')" id="navStatus">
|
||||
<span class="nav-icon">🍽️</span>
|
||||
<span class="nav-label">Zamówienie</span>
|
||||
</div>
|
||||
<div class="nav-item" onclick="switchTab('menu')" id="navMenu">
|
||||
<span class="nav-icon">📖</span>
|
||||
<span class="nav-label">Menu</span>
|
||||
</div>
|
||||
<div class="nav-item action-call" onclick="openWaiterDialog()">
|
||||
<span class="nav-icon">🛎️</span>
|
||||
<span class="nav-label">Kelner</span>
|
||||
</div>
|
||||
<div class="nav-item action-bill" onclick="openBillDialog()">
|
||||
<span class="nav-icon">💳</span>
|
||||
<span class="nav-label">Rachunek</span>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- WAITER DIALOG -->
|
||||
<div class="modal-overlay" id="waiterModal">
|
||||
<div class="modal-content" style="text-align: center;">
|
||||
<div style="font-size: 48px; margin-bottom: 15px;">🛎️</div>
|
||||
<h3 style="margin-top: 0; color: var(--text-main); font-family: 'Playfair Display', serif; font-size: 24px;">
|
||||
Przywołać obsługę?</h3>
|
||||
<p style="color: var(--text-muted); font-size: 15px; margin-bottom: 25px; line-height: 1.5;">
|
||||
Kelner otrzyma natychmiastowe powiadomienie na swoim panelu i podejdzie do Twojego stolika najszybciej jak to
|
||||
możliwe.
|
||||
</p>
|
||||
<div style="display: flex; gap: 12px; flex-direction: column;">
|
||||
<button class="btn btn-primary" onclick="confirmCallWaiter()" style="padding: 14px; font-size: 16px;">Tak,
|
||||
poproś kelnera</button>
|
||||
<button class="btn btn-secondary" onclick="closeWaiterDialog()" style="padding: 14px;">Anuluj</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 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>
|
||||
<h3 style="margin-top: 0; color: var(--text-main); font-family: 'Playfair Display', serif; font-size: 24px;">Podaj
|
||||
swoje imię</h3>
|
||||
<p style="color: var(--text-muted); font-size: 15px; margin-bottom: 20px; line-height: 1.5;">
|
||||
Dzięki temu będziemy mogli powitać Cię osobiście podczas Twojej wizyty!
|
||||
</p>
|
||||
<div class="input-group" style="margin-bottom: 25px; text-align: left;">
|
||||
<input type="text" id="userNameInput" class="input-field" placeholder="Twoje imię..." autocomplete="off" />
|
||||
</div>
|
||||
<div style="display: flex; gap: 12px; flex-direction: column;">
|
||||
<button class="btn btn-primary" onclick="saveUserName()" style="padding: 14px; font-size: 16px;">Idę
|
||||
dalej</button>
|
||||
<button class="btn btn-secondary" onclick="declineUserName()" style="padding: 14px;">Nie chcę podawać</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<!-- ITEM MODAL -->
|
||||
<div class="modal-overlay" id="itemModal">
|
||||
<div class="modal-content" style="padding: 0; overflow: hidden; max-width: 380px;">
|
||||
<div style="position: relative;">
|
||||
<img id="itemModalImage" src="" style="width: 100%; height: 240px; object-fit: cover; display: block;" alt="">
|
||||
<button class="close-btn" onclick="closeItemModal()" style="position: absolute; top: 10px; right: 15px; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.8); font-size: 32px; z-index: 10; background: rgba(0,0,0,0.3); width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; line-height: 1;">×</button>
|
||||
</div>
|
||||
<div style="padding: 24px; text-align: left;">
|
||||
<h3 id="itemModalTitle" style="margin-top: 0; color: var(--text-main); font-family: 'Playfair Display', serif; font-size: 24px; margin-bottom: 8px;"></h3>
|
||||
<div id="itemModalPrice" style="color: var(--primary); font-weight: 700; font-size: 20px; margin-bottom: 16px;"></div>
|
||||
<p id="itemModalDesc" style="color: var(--text-muted); font-size: 15px; line-height: 1.6; margin-bottom: 24px;"></p>
|
||||
<button class="btn btn-secondary" onclick="closeItemModal()" style="width: 100%;">Zamknij</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- BILL DIALOG -->
|
||||
<div class="modal-overlay" id="billModal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3 id="modalTitle">Rozliczenie</h3>
|
||||
<button class="close-btn" onclick="closeBillDialog()">×</button>
|
||||
</div>
|
||||
|
||||
<!-- Step 0: Loading or List of Bills -->
|
||||
<div class="step active" id="stepBillList">
|
||||
<div id="billLoading" style="text-align:center; padding: 20px;">
|
||||
⏳ Pobieranie rachunków...
|
||||
</div>
|
||||
<div id="billListContainer" class="hidden">
|
||||
<p style="margin-top:0; color:var(--text-muted); font-size:14px; margin-bottom: 20px;">Mamy kilka otwartych
|
||||
rachunków na tym stoliku. Który chcesz opłacić?</p>
|
||||
<div id="billListItems" style="display:flex; flex-direction:column; gap:10px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 0.5: Bill Review -->
|
||||
<div class="step" id="stepBillReview">
|
||||
<p style="margin-top:0; color:var(--text-muted); font-size:14px; margin-bottom: 20px;">Podsumowanie rachunku:
|
||||
</p>
|
||||
<div id="billReviewContent"
|
||||
style="background: var(--surface-light); padding: 15px; border-radius: 12px; max-height: 40vh; overflow-y: auto; margin-bottom: 15px;">
|
||||
</div>
|
||||
<div style="display:flex; justify-content:space-between; font-weight:700; font-size:18px; margin-bottom: 20px;">
|
||||
<span>Do zapłaty:</span>
|
||||
<span id="billTotalAmount" style="color:var(--primary);">0.00 PLN</span>
|
||||
</div>
|
||||
<div style="display:flex; gap:12px;">
|
||||
<button class="btn btn-secondary" style="flex:1;" onclick="goBackToBillList()"
|
||||
id="btnBackToBills">Wróć</button>
|
||||
<button class="btn btn-primary" style="flex:2;" onclick="proceedToBillPayment()">Poproś rachunek</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 1: Payment Method -->
|
||||
<div class="step" id="stepPayment">
|
||||
<p style="margin-top:0; color:var(--text-muted); font-size:14px; margin-bottom: 20px;">Wybierz preferowaną formę
|
||||
płatności:</p>
|
||||
<div class="option-grid">
|
||||
<div class="option-card" onclick="selectPayment('karta')">
|
||||
<span class="option-icon">💳</span>
|
||||
<span class="option-label">Karta</span>
|
||||
</div>
|
||||
<div class="option-card" onclick="selectPayment('gotówka')">
|
||||
<span class="option-icon">💵</span>
|
||||
<span class="option-label">Gotówka</span>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-secondary" onclick="goToStep('stepBillReview')" style="margin-top: 15px;">Wróć do
|
||||
podsumowania</button>
|
||||
</div>
|
||||
|
||||
<!-- Step 2: Document Type -->
|
||||
<div class="step" id="stepDocument">
|
||||
<p style="margin-top:0; color:var(--text-muted); font-size:14px; margin-bottom: 20px;">Jakiego dokumentu
|
||||
potrzebujesz?</p>
|
||||
<div class="option-grid">
|
||||
<div class="option-card" onclick="selectDocument('paragon')">
|
||||
<span class="option-icon">🧾</span>
|
||||
<span class="option-label">Paragon</span>
|
||||
</div>
|
||||
<div class="option-card" onclick="selectDocument('faktura')">
|
||||
<span class="option-icon">📄</span>
|
||||
<span class="option-label">Faktura</span>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-secondary" onclick="goToStep('stepPayment')" style="margin-top: 8px;">Wróć</button>
|
||||
</div>
|
||||
|
||||
<!-- Step 3: NIP Input -->
|
||||
<div class="step" id="stepNIP">
|
||||
<p style="margin-top:0; color:var(--text-muted); font-size:14px; margin-bottom: 20px;">Wprowadź NIP firmy,
|
||||
abyśmy mogli automatycznie pobrać dane.</p>
|
||||
<div class="input-group">
|
||||
<label class="input-label">Numer NIP</label>
|
||||
<input type="number" id="nipInput" class="input-field" placeholder="np. 1234567890" autocomplete="off" />
|
||||
</div>
|
||||
<div style="display:flex; gap:12px; margin-top: 24px;">
|
||||
<button class="btn btn-secondary" style="flex:1;" onclick="goToStep('stepDocument')">Wróć</button>
|
||||
<button class="btn btn-primary" style="flex:2;" onclick="fetchGUS()" id="btnGUS">Pobierz z GUS</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 4: Verify Data -->
|
||||
<div class="step" id="stepVerify">
|
||||
<p style="margin-top:0; color:var(--text-muted); font-size:14px; margin-bottom: 20px;">Czy poniższe dane do
|
||||
faktury są prawidłowe?</p>
|
||||
|
||||
<div class="company-details">
|
||||
<input type="text" id="cmpName" class="company-input" style="font-weight:700; margin-bottom:4px;" readonly />
|
||||
<input type="text" id="cmpStreet" class="company-input" placeholder="Ulica i numer" style="margin-bottom:4px;"
|
||||
readonly />
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 4px;">
|
||||
<input type="text" id="cmpZip" class="company-input" placeholder="Kod" style="flex: 1;" readonly />
|
||||
<input type="text" id="cmpCity" class="company-input" placeholder="Miasto" style="flex: 2;" readonly />
|
||||
</div>
|
||||
<input type="text" id="cmpNip" class="company-input muted" readonly />
|
||||
</div>
|
||||
|
||||
<div style="display:flex; gap:12px; flex-direction:column;">
|
||||
<button class="btn btn-primary" onclick="confirmInvoice()">Tak, poproszę fakturę!</button>
|
||||
<div style="display:flex; gap:12px;">
|
||||
<button class="btn btn-secondary" onclick="goToStep('stepNIP')">Zmień NIP</button>
|
||||
<button class="btn btn-secondary" onclick="editCompanyData()" id="btnEditCompany">Popraw ręcznie</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Toast -->
|
||||
<div class="toast" id="toastMsg">
|
||||
<span style="font-size:20px;">✓</span> <span id="toastText">Wysłano!</span>
|
||||
</div>
|
||||
|
||||
<script src="assets/js/app.js"></script>
|
||||
<p style="font-family: sans-serif; text-align: center; margin-top: 2rem; color: #333;">
|
||||
Przekierowanie do aplikacji…
|
||||
<br><br>
|
||||
<a href="app.php">Kliknij tutaj, jeśli nic się nie dzieje</a>
|
||||
</p>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
||||
390
public/app.php
Normal file
390
public/app.php
Normal file
@@ -0,0 +1,390 @@
|
||||
<?php
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
header('Expires: 0');
|
||||
|
||||
require_once __DIR__ . '/includes/asset_version.php';
|
||||
$publicDir = __DIR__;
|
||||
$vCss = publicAssetVersion($publicDir, 'assets/css/app.css');
|
||||
$vJs = publicAssetVersion($publicDir, 'assets/js/app.js');
|
||||
$vMenu = publicAssetVersion($publicDir, 'menu.json');
|
||||
?><!doctype html>
|
||||
<html lang="pl">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<!-- build: css=<?= assetVersionAttr($vCss) ?> js=<?= assetVersionAttr($vJs) ?> -->
|
||||
<title>Karczma Biesiada – Twoje Zamówienie</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;600;700&family=Playfair+Display:wght@700&display=swap"
|
||||
rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/app.css?v=<?= assetVersionAttr($vCss) ?>">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="loadingScreen">
|
||||
<div class="loader-icon"></div>
|
||||
<div class="loader-text">
|
||||
<h2>Karczma Biesiada</h2>
|
||||
<div class="loader-msg" id="loaderMsg">Łączenie z kuchnią...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="geoScreen" class="hidden">
|
||||
<div class="geo-shell">
|
||||
<div class="geo-icon">📍</div>
|
||||
<h2 class="geo-title">Witamy w Karcznie</h2>
|
||||
<p class="geo-lead" id="geoLead">
|
||||
Przeglądaj menu od razu — albo potwierdź, że jesteś u nas, aby wezwać kelnera, śledzić zamówienie i poprosić o rachunek.
|
||||
</p>
|
||||
<p class="geo-status" id="geoMsg"></p>
|
||||
|
||||
<div class="geo-actions" id="geoActions">
|
||||
<button type="button" id="geoMenuOnlyBtn" class="geo-btn geo-btn-menu">
|
||||
<span class="geo-btn-main">Przejdź do menu</span>
|
||||
<span class="geo-btn-sub">bez lokalizacji</span>
|
||||
</button>
|
||||
<button type="button" id="geoActionBtn" class="geo-btn geo-btn-locate btn btn-primary">
|
||||
<span class="geo-btn-main">Zgoda, sprawdź lokalizację</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="geo-instructions hidden" id="geoInstructions" aria-live="polite"></div>
|
||||
|
||||
<div class="geo-wifi-callout">
|
||||
<p class="geo-wifi-callout-title">📶 Wejdź bez zgody na lokalizację</p>
|
||||
<p>Połącz telefon z siecią Wi‑Fi restauracji:</p>
|
||||
<p class="geo-wifi-network"><strong>HotSpot Karczmy</strong></p>
|
||||
<p class="geo-wifi-password">Hasło: <strong>karczmabiesiada</strong></p>
|
||||
<p>Po połączeniu <strong>odśwież stronę</strong> (lub zamknij i otwórz ponownie kod QR). Aplikacja wpuści Cię <strong>bez pytania o lokalizację</strong> — z pełnym dostępem do:</p>
|
||||
<ul class="geo-wifi-list">
|
||||
<li>wezwania kelnera</li>
|
||||
<li>prośby o rachunek</li>
|
||||
<li>statusu zamówienia</li>
|
||||
<li>całej aplikacji przy stoliku</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<header id="mainHeader">
|
||||
<h1 class="logo-text">Karczma Biesiada</h1>
|
||||
<div id="tableLabel" class="table-badge">Wybierz stolik</div>
|
||||
</header>
|
||||
<!-- <div id="greetingBanner"
|
||||
style="display:none; text-align:center; padding: 10px; font-weight:600; color:var(--primary); font-family:'Playfair Display', serif; font-size:18px;">
|
||||
</div> -->
|
||||
|
||||
<main id="mainContent">
|
||||
<div id="statusView" class="view-section active">
|
||||
|
||||
<section class="status-card">
|
||||
<div class="status-header">
|
||||
<div>
|
||||
<span class="status-title">Aktualny status</span>
|
||||
<div id="prepStatus" class="status-value">Oczekiwanie...</div>
|
||||
</div>
|
||||
<div id="statusIcon" style="font-size: 28px;">⏳</div>
|
||||
</div>
|
||||
|
||||
<div class="progress-container">
|
||||
<div id="progressBar" class="progress-bar"></div>
|
||||
</div>
|
||||
|
||||
<div id="statusMeta" style="font-size: 12px; color: var(--text-muted);">
|
||||
Sprawdzamy co pysznego się przygotowuje...
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="items-container" id="ordersContainer">
|
||||
<h3 id="ordersTitle">Twoje zamówione dania</h3>
|
||||
<div id="emptyState" class="empty-state hidden">
|
||||
<div class="empty-icon">📖</div>
|
||||
<p style="color: var(--text-muted)">Jeśli właśnie złożyłeś zamówienie, daj nam chwilkę na jego
|
||||
przetworzenie.</p>
|
||||
<button class="btn btn-primary" style="margin-top: 15px; padding: 12px 20px; font-size: 15px;"
|
||||
onclick="switchTab('menu')">Przeglądaj menu</button>
|
||||
</div>
|
||||
<div id="itemsList"></div>
|
||||
</section>
|
||||
|
||||
<section id="historySection" class="items-container history-section hidden">
|
||||
<h3>Twoje poprzednie zamówienia</h3>
|
||||
<p class="history-note">To są pozycje z innych wizyt, które były widoczne na tym telefonie po zeskanowaniu
|
||||
kodów QR. Jeśli kiedyś byłeś w restauracji bez skanowania kodu, tych pozycji tu nie będzie 🙂</p>
|
||||
<div id="historyList"></div>
|
||||
<div style="text-align: center; margin-top: 15px;">
|
||||
<a href="#" onclick="clearGlobalHistory(event)"
|
||||
style="font-size: 12px; color: var(--text-muted); text-decoration: underline;">Usuń historię</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div id="metaFooter" class="meta-footer"></div>
|
||||
</div> <!-- Koniec statusView -->
|
||||
|
||||
<div id="menuView" class="view-section hidden">
|
||||
<div id="menuOnlyBanner" class="menu-only-banner is-hidden">
|
||||
<span>Potwierdź lokalizację, aby wezwać kelnera lub poprosić o rachunek.</span>
|
||||
<button type="button" class="menu-only-banner-btn" onclick="promptGeoForFullAccess()">Sprawdź teraz</button>
|
||||
</div>
|
||||
<div class="menu-search-container">
|
||||
<input type="text" id="menuSearchInput" placeholder="Szukaj dania..." oninput="filterMenu()" />
|
||||
</div>
|
||||
|
||||
<div class="restaurant-menu-container">
|
||||
<nav class="menu-categories-nav">
|
||||
<ul>
|
||||
<li><a href="#" class="active" data-category-badge="0" onclick="showCategory(0)">Wszystko</a></li>
|
||||
<li><a href="#" onclick="showCategory(1)" data-category-badge="1">Przystawki</a></li>
|
||||
<li><a href="#" onclick="showCategory(2)" data-category-badge="2">Zupy</a></li>
|
||||
<li><a href="#" onclick="showCategory(3)" data-category-badge="3">Dania główne</a></li>
|
||||
<li><a href="#" onclick="showCategory(4)" data-category-badge="4">Dania swojskie</a></li>
|
||||
<li><a href="#" onclick="showCategory(5)" data-category-badge="5">Ryby</a></li>
|
||||
<li><a href="#" onclick="showCategory(7)" data-category-badge="7">Sałatki</a></li>
|
||||
<li><a href="#" onclick="showCategory(6)" data-category-badge="6">Makarony</a></li>
|
||||
<li><a href="#" onclick="showCategory(9)" data-category-badge="9">Dla dzieci</a></li>
|
||||
<li><a href="#" onclick="showCategory(8)" data-category-badge="8">Dodatki</a></li>
|
||||
<li><a href="#" onclick="showCategory(10)" data-category-badge="10">Desery</a></li>
|
||||
<li><a href="#" onclick="showCategory(11)" data-category-badge="11">Napoje</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<div class="restaurant-menu-scroll" id="menuContainer">
|
||||
<!-- Dynamiczne menu załaduje się tutaj -->
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- Koniec menuView -->
|
||||
|
||||
</main>
|
||||
|
||||
<footer style="text-align: center; padding: 10px 0 20px; margin-top: 5px;">
|
||||
<a href="https://magico.pl" target="_blank"
|
||||
style="font-size: 12px; color: var(--text-muted); text-decoration: none;">
|
||||
© Magico Software
|
||||
</a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<!-- Bottom Navigation Bar -->
|
||||
<nav class="bottom-nav" id="bottomNav" style="display: none;">
|
||||
<div class="nav-item active" onclick="switchTab('status')" id="navStatus">
|
||||
<span class="nav-icon">🍽️</span>
|
||||
<span class="nav-label">Zamówienie</span>
|
||||
</div>
|
||||
<div class="nav-item" onclick="switchTab('menu')" id="navMenu">
|
||||
<span class="nav-icon">📖</span>
|
||||
<span class="nav-label">Menu</span>
|
||||
</div>
|
||||
<div class="nav-item action-call" onclick="openWaiterDialog()" id="navWaiter">
|
||||
<span class="nav-icon">🛎️</span>
|
||||
<span class="nav-label">Kelner</span>
|
||||
</div>
|
||||
<div class="nav-item action-bill" onclick="openBillDialog()" id="navBill">
|
||||
<span class="nav-icon">💳</span>
|
||||
<span class="nav-label">Rachunek</span>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- WAITER DIALOG -->
|
||||
<div class="modal-overlay" id="waiterModal">
|
||||
<div class="modal-content" style="text-align: center;">
|
||||
<div style="font-size: 48px; margin-bottom: 15px;">🛎️</div>
|
||||
<h3 style="margin-top: 0; color: var(--text-main); font-family: 'Playfair Display', serif; font-size: 24px;">
|
||||
Przywołać obsługę?</h3>
|
||||
<p style="color: var(--text-muted); font-size: 15px; margin-bottom: 25px; line-height: 1.5;">
|
||||
Kelner otrzyma natychmiastowe powiadomienie na swoim panelu i podejdzie do Twojego stolika najszybciej jak to
|
||||
możliwe.
|
||||
</p>
|
||||
<div style="display: flex; gap: 12px; flex-direction: column;">
|
||||
<button class="btn btn-primary" onclick="confirmCallWaiter()" style="padding: 14px; font-size: 16px;">Tak,
|
||||
poproś kelnera</button>
|
||||
<button class="btn btn-secondary" onclick="closeWaiterDialog()" style="padding: 14px;">Anuluj</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 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>
|
||||
<h3 style="margin-top: 0; color: var(--text-main); font-family: 'Playfair Display', serif; font-size: 24px;">Podaj
|
||||
swoje imię</h3>
|
||||
<p style="color: var(--text-muted); font-size: 15px; margin-bottom: 20px; line-height: 1.5;">
|
||||
Dzięki temu będziemy mogli powitać Cię osobiście podczas Twojej wizyty!
|
||||
</p>
|
||||
<div class="input-group" style="margin-bottom: 25px; text-align: left;">
|
||||
<input type="text" id="userNameInput" class="input-field" placeholder="Twoje imię..." autocomplete="off" />
|
||||
</div>
|
||||
<div style="display: flex; gap: 12px; flex-direction: column;">
|
||||
<button class="btn btn-primary" onclick="saveUserName()" style="padding: 14px; font-size: 16px;">Idę
|
||||
dalej</button>
|
||||
<button class="btn btn-secondary" onclick="declineUserName()" style="padding: 14px;">Nie chcę podawać</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<!-- ITEM MODAL -->
|
||||
<div class="modal-overlay" id="itemModal">
|
||||
<div class="modal-content item-modal-content" id="itemModalContent">
|
||||
<button type="button" class="close-btn item-modal-close" onclick="closeItemModal()" aria-label="Zamknij">×</button>
|
||||
<div class="item-modal-pane" id="itemModalPane">
|
||||
<div class="item-modal-image-wrap">
|
||||
<img id="itemModalImage" class="item-modal-image" src="" alt="">
|
||||
<div id="itemModalImagePlaceholder" class="menu-image-placeholder" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" width="48" height="48" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/>
|
||||
<circle cx="12" cy="13" r="4"/>
|
||||
</svg>
|
||||
<span>Brak zdjęcia</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item-modal-body">
|
||||
<div class="item-modal-meta">
|
||||
<span id="itemModalCounter" class="item-modal-counter"></span>
|
||||
</div>
|
||||
<h3 id="itemModalTitle" class="item-modal-title"></h3>
|
||||
<div id="itemModalPrice" class="item-modal-price"></div>
|
||||
<p id="itemModalDesc" class="item-modal-desc"></p>
|
||||
<button type="button" class="btn btn-secondary item-modal-close-btn" onclick="closeItemModal()">Zamknij</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- BILL DIALOG -->
|
||||
<div class="modal-overlay" id="billModal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3 id="modalTitle">Rozliczenie</h3>
|
||||
<button class="close-btn" onclick="closeBillDialog()">×</button>
|
||||
</div>
|
||||
|
||||
<!-- Step 0: Loading or List of Bills -->
|
||||
<div class="step active" id="stepBillList">
|
||||
<div id="billLoading" style="text-align:center; padding: 20px;">
|
||||
⏳ Pobieranie rachunków...
|
||||
</div>
|
||||
<div id="billListContainer" class="hidden">
|
||||
<p style="margin-top:0; color:var(--text-muted); font-size:14px; margin-bottom: 20px;">Mamy kilka otwartych
|
||||
rachunków na tym stoliku. Który chcesz opłacić?</p>
|
||||
<div id="billListItems" style="display:flex; flex-direction:column; gap:10px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 0.5: Bill Review -->
|
||||
<div class="step" id="stepBillReview">
|
||||
<p style="margin-top:0; color:var(--text-muted); font-size:14px; margin-bottom: 20px;">Podsumowanie rachunku:
|
||||
</p>
|
||||
<div id="billReviewContent"
|
||||
style="background: var(--surface-light); padding: 15px; border-radius: 12px; max-height: 40vh; overflow-y: auto; margin-bottom: 15px;">
|
||||
</div>
|
||||
<div style="display:flex; justify-content:space-between; font-weight:700; font-size:18px; margin-bottom: 20px;">
|
||||
<span>Do zapłaty:</span>
|
||||
<span id="billTotalAmount" style="color:var(--primary);">0.00 PLN</span>
|
||||
</div>
|
||||
<div style="display:flex; gap:12px;">
|
||||
<button class="btn btn-secondary" style="flex:1;" onclick="goBackToBillList()"
|
||||
id="btnBackToBills">Wróć</button>
|
||||
<button class="btn btn-primary" style="flex:2;" onclick="proceedToBillPayment()">Poproś rachunek</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 1: Payment Method -->
|
||||
<div class="step" id="stepPayment">
|
||||
<p style="margin-top:0; color:var(--text-muted); font-size:14px; margin-bottom: 20px;">Wybierz preferowaną formę
|
||||
płatności:</p>
|
||||
<div class="option-grid">
|
||||
<div class="option-card" onclick="selectPayment('karta')">
|
||||
<span class="option-icon">💳</span>
|
||||
<span class="option-label">Karta</span>
|
||||
</div>
|
||||
<div class="option-card" onclick="selectPayment('gotówka')">
|
||||
<span class="option-icon">💵</span>
|
||||
<span class="option-label">Gotówka</span>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-secondary" onclick="goToStep('stepBillReview')" style="margin-top: 15px;">Wróć do
|
||||
podsumowania</button>
|
||||
</div>
|
||||
|
||||
<!-- Step 2: Document Type -->
|
||||
<div class="step" id="stepDocument">
|
||||
<p style="margin-top:0; color:var(--text-muted); font-size:14px; margin-bottom: 20px;">Jakiego dokumentu
|
||||
potrzebujesz?</p>
|
||||
<div class="option-grid">
|
||||
<div class="option-card" onclick="selectDocument('paragon')">
|
||||
<span class="option-icon">🧾</span>
|
||||
<span class="option-label">Paragon</span>
|
||||
</div>
|
||||
<div class="option-card" onclick="selectDocument('faktura')">
|
||||
<span class="option-icon">📄</span>
|
||||
<span class="option-label">Faktura</span>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-secondary" onclick="goToStep('stepPayment')" style="margin-top: 8px;">Wróć</button>
|
||||
</div>
|
||||
|
||||
<!-- Step 3: NIP Input -->
|
||||
<div class="step" id="stepNIP">
|
||||
<p style="margin-top:0; color:var(--text-muted); font-size:14px; margin-bottom: 20px;">Wprowadź NIP firmy,
|
||||
abyśmy mogli automatycznie pobrać dane.</p>
|
||||
<div class="input-group">
|
||||
<label class="input-label">Numer NIP</label>
|
||||
<input type="number" id="nipInput" class="input-field" placeholder="np. 1234567890" autocomplete="off" />
|
||||
</div>
|
||||
<div style="display:flex; gap:12px; margin-top: 24px;">
|
||||
<button class="btn btn-secondary" style="flex:1;" onclick="goToStep('stepDocument')">Wróć</button>
|
||||
<button class="btn btn-primary" style="flex:2;" onclick="fetchGUS()" id="btnGUS">Pobierz z GUS</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 4: Verify Data -->
|
||||
<div class="step" id="stepVerify">
|
||||
<p style="margin-top:0; color:var(--text-muted); font-size:14px; margin-bottom: 20px;">Czy poniższe dane do
|
||||
faktury są prawidłowe?</p>
|
||||
|
||||
<div class="company-details">
|
||||
<input type="text" id="cmpName" class="company-input" style="font-weight:700; margin-bottom:4px;" readonly />
|
||||
<input type="text" id="cmpStreet" class="company-input" placeholder="Ulica i numer" style="margin-bottom:4px;"
|
||||
readonly />
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 4px;">
|
||||
<input type="text" id="cmpZip" class="company-input" placeholder="Kod" style="flex: 1;" readonly />
|
||||
<input type="text" id="cmpCity" class="company-input" placeholder="Miasto" style="flex: 2;" readonly />
|
||||
</div>
|
||||
<input type="text" id="cmpNip" class="company-input muted" readonly />
|
||||
</div>
|
||||
|
||||
<div style="display:flex; gap:12px; flex-direction:column;">
|
||||
<button class="btn btn-primary" onclick="confirmInvoice()">Tak, poproszę fakturę!</button>
|
||||
<div style="display:flex; gap:12px;">
|
||||
<button class="btn btn-secondary" onclick="goToStep('stepNIP')">Zmień NIP</button>
|
||||
<button class="btn btn-secondary" onclick="editCompanyData()" id="btnEditCompany">Popraw ręcznie</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Toast -->
|
||||
<div class="toast" id="toastMsg">
|
||||
<span style="font-size:20px;">✓</span> <span id="toastText">Wysłano!</span>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.MENU_ASSET_VERSION = <?= json_encode($vMenu, JSON_UNESCAPED_UNICODE) ?>;
|
||||
window.APP_JS_VERSION = <?= json_encode($vJs, JSON_UNESCAPED_UNICODE) ?>;
|
||||
</script>
|
||||
<script src="assets/js/app.js?v=<?= assetVersionAttr($vJs) ?>"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -71,33 +71,191 @@ body {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px;
|
||||
padding: 24px 20px;
|
||||
text-align: center;
|
||||
transition: opacity 0.5s ease, visibility 0.5s;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.geo-shell {
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.geo-icon {
|
||||
font-size: 80px;
|
||||
margin-bottom: 16px;
|
||||
font-size: 64px;
|
||||
margin-bottom: 12px;
|
||||
animation: bounce 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes bounce {
|
||||
0%, 100% { transform: translateY(0); }
|
||||
50% { transform: translateY(-15px); }
|
||||
50% { transform: translateY(-10px); }
|
||||
}
|
||||
|
||||
.geo-text h2 {
|
||||
.geo-title {
|
||||
font-family: 'Playfair Display', serif;
|
||||
margin: 0 0 12px;
|
||||
margin: 0 0 10px;
|
||||
color: var(--primary);
|
||||
font-size: 1.65rem;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.geo-lead {
|
||||
color: var(--text-muted);
|
||||
font-size: 15px;
|
||||
line-height: 1.45;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.geo-status {
|
||||
color: var(--text-muted);
|
||||
font-size: 14px;
|
||||
line-height: 1.45;
|
||||
margin: 14px 0 0;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.geo-status:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.geo-status.is-error {
|
||||
color: #ff8a8a;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.geo-status.is-info {
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
.geo-msg {
|
||||
.geo-actions {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1.2fr;
|
||||
gap: 10px;
|
||||
margin-top: 20px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.geo-btn {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 2px;
|
||||
min-height: 76px;
|
||||
padding: 12px 10px;
|
||||
border-radius: 14px;
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
line-height: 1.25;
|
||||
transition: transform 0.15s ease, box-shadow 0.15s ease;
|
||||
}
|
||||
|
||||
.geo-btn:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
.geo-btn-main {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.geo-btn-sub {
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.geo-btn-menu {
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border: 1.5px solid rgba(226, 176, 126, 0.25);
|
||||
color: var(--text-muted);
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.geo-btn-menu .geo-btn-main {
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.geo-btn-locate {
|
||||
border: none;
|
||||
box-shadow: 0 4px 18px rgba(226, 176, 126, 0.28);
|
||||
}
|
||||
|
||||
.geo-btn-locate .geo-btn-main {
|
||||
font-size: 13px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.geo-btn-locate:disabled {
|
||||
opacity: 0.65;
|
||||
cursor: wait;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.geo-instructions {
|
||||
margin-top: 16px;
|
||||
padding: 14px 16px;
|
||||
background: var(--surface-light);
|
||||
border: 1px solid rgba(226, 176, 126, 0.2);
|
||||
border-radius: 12px;
|
||||
font-size: 13px;
|
||||
line-height: 1.55;
|
||||
color: #d1d5db;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.geo-instructions.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.geo-wifi-callout {
|
||||
margin: 20px 0 0;
|
||||
padding: 16px 18px;
|
||||
background: rgba(226, 176, 126, 0.1);
|
||||
border: 1.5px solid rgba(226, 176, 126, 0.35);
|
||||
border-radius: 14px;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
margin-bottom: 16px;
|
||||
color: #e8e8ea;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.geo-wifi-callout-title {
|
||||
margin: 0 0 10px;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
.geo-wifi-callout p {
|
||||
margin: 0 0 8px;
|
||||
}
|
||||
|
||||
.geo-wifi-network,
|
||||
.geo-wifi-password {
|
||||
font-size: 15px;
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.geo-wifi-list {
|
||||
margin: 8px 0 0;
|
||||
padding-left: 20px;
|
||||
color: #d1d5db;
|
||||
}
|
||||
|
||||
.geo-wifi-list li {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.geo-wifi-list li:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 360px) {
|
||||
.geo-actions {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
/* --- MAIN LAYOUT --- */
|
||||
@@ -881,6 +1039,48 @@ header {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.nav-item.nav-locked {
|
||||
opacity: 0.48;
|
||||
filter: grayscale(0.35);
|
||||
}
|
||||
|
||||
.nav-item.nav-locked .nav-label::after {
|
||||
content: " 🔒";
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.menu-only-banner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 12px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 12px;
|
||||
background: rgba(226, 176, 126, 0.12);
|
||||
border: 1px solid rgba(226, 176, 126, 0.28);
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.menu-only-banner.is-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.menu-only-banner-btn {
|
||||
flex-shrink: 0;
|
||||
border: 1px solid rgba(226, 176, 126, 0.45);
|
||||
background: rgba(226, 176, 126, 0.15);
|
||||
color: var(--primary);
|
||||
border-radius: 999px;
|
||||
padding: 8px 14px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.nav-item:active .nav-icon {
|
||||
transform: scale(0.9);
|
||||
}
|
||||
@@ -906,6 +1106,10 @@ header {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#menuOnlyBanner.is-hidden + .menu-search-container {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
#menuSearchInput {
|
||||
width: 100%;
|
||||
background: var(--surface);
|
||||
@@ -1052,4 +1256,158 @@ header {
|
||||
content: " zł";
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
/* --- ITEM MODAL --- */
|
||||
.item-modal-content {
|
||||
position: relative;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
max-width: 380px;
|
||||
touch-action: pan-y;
|
||||
}
|
||||
|
||||
.item-modal-pane {
|
||||
transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.34s ease;
|
||||
will-change: transform, opacity;
|
||||
}
|
||||
|
||||
.item-modal-pane.is-dragging {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.item-modal-pane.is-exiting-left {
|
||||
transform: translateX(-18%);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.item-modal-pane.is-exiting-right {
|
||||
transform: translateX(18%);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.item-modal-pane.is-entering-from-right {
|
||||
transition: none;
|
||||
transform: translateX(18%);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.item-modal-pane.is-entering-from-left {
|
||||
transition: none;
|
||||
transform: translateX(-18%);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.item-modal-image-wrap {
|
||||
position: relative;
|
||||
height: 240px;
|
||||
background: var(--surface-light);
|
||||
}
|
||||
|
||||
.item-modal-image {
|
||||
width: 100%;
|
||||
height: 240px;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.menu-image-placeholder {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
color: var(--text-muted);
|
||||
background: linear-gradient(145deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.15));
|
||||
}
|
||||
|
||||
.menu-image-placeholder span {
|
||||
font-size: 13px;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.menu-image-placeholder.hidden,
|
||||
.item-modal-image.hidden,
|
||||
.rmc-image.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.rmc-image-wrap {
|
||||
position: relative;
|
||||
width: 90px;
|
||||
height: 90px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.rmc-image-wrap .menu-image-placeholder {
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.rmc-image-wrap .menu-image-placeholder svg {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
.rmc-image-wrap .menu-image-placeholder span {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.item-modal-close {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 15px;
|
||||
z-index: 12;
|
||||
color: #fff;
|
||||
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
|
||||
font-size: 32px;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.item-modal-body {
|
||||
padding: 24px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.item-modal-meta {
|
||||
min-height: 18px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.item-modal-counter {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.item-modal-title {
|
||||
margin: 0 0 8px;
|
||||
color: var(--text-main);
|
||||
font-family: 'Playfair Display', serif;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.item-modal-price {
|
||||
color: var(--primary);
|
||||
font-weight: 700;
|
||||
font-size: 20px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.item-modal-desc {
|
||||
color: var(--text-muted);
|
||||
font-size: 15px;
|
||||
line-height: 1.6;
|
||||
margin: 0 0 24px;
|
||||
}
|
||||
|
||||
.item-modal-close-btn {
|
||||
width: 100%;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
23
public/includes/asset_version.php
Normal file
23
public/includes/asset_version.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Wersja statycznego pliku w public/ — timestamp modyfikacji (cache busting po FTP).
|
||||
*/
|
||||
function publicAssetVersion(string $publicDir, string $relativePath): string
|
||||
{
|
||||
$path = $publicDir . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, ltrim($relativePath, '/'));
|
||||
if (!is_file($path)) {
|
||||
return '0';
|
||||
}
|
||||
|
||||
$mtime = filemtime($path);
|
||||
|
||||
return $mtime !== false ? (string) $mtime : '0';
|
||||
}
|
||||
|
||||
function assetVersionAttr(string $version): string
|
||||
{
|
||||
return htmlspecialchars($version, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
@@ -12,6 +12,12 @@ $scriptDir = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'] ?? '/public/
|
||||
$publicDir = str_replace('\\', '/', dirname($scriptDir));
|
||||
$basePath = rtrim($publicDir, '/') . '/app.html?h=';
|
||||
$baseUrl = "{$scheme}://{$host}{$basePath}";
|
||||
$previewQuery = 'preview=staff';
|
||||
|
||||
function appendPreviewParam(string $link, string $previewQuery): string
|
||||
{
|
||||
return str_contains($link, '?') ? $link . '&' . $previewQuery : $link . '?' . $previewQuery;
|
||||
}
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="pl">
|
||||
@@ -30,6 +36,9 @@ $baseUrl = "{$scheme}://{$host}{$basePath}";
|
||||
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-preview { display: inline-block; padding: 8px 10px; background: transparent; color: #cbd5e1; border: 1px solid #475569; border-radius: 8px; cursor: pointer; margin-left: 6px; text-decoration: none; font-size: 14px; }
|
||||
.btn-preview:hover { background: #1e293b; border-color: #64748b; color: #e2e8f0; text-decoration: none; }
|
||||
.actions-cell { white-space: nowrap; }
|
||||
.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%; }
|
||||
@@ -42,7 +51,7 @@ $baseUrl = "{$scheme}://{$host}{$basePath}";
|
||||
<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>
|
||||
<p>Skopiuj poniższe linki lub wygeneruj z nich kody QR do umieszczenia na stolikach. Podgląd admina nie trafia do analityki.</p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Nazwa stolika</th>
|
||||
@@ -55,12 +64,16 @@ $baseUrl = "{$scheme}://{$host}{$basePath}";
|
||||
$id = strtoupper((string)$row['ID']);
|
||||
$nazwa = htmlspecialchars((string)$row['Nazwa'], ENT_QUOTES, 'UTF-8');
|
||||
$link = $baseUrl . $id;
|
||||
$previewLink = appendPreviewParam($link, $previewQuery);
|
||||
?>
|
||||
<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>
|
||||
<td class="actions-cell">
|
||||
<button class="btn-qr" onclick="openQR('<?= htmlspecialchars($link, ENT_QUOTES, 'UTF-8') ?>', '<?= $nazwa ?>')">Pokaż QR</button>
|
||||
<a class="btn-preview" href="<?= htmlspecialchars($previewLink, ENT_QUOTES, 'UTF-8') ?>" target="_blank" rel="noopener">Podgląd admina</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endwhile; ?>
|
||||
</table>
|
||||
|
||||
@@ -27,6 +27,33 @@ requireAdminAuth(true);
|
||||
table { width: 100%; border-collapse: collapse; }
|
||||
th, td { border-bottom: 1px solid #263446; padding: 8px 6px; text-align: left; font-size: .9rem; }
|
||||
th { color: #cbd5e1; }
|
||||
#recentOpensBody tr.recent-open-row {
|
||||
border-left: 4px solid transparent;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.15s ease, box-shadow 0.15s ease;
|
||||
}
|
||||
#recentOpensBody tr.recent-open-row:hover {
|
||||
background-color: rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
#recentOpensBody tr.recent-open-row.session-row-highlight {
|
||||
background-color: var(--session-highlight-bg, rgba(59, 130, 246, 0.18));
|
||||
box-shadow: inset 0 0 0 1px var(--session-highlight-border, rgba(59, 130, 246, 0.45));
|
||||
}
|
||||
.visitor-cell { display: flex; align-items: flex-start; gap: 8px; }
|
||||
.visitor-session-dot {
|
||||
width: 11px;
|
||||
height: 11px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
margin-top: 3px;
|
||||
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
.visitor-session-dash {
|
||||
width: 4px;
|
||||
min-height: 34px;
|
||||
border-radius: 2px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
|
||||
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; background: #0b1220; color: var(--text); cursor: pointer; }
|
||||
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
|
||||
@@ -34,10 +61,14 @@ requireAdminAuth(true);
|
||||
.legend-list li { margin-bottom: 6px; }
|
||||
.status-ok { color: #22c55e; font-weight: 700; }
|
||||
.status-fail { color: #ef4444; font-weight: 700; }
|
||||
.status-menu { color: #fbbf24; font-weight: 700; }
|
||||
.chart-wrap { max-width: 360px; margin: 0 auto; }
|
||||
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px 20px; justify-content: center; margin-top: 12px; font-size: .88rem; color: #cbd5e1; }
|
||||
.chart-legend-item { display: flex; align-items: center; gap: 6px; }
|
||||
.chart-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
|
||||
.visitor-id { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; color: #94a3b8; }
|
||||
.visitor-new { color: var(--muted); font-size: .88rem; }
|
||||
.visitor-return { color: #fbbf24; font-weight: 600; font-size: .88rem; }
|
||||
@media (max-width: 900px) { .col-3,.col-4,.col-6,.col-8 { grid-column: span 12; } .top { flex-direction: column; align-items: flex-start; } }
|
||||
</style>
|
||||
</head>
|
||||
@@ -57,6 +88,7 @@ requireAdminAuth(true);
|
||||
|
||||
<div class="card col-12" style="margin-bottom:14px;">
|
||||
<div class="filters">
|
||||
<button class="chip" data-days="today">Dzisiaj</button>
|
||||
<button class="chip active" data-days="7">Ostatnie 7 dni</button>
|
||||
<button class="chip" data-days="30">Ostatnie 30 dni</button>
|
||||
<button class="chip" data-days="90">Ostatnie 90 dni</button>
|
||||
@@ -70,7 +102,7 @@ requireAdminAuth(true);
|
||||
<div class="card col-3"><h3>Skanowania QR</h3><div class="kpi" id="kpiScans">-</div><div class="muted">Otwarcia stron stolików</div></div>
|
||||
<div class="card col-3"><h3>Sesje</h3><div class="kpi" id="kpiSessions">-</div><div class="muted">Użytkownicy, którzy weszli do aplikacji</div></div>
|
||||
<div class="card col-3"><h3>Lokalizacja OK</h3><div class="kpi" id="kpiGeoPass">-</div><div class="muted">Pozytywna weryfikacja geolokalizacji</div></div>
|
||||
<div class="card col-3"><h3>Przywołania kelnera</h3><div class="kpi" id="kpiWaiterCall">-</div><div class="muted">Wysłane prośby o podejście obsługi</div></div>
|
||||
<div class="card col-3"><h3>Przywołania kelnera</h3><div class="kpi" id="kpiWaiterCall">-</div><div class="muted">Wpisy w kolejce gościa (KDS)</div></div>
|
||||
|
||||
<div class="card col-8">
|
||||
<h3>Top stoliki</h3>
|
||||
@@ -104,8 +136,9 @@ requireAdminAuth(true);
|
||||
|
||||
<div class="card col-12">
|
||||
<h3>Ostatnie otwarcia stron stolików</h3>
|
||||
<div class="muted" id="visitorSummaryLine" style="margin-bottom:10px;">Ładowanie podsumowania gości…</div>
|
||||
<table>
|
||||
<thead><tr><th>Kiedy</th><th>Stolik</th><th>Strefa</th><th>W aplikacji</th><th>Urządzenie</th><th>Przeglądarka</th><th>IP</th></tr></thead>
|
||||
<thead><tr><th>Kiedy</th><th>Stolik</th><th>Gość</th><th>W aplikacji</th><th>Urządzenie</th><th>Przeglądarka</th><th>IP</th></tr></thead>
|
||||
<tbody id="recentOpensBody"><tr><td colspan="7" class="muted">Ładowanie...</td></tr></tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -141,10 +174,12 @@ requireAdminAuth(true);
|
||||
<li><strong>Skanowania QR</strong> - ile razy otwarto stronę stolika z kodu QR.</li>
|
||||
<li><strong>Sesje</strong> - ile razy użytkownik faktycznie wszedł do aplikacji po starcie.</li>
|
||||
<li><strong>Lokalizacja OK</strong> - ile razy weryfikacja geolokalizacji zakończyła się powodzeniem.</li>
|
||||
<li><strong>Przywołania kelnera</strong> - ile razy gość poprosił o podejście obsługi.</li>
|
||||
<li><strong>Przywołania kelnera (kafelek KPI)</strong> - liczba wpisów <code>waiter_call</code> w kolejce gościa (ta sama baza co tabela na dole).</li>
|
||||
<li><strong>Lejek → Przywołanie kelnera (analityka kliknięć)</strong> - osobna liczba z tabeli <code>analytics_events</code>; może być wyższa po testach lub po wyczyszczeniu tylko kolejki.</li>
|
||||
<li><strong>Top stoliki</strong> - które stoliki są najczęściej otwierane i używane.</li>
|
||||
<li><strong>Lejek użycia</strong> - droga użytkownika: wejście -> start aplikacji -> menu -> rachunek.</li>
|
||||
<li><strong>Kolumna W aplikacji (✓/✗)</strong> - ✓ oznacza przejście przez ekran lokalizacji (widok statusu zamówień); ✗ oznacza zatrzymanie na geo.</li>
|
||||
<li><strong>Kolumna W aplikacji</strong> - ✓ pełna aplikacja (geo OK), M tylko menu bez lokalizacji, ✗ zatrzymanie na geo.</li>
|
||||
<li><strong>Kolumna Gość</strong> - szacunkowy identyfikator urządzenia/przeglądarki (localStorage). Ten sam kolor = ta sama sesja. Kliknij wiersz, aby podświetlić wszystkie wizyty gościa.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -155,6 +190,7 @@ requireAdminAuth(true);
|
||||
let selectedDays = "7";
|
||||
let isLoadingAnalytics = false;
|
||||
let devicePieChart = null;
|
||||
let selectedVisitorSessionId = null;
|
||||
|
||||
const deviceChartLabels = {
|
||||
ios: "iPhone (iOS)",
|
||||
@@ -227,6 +263,93 @@ requireAdminAuth(true);
|
||||
}).join("");
|
||||
}
|
||||
|
||||
function visitorSessionColor(sessionId) {
|
||||
const id = String(sessionId || "");
|
||||
if (!id) return "#64748b";
|
||||
let hash = 0;
|
||||
for (let i = 0; i < id.length; i++) {
|
||||
hash = id.charCodeAt(i) + ((hash << 5) - hash);
|
||||
}
|
||||
const hue = Math.abs(hash) % 360;
|
||||
return `hsl(${hue}, 70%, 58%)`;
|
||||
}
|
||||
|
||||
function hslToHighlightVars(hslColor) {
|
||||
const match = String(hslColor).match(/hsl\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%\s*\)/i);
|
||||
if (!match) {
|
||||
return {
|
||||
bg: "rgba(59, 130, 246, 0.18)",
|
||||
border: "rgba(59, 130, 246, 0.45)",
|
||||
};
|
||||
}
|
||||
const h = match[1];
|
||||
const s = match[2];
|
||||
const l = match[3];
|
||||
return {
|
||||
bg: `hsla(${h}, ${s}%, ${l}%, 0.22)`,
|
||||
border: `hsla(${h}, ${s}%, ${l}%, 0.55)`,
|
||||
};
|
||||
}
|
||||
|
||||
function escapeAttr(value) {
|
||||
return String(value ?? "")
|
||||
.replace(/&/g, "&")
|
||||
.replace(/"/g, """);
|
||||
}
|
||||
|
||||
function applyVisitorSessionHighlight(sessionId) {
|
||||
document.querySelectorAll("#recentOpensBody tr.recent-open-row").forEach((row) => {
|
||||
const rowSessionId = row.dataset.sessionId || "";
|
||||
const isMatch = !!sessionId && rowSessionId === sessionId;
|
||||
row.classList.toggle("session-row-highlight", isMatch);
|
||||
if (isMatch) {
|
||||
const vars = hslToHighlightVars(row.dataset.sessionColor || "");
|
||||
row.style.setProperty("--session-highlight-bg", vars.bg);
|
||||
row.style.setProperty("--session-highlight-border", vars.border);
|
||||
} else {
|
||||
row.style.removeProperty("--session-highlight-bg");
|
||||
row.style.removeProperty("--session-highlight-border");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function bindRecentOpensRowClicks() {
|
||||
const tbody = document.getElementById("recentOpensBody");
|
||||
if (!tbody || tbody.dataset.clickBound === "1") return;
|
||||
tbody.dataset.clickBound = "1";
|
||||
tbody.addEventListener("click", (event) => {
|
||||
const row = event.target.closest("tr.recent-open-row");
|
||||
if (!row) return;
|
||||
const sessionId = row.dataset.sessionId || "";
|
||||
if (!sessionId) return;
|
||||
selectedVisitorSessionId = selectedVisitorSessionId === sessionId ? null : sessionId;
|
||||
applyVisitorSessionHighlight(selectedVisitorSessionId);
|
||||
});
|
||||
}
|
||||
|
||||
function formatVisitorCell(row, markColor) {
|
||||
const visitNo = Number(row.visitor_visit_number || 1);
|
||||
const total = Number(row.visitor_total_visits || visitNo);
|
||||
const isReturning = Number(row.visitor_is_returning) === 1;
|
||||
const shortId = row.visitor_id_short || "—";
|
||||
const firstSeen = row.visitor_first_seen_at
|
||||
? String(row.visitor_first_seen_at).replace("T", " ").slice(0, 16)
|
||||
: "—";
|
||||
const statusLabel = isReturning
|
||||
? `<span class="visitor-return">Powrót · ${visitNo}. wizyta</span>`
|
||||
: `<span class="visitor-new">Nowy · 1. wizyta</span>`;
|
||||
const title = `Ten sam kolor = ta sama sesja/urządzenie · ID: ${shortId}… · Łącznie skanów: ${total} · Pierwsze wejście: ${firstSeen}`;
|
||||
return `<span class="visitor-cell" title="${title}">
|
||||
<span class="visitor-session-dash" style="background:${markColor}"></span>
|
||||
<span>
|
||||
<span style="display:inline-flex;align-items:center;gap:6px;">
|
||||
<span class="visitor-session-dot" style="background:${markColor}"></span>
|
||||
<span class="visitor-id" style="color:${markColor}">#${shortId}</span>
|
||||
</span><br>${statusLabel}
|
||||
</span>
|
||||
</span>`;
|
||||
}
|
||||
|
||||
function setChip(days) {
|
||||
chips.forEach(c => c.classList.toggle("active", c.dataset.days === String(days)));
|
||||
}
|
||||
@@ -248,7 +371,7 @@ requireAdminAuth(true);
|
||||
document.getElementById("kpiScans").textContent = n(totalScans);
|
||||
document.getElementById("kpiSessions").textContent = n(totalSessions);
|
||||
document.getElementById("kpiGeoPass").textContent = n(data.geolocation?.passed);
|
||||
document.getElementById("kpiWaiterCall").textContent = n(data.funnel?.waiter_call_requested);
|
||||
document.getElementById("kpiWaiterCall").textContent = n(data.guestQueueSummary?.waiterCalls);
|
||||
|
||||
const topBody = document.getElementById("topTablesBody");
|
||||
const top = data.topTables || [];
|
||||
@@ -265,9 +388,12 @@ requireAdminAuth(true);
|
||||
const f = data.funnel || {};
|
||||
document.getElementById("funnelBody").innerHTML = `
|
||||
<tr><td>Otwarcie strony stolika (QR)</td><td>${n(f.qr_scan)}</td></tr>
|
||||
<tr><td>Start aplikacji</td><td>${n(f.session_start)}</td></tr>
|
||||
<tr><td>Start aplikacji (geo OK)</td><td>${n(f.session_start)}</td></tr>
|
||||
<tr><td>Tylko menu (bez geo)</td><td>${n(f.menu_only_entered)}</td></tr>
|
||||
<tr><td>Wejście do menu</td><td>${n(f.view_menu)}</td></tr>
|
||||
<tr><td>Przywołanie kelnera</td><td>${n(f.waiter_call_requested)}</td></tr>
|
||||
<tr><td>Próba odblokowania funkcji (geo gate)</td><td>${n(f.geo_gate_prompted)}</td></tr>
|
||||
<tr><td>Ponowna geo z trybu menu</td><td>${n(f.geo_retry_from_menu)}</td></tr>
|
||||
<tr><td>Przywołanie kelnera (analityka kliknięć)</td><td>${n(f.waiter_call_requested)}</td></tr>
|
||||
<tr><td>Otwarcie modułu rachunku</td><td>${n(f.bill_dialog_opened)}</td></tr>
|
||||
<tr><td>Wysłanie prośby o rachunek</td><td>${n(f.bill_request_sent)}</td></tr>
|
||||
`;
|
||||
@@ -280,6 +406,15 @@ requireAdminAuth(true);
|
||||
`;
|
||||
|
||||
const recent = data.recentOpens || [];
|
||||
const visitorSummary = data.visitorSummary || {};
|
||||
const uniqueVisitors = Number(visitorSummary.uniqueVisitors || 0);
|
||||
const returningVisitors = Number(visitorSummary.returningVisitors || 0);
|
||||
const repeatPct = uniqueVisitors
|
||||
? ((returningVisitors / uniqueVisitors) * 100).toFixed(1)
|
||||
: "0";
|
||||
document.getElementById("visitorSummaryLine").textContent =
|
||||
`W wybranym okresie: ${n(uniqueVisitors)} unikalnych gości (urządzeń), ${n(returningVisitors)} powracających (${repeatPct}%). Kliknij wiersz, aby podświetlić wszystkie wizyty tego gościa (ten sam kolor).`;
|
||||
|
||||
const recentBody = document.getElementById("recentOpensBody");
|
||||
recentBody.innerHTML = recent.length
|
||||
? recent.map(r => {
|
||||
@@ -288,13 +423,24 @@ requireAdminAuth(true);
|
||||
const device = r.device_type || "-";
|
||||
const browser = r.browser || "-";
|
||||
const reachedApp = Number(r.reached_app) === 1;
|
||||
const appCell = reachedApp
|
||||
? `<span class="status-ok" title="Przeszedł lokalizację — widok statusu zamówień">✓</span>`
|
||||
: `<span class="status-fail" title="Zatrzymano na ekranie lokalizacji">✗</span>`;
|
||||
return `<tr><td>${when}</td><td>${r.table_id || "-"}</td><td>${r.zone || "-"}</td><td>${appCell}</td><td>${device}</td><td>${browser}</td><td>${r.ip_address || "-"}</td></tr>`;
|
||||
const menuOnly = Number(r.menu_only) === 1;
|
||||
let appCell;
|
||||
if (reachedApp) {
|
||||
appCell = `<span class="status-ok" title="Pełna aplikacja — geo OK">✓</span>`;
|
||||
} else if (menuOnly) {
|
||||
appCell = `<span class="status-menu" title="Tylko menu — bez lokalizacji">M</span>`;
|
||||
} else {
|
||||
appCell = `<span class="status-fail" title="Zatrzymano na ekranie lokalizacji">✗</span>`;
|
||||
}
|
||||
const markColor = visitorSessionColor(r.session_id);
|
||||
const sessionId = escapeAttr(r.session_id || "");
|
||||
return `<tr class="recent-open-row" data-session-id="${sessionId}" data-session-color="${markColor}" style="border-left-color:${markColor}"><td>${when}</td><td>${r.table_id || "-"}</td><td>${formatVisitorCell(r, markColor)}</td><td>${appCell}</td><td>${device}</td><td>${browser}</td><td>${r.ip_address || "-"}</td></tr>`;
|
||||
}).join("")
|
||||
: `<tr><td colspan="7" class="muted">Brak danych</td></tr>`;
|
||||
|
||||
bindRecentOpensRowClicks();
|
||||
applyVisitorSessionHighlight(selectedVisitorSessionId);
|
||||
|
||||
renderDevicePieChart(data.deviceStats || {});
|
||||
|
||||
const queueSummary = data.guestQueueSummary || {};
|
||||
@@ -331,6 +477,8 @@ requireAdminAuth(true);
|
||||
document.getElementById("topTablesBody").innerHTML = `<tr><td colspan="5" class="muted">Nie udało się załadować analityki.</td></tr>`;
|
||||
document.getElementById("zonesBody").innerHTML = `<tr><td colspan="3" class="muted">Sprawdź połączenie/API.</td></tr>`;
|
||||
document.getElementById("recentOpensBody").innerHTML = `<tr><td colspan="7" class="muted">Nie udało się pobrać ostatnich otwarć.</td></tr>`;
|
||||
document.getElementById("visitorSummaryLine").textContent = "Nie udało się pobrać statystyk gości.";
|
||||
selectedVisitorSessionId = null;
|
||||
renderDevicePieChart({});
|
||||
document.getElementById("guestQueueSummaryBody").innerHTML = `<tr><td colspan="4" class="muted">Nie udało się pobrać podsumowania kolejki.</td></tr>`;
|
||||
document.getElementById("guestQueueBody").innerHTML = `<tr><td colspan="8" class="muted">Nie udało się pobrać kolejki.</td></tr>`;
|
||||
|
||||
291
public/waiter/app.css
Normal file
291
public/waiter/app.css
Normal file
@@ -0,0 +1,291 @@
|
||||
:root {
|
||||
--bg: #0f172a;
|
||||
--card: #1e293b;
|
||||
--border: #334155;
|
||||
--text: #f8fafc;
|
||||
--muted: #94a3b8;
|
||||
--accent: #3b82f6;
|
||||
--danger: #ef4444;
|
||||
--warning: #f59e0b;
|
||||
--success: #22c55e;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
min-height: 100vh;
|
||||
padding: 16px;
|
||||
padding-bottom: max(24px, env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.top-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.top-bar h1 {
|
||||
font-size: 1.45rem;
|
||||
font-weight: 800;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
margin-top: 4px;
|
||||
font-size: 0.85rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.sync-pill {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 0.78rem;
|
||||
color: var(--muted);
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 999px;
|
||||
padding: 8px 12px;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.sync-dot {
|
||||
width: 9px;
|
||||
height: 9px;
|
||||
border-radius: 50%;
|
||||
background: var(--muted);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.sync-dot.ok {
|
||||
background: var(--success);
|
||||
box-shadow: 0 0 8px var(--success);
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
|
||||
.sync-dot.err {
|
||||
background: var(--danger);
|
||||
box-shadow: 0 0 8px var(--danger);
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 0.75; transform: scale(0.95); }
|
||||
50% { opacity: 1; transform: scale(1.1); }
|
||||
}
|
||||
|
||||
.notify-banner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
background: linear-gradient(135deg, #1e3a5f 0%, #1e293b 100%);
|
||||
border: 1px solid #2563eb;
|
||||
border-radius: 14px;
|
||||
padding: 14px 16px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.notify-banner p {
|
||||
margin-top: 4px;
|
||||
font-size: 0.82rem;
|
||||
color: #cbd5e1;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.btn {
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
padding: 10px 14px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 10px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
padding: 12px 14px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
display: block;
|
||||
font-size: 0.75rem;
|
||||
color: var(--muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.4px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.feed-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 48px 20px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.empty-icon {
|
||||
font-size: 2.5rem;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.feed-card {
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
padding: 16px;
|
||||
animation: slideIn 0.25s ease-out;
|
||||
}
|
||||
|
||||
.feed-card.is-new {
|
||||
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35);
|
||||
}
|
||||
|
||||
.feed-card.waiter {
|
||||
border-left: 5px solid var(--danger);
|
||||
}
|
||||
|
||||
.feed-card.bill {
|
||||
border-left: 5px solid var(--warning);
|
||||
}
|
||||
|
||||
.feed-card.done {
|
||||
opacity: 0.72;
|
||||
}
|
||||
|
||||
@keyframes slideIn {
|
||||
from { opacity: 0; transform: translateY(8px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.feed-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.feed-title {
|
||||
font-size: 1rem;
|
||||
font-weight: 800;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.3px;
|
||||
}
|
||||
|
||||
.feed-card.waiter .feed-title {
|
||||
color: #fca5a5;
|
||||
}
|
||||
|
||||
.feed-card.bill .feed-title {
|
||||
color: #fcd34d;
|
||||
}
|
||||
|
||||
.feed-time {
|
||||
font-size: 0.8rem;
|
||||
color: var(--muted);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.feed-table {
|
||||
font-size: 1.05rem;
|
||||
font-weight: 700;
|
||||
color: var(--accent);
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.feed-operator {
|
||||
font-size: 0.88rem;
|
||||
color: var(--muted);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.feed-operator strong {
|
||||
color: #e2e8f0;
|
||||
}
|
||||
|
||||
.feed-msg {
|
||||
font-size: 0.9rem;
|
||||
color: #cbd5e1;
|
||||
line-height: 1.45;
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
.feed-badges {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.badge {
|
||||
font-size: 0.72rem;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.3px;
|
||||
padding: 4px 8px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.badge-pending {
|
||||
background: rgba(239, 68, 68, 0.15);
|
||||
color: #fca5a5;
|
||||
border-color: rgba(239, 68, 68, 0.35);
|
||||
}
|
||||
|
||||
.badge-done {
|
||||
background: rgba(34, 197, 94, 0.12);
|
||||
color: #86efac;
|
||||
border-color: rgba(34, 197, 94, 0.3);
|
||||
}
|
||||
|
||||
@media (min-width: 640px) {
|
||||
body {
|
||||
max-width: 720px;
|
||||
margin: 0 auto;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
}
|
||||
249
public/waiter/app.js
Normal file
249
public/waiter/app.js
Normal file
@@ -0,0 +1,249 @@
|
||||
const API_URL = '../../api/waiter_feed.php';
|
||||
const POLL_MS = 15000;
|
||||
|
||||
const feedList = document.getElementById('feedList');
|
||||
const emptyState = document.getElementById('emptyState');
|
||||
const syncDot = document.getElementById('syncDot');
|
||||
const syncLabel = document.getElementById('syncLabel');
|
||||
const notifyBanner = document.getElementById('notifyBanner');
|
||||
const enableNotifyBtn = document.getElementById('enableNotifyBtn');
|
||||
|
||||
const statPending = document.getElementById('statPending');
|
||||
const statWaiter = document.getElementById('statWaiter');
|
||||
const statBill = document.getElementById('statBill');
|
||||
const statTotal = document.getElementById('statTotal');
|
||||
|
||||
let knownIds = new Set();
|
||||
let feedInitialized = false;
|
||||
let pollTimer = null;
|
||||
let lastPayload = '';
|
||||
let swRegistration = null;
|
||||
|
||||
function escapeHtml(value) {
|
||||
return String(value ?? '')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>');
|
||||
}
|
||||
|
||||
function formatTime(isoLike) {
|
||||
if (!isoLike) return '';
|
||||
const dt = new Date(String(isoLike).replace(' ', 'T'));
|
||||
if (Number.isNaN(dt.getTime())) return '';
|
||||
return dt.toLocaleTimeString('pl-PL', { hour: '2-digit', minute: '2-digit' });
|
||||
}
|
||||
|
||||
function formatOperator(row) {
|
||||
const imie = (row.otwierajacy_imie || '').trim();
|
||||
const nazwisko = (row.otwierajacy_nazwisko || '').trim();
|
||||
return `${imie} ${nazwisko}`.trim();
|
||||
}
|
||||
|
||||
function updateNotifyBanner() {
|
||||
if (!('Notification' in window)) {
|
||||
notifyBanner.classList.add('hidden');
|
||||
return;
|
||||
}
|
||||
|
||||
if (Notification.permission === 'default') {
|
||||
notifyBanner.classList.remove('hidden');
|
||||
return;
|
||||
}
|
||||
|
||||
notifyBanner.classList.add('hidden');
|
||||
}
|
||||
|
||||
async function registerServiceWorker() {
|
||||
if (!('serviceWorker' in navigator)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
swRegistration = await navigator.serviceWorker.register('sw.js');
|
||||
await navigator.serviceWorker.ready;
|
||||
return swRegistration;
|
||||
} catch (err) {
|
||||
console.warn('[waiter] SW registration failed', err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function requestNotifications() {
|
||||
if (!('Notification' in window)) {
|
||||
alert('Ta przeglądarka nie obsługuje powiadomień.');
|
||||
return;
|
||||
}
|
||||
|
||||
const permission = await Notification.requestPermission();
|
||||
updateNotifyBanner();
|
||||
|
||||
if (permission === 'granted') {
|
||||
await registerServiceWorker();
|
||||
}
|
||||
}
|
||||
|
||||
function showNotification(row) {
|
||||
const isWaiter = row.message_type === 'waiter_call';
|
||||
const title = isWaiter ? 'Wezwanie kelnera' : 'Prośba o rachunek';
|
||||
const firstLine = (row.message_text || '').split('\n')[0].trim();
|
||||
const body = `Stolik ${row.table_id || '?'}` + (firstLine ? `\n${firstLine}` : '');
|
||||
|
||||
const payload = {
|
||||
type: 'notify',
|
||||
title,
|
||||
body,
|
||||
tag: `waiter-${row.id}`,
|
||||
};
|
||||
|
||||
if (swRegistration && swRegistration.active) {
|
||||
swRegistration.active.postMessage(payload);
|
||||
return;
|
||||
}
|
||||
|
||||
if (navigator.serviceWorker && navigator.serviceWorker.controller) {
|
||||
navigator.serviceWorker.controller.postMessage(payload);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Notification.permission === 'granted') {
|
||||
new Notification(title, {
|
||||
body,
|
||||
tag: payload.tag,
|
||||
renotify: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function handleNewRows(rows) {
|
||||
const fresh = [];
|
||||
|
||||
for (const row of rows) {
|
||||
const id = Number(row.id);
|
||||
if (!feedInitialized) {
|
||||
knownIds.add(id);
|
||||
continue;
|
||||
}
|
||||
if (!knownIds.has(id)) {
|
||||
knownIds.add(id);
|
||||
fresh.push(row);
|
||||
}
|
||||
}
|
||||
|
||||
feedInitialized = true;
|
||||
|
||||
for (const row of fresh) {
|
||||
showNotification(row);
|
||||
}
|
||||
}
|
||||
|
||||
function renderFeed(rows) {
|
||||
if (!rows.length) {
|
||||
feedList.innerHTML = '';
|
||||
emptyState.classList.remove('hidden');
|
||||
return;
|
||||
}
|
||||
|
||||
emptyState.classList.add('hidden');
|
||||
|
||||
feedList.innerHTML = rows.map((row) => {
|
||||
const isWaiter = row.message_type === 'waiter_call';
|
||||
const typeLabel = isWaiter ? 'Wezwanie kelnera' : 'Prośba o rachunek';
|
||||
const operator = formatOperator(row);
|
||||
const operatorHtml = operator
|
||||
? `<div class="feed-operator">Kelner stolika: <strong>${escapeHtml(operator)}</strong></div>`
|
||||
: '';
|
||||
const pending = Number(row.status_kds) === 0;
|
||||
const cardClass = [
|
||||
'feed-card',
|
||||
isWaiter ? 'waiter' : 'bill',
|
||||
pending ? '' : 'done',
|
||||
].filter(Boolean).join(' ');
|
||||
|
||||
return `
|
||||
<article class="${cardClass}" data-id="${row.id}">
|
||||
<div class="feed-head">
|
||||
<div class="feed-title">${escapeHtml(typeLabel)}</div>
|
||||
<div class="feed-time">${escapeHtml(formatTime(row.created_at))}</div>
|
||||
</div>
|
||||
<div class="feed-table">Stolik ${escapeHtml(row.table_id || '?')}</div>
|
||||
${operatorHtml}
|
||||
<div class="feed-msg">${escapeHtml(row.message_text || '')}</div>
|
||||
<div class="feed-badges">
|
||||
<span class="badge ${pending ? 'badge-pending' : 'badge-done'}">
|
||||
${pending ? 'Aktywne w KDS' : 'Obsłużone w KDS'}
|
||||
</span>
|
||||
</div>
|
||||
</article>
|
||||
`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function updateStats(summary, total) {
|
||||
statPending.textContent = String(summary?.pending ?? 0);
|
||||
statWaiter.textContent = String(summary?.waiter_calls ?? 0);
|
||||
statBill.textContent = String(summary?.bill_requests ?? 0);
|
||||
statTotal.textContent = String(total ?? 0);
|
||||
}
|
||||
|
||||
function setSyncState(ok, message) {
|
||||
syncDot.classList.toggle('ok', ok);
|
||||
syncDot.classList.toggle('err', !ok);
|
||||
syncLabel.textContent = message;
|
||||
}
|
||||
|
||||
async function pollFeed() {
|
||||
try {
|
||||
const response = await fetch(API_URL, { cache: 'no-store' });
|
||||
const result = await response.json();
|
||||
|
||||
if (result.status !== 'success') {
|
||||
setSyncState(false, 'Błąd API');
|
||||
return;
|
||||
}
|
||||
|
||||
const payload = JSON.stringify(result.data || []);
|
||||
const rows = result.data || [];
|
||||
|
||||
handleNewRows(rows);
|
||||
|
||||
if (payload !== lastPayload) {
|
||||
renderFeed(rows);
|
||||
lastPayload = payload;
|
||||
}
|
||||
|
||||
updateStats(result.summary, result.count);
|
||||
|
||||
const now = new Date();
|
||||
setSyncState(true, `Sync ${now.toLocaleTimeString('pl-PL', { hour: '2-digit', minute: '2-digit', second: '2-digit' })}`);
|
||||
} catch {
|
||||
setSyncState(false, 'Brak połączenia');
|
||||
}
|
||||
}
|
||||
|
||||
function startPolling() {
|
||||
pollFeed();
|
||||
if (pollTimer) clearInterval(pollTimer);
|
||||
pollTimer = setInterval(pollFeed, POLL_MS);
|
||||
}
|
||||
|
||||
enableNotifyBtn?.addEventListener('click', () => {
|
||||
requestNotifications();
|
||||
});
|
||||
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
if (!document.hidden) {
|
||||
pollFeed();
|
||||
}
|
||||
});
|
||||
|
||||
(async function init() {
|
||||
updateNotifyBanner();
|
||||
|
||||
if ('Notification' in window && Notification.permission === 'granted') {
|
||||
await registerServiceWorker();
|
||||
} else if ('Notification' in window && Notification.permission === 'default') {
|
||||
notifyBanner.classList.remove('hidden');
|
||||
}
|
||||
|
||||
startPolling();
|
||||
})();
|
||||
66
public/waiter/index.php
Normal file
66
public/waiter/index.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../includes/asset_version.php';
|
||||
$waiterDir = __DIR__;
|
||||
$vCss = publicAssetVersion($waiterDir, 'app.css');
|
||||
$vJs = publicAssetVersion($waiterDir, 'app.js');
|
||||
?><!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
|
||||
<meta name="theme-color" content="#0f172a">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<title>Kelner – wezwania</title>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="app.css?v=<?= assetVersionAttr($vCss) ?>">
|
||||
</head>
|
||||
<body>
|
||||
<header class="top-bar">
|
||||
<div>
|
||||
<h1>Panel kelnera</h1>
|
||||
<p class="subtitle">Wezwania i prośby o rachunek · dziś</p>
|
||||
</div>
|
||||
<div class="sync-pill" id="syncPill">
|
||||
<span class="sync-dot" id="syncDot"></span>
|
||||
<span id="syncLabel">Łączenie…</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="notify-banner hidden" id="notifyBanner">
|
||||
<div>
|
||||
<strong>Powiadomienia wyłączone</strong>
|
||||
<p>Włącz je, aby dostać alert przy nowym wezwaniu, nawet gdy ekran jest zablokowany w tle.</p>
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary" id="enableNotifyBtn">Włącz powiadomienia</button>
|
||||
</section>
|
||||
|
||||
<section class="stats-grid" id="statsGrid">
|
||||
<div class="stat-card">
|
||||
<span class="stat-label">Aktywne</span>
|
||||
<span class="stat-value" id="statPending">–</span>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<span class="stat-label">Kelner</span>
|
||||
<span class="stat-value" id="statWaiter">–</span>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<span class="stat-label">Rachunek</span>
|
||||
<span class="stat-value" id="statBill">–</span>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<span class="stat-label">Razem dziś</span>
|
||||
<span class="stat-value" id="statTotal">–</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<main id="feedList" class="feed-list"></main>
|
||||
|
||||
<div class="empty-state hidden" id="emptyState">
|
||||
<div class="empty-icon">🛎️</div>
|
||||
<p>Brak wezwań na dziś. Czekam na nowe…</p>
|
||||
</div>
|
||||
|
||||
<script src="app.js?v=<?= assetVersionAttr($vJs) ?>"></script>
|
||||
</body>
|
||||
</html>
|
||||
23
public/waiter/sw.js
Normal file
23
public/waiter/sw.js
Normal file
@@ -0,0 +1,23 @@
|
||||
self.addEventListener('install', (event) => {
|
||||
event.waitUntil(self.skipWaiting());
|
||||
});
|
||||
|
||||
self.addEventListener('activate', (event) => {
|
||||
event.waitUntil(self.clients.claim());
|
||||
});
|
||||
|
||||
self.addEventListener('message', (event) => {
|
||||
const data = event.data;
|
||||
if (!data || data.type !== 'notify') {
|
||||
return;
|
||||
}
|
||||
|
||||
event.waitUntil(
|
||||
self.registration.showNotification(data.title || 'Panel kelnera', {
|
||||
body: data.body || '',
|
||||
tag: data.tag || 'waiter-alert',
|
||||
renotify: true,
|
||||
requireInteraction: true,
|
||||
})
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user