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

View File

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

View File

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

View File

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