fixing tables and order
This commit is contained in:
parent
8faf7adbb6
commit
4268e51b35
@ -1,34 +1,36 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
require_once 'includes/functions.php';
|
||||
$pdo = db();
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
require_once __DIR__ . '/includes/functions.php';
|
||||
|
||||
// Simulate variables
|
||||
$_SERVER['HTTPS'] = 'off';
|
||||
$_SERVER['SERVER_PORT'] = 80;
|
||||
$_SERVER['HTTP_HOST'] = 'localhost';
|
||||
$_SERVER['PHP_SELF'] = '/admin/tables.php';
|
||||
echo "Checking tables permission...\n";
|
||||
try {
|
||||
// Mock session for a user with all permissions
|
||||
init_session();
|
||||
$_SESSION['user'] = [
|
||||
'id' => 1,
|
||||
'username' => 'admin',
|
||||
'group_name' => 'Admin',
|
||||
'permissions' => 'all'
|
||||
];
|
||||
|
||||
// Fetch tables with area names
|
||||
$query = "SELECT tables.*, areas.name as area_name
|
||||
FROM tables
|
||||
LEFT JOIN areas ON tables.area_id = areas.id
|
||||
ORDER BY tables.id DESC";
|
||||
require_permission("tables_view");
|
||||
echo "Tables permission OK\n";
|
||||
|
||||
$tables_pagination = paginate_query($pdo, $query);
|
||||
$tables = $tables_pagination['data'];
|
||||
require_permission("orders_view");
|
||||
echo "Orders permission OK\n";
|
||||
|
||||
// Determine base URL for QR codes
|
||||
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
$dir = dirname($_SERVER['PHP_SELF'], 2);
|
||||
$baseUrl = $protocol . $host . ($dir === '/' ? '' : $dir) . '/qorder.php';
|
||||
$pdo = db();
|
||||
$query = "SELECT t.*, a.name as area_name
|
||||
FROM tables t
|
||||
LEFT JOIN areas a ON t.area_id = a.id
|
||||
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";
|
||||
echo "Tables found: " . count($tables) . "\n";
|
||||
|
||||
foreach ($tables as $table) {
|
||||
$qrUrl = $baseUrl . '?table_id=' . $table['id'];
|
||||
echo "Table: " . $table['name'] . " - QR URL: " . $qrUrl . "\n";
|
||||
} catch (Exception $e) {
|
||||
echo "Caught exception: " . $e->getMessage() . "\n";
|
||||
} catch (Error $e) {
|
||||
echo "Caught error: " . $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user