-- OurOutlet Food Database Backup
-- Created: 2026-09-02 21:36:11 Asia/Karachi
-- Database: irsazivy_blends_n_bites
-- Mode: FULL STRUCTURE + DATA

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- --------------------------------------------------------
-- Table: qd_categories
DROP TABLE IF EXISTS `qd_categories`;
CREATE TABLE `qd_categories` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) DEFAULT NULL,
  `category_name` varchar(190) NOT NULL,
  `sort_order` int(11) NOT NULL DEFAULT 0,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_category_sort` (`sort_order`),
  KEY `idx_category_brand` (`brand_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `qd_categories` (`id`,`brand_id`,`category_name`,`sort_order`,`is_active`,`created_at`,`updated_at`) VALUES
('1',NULL,'Plain White Rice','1','1','2026-09-02 13:41:24','2026-09-02 13:41:25'),
('2',NULL,'Matka Biryani','2','1','2026-09-02 13:41:24','2026-09-02 13:41:25'),
('3',NULL,'Coffee Menu','3','1','2026-09-02 13:41:24','2026-09-02 13:41:25'),
('4',NULL,'Fresh & Dry Fruit Chat','4','1','2026-09-02 13:41:24','2026-09-02 13:41:25'),
('5',NULL,'Lassi','5','1','2026-09-02 13:41:24','2026-09-02 13:41:25'),
('6',NULL,'Samosa Chat','6','1','2026-09-02 13:41:24','2026-09-02 13:41:25');

