diff --git a/api/tables.php b/api/tables.php index f020ea3..f9bba96 100644 --- a/api/tables.php +++ b/api/tables.php @@ -9,11 +9,11 @@ try { // Fetch all tables with their area names, filtered by outlet_id $sql = " - SELECT t.id, t.name, t.capacity, a.name AS area_name + 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 - ORDER BY a.name ASC, t.name ASC + 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]); @@ -34,7 +34,7 @@ try { // Mark tables as occupied foreach ($tables as &$table) { - $table['is_occupied'] = in_array($table['id'], $occupiedTableIds); + $table['is_occupied'] = in_array($table['id'], $occupiedTableIds) || $table['status'] === 'occupied'; } echo json_encode(['success' => true, 'tables' => $tables]);