diff --git a/admin/tables.php b/admin/tables.php index 7f560b4..79b153a 100644 --- a/admin/tables.php +++ b/admin/tables.php @@ -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']; @@ -261,4 +261,4 @@ function editTable(table) { } - + \ No newline at end of file diff --git a/api/order.php b/api/order.php index 6bea303..15f0e7d 100644 --- a/api/order.php +++ b/api/order.php @@ -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]); @@ -419,4 +419,4 @@ You've earned *{points_earned} points* with this order. if ($pdo->inTransaction()) $pdo->rollBack(); error_log("Order Error: " . $e->getMessage()); echo json_encode(['success' => false, 'error' => $e->getMessage()]); -} +} \ No newline at end of file diff --git a/api/tables.php b/api/tables.php index ea4a78a..d9e899e 100644 --- a/api/tables.php +++ b/api/tables.php @@ -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]); diff --git a/qorder.php b/qorder.php index 3453609..8aae575 100644 --- a/qorder.php +++ b/qorder.php @@ -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(); @@ -526,4 +526,4 @@ foreach ($variants_raw as $v) { } - \ No newline at end of file +