-- --------------------------------------------------------
-- Table: qd_customer_cancel_alerts
DROP TABLE IF EXISTS `qd_customer_cancel_alerts`;
CREATE TABLE `qd_customer_cancel_alerts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) NOT NULL DEFAULT 0,
  `order_id` int(11) NOT NULL,
  `cancel_reason` varchar(500) NOT NULL DEFAULT '',
  `cancelled_at` datetime NOT NULL,
  `kds_acknowledged_at` datetime DEFAULT NULL,
  `kds_acknowledged_by` varchar(190) DEFAULT NULL,
  `bill_acknowledged_at` datetime DEFAULT NULL,
  `bill_acknowledged_by` varchar(190) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_qd_customer_cancel_order` (`brand_id`,`order_id`),
  KEY `idx_qd_customer_cancel_kds` (`brand_id`,`kds_acknowledged_at`,`cancelled_at`),
  KEY `idx_qd_customer_cancel_bill` (`brand_id`,`bill_acknowledged_at`,`cancelled_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_customer_locations
DROP TABLE IF EXISTS `qd_customer_locations`;
CREATE TABLE `qd_customer_locations` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `customer_id` int(11) DEFAULT NULL,
  `customer_name` varchar(190) DEFAULT NULL,
  `phone` varchar(50) NOT NULL,
  `location_lat` decimal(10,6) DEFAULT NULL,
  `location_lng` decimal(10,6) DEFAULT NULL,
  `maps_url` text DEFAULT NULL,
  `source` varchar(50) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_qd_customer_location_phone` (`phone`),
  KEY `idx_customer_location_customer_id` (`customer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_customer_payments
DROP TABLE IF EXISTS `qd_customer_payments`;
CREATE TABLE `qd_customer_payments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `customer_id` int(11) DEFAULT NULL,
  `customer_name` varchar(190) DEFAULT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `order_id` int(11) DEFAULT NULL,
  `order_total` decimal(12,2) NOT NULL DEFAULT 0.00,
  `amount_paid` decimal(12,2) NOT NULL DEFAULT 0.00,
  `amount_due` decimal(12,2) NOT NULL DEFAULT 0.00,
  `payment_type` varchar(20) NOT NULL DEFAULT 'received',
  `payment_method` varchar(20) DEFAULT NULL,
  `payment_recorded_at` datetime DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_customer_payments_customer` (`customer_id`),
  KEY `idx_customer_payments_phone` (`phone`),
  KEY `idx_customer_payments_order` (`order_id`),
  KEY `idx_customer_payments_recorded` (`payment_recorded_at`),
  KEY `idx_customer_payments_method` (`payment_method`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_daily_expenses
DROP TABLE IF EXISTS `qd_daily_expenses`;
CREATE TABLE `qd_daily_expenses` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) DEFAULT NULL,
  `expense_date` date NOT NULL,
  `expenses_json` mediumtext DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_daily_brand_date` (`brand_id`,`expense_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_items
DROP TABLE IF EXISTS `qd_items`;
CREATE TABLE `qd_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) DEFAULT NULL,
  `category_id` int(11) NOT NULL DEFAULT 0,
  `item_name` varchar(190) NOT NULL,
  `item_type` varchar(40) NOT NULL DEFAULT 'single',
  `item_description` text DEFAULT NULL,
  `item_discount` decimal(10,2) NOT NULL DEFAULT 0.00,
  `base_price` decimal(10,2) NOT NULL DEFAULT 0.00,
  `image_path` varchar(255) DEFAULT NULL,
  `is_available` tinyint(1) NOT NULL DEFAULT 1,
  `sort_order` int(11) NOT NULL DEFAULT 0,
  `inventory_quantity` decimal(12,2) NOT NULL DEFAULT 0.00,
  `cost_price` decimal(10,2) NOT NULL DEFAULT 0.00,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(),
  `stock_monitor_enabled` tinyint(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `idx_item_category` (`category_id`),
  KEY `idx_item_brand` (`brand_id`),
  KEY `idx_item_available` (`is_available`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `qd_items` (`id`,`brand_id`,`category_id`,`item_name`,`item_type`,`item_description`,`item_discount`,`base_price`,`image_path`,`is_available`,`sort_order`,`inventory_quantity`,`cost_price`,`created_at`,`updated_at`,`stock_monitor_enabled`) VALUES
('1',NULL,'1','Plain White Rice','single','Karachi\'s Famous Memon-Style Daal with Fluffy White Rice & Achar','0.00','0.00','img_6a97e7ee668560.59811084.jpg','1','10','0.00','0.00','2026-09-02 13:41:24','2026-09-02 14:10:06','0'),
('2',NULL,'2','Matka Biryani','single','Aroma of Tradition, Dum Cooked, Served Hot with Raita','0.00','0.00','Matka Biryani.jpg','1','20','0.00','0.00','2026-09-02 13:41:24','2026-09-02 14:08:28','0'),
('3',NULL,'3','Black Coffee','single','','0.00','0.00','Black Coffee.jpg','1','30','0.00','0.00','2026-09-02 13:41:24','2026-09-02 14:08:27','0'),
('4',NULL,'3','Cappuccino Coffee','single','','0.00','0.00','Cappuccino Coffee.jpg','1','40','0.00','0.00','2026-09-02 13:41:24','2026-09-02 14:08:28','0'),
('5',NULL,'3','Latte Coffee','single','','0.00','0.00','Latte Coffee.jpg','1','50','0.00','0.00','2026-09-02 13:41:24','2026-09-02 14:08:28','0'),
('6',NULL,'3','Mocha','single','','0.00','0.00','Mocha.jpg','1','60','0.00','0.00','2026-09-02 13:41:24','2026-09-02 14:08:29','0'),
('7',NULL,'3','Classic Cold Coffee','single','','0.00','0.00','Classic Cold Coffee.jpg','1','70','0.00','0.00','2026-09-02 13:41:24','2026-09-02 14:08:28','0'),
('8',NULL,'3','Oreo Latte Coffee','single','With Oreo Biscuits, Condensed Milk, Fresh Milk, Ice & Cream Topping','0.00','0.00','Oreo Latte Coffee.jpg','1','80','0.00','0.00','2026-09-02 13:41:24','2026-09-02 14:08:30','0'),
('9',NULL,'4','Fresh & Dry Fruit Chat','single','Fresh Seasonal Fruits, Dry Fruits & Nuts, Healthy & Delicious','0.00','0.00','Fresh & Dry Fruit Chat.jpg','1','90','0.00','0.00','2026-09-02 13:41:24','2026-09-02 14:08:28','0'),
('10',NULL,'5','Namkeen Lassi','single','Perfectly Salted & Refreshing','0.00','0.00','Namkeen Lassi.jpg','1','100','0.00','0.00','2026-09-02 13:41:24','2026-09-02 14:08:29','0'),
('11',NULL,'5','Meethi Lassi','single','Sweet, Creamy & Traditional','0.00','0.00','Meethi Lassi.jpg','1','110','0.00','0.00','2026-09-02 13:41:24','2026-09-02 14:08:29','0'),
('12',NULL,'5','Mint Lassi','single','Cool, Refreshing & Minty','0.00','0.00','Mint Lassi.jpg','1','120','0.00','0.00','2026-09-02 13:41:24','2026-09-02 14:08:29','0'),
('13',NULL,'5','Fruit Flavoured Lassi','variation','','0.00','0.00','Fruit Flavoured Lassi.jpg','1','130','0.00','0.00','2026-09-02 13:41:24','2026-09-02 14:08:28','0'),
('14',NULL,'6','Samosa Chat','single','Crispy Samosa with 3 Signature Chutneys / Sauces: Samo Chutney (Spicy & Tangy), Imli Chutney (Tamarind Sweet & Sour), Raita (Cooling & Creamy)','0.00','0.00','Samosa Chat.jpg','1','140','0.00','0.00','2026-09-02 13:41:24','2026-09-02 14:08:30','0');

-- --------------------------------------------------------
-- Table: qd_monthly_expenses
DROP TABLE IF EXISTS `qd_monthly_expenses`;
CREATE TABLE `qd_monthly_expenses` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) DEFAULT NULL,
  `expense_month` char(7) NOT NULL,
  `rent_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `bill_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `extra_expenses_json` mediumtext DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(),
  `rent_paid_at` datetime DEFAULT NULL,
  `bill_paid_at` datetime DEFAULT NULL,
  `rent_added_at` datetime DEFAULT NULL,
  `bill_added_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_expense_brand_month` (`brand_id`,`expense_month`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_order_items
DROP TABLE IF EXISTS `qd_order_items`;
CREATE TABLE `qd_order_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `order_id` int(11) NOT NULL,
  `item_name` varchar(255) NOT NULL,
  `variant_name` varchar(255) DEFAULT NULL,
  `unit_price` decimal(12,2) NOT NULL DEFAULT 0.00,
  `quantity` int(11) NOT NULL DEFAULT 1,
  `line_total` decimal(12,2) NOT NULL DEFAULT 0.00,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_order_id` (`order_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `qd_order_items` (`id`,`order_id`,`item_name`,`variant_name`,`unit_price`,`quantity`,`line_total`,`created_at`) VALUES
('1','1','Plain White Rice','Single','0.00','1','0.00','2026-09-02 21:30:34');

-- --------------------------------------------------------
-- Table: qd_order_modifications
DROP TABLE IF EXISTS `qd_order_modifications`;
CREATE TABLE `qd_order_modifications` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) NOT NULL DEFAULT 0,
  `order_id` int(11) NOT NULL,
  `source` varchar(50) NOT NULL DEFAULT 'pos_bill',
  `items_json` longtext NOT NULL,
  `added_subtotal` decimal(12,2) NOT NULL DEFAULT 0.00,
  `created_by_name` varchar(190) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `acknowledged_at` datetime DEFAULT NULL,
  `acknowledged_by` varchar(190) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_qd_mod_order` (`order_id`),
  KEY `idx_qd_mod_brand_pending` (`brand_id`,`acknowledged_at`,`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_orders
DROP TABLE IF EXISTS `qd_orders`;
CREATE TABLE `qd_orders` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) DEFAULT NULL,
  `customer_id` int(11) DEFAULT NULL,
  `source` varchar(60) NOT NULL DEFAULT 'customer_page',
  `created_by_name` varchar(190) DEFAULT NULL,
  `order_type` varchar(30) NOT NULL DEFAULT 'delivery',
  `status` varchar(40) NOT NULL DEFAULT 'placed',
  `customer_name` varchar(190) NOT NULL,
  `phone_number` varchar(40) DEFAULT NULL,
  `address` text DEFAULT NULL,
  `precise_address` text DEFAULT NULL,
  `location_lat` decimal(10,6) DEFAULT NULL,
  `location_lng` decimal(10,6) DEFAULT NULL,
  `maps_url` text DEFAULT NULL,
  `kitchen_note` varchar(500) DEFAULT NULL,
  `subtotal_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `delivery_charge` decimal(12,2) NOT NULL DEFAULT 0.00,
  `total_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `table_number` int(11) DEFAULT NULL,
  `payment_method` varchar(40) DEFAULT NULL,
  `gst_percent` decimal(10,2) NOT NULL DEFAULT 0.00,
  `gst_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `service_charge_percent` decimal(10,2) NOT NULL DEFAULT 0.00,
  `service_charge_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `raw_whatsapp_text` mediumtext DEFAULT NULL,
  `rider_id` int(11) DEFAULT NULL,
  `cancel_reason` text DEFAULT NULL,
  `cancelled_by` varchar(40) DEFAULT NULL,
  `inventory_deducted` tinyint(1) NOT NULL DEFAULT 0,
  `accepted_at` datetime DEFAULT NULL,
  `processing_at` datetime DEFAULT NULL,
  `ready_at` datetime DEFAULT NULL,
  `picked_up_at` datetime DEFAULT NULL,
  `delivered_at` datetime DEFAULT NULL,
  `cancelled_at` datetime DEFAULT NULL,
  `auto_accepted_at` datetime DEFAULT NULL,
  `auto_completed_at` datetime DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_status` (`status`),
  KEY `idx_order_type` (`order_type`),
  KEY `idx_source` (`source`),
  KEY `idx_created` (`created_at`),
  KEY `idx_brand` (`brand_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `qd_orders` (`id`,`brand_id`,`customer_id`,`source`,`created_by_name`,`order_type`,`status`,`customer_name`,`phone_number`,`address`,`precise_address`,`location_lat`,`location_lng`,`maps_url`,`kitchen_note`,`subtotal_amount`,`delivery_charge`,`total_amount`,`table_number`,`payment_method`,`gst_percent`,`gst_amount`,`service_charge_percent`,`service_charge_amount`,`raw_whatsapp_text`,`rider_id`,`cancel_reason`,`cancelled_by`,`inventory_deducted`,`accepted_at`,`processing_at`,`ready_at`,`picked_up_at`,`delivered_at`,`cancelled_at`,`auto_accepted_at`,`auto_completed_at`,`created_at`,`updated_at`) VALUES
('1','1','1','customer_page','Website Customer','delivery','processing','waaqas','3253679202','janjkdnkjd','',NULL,NULL,'',NULL,'0.00','50.00','50.00',NULL,'cash','0.00','0.00','0.00','0.00','*New Order - Blends N Bites*\n\nOrder ID: #1\nOrder Type: Delivery\nPayment: Cash\n\n━━━━━━━━━━━━━━━━━━━━\nPlain White Rice\nSingle\nQty: 1\nPrice: Rs. 0\nLine Total: Rs. 0\n\n====================\nSubtotal: Rs. 0\nDelivery: Rs. 50\nTotal Bill: Rs. 50\n\n━━━━━━━━━━━━━━━━━━━━\nCustomer Details\nCustomer Name: waaqas\nPhone: 3253679202\nManual Address: janjkdnkjd\n━━━━━━━━━━━━━━━━━━━━',NULL,NULL,NULL,'1','2026-09-02 21:32:38','2026-09-02 21:32:38',NULL,NULL,NULL,NULL,NULL,NULL,'2026-09-02 21:30:34','2026-09-02 21:32:38');

-- --------------------------------------------------------
-- Table: qd_promotions
DROP TABLE IF EXISTS `qd_promotions`;
CREATE TABLE `qd_promotions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) NOT NULL DEFAULT 0,
  `promo_type` varchar(30) NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 0,
  `desktop_image` varchar(255) DEFAULT NULL,
  `mobile_image` varchar(255) DEFAULT NULL,
  `link_url` varchar(500) DEFAULT NULL,
  `marquee_text` text DEFAULT NULL,
  `popup_delay` int(11) NOT NULL DEFAULT 2,
  `popup_duration` int(11) NOT NULL DEFAULT 6,
  `marquee_speed` int(11) NOT NULL DEFAULT 18,
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(),
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_brand_type` (`brand_id`,`promo_type`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `qd_promotions` (`id`,`brand_id`,`promo_type`,`is_active`,`desktop_image`,`mobile_image`,`link_url`,`marquee_text`,`popup_delay`,`popup_duration`,`marquee_speed`,`updated_at`,`created_at`) VALUES
('1','1','banner','1','img_6a97eca883a7e8.74415033.jpg','img_6a97eca8c7c410.03885317.jpg','','','2','6','18','2026-09-02 14:30:16','2026-09-02 14:27:34'),
('5','1','menu_banner','1','img_6a97ecc51f9856.51025037.jpg','img_6a97ecc5584ca9.04611282.jpg','','','2','6','18',NULL,'2026-09-02 14:30:45');

-- --------------------------------------------------------
-- Table: qd_recipe_ingredients
DROP TABLE IF EXISTS `qd_recipe_ingredients`;
CREATE TABLE `qd_recipe_ingredients` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `scope` varchar(10) NOT NULL DEFAULT 'item',
  `ref_id` int(11) NOT NULL DEFAULT 0,
  `ingredient_name` varchar(190) NOT NULL DEFAULT '',
  `unit` varchar(20) NOT NULL DEFAULT 'piece',
  `quantity_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `makes_count` decimal(12,2) NOT NULL DEFAULT 0.00,
  `available_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `sort_order` int(11) NOT NULL DEFAULT 0,
  `brand_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_recipe_ref` (`scope`,`ref_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;


-- --------------------------------------------------------
-- Table: qd_salary_payments
DROP TABLE IF EXISTS `qd_salary_payments`;
CREATE TABLE `qd_salary_payments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) DEFAULT NULL,
  `staff_id` int(11) NOT NULL,
  `pay_month` char(7) NOT NULL,
  `amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `paid_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_salary_staff_month` (`staff_id`,`pay_month`),
  KEY `idx_salary_brand_month` (`brand_id`,`pay_month`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_settings
DROP TABLE IF EXISTS `qd_settings`;
CREATE TABLE `qd_settings` (
  `setting_key` varchar(190) NOT NULL,
  `setting_value` mediumtext DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(),
  PRIMARY KEY (`setting_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `qd_settings` (`setting_key`,`setting_value`,`created_at`,`updated_at`) VALUES
('active_brand_id','1','2026-09-02 13:31:29','2026-09-02 21:23:17'),
('bill_delivery_card_gst_tax','0','2026-09-02 13:31:29',NULL),
('bill_delivery_cash_gst_tax','0','2026-09-02 13:31:29',NULL),
('bill_pickup_card_gst_tax','0','2026-09-02 13:31:29',NULL),
('bill_pickup_cash_gst_tax','0','2026-09-02 13:31:29',NULL),
('business_website','','2026-09-02 13:31:29','2026-09-02 13:33:32'),
('delivery_charge','50','2026-09-02 13:31:29',NULL),
('dinein_card_gst','5','2026-09-02 13:31:29',NULL),
('dinein_cash_gst','16','2026-09-02 13:31:29',NULL),
('dinein_service_charge','0','2026-09-02 13:31:29',NULL),
('global_discount','0','2026-09-02 13:31:29',NULL),
('main_brand_id','1','2026-09-02 13:33:20','2026-09-02 13:33:32'),
('site_name','Blends N Bites','2026-09-02 13:31:29',NULL),
('website_card_gst_tax','0','2026-09-02 13:31:29',NULL),
('website_cash_gst_tax','0','2026-09-02 13:31:29',NULL),
('whatsapp_number','03163639901','2026-09-02 13:31:29',NULL);

-- --------------------------------------------------------
-- Table: qd_staff_due_payments
DROP TABLE IF EXISTS `qd_staff_due_payments`;
CREATE TABLE `qd_staff_due_payments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) DEFAULT NULL,
  `staff_id` int(11) NOT NULL,
  `amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `payment_type` varchar(20) DEFAULT NULL,
  `created_by` varchar(190) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_staff_due_payments_staff` (`staff_id`),
  KEY `idx_staff_due_payments_brand` (`brand_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_staff_expense_staff
DROP TABLE IF EXISTS `qd_staff_expense_staff`;
CREATE TABLE `qd_staff_expense_staff` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `expense_id` int(11) NOT NULL,
  `staff_id` int(11) NOT NULL,
  `staff_name` varchar(190) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_staff_expense_staff_expense` (`expense_id`),
  KEY `idx_staff_expense_staff_staff` (`staff_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_staff_expenses
DROP TABLE IF EXISTS `qd_staff_expenses`;
CREATE TABLE `qd_staff_expenses` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) DEFAULT NULL,
  `title` varchar(190) NOT NULL,
  `amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `expense_category` varchar(20) NOT NULL DEFAULT 'personal',
  `created_by` varchar(190) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_staff_expenses_brand` (`brand_id`),
  KEY `idx_staff_expenses_created` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_staff_order_items
DROP TABLE IF EXISTS `qd_staff_order_items`;
CREATE TABLE `qd_staff_order_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `order_id` int(11) NOT NULL,
  `item_name` varchar(190) NOT NULL,
  `variant_name` varchar(190) DEFAULT NULL,
  `quantity` int(11) NOT NULL DEFAULT 1,
  `unit_price` decimal(12,2) NOT NULL DEFAULT 0.00,
  `line_total` decimal(12,2) NOT NULL DEFAULT 0.00,
  PRIMARY KEY (`id`),
  KEY `idx_staff_order_items_order` (`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_staff_order_staff
DROP TABLE IF EXISTS `qd_staff_order_staff`;
CREATE TABLE `qd_staff_order_staff` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `order_id` int(11) NOT NULL,
  `staff_id` int(11) NOT NULL,
  `staff_name` varchar(190) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_staff_order_staff_order` (`order_id`),
  KEY `idx_staff_order_staff_staff` (`staff_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_staff_orders
DROP TABLE IF EXISTS `qd_staff_orders`;
CREATE TABLE `qd_staff_orders` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) DEFAULT NULL,
  `total_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `items_count` int(11) NOT NULL DEFAULT 0,
  `expense_category` varchar(20) NOT NULL DEFAULT 'personal',
  `created_by` varchar(190) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_staff_orders_brand` (`brand_id`),
  KEY `idx_staff_orders_created` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_staff_page_access
DROP TABLE IF EXISTS `qd_staff_page_access`;
CREATE TABLE `qd_staff_page_access` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) NOT NULL,
  `staff_id` int(11) NOT NULL,
  `page_key` varchar(80) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_staff_page_access` (`brand_id`,`staff_id`,`page_key`),
  KEY `idx_staff_access_brand_page` (`brand_id`,`page_key`),
  KEY `idx_staff_access_staff` (`staff_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_storefront_category_images
DROP TABLE IF EXISTS `qd_storefront_category_images`;
CREATE TABLE `qd_storefront_category_images` (
  `brand_id` int(11) NOT NULL DEFAULT 0,
  `category_id` int(11) NOT NULL,
  `image_path` varchar(255) DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(),
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`brand_id`,`category_id`),
  KEY `idx_sf_category` (`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `qd_storefront_category_images` (`brand_id`,`category_id`,`image_path`,`updated_at`,`created_at`) VALUES
('1','1','img_6a97f073257103.33839952.jpg',NULL,'2026-09-02 14:46:27'),
('1','2','img_6a97f072dbc5a1.15643625.jpg',NULL,'2026-09-02 14:46:27'),
('1','3','img_6a97f072072a51.65598081.jpg',NULL,'2026-09-02 14:46:26'),
('1','4','img_6a97f0724f83c5.54194587.jpg',NULL,'2026-09-02 14:46:26'),
('1','5','img_6a97f0729c9287.25623531.jpg',NULL,'2026-09-02 14:46:26'),
('1','6','img_6a97f07368b009.88433067.jpg',NULL,'2026-09-02 14:46:27');

-- --------------------------------------------------------
-- Table: qd_storefront_content
DROP TABLE IF EXISTS `qd_storefront_content`;
CREATE TABLE `qd_storefront_content` (
  `brand_id` int(11) NOT NULL DEFAULT 0,
  `home_kicker` varchar(120) DEFAULT NULL,
  `home_title` varchar(220) DEFAULT NULL,
  `home_text` text DEFAULT NULL,
  `home_intro_active` tinyint(1) NOT NULL DEFAULT 1,
  `show_logo` tinyint(1) NOT NULL DEFAULT 1,
  `nav_home` varchar(80) DEFAULT NULL,
  `nav_menu` varchar(80) DEFAULT NULL,
  `nav_about` varchar(80) DEFAULT NULL,
  `nav_contact` varchar(80) DEFAULT NULL,
  `help_phone` varchar(80) DEFAULT NULL,
  `instagram_url` varchar(500) DEFAULT NULL,
  `facebook_url` varchar(500) DEFAULT NULL,
  `tiktok_url` varchar(500) DEFAULT NULL,
  `category_title` varchar(220) DEFAULT NULL,
  `about_title` varchar(220) DEFAULT NULL,
  `about_text` text DEFAULT NULL,
  `contact_title` varchar(220) DEFAULT NULL,
  `contact_text` text DEFAULT NULL,
  `contact_phone` varchar(80) DEFAULT NULL,
  `contact_email` varchar(190) DEFAULT NULL,
  `contact_address` text DEFAULT NULL,
  `contact_hours` varchar(255) DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(),
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`brand_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `qd_storefront_content` (`brand_id`,`home_kicker`,`home_title`,`home_text`,`home_intro_active`,`show_logo`,`nav_home`,`nav_menu`,`nav_about`,`nav_contact`,`help_phone`,`instagram_url`,`facebook_url`,`tiktok_url`,`category_title`,`about_title`,`about_text`,`contact_title`,`contact_text`,`contact_phone`,`contact_email`,`contact_address`,`contact_hours`,`updated_at`,`created_at`) VALUES
('1','Welcome','We are Coming Soon','','1','1','Home','Menu','About Us','Contact',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-09-02 15:45:10','2026-09-02 14:10:43');

-- --------------------------------------------------------
-- Table: qd_storefront_side_banners
DROP TABLE IF EXISTS `qd_storefront_side_banners`;
CREATE TABLE `qd_storefront_side_banners` (
  `brand_id` int(11) NOT NULL DEFAULT 0,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `left_image` varchar(255) DEFAULT NULL,
  `right_image` varchar(255) DEFAULT NULL,
  `left_link` varchar(500) DEFAULT NULL,
  `right_link` varchar(500) DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(),
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`brand_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_supplier_transactions
DROP TABLE IF EXISTS `qd_supplier_transactions`;
CREATE TABLE `qd_supplier_transactions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) DEFAULT NULL,
  `supplier_id` int(11) NOT NULL,
  `type` varchar(10) NOT NULL DEFAULT 'purchase',
  `purchase_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `payment_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `note` varchar(255) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_supplier_txn_supplier` (`supplier_id`),
  KEY `idx_supplier_txn_brand` (`brand_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_suppliers
DROP TABLE IF EXISTS `qd_suppliers`;
CREATE TABLE `qd_suppliers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) DEFAULT NULL,
  `name` varchar(190) NOT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `supplier_title` varchar(150) DEFAULT NULL,
  `goods_supplied` text DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_supplier_name` (`name`),
  KEY `idx_supplier_active` (`is_active`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_tax_settings
DROP TABLE IF EXISTS `qd_tax_settings`;
CREATE TABLE `qd_tax_settings` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) DEFAULT NULL,
  `setting_key` varchar(120) NOT NULL,
  `setting_value` text DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_tax_setting_brand_key` (`brand_id`,`setting_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------
-- Table: qd_variants
DROP TABLE IF EXISTS `qd_variants`;
CREATE TABLE `qd_variants` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) DEFAULT NULL,
  `item_id` int(11) NOT NULL DEFAULT 0,
  `variant_name` varchar(190) NOT NULL,
  `variant_group` varchar(50) NOT NULL DEFAULT 'variation',
  `price` decimal(10,2) NOT NULL DEFAULT 0.00,
  `sort_order` int(11) NOT NULL DEFAULT 0,
  `is_available` tinyint(1) NOT NULL DEFAULT 1,
  `inventory_quantity` decimal(12,2) NOT NULL DEFAULT 0.00,
  `cost_price` decimal(10,2) NOT NULL DEFAULT 0.00,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(),
  `stock_monitor_enabled` tinyint(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `idx_variant_item` (`item_id`),
  KEY `idx_variant_brand` (`brand_id`),
  KEY `idx_variant_available` (`is_available`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `qd_variants` (`id`,`brand_id`,`item_id`,`variant_name`,`variant_group`,`price`,`sort_order`,`is_available`,`inventory_quantity`,`cost_price`,`created_at`,`updated_at`,`stock_monitor_enabled`) VALUES
('1',NULL,'13','Mango','variation','0.00','130','1','0.00','0.00','2026-09-02 13:41:24',NULL,'0'),
('2',NULL,'13','Strawberry','variation','0.00','130','1','0.00','0.00','2026-09-02 13:41:24',NULL,'0'),
('3',NULL,'13','Mixed Fruit','variation','0.00','130','1','0.00','0.00','2026-09-02 13:41:24',NULL,'0');

SET FOREIGN_KEY_CHECKS = 1;
-- Backup complete.
