35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
require_once 'includes/functions.php';
|
|
$pdo = db();
|
|
|
|
// Simulate variables
|
|
$_SERVER['HTTPS'] = 'off';
|
|
$_SERVER['SERVER_PORT'] = 80;
|
|
$_SERVER['HTTP_HOST'] = 'localhost';
|
|
$_SERVER['PHP_SELF'] = '/admin/tables.php';
|
|
|
|
// 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";
|
|
|
|
$tables_pagination = paginate_query($pdo, $query);
|
|
$tables = $tables_pagination['data'];
|
|
|
|
// 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';
|
|
|
|
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";
|
|
}
|
|
|