fixing tables and order

This commit is contained in:
Flatlogic Bot 2026-02-27 02:35:58 +00:00
parent 8faf7adbb6
commit 4268e51b35

View File

@ -1,34 +1,36 @@
<?php <?php
require_once 'db/config.php'; require_once __DIR__ . '/db/config.php';
require_once 'includes/functions.php'; require_once __DIR__ . '/includes/functions.php';
$pdo = db();
// Simulate variables echo "Checking tables permission...\n";
$_SERVER['HTTPS'] = 'off'; try {
$_SERVER['SERVER_PORT'] = 80; // Mock session for a user with all permissions
$_SERVER['HTTP_HOST'] = 'localhost'; init_session();
$_SERVER['PHP_SELF'] = '/admin/tables.php'; $_SESSION['user'] = [
'id' => 1,
'username' => 'admin',
'group_name' => 'Admin',
'permissions' => 'all'
];
// Fetch tables with area names require_permission("tables_view");
$query = "SELECT tables.*, areas.name as area_name echo "Tables permission OK\n";
FROM tables
LEFT JOIN areas ON tables.area_id = areas.id
ORDER BY tables.id DESC";
$tables_pagination = paginate_query($pdo, $query); require_permission("orders_view");
$tables = $tables_pagination['data']; echo "Orders permission OK\n";
// Determine base URL for QR codes $pdo = db();
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; $query = "SELECT t.*, a.name as area_name
$host = $_SERVER['HTTP_HOST']; FROM tables t
$dir = dirname($_SERVER['PHP_SELF'], 2); LEFT JOIN areas a ON t.area_id = a.id
$baseUrl = $protocol . $host . ($dir === '/' ? '' : $dir) . '/qorder.php'; WHERE t.is_deleted = 0
ORDER BY a.name ASC, t.table_number ASC";
$stmt = $pdo->query($query);
$tables = $stmt->fetchAll();
echo "Tables query OK, found " . count($tables) . " tables\n";
echo "Base URL: " . $baseUrl . "\n"; } catch (Exception $e) {
echo "Tables found: " . count($tables) . "\n"; echo "Caught exception: " . $e->getMessage() . "\n";
} catch (Error $e) {
foreach ($tables as $table) { echo "Caught error: " . $e->getMessage() . "\n";
$qrUrl = $baseUrl . '?table_id=' . $table['id'];
echo "Table: " . $table['name'] . " - QR URL: " . $qrUrl . "\n";
} }