qorder update
This commit is contained in:
parent
a70af4ac2a
commit
c5bf0227e4
24
db/migrations/041_fix_tables_naming.sql
Normal file
24
db/migrations/041_fix_tables_naming.sql
Normal file
@ -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;
|
||||
@ -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
|
||||
);
|
||||
);
|
||||
@ -109,7 +109,7 @@ foreach ($variants_raw as $v) {
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<div class="lang-toggle" onclick="toggleLanguage()" id="lang-btn">AR</div>
|
||||
<div class="badge bg-light text-dark border"><span data-t="table">Table</span> <?= htmlspecialchars($table_info['table_name']) ?></div>
|
||||
<div class="badge bg-light text-dark border"><span data-t="table">Table</span> <?= htmlspecialchars((string)$table_info['table_name']) ?></div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@ -140,7 +140,7 @@ foreach ($variants_raw as $v) {
|
||||
?>
|
||||
<div class="col-6 col-md-4 product-item" data-category-id="<?= $product['category_id'] ?>">
|
||||
<div class="card h-100 product-card"
|
||||
onclick="handleProductClick(<?= htmlspecialchars(json_encode([
|
||||
onclick="handleProductClick(<?= htmlspecialchars((string)json_encode([
|
||||
'id' => $product['id'],
|
||||
'name' => $product['name'],
|
||||
'name_ar' => $product['name_ar'] ?? $product['name'],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user