This commit is contained in:
Flatlogic Bot 2026-02-27 03:25:14 +00:00
parent 130a0dc0a3
commit 1e9abec636
4 changed files with 26 additions and 26 deletions

View File

@ -67,11 +67,11 @@ if (isset($_GET['deleted'])) {
$areas = $pdo->query("SELECT * FROM areas WHERE is_deleted = 0 ORDER BY name ASC")->fetchAll();
$query = "SELECT t.id, t.table_number, t.capacity, t.status, t.area_id, 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";
$query = "SELECT `t`.`id`, `t`.`table_number`, `t`.`capacity`, `t`.`status`, `t`.`area_id`, `a`.`name` AS `area_name`
FROM `tables` AS `t`
LEFT JOIN `areas` AS `a` ON `t`.`area_id` = `a`.`id`
WHERE `t`.`is_deleted` = 0
ORDER BY `a`.`name` ASC, `t`.`table_number` ASC";
$tables_pagination = paginate_query($pdo, $query);
$tables = $tables_pagination['data'];

View File

@ -35,10 +35,10 @@ try {
if ($tid) {
// Validate table exists AND belongs to the correct outlet
$stmt = $pdo->prepare(
"SELECT t.id, t.table_number
FROM tables t
JOIN areas a ON t.area_id = a.id
WHERE t.id = ? AND a.outlet_id = ?"
"SELECT `t`.`id`, `t`.`table_number`
FROM `tables` AS `t`
JOIN `areas` AS `a` ON `t`.`area_id` = `a`.`id`
WHERE `t`.`id` = ? AND `a`.`outlet_id` = ?"
);
$stmt->execute([$tid, $outlet_id]);
$table = $stmt->fetch(PDO::FETCH_ASSOC);
@ -52,10 +52,10 @@ try {
if (!$table_id) {
// Optional: try to find the first available table for this outlet
$stmt = $pdo->prepare(
"SELECT t.id, t.table_number
FROM tables t
JOIN areas a ON t.area_id = a.id
WHERE a.outlet_id = ?
"SELECT `t`.`id`, `t`.`table_number`
FROM `tables` AS `t`
JOIN `areas` AS `a` ON `t`.`area_id` = `a`.`id`
WHERE `a`.`outlet_id` = ?
LIMIT 1"
);
$stmt->execute([$outlet_id]);

View File

@ -11,11 +11,11 @@ try {
// Fetch all tables with their area names, filtered by outlet_id
$sql = "
SELECT t.id, t.table_number as name, t.capacity, a.name AS area_name, t.status
FROM tables t
LEFT JOIN areas a ON t.area_id = a.id
WHERE a.outlet_id = :outlet_id AND t.is_deleted = 0
ORDER BY a.name ASC, t.`table_number` ASC
SELECT `t`.`id`, `t`.`table_number` AS `name`, `t`.`capacity`, `a`.`name` AS `area_name`, `t`.`status`
FROM `tables` AS `t`
LEFT JOIN `areas` AS `a` ON `t`.`area_id` = `a`.`id`
WHERE `a`.`outlet_id` = :outlet_id AND `t`.`is_deleted` = 0
ORDER BY `a`.`name` ASC, `t`.`table_number` ASC
";
$stmt = $pdo->prepare($sql);
$stmt->execute(['outlet_id' => $outlet_id]);

View File

@ -18,11 +18,11 @@ if ($table_id <= 0) {
// Fetch table and outlet info
try {
$stmt = $pdo->prepare("
SELECT t.id, t.table_number as table_name, a.outlet_id, o.name as outlet_name
FROM tables t
JOIN areas a ON t.area_id = a.id
JOIN outlets o ON a.outlet_id = o.id
WHERE t.id = ?
SELECT `t`.`id`, `t`.`table_number` AS `table_name`, `a`.`outlet_id`, `o`.`name` AS `outlet_name`
FROM `tables` AS `t`
JOIN `areas` AS `a` ON `t`.`area_id` = `a`.`id`
JOIN `outlets` AS `o` ON `a`.`outlet_id` = `o`.`id`
WHERE `t`.`id` = ?
");
$stmt->execute([$table_id]);
$table_info = $stmt->fetch();