From c5bf0227e47002b0ae7ef9814458beb6d5d0b72a Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 27 Feb 2026 04:20:26 +0000 Subject: [PATCH] qorder update --- db/migrations/041_fix_tables_naming.sql | 24 ++++++++++++++++++++++++ db/schema.sql | 14 ++++++++++---- qorder.php | 4 ++-- 3 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 db/migrations/041_fix_tables_naming.sql diff --git a/db/migrations/041_fix_tables_naming.sql b/db/migrations/041_fix_tables_naming.sql new file mode 100644 index 0000000..32a00bb --- /dev/null +++ b/db/migrations/041_fix_tables_naming.sql @@ -0,0 +1,24 @@ +-- Fix Tables Naming and Missing Columns +-- Rename name to table_number if it exists (using a more compatible approach) +-- Note: In older MySQL/MariaDB, we might need to check column existence via information_schema +-- but for simplicity in a migration file, we'll try to add the column if missing or rename it. + +-- Check if table_number exists, if not, try to rename name or add table_number +-- Since we can't easily do IF/ELSE in plain SQL without procedures, we'll use targeted ALTERs +-- that might fail if already corrected, which db/migrate.php will report. + +ALTER TABLE `tables` ADD COLUMN IF NOT EXISTS `table_number` VARCHAR(50) AFTER `area_id`; +ALTER TABLE `tables` ADD COLUMN IF NOT EXISTS `status` ENUM('available', 'occupied', 'reserved', 'inactive') DEFAULT 'available' AFTER `capacity`; +ALTER TABLE `tables` ADD COLUMN IF NOT EXISTS `is_deleted` TINYINT(1) DEFAULT 0; + +-- Copy name to table_number if name exists and table_number is empty +-- This is a bit tricky in pure SQL without knowing if 'name' still exists. +-- But usually, if they have 'name', they need to move it to 'table_number'. + +-- If name exists, this will work. If not, it will fail, which is okay for this specific fix. +UPDATE `tables` SET `table_number` = `name` WHERE `table_number` IS NULL OR `table_number` = ''; + +-- Fix areas foreign key if it was wrong in their initial setup +ALTER TABLE `areas` DROP FOREIGN KEY IF EXISTS `areas_ibfk_1`; +ALTER TABLE `areas` ADD CONSTRAINT `areas_ibfk_1` FOREIGN KEY (`outlet_id`) REFERENCES `outlets`(`id`); +ALTER TABLE `areas` ADD COLUMN IF NOT EXISTS `is_deleted` TINYINT(1) DEFAULT 0; diff --git a/db/schema.sql b/db/schema.sql index 427a5e8..6e8fb15 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -3,6 +3,7 @@ CREATE TABLE IF NOT EXISTS outlets ( name VARCHAR(255) NOT NULL, name_ar VARCHAR(255), address TEXT, + is_deleted TINYINT(1) DEFAULT 0, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); @@ -11,7 +12,8 @@ CREATE TABLE IF NOT EXISTS categories ( name VARCHAR(255) NOT NULL, name_ar VARCHAR(255), image_url VARCHAR(255), - sort_order INT DEFAULT 0 + sort_order INT DEFAULT 0, + is_deleted TINYINT(1) DEFAULT 0 ); CREATE TABLE IF NOT EXISTS products ( @@ -47,6 +49,7 @@ CREATE TABLE IF NOT EXISTS areas ( id INT AUTO_INCREMENT PRIMARY KEY, outlet_id INT, name VARCHAR(255) NOT NULL, + is_deleted TINYINT(1) DEFAULT 0, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (outlet_id) REFERENCES outlets(id) ); @@ -54,8 +57,10 @@ CREATE TABLE IF NOT EXISTS areas ( CREATE TABLE IF NOT EXISTS tables ( id INT AUTO_INCREMENT PRIMARY KEY, area_id INT, - name VARCHAR(50) NOT NULL, + table_number VARCHAR(50) NOT NULL, capacity INT DEFAULT 4, + status ENUM('available', 'occupied', 'reserved', 'inactive') DEFAULT 'available', + is_deleted TINYINT(1) DEFAULT 0, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (area_id) REFERENCES areas(id) ); @@ -64,7 +69,8 @@ CREATE TABLE IF NOT EXISTS payment_types ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL, name_ar VARCHAR(255), - is_active TINYINT(1) DEFAULT 1 + is_active TINYINT(1) DEFAULT 1, + is_deleted TINYINT(1) DEFAULT 0 ); CREATE TABLE IF NOT EXISTS orders ( @@ -113,4 +119,4 @@ CREATE TABLE IF NOT EXISTS loyalty_customers ( total_redemptions INT DEFAULT 0, address TEXT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP -); +); \ No newline at end of file diff --git a/qorder.php b/qorder.php index d7b1210..8550eb7 100644 --- a/qorder.php +++ b/qorder.php @@ -109,7 +109,7 @@ foreach ($variants_raw as $v) {
AR
-
Table
+
Table
@@ -140,7 +140,7 @@ foreach ($variants_raw as $v) { ?>
$product['id'], 'name' => $product['name'], 'name_ar' => $product['name_ar'] ?? $product['name'],