fixing tables and order
This commit is contained in:
parent
8faf7adbb6
commit
4268e51b35
@ -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,
|
||||||
// Fetch tables with area names
|
'username' => 'admin',
|
||||||
$query = "SELECT tables.*, areas.name as area_name
|
'group_name' => 'Admin',
|
||||||
FROM tables
|
'permissions' => 'all'
|
||||||
LEFT JOIN areas ON tables.area_id = areas.id
|
];
|
||||||
ORDER BY tables.id DESC";
|
|
||||||
|
require_permission("tables_view");
|
||||||
$tables_pagination = paginate_query($pdo, $query);
|
echo "Tables permission OK\n";
|
||||||
$tables = $tables_pagination['data'];
|
|
||||||
|
require_permission("orders_view");
|
||||||
// Determine base URL for QR codes
|
echo "Orders permission OK\n";
|
||||||
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
|
|
||||||
$host = $_SERVER['HTTP_HOST'];
|
$pdo = db();
|
||||||
$dir = dirname($_SERVER['PHP_SELF'], 2);
|
$query = "SELECT t.*, a.name as area_name
|
||||||
$baseUrl = $protocol . $host . ($dir === '/' ? '' : $dir) . '/qorder.php';
|
FROM tables t
|
||||||
|
LEFT JOIN areas a ON t.area_id = a.id
|
||||||
echo "Base URL: " . $baseUrl . "\n";
|
WHERE t.is_deleted = 0
|
||||||
echo "Tables found: " . count($tables) . "\n";
|
ORDER BY a.name ASC, t.table_number ASC";
|
||||||
|
$stmt = $pdo->query($query);
|
||||||
foreach ($tables as $table) {
|
$tables = $stmt->fetchAll();
|
||||||
$qrUrl = $baseUrl . '?table_id=' . $table['id'];
|
echo "Tables query OK, found " . count($tables) . " tables\n";
|
||||||
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