--
-- Host: 127.0.0.1    Database: CCW
-- ------------------------------------------------------


--
-- Current Database: `CCW`
--

/*!40000 DROP DATABASE IF EXISTS `CCW`*/;

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `CCW` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;

USE `CCW`;

--
-- Table structure for table `audit_logs`
--

CREATE TABLE `audit_logs` (
  `audit_log_id` int NOT NULL AUTO_INCREMENT,
  `module_key` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `action_key` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `entity_type` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `entity_id` int DEFAULT NULL,
  `order_id` int DEFAULT NULL,
  `payment_id` int DEFAULT NULL,
  `customer_id` int DEFAULT NULL,
  `car_id` int DEFAULT NULL,
  `actor_employee_id` int DEFAULT NULL,
  `actor_name` varchar(120) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `branch_name` varchar(120) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `bill_number` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `amount` decimal(10,2) DEFAULT NULL,
  `message` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `before_json` longtext COLLATE utf8mb4_unicode_ci,
  `after_json` longtext COLLATE utf8mb4_unicode_ci,
  `meta_json` longtext COLLATE utf8mb4_unicode_ci,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`audit_log_id`),
  KEY `idx_audit_logs_created_at` (`created_at`),
  KEY `idx_audit_logs_module_key` (`module_key`),
  KEY `idx_audit_logs_action_key` (`action_key`),
  KEY `idx_audit_logs_order_id` (`order_id`),
  KEY `idx_audit_logs_payment_id` (`payment_id`),
  KEY `idx_audit_logs_actor_employee_id` (`actor_employee_id`),
  KEY `idx_audit_logs_branch_name` (`branch_name`),
  KEY `idx_audit_logs_bill_number` (`bill_number`),
  KEY `idx_audit_logs_report` (`created_at`,`module_key`,`action_key`),
  KEY `idx_audit_logs_branch_created` (`branch_name`,`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `audit_logs`
--

INSERT INTO `audit_logs` VALUES (1,'bill','create','order',43,43,NULL,1,2,2,'System Administrator','สาขารามอินทรา','RMI052026/0043',5000.00,'Booking bill created.',NULL,'{\"order_source\":\"booking\",\"status\":\"waiting\",\"payment_status\":\"partial\",\"queue_number\":1,\"total_price\":5000,\"deposit_amount\":3000,\"admin_deposit_amount\":3000,\"branch_deposit_amount\":0,\"pickup_due_at\":\"2026-05-10 17:02:00\",\"service_count\":1,\"service_names\":[\"ติดฟิล์มกรองแสง\"],\"notes\":\"\"}','{\"package_usage_count\":0,\"package_purchase_count\":0}','2026-05-07 17:02:57'),(2,'payment','receive','payment',49,43,49,1,2,2,'System Administrator','สาขารามอินทรา','RMI052026/0043',3000.00,'Deposit @Admin received at booking.',NULL,'{\"payment_method\":\"transfer\",\"recognized_amount\":3000,\"received_amount\":3000,\"change_amount\":0,\"payment_status_after\":\"partial\"}','{\"deposit_type\":\"admin\",\"order_source\":\"booking\"}','2026-05-07 17:02:57');

--
-- Table structure for table `cars`
--

CREATE TABLE `cars` (
  `car_id` int NOT NULL AUTO_INCREMENT,
  `customer_id` int NOT NULL,
  `plate_number` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
  `province` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `vehicle_type` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `brand` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `model` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `color` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`car_id`),
  UNIQUE KEY `uniq_cars_plate` (`plate_number`),
  KEY `idx_cars_customer` (`customer_id`),
  CONSTRAINT `fk_cars_customer` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`customer_id`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `cars`
--

INSERT INTO `cars` VALUES (1,1,'8154','Bangkok','SUV','Mazda','CX-30','เทาดำ','2026-04-22 12:37:08','2026-04-22 12:37:08'),(2,1,'3304','Bangkok','EV','Tesla','Model 3','ขาว','2026-04-22 12:50:23','2026-04-22 12:54:29'),(3,2,'3344','กรุงเทพมหานคร','Motorcycle','Honda','PCX','เทาดำ','2026-04-22 14:57:49','2026-04-23 20:56:54'),(4,3,'4ขส4501','กรุงเทพมหานคร','Pickup','Ford','Ranger','ขาว','2026-04-22 16:39:47','2026-04-22 16:39:47'),(5,4,'123','Bangkok','EV','Volvo','c','ดำ','2026-04-22 21:18:06','2026-04-22 21:18:06'),(6,5,'XXX','Bangkok','','','','','2026-04-22 21:32:37','2026-04-22 21:32:37'),(7,1,'5ขส8154','กรุงเทพมหานคร','SUV','Mazda','CX-30','เทาดำ','2026-04-23 19:13:06','2026-04-23 19:13:06'),(8,6,'2ขฒ7921','กรุงเทพมหานคร','Sedan','Mazda','Mazda 2','ดำ','2026-04-24 12:40:32','2026-04-24 12:40:32'),(9,2,'1234','กรุงเทพมหานคร','SUV','Honda','Cevic','ขาว','2026-04-30 11:34:42','2026-04-30 11:34:42'),(10,7,'QS-SRN','','Quick Service','Quick Service','สาขาศรีนครินทร์','','2026-05-04 12:50:22','2026-05-04 12:50:22');

--
-- Table structure for table `customer_package_items`
--

CREATE TABLE `customer_package_items` (
  `customer_package_item_id` int NOT NULL AUTO_INCREMENT,
  `customer_package_id` int NOT NULL,
  `sub_service_id` int NOT NULL,
  `service_name_snapshot` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
  `included_uses` int NOT NULL DEFAULT '1',
  `used_uses` int NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`customer_package_item_id`),
  KEY `idx_customer_package_items_package` (`customer_package_id`),
  KEY `idx_customer_package_items_sub_service` (`sub_service_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `customer_package_items`
--

INSERT INTO `customer_package_items` VALUES (1,1,7,'Engine Cleaning',5,0,'2026-04-28 17:18:42'),(2,1,3,'Interior Deep Clean',5,0,'2026-04-28 17:18:42'),(3,1,1,'Standard Wash',10,2,'2026-04-28 17:18:42'),(4,2,1,'Standard Wash',2,0,'2026-04-30 11:34:42');

--
-- Table structure for table `customer_packages`
--

CREATE TABLE `customer_packages` (
  `customer_package_id` int NOT NULL AUTO_INCREMENT,
  `customer_id` int NOT NULL,
  `car_id` int DEFAULT NULL,
  `vehicle_scope` enum('member','car') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'member',
  `package_service_id` int NOT NULL,
  `order_id` int NOT NULL,
  `package_name_snapshot` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` enum('active','cancelled') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `cancelled_at` datetime DEFAULT NULL,
  PRIMARY KEY (`customer_package_id`),
  KEY `idx_customer_packages_customer` (`customer_id`),
  KEY `idx_customer_packages_order` (`order_id`),
  KEY `idx_customer_packages_status` (`status`),
  KEY `idx_customer_packages_car` (`car_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `customer_packages`
--

INSERT INTO `customer_packages` VALUES (1,1,7,'member',15,16,'เคลือบเซรามิค','active','2026-04-28 17:18:42',NULL),(2,2,9,'car',16,19,'Package wash 2000','active','2026-04-30 11:34:42',NULL);

--
-- Table structure for table `customers`
--

CREATE TABLE `customers` (
  `customer_id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(120) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `loyalty_points` int NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`customer_id`),
  KEY `idx_customers_phone` (`phone`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `customers`
--

INSERT INTO `customers` VALUES (1,'ณรงค์ ทูลจินดา','0939659871',NULL,375,'2026-04-22 12:37:08','2026-04-28 17:21:19'),(2,'คุณแนน','0973294505',NULL,27,'2026-04-22 14:57:49','2026-05-05 21:04:49'),(3,'คุณเอ็ก','093556666',NULL,5,'2026-04-22 16:39:47','2026-04-22 16:43:45'),(4,'อาท','0957451703',NULL,379,'2026-04-22 21:18:06','2026-04-23 21:14:50'),(5,'อาม','123456',NULL,9,'2026-04-22 21:32:37','2026-04-23 11:06:01'),(6,'บลู','0944551535',NULL,1,'2026-04-24 12:40:32','2026-04-30 16:33:07'),(7,'Quick Service สาขาศรีนครินทร์','',NULL,0,'2026-05-04 12:50:22','2026-05-04 12:50:22');

--
-- Table structure for table `employee_branch_access`
--

CREATE TABLE `employee_branch_access` (
  `employee_id` int NOT NULL,
  `branch_name` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`employee_id`,`branch_name`),
  KEY `idx_employee_branch_name` (`branch_name`),
  CONSTRAINT `fk_employee_branch_access_employee` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`employee_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `employee_branch_access`
--

INSERT INTO `employee_branch_access` VALUES (3,'สาขาศรีนครินทร์'),(4,'สาขาศรีนครินทร์'),(5,'สาขาศรีนครินทร์');

--
-- Table structure for table `loyalty_transactions`
--

CREATE TABLE `loyalty_transactions` (
  `transaction_id` int NOT NULL AUTO_INCREMENT,
  `customer_id` int NOT NULL,
  `order_id` int DEFAULT NULL,
  `points` int NOT NULL,
  `transaction_type` enum('earn','redeem','adjust') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'earn',
  `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`transaction_id`),
  UNIQUE KEY `uniq_loyalty_order_type` (`order_id`,`transaction_type`),
  KEY `idx_loyalty_customer` (`customer_id`),
  CONSTRAINT `fk_loyalty_customer` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`customer_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_loyalty_order` FOREIGN KEY (`order_id`) REFERENCES `orders` (`order_id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `loyalty_transactions`
--

INSERT INTO `loyalty_transactions` VALUES (2,1,2,2,'earn','Earned from order #2','2026-04-22 14:20:17'),(5,3,5,5,'earn','Earned from order #5','2026-04-22 16:43:45'),(7,1,6,6,'earn','Earned from order #6','2026-04-22 21:46:16'),(9,5,8,9,'earn','Earned from order #8','2026-04-23 11:06:01'),(10,1,3,200,'earn','Earned from order #3','2026-04-23 11:25:39'),(13,1,10,5,'earn','Earned from order #10','2026-04-23 13:13:52'),(16,1,11,100,'earn','Earned from order #11','2026-04-23 20:38:42'),(18,4,12,379,'earn','Earned from order #12','2026-04-23 21:14:50'),(19,2,13,5,'earn','Earned from order #13','2026-04-24 12:33:59'),(20,1,15,1,'earn','Earned from order #15','2026-04-28 13:20:57'),(21,1,16,59,'earn','Earned from order #16','2026-04-28 17:18:46'),(23,1,17,1,'earn','Earned from order #17','2026-04-28 17:20:40'),(24,1,18,1,'earn','Earned from order #18','2026-04-28 17:21:19'),(25,2,19,20,'earn','Earned from order #19','2026-04-30 11:34:45'),(26,6,14,1,'earn','Earned from order #14','2026-04-30 16:33:07'),(27,2,9,2,'earn','Earned from order #9','2026-05-05 21:04:49');

--
-- Table structure for table `order_details`
--

CREATE TABLE `order_details` (
  `detail_id` int NOT NULL AUTO_INCREMENT,
  `order_id` int NOT NULL,
  `service_id` int NOT NULL,
  `service_name_snapshot` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
  `price` decimal(10,2) NOT NULL DEFAULT '0.00',
  `duration_minutes` int NOT NULL DEFAULT '60',
  `service_options` text COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`detail_id`),
  KEY `idx_order_details_order` (`order_id`),
  KEY `idx_order_details_service` (`service_id`),
  CONSTRAINT `fk_order_details_order` FOREIGN KEY (`order_id`) REFERENCES `orders` (`order_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_order_details_service` FOREIGN KEY (`service_id`) REFERENCES `services` (`service_id`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=65 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `order_details`
--

INSERT INTO `order_details` VALUES (1,1,7,'Engine Cleaning',800.00,45,NULL),(2,2,8,'AC System Ozone',500.00,30,NULL),(3,3,5,'Ceramic Pro Gold Package',37900.00,1440,NULL),(4,4,1,'Standard Wash',550.00,45,NULL),(5,5,1,'Standard Wash',550.00,45,NULL),(6,6,7,'Engine Cleaning',800.00,45,NULL),(7,6,9,'ติดฟิล์มกรองแสง รอบคัน',100.00,300,'{\"type\":\"window_tint\",\"front_percent\":\"40\",\"front_side_percent\":\"60\",\"rear_side_percent\":\"80\",\"rear_percent\":\"80\",\"notes\":\"\"}'),(8,7,5,'Ceramic Pro Gold Package',37900.00,1440,NULL),(9,8,8,'AC System Ozone',500.00,30,NULL),(10,9,1,'Standard Wash',550.00,45,NULL),(11,10,7,'Engine Cleaning',800.00,45,NULL),(12,11,8,'AC System Ozone',500.00,30,NULL),(13,11,7,'Engine Cleaning',800.00,45,NULL),(14,11,4,'Glass Coating',12900.00,480,NULL),(15,12,5,'Ceramic Pro Gold Package',37900.00,1440,NULL),(16,13,8,'AC System Ozone',500.00,30,NULL),(17,14,9,'ติดฟิล์มกรองแสง รอบคัน',100.00,300,'{\"type\":\"window_tint\",\"front_percent\":\"60\",\"front_side_percent\":\"80\",\"rear_side_percent\":\"80\",\"rear_percent\":\"80\",\"notes\":\"\"}'),(18,15,9,'ติดฟิล์มกรองแสง รอบคัน',100.00,300,'{\"type\":\"window_tint\",\"front_percent\":\"40\",\"front_side_percent\":\"40\",\"rear_side_percent\":\"40\",\"rear_percent\":\"40\",\"notes\":\"\"}'),(19,16,15,'เคลือบเซรามิค',5900.00,0,'{\"package_purchase\":{\"items\":[{\"sub_service_id\":7,\"service_name\":\"Engine Cleaning\",\"included_uses\":5},{\"sub_service_id\":3,\"service_name\":\"Interior Deep Clean\",\"included_uses\":5},{\"sub_service_id\":1,\"service_name\":\"Standard Wash\",\"included_uses\":10}]}}'),(20,17,1,'Standard Wash',0.00,0,'{\"package_usage\":{\"customer_package_item_id\":3,\"customer_package_id\":1,\"package_name\":\"เคลือบเซรามิค\",\"remaining_after_use\":9}}'),(21,18,1,'Standard Wash',0.00,0,'{\"package_usage\":{\"customer_package_item_id\":3,\"customer_package_id\":1,\"package_name\":\"เคลือบเซรามิค\",\"remaining_after_use\":8}}'),(22,19,16,'Package wash 2000',2000.00,0,'{\"package_purchase\":{\"items\":[{\"sub_service_id\":1,\"service_name\":\"Standard Wash\",\"included_uses\":2}]}}'),(23,20,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(24,20,47,'ล้างภายนอก + ดูดฝุ่น (S)',150.00,0,NULL),(25,21,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(26,22,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(27,23,47,'ล้างภายนอก + ดูดฝุ่น (S)',150.00,0,NULL),(28,24,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(30,25,47,'ล้างภายนอก + ดูดฝุ่น (S)',150.00,0,NULL),(31,26,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(32,27,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(34,28,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(36,29,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(38,30,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(40,31,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(41,32,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(43,33,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(45,34,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(49,35,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(51,36,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(53,37,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(56,38,48,'ล้างภายนอก + ดูดฝุ่น (M)',200.00,0,NULL),(57,38,47,'ล้างภายนอก + ดูดฝุ่น (S)',150.00,0,NULL),(60,39,47,'ล้างภายนอก + ดูดฝุ่น (S)',150.00,0,NULL),(61,40,11,'ติดฟิล์มกรองแสง',5000.00,0,'{\"type\":\"window_tint\",\"group_id\":9,\"group_name\":\"HI-Kool\",\"main_service_id\":11,\"front_service_id\":32,\"front_service_name\":\"HI-Kool (BY05)\",\"front_side_service_id\":32,\"front_side_service_name\":\"HI-Kool (BY05)\",\"rear_side_service_id\":32,\"rear_side_service_name\":\"HI-Kool (BY05)\",\"rear_service_id\":32,\"rear_service_name\":\"HI-Kool (BY05)\",\"notes\":\"\"}'),(62,41,47,'ล้างภายนอก + ดูดฝุ่น (S)',150.00,0,NULL),(63,42,7,'Engine Cleaning',800.00,45,NULL),(64,43,11,'ติดฟิล์มกรองแสง',5000.00,0,'{\"type\":\"window_tint\",\"group_id\":8,\"group_name\":\"AVERY\",\"main_service_id\":11,\"front_service_id\":28,\"front_service_name\":\"AVERY (PRO10)\",\"front_side_service_id\":28,\"front_side_service_name\":\"AVERY (PRO10)\",\"rear_side_service_id\":28,\"rear_side_service_name\":\"AVERY (PRO10)\",\"rear_service_id\":28,\"rear_service_name\":\"AVERY (PRO10)\",\"notes\":\"\"}');

--
-- Table structure for table `order_package_usages`
--

CREATE TABLE `order_package_usages` (
  `usage_id` int NOT NULL AUTO_INCREMENT,
  `order_id` int NOT NULL,
  `customer_package_item_id` int NOT NULL,
  `service_id` int NOT NULL,
  `service_name_snapshot` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
  `used_uses` int NOT NULL DEFAULT '1',
  `is_reversed` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `reversed_at` datetime DEFAULT NULL,
  PRIMARY KEY (`usage_id`),
  KEY `idx_order_package_usages_order` (`order_id`),
  KEY `idx_order_package_usages_package_item` (`customer_package_item_id`),
  KEY `idx_order_package_usages_service` (`service_id`),
  KEY `idx_order_package_usages_reversed` (`is_reversed`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `order_package_usages`
--

INSERT INTO `order_package_usages` VALUES (1,17,3,1,'Standard Wash',1,0,'2026-04-28 17:20:34',NULL),(2,18,3,1,'Standard Wash',1,0,'2026-04-28 17:21:16',NULL);

--
-- Table structure for table `orders`
--

CREATE TABLE `orders` (
  `order_id` int NOT NULL AUTO_INCREMENT,
  `bill_number` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `customer_id` int NOT NULL,
  `car_id` int NOT NULL,
  `employee_id` int DEFAULT NULL,
  `branch_name` varchar(120) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `order_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `scheduled_at` datetime DEFAULT NULL,
  `return_at` datetime DEFAULT NULL,
  `order_source` enum('booking','quick_service') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'booking',
  `started_at` datetime DEFAULT NULL,
  `finished_at` datetime DEFAULT NULL,
  `cancelled_at` datetime DEFAULT NULL,
  `cancelled_by_employee_id` int DEFAULT NULL,
  `cancellation_reason` text COLLATE utf8mb4_unicode_ci,
  `reopened_from_order_id` int DEFAULT NULL,
  `status` enum('waiting','washing','done','cancelled') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'waiting',
  `payment_status` enum('unpaid','partial','paid') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'unpaid',
  `total_price` decimal(10,2) NOT NULL DEFAULT '0.00',
  `deposit_amount` decimal(10,2) NOT NULL DEFAULT '0.00',
  `deposit_method` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `admin_deposit_amount` decimal(10,2) NOT NULL DEFAULT '0.00',
  `admin_deposit_method` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `branch_deposit_amount` decimal(10,2) NOT NULL DEFAULT '0.00',
  `branch_deposit_method` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`order_id`),
  UNIQUE KEY `uniq_orders_bill_number` (`bill_number`),
  KEY `idx_orders_status` (`status`),
  KEY `idx_orders_payment_status` (`payment_status`),
  KEY `idx_orders_order_date` (`order_date`),
  KEY `idx_orders_customer` (`customer_id`),
  KEY `idx_orders_car` (`car_id`),
  KEY `fk_orders_employee` (`employee_id`),
  KEY `idx_orders_branch_name` (`branch_name`),
  KEY `idx_orders_return_at` (`return_at`),
  KEY `idx_orders_deposit_method` (`deposit_method`),
  KEY `idx_orders_cancelled_at` (`cancelled_at`),
  KEY `idx_orders_cancelled_by_employee` (`cancelled_by_employee_id`),
  KEY `idx_orders_reopened_from` (`reopened_from_order_id`),
  KEY `idx_orders_order_source` (`order_source`),
  KEY `idx_orders_admin_deposit_method` (`admin_deposit_method`),
  KEY `idx_orders_branch_deposit_method` (`branch_deposit_method`),
  CONSTRAINT `fk_orders_car` FOREIGN KEY (`car_id`) REFERENCES `cars` (`car_id`) ON DELETE RESTRICT ON UPDATE CASCADE,
  CONSTRAINT `fk_orders_customer` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`customer_id`) ON DELETE RESTRICT ON UPDATE CASCADE,
  CONSTRAINT `fk_orders_employee` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`employee_id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `orders`
--

INSERT INTO `orders` VALUES (1,'CCW042026/0001',1,1,NULL,NULL,'2026-04-22 12:37:08',NULL,NULL,'booking','2026-04-23 11:41:45','2026-04-23 11:41:53','2026-04-23 13:13:10',2,'77',NULL,'cancelled','paid',500.00,500.00,'cash',500.00,'cash',0.00,NULL,'','2026-05-05 20:49:14'),(2,'CCW042026/0002',1,2,NULL,NULL,'2026-04-22 12:50:23','2026-04-22 13:00:00',NULL,'booking','2026-04-22 12:51:27','2026-04-22 14:20:17',NULL,NULL,NULL,NULL,'done','paid',200.00,200.00,'transfer',200.00,'transfer',0.00,NULL,'','2026-05-05 20:49:14'),(3,'CCW042026/0003',1,2,NULL,NULL,'2026-04-22 12:54:29','2026-04-22 13:54:00',NULL,'booking','2026-04-23 11:25:31','2026-04-23 11:25:39',NULL,NULL,NULL,NULL,'done','paid',20000.00,20000.00,'qr',20000.00,'qr',0.00,NULL,'','2026-05-05 20:49:14'),(4,'SRN042026/0004',2,3,NULL,'สาขาศรีนครินทร์','2026-04-22 14:57:49','2026-04-22 14:56:00','2026-04-22 15:00:00','booking','2026-04-22 14:59:46','2026-04-22 14:59:48','2026-04-23 11:21:56',2,'test',NULL,'cancelled','paid',250.00,100.00,'transfer',100.00,'transfer',0.00,NULL,'ถอดเครื่องมาล้างด้วย','2026-05-05 20:49:14'),(5,'SRN042026/0005',3,4,NULL,'สาขาศรีนครินทร์','2026-04-22 16:39:47',NULL,NULL,'booking','2026-04-22 16:40:10','2026-04-22 16:43:45',NULL,NULL,NULL,NULL,'done','paid',550.00,100.00,'transfer',100.00,'transfer',0.00,NULL,'','2026-05-05 20:49:14'),(6,'BNA042026/0006',1,2,NULL,'สาขาบางนา','2026-04-22 21:10:39','2026-04-23 08:00:00','2026-04-25 21:10:00','booking','2026-04-22 21:45:18','2026-04-22 21:46:16',NULL,NULL,NULL,NULL,'done','paid',600.00,200.00,'transfer',200.00,'transfer',0.00,NULL,'test','2026-05-05 20:49:14'),(7,'SRN042026/0007',4,5,NULL,'สาขาศรีนครินทร์','2026-04-22 21:18:06',NULL,NULL,'booking','2026-04-22 21:20:10','2026-04-22 21:20:36','2026-04-23 13:15:24',2,'ทดสอบ',NULL,'cancelled','paid',37900.01,2900.00,'transfer',2900.00,'transfer',0.00,NULL,'','2026-05-05 20:49:14'),(8,'BNA042026/0008',5,6,NULL,'สาขาบางนา','2026-04-22 21:32:37',NULL,NULL,'booking','2026-04-23 11:03:23','2026-04-23 11:06:01',NULL,NULL,NULL,NULL,'done','paid',900.00,0.00,'cash',0.00,NULL,0.00,NULL,'','2026-04-23 11:06:01'),(9,'SRN042026/0009',2,3,2,'สาขาศรีนครินทร์','2026-04-23 11:39:31','2026-04-22 14:56:00','2026-04-22 15:00:00','booking','2026-04-23 20:19:09','2026-05-05 21:04:49',NULL,NULL,NULL,4,'done','paid',250.00,0.00,NULL,0.00,NULL,0.00,NULL,'ถอดเครื่องมาล้างด้วย','2026-05-05 21:04:49'),(10,'CCW042026/0010',1,1,2,'','2026-04-22 12:37:08',NULL,NULL,'booking','2026-04-23 13:13:46','2026-04-23 13:13:52',NULL,NULL,NULL,1,'done','paid',500.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-04-23 13:13:54'),(11,'SRN042026/0011',1,7,NULL,'สาขาศรีนครินทร์','2026-04-23 19:13:06',NULL,NULL,'booking','2026-04-23 20:38:35','2026-04-23 20:38:42',NULL,NULL,NULL,NULL,'done','paid',10000.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-04-23 21:26:21'),(12,'SRN042026/0012',4,5,2,'สาขาศรีนครินทร์','2026-04-22 21:18:06',NULL,NULL,'booking','2026-04-23 20:58:02','2026-04-23 21:14:50',NULL,NULL,NULL,7,'done','unpaid',37900.01,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-04-23 21:14:50'),(13,'SRN042026/0013',2,3,NULL,'สาขาศรีนครินทร์','2026-04-23 20:55:56',NULL,NULL,'booking','2026-04-23 20:57:35','2026-04-24 12:33:59',NULL,NULL,NULL,NULL,'done','unpaid',500.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-04-24 12:33:59'),(14,'SRN042026/0014',6,8,NULL,'สาขาศรีนครินทร์','2026-04-24 12:40:32',NULL,NULL,'booking','2026-04-30 16:33:03','2026-04-30 16:33:07',NULL,NULL,NULL,NULL,'done','unpaid',80.00,0.00,NULL,0.00,NULL,0.00,NULL,'test','2026-04-30 16:33:07'),(15,'RMI042026/0015',1,7,NULL,'สาขารามอินทรา','2026-04-28 13:20:35',NULL,NULL,'booking','2026-04-28 13:20:51','2026-04-28 13:20:57',NULL,NULL,NULL,NULL,'done','unpaid',100.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-04-28 13:20:57'),(16,'RMI042026/0016',1,7,NULL,'สาขารามอินทรา','2026-04-28 17:18:42',NULL,NULL,'booking','2026-04-28 17:18:45','2026-04-28 17:18:46',NULL,NULL,NULL,NULL,'done','paid',5900.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-04-28 17:18:50'),(17,'SRN042026/0017',1,7,NULL,'สาขาศรีนครินทร์','2026-04-28 17:20:34',NULL,NULL,'booking','2026-04-28 17:20:37','2026-04-28 17:20:40',NULL,NULL,NULL,NULL,'done','unpaid',0.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-04-28 17:20:40'),(18,'SRN042026/0018',1,7,NULL,'สาขาศรีนครินทร์','2026-04-28 17:21:16',NULL,NULL,'booking','2026-04-28 17:21:18','2026-04-28 17:21:19',NULL,NULL,NULL,NULL,'done','unpaid',0.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-04-28 17:21:19'),(19,'SRN042026/0019',2,9,NULL,'สาขาศรีนครินทร์','2026-04-30 11:34:42',NULL,NULL,'booking','2026-04-30 11:34:44','2026-04-30 11:34:45',NULL,NULL,NULL,NULL,'done','unpaid',2000.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-04-30 11:34:45'),(20,'SRN052026/0020',7,10,2,'สาขาศรีนครินทร์','2026-05-04 12:50:22',NULL,NULL,'quick_service',NULL,'2026-05-04 12:50:22',NULL,NULL,NULL,NULL,'done','paid',350.00,0.00,NULL,0.00,NULL,0.00,NULL,'Test','2026-05-04 12:50:22'),(21,'SRN052026/0021',7,10,5,'สาขาศรีนครินทร์','2026-05-04 12:59:19',NULL,NULL,'quick_service',NULL,'2026-05-04 12:59:19',NULL,NULL,NULL,NULL,'done','paid',200.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 12:59:19'),(22,'SRN052026/0022',7,10,5,'สาขาศรีนครินทร์','2026-05-04 13:01:31',NULL,NULL,'quick_service',NULL,'2026-05-04 13:01:31',NULL,NULL,NULL,NULL,'done','paid',120.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 13:01:31'),(23,'SRN052026/0023',7,10,5,'สาขาศรีนครินทร์','2026-05-04 13:01:45',NULL,NULL,'quick_service',NULL,'2026-05-04 13:01:45',NULL,NULL,NULL,NULL,'done','paid',200.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 13:01:45'),(24,'SRN052026/0024',7,10,2,'สาขาศรีนครินทร์','2026-05-04 14:32:04',NULL,NULL,'quick_service',NULL,'2026-05-04 14:32:04',NULL,NULL,NULL,NULL,'done','paid',200.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 14:32:04'),(25,'SRN052026/0025',7,10,2,'สาขาศรีนครินทร์','2026-05-04 14:50:26',NULL,NULL,'quick_service',NULL,'2026-05-04 14:51:08',NULL,NULL,NULL,NULL,'done','paid',150.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 14:51:08'),(26,'SRN052026/0026',7,10,2,'สาขาศรีนครินทร์','2026-05-04 17:16:34',NULL,NULL,'quick_service',NULL,'2026-05-04 17:16:34',NULL,NULL,NULL,NULL,'done','paid',200.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 17:16:34'),(27,'SRN052026/0027',7,10,2,'สาขาศรีนครินทร์','2026-05-04 17:17:07',NULL,NULL,'quick_service',NULL,NULL,'2026-05-04 17:17:28',2,'test',NULL,'cancelled','unpaid',200.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 17:17:28'),(28,'SRN052026/0028',7,10,2,'สาขาศรีนครินทร์','2026-05-04 17:28:26',NULL,NULL,'quick_service',NULL,'2026-05-04 17:31:07',NULL,NULL,NULL,NULL,'done','paid',200.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 17:31:07'),(29,'SRN052026/0029',7,10,2,'สาขาศรีนครินทร์','2026-05-04 17:31:30',NULL,NULL,'quick_service',NULL,'2026-05-04 17:32:07',NULL,NULL,NULL,NULL,'done','paid',200.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 17:32:07'),(30,'SRN052026/0030',7,10,2,'สาขาศรีนครินทร์','2026-05-04 17:32:44',NULL,NULL,'quick_service',NULL,'2026-05-04 17:33:03',NULL,NULL,NULL,NULL,'done','paid',200.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 17:33:03'),(31,'SRN052026/0031',7,10,2,'สาขาศรีนครินทร์','2026-05-04 17:44:14',NULL,NULL,'quick_service',NULL,'2026-05-04 17:44:33',NULL,NULL,NULL,NULL,'done','paid',200.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 17:44:33'),(32,'SRN052026/0032',7,10,2,'สาขาศรีนครินทร์','2026-05-04 17:45:19',NULL,NULL,'quick_service',NULL,'2026-05-04 17:45:19',NULL,NULL,NULL,NULL,'done','paid',200.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 17:45:19'),(33,'SRN052026/0033',7,10,2,'สาขาศรีนครินทร์','2026-05-04 17:47:37',NULL,NULL,'quick_service',NULL,'2026-05-04 17:53:18',NULL,NULL,NULL,NULL,'done','paid',200.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 17:53:18'),(34,'SRN052026/0034',7,10,5,'สาขาศรีนครินทร์','2026-05-04 18:05:17',NULL,NULL,'quick_service',NULL,'2026-05-04 18:06:25',NULL,NULL,NULL,NULL,'done','paid',200.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 18:06:25'),(35,'SRN052026/0035',7,10,5,'สาขาศรีนครินทร์','2026-05-04 18:06:36',NULL,NULL,'quick_service',NULL,'2026-05-04 18:20:41',NULL,NULL,NULL,NULL,'done','paid',200.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 18:20:41'),(36,'SRN052026/0036',7,10,5,'สาขาศรีนครินทร์','2026-05-04 18:20:51',NULL,NULL,'quick_service',NULL,NULL,'2026-05-04 18:26:50',5,'test',NULL,'cancelled','partial',200.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 18:26:50'),(37,'SRN052026/0037',7,10,5,'สาขาศรีนครินทร์','2026-05-04 18:27:15',NULL,NULL,'quick_service',NULL,NULL,'2026-05-04 18:28:52',5,'jof',NULL,'cancelled','partial',200.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 18:28:52'),(38,'SRN052026/0038',7,10,2,'สาขาศรีนครินทร์','2026-05-04 18:27:56',NULL,NULL,'quick_service',NULL,'2026-05-04 18:50:24',NULL,NULL,NULL,NULL,'done','paid',350.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-04 18:50:24'),(39,'SRN052026/0039',7,10,2,'สาขาศรีนครินทร์','2026-05-04 18:58:10',NULL,NULL,'quick_service',NULL,'2026-05-05 19:47:38',NULL,NULL,NULL,NULL,'done','paid',150.00,0.00,NULL,0.00,NULL,0.00,NULL,'ทดสอบ','2026-05-05 19:47:38'),(40,'BNA052026/0040',1,7,NULL,'สาขาบางนา','2026-05-05 21:58:31',NULL,'2026-05-10 15:00:00','booking',NULL,NULL,'2026-05-05 22:26:56',6,'test',NULL,'cancelled','partial',5000.00,2000.00,'transfer',2000.00,'transfer',0.00,'cash','','2026-05-05 22:26:56'),(41,'BNA052026/0041',2,3,NULL,'สาขาบางนา','2026-05-05 22:47:34',NULL,NULL,'booking',NULL,NULL,NULL,NULL,NULL,NULL,'waiting','partial',150.00,100.00,'transfer',100.00,'transfer',0.00,'cash','','2026-05-05 22:47:34'),(42,'CCW042026/0042',1,1,2,'','2026-04-22 12:37:08',NULL,NULL,'booking',NULL,NULL,NULL,NULL,NULL,1,'waiting','unpaid',500.00,0.00,NULL,0.00,NULL,0.00,NULL,'','2026-05-06 15:45:17'),(43,'RMI052026/0043',1,2,NULL,'สาขารามอินทรา','2026-05-07 17:02:57',NULL,'2026-05-10 17:02:00','booking',NULL,NULL,NULL,NULL,NULL,NULL,'waiting','partial',5000.00,3000.00,'transfer',3000.00,'transfer',0.00,'cash','','2026-05-07 17:02:57');

--
-- Table structure for table `payments`
--

CREATE TABLE `payments` (
  `payment_id` int NOT NULL AUTO_INCREMENT,
  `order_id` int NOT NULL,
  `payment_method` enum('cash','transfer','qr','card') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'cash',
  `amount` decimal(10,2) NOT NULL DEFAULT '0.00',
  `received_amount` decimal(10,2) DEFAULT NULL,
  `change_amount` decimal(10,2) NOT NULL DEFAULT '0.00',
  `note` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `payment_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`payment_id`),
  KEY `idx_payments_order` (`order_id`),
  KEY `idx_payments_date` (`payment_date`),
  CONSTRAINT `fk_payments_order` FOREIGN KEY (`order_id`) REFERENCES `orders` (`order_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `payments`
--

INSERT INTO `payments` VALUES (1,2,'transfer',50.00,50.00,0.00,'Deposit at booking','2026-04-22 12:50:23'),(2,3,'qr',10000.00,10000.00,0.00,'Deposit at booking','2026-04-22 12:54:29'),(3,2,'card',150.00,150.00,0.00,'test','2026-04-22 14:20:41'),(4,1,'cash',500.00,500.00,0.00,'600','2026-04-22 14:21:14'),(5,3,'card',10000.00,10000.00,0.00,'Test by joe','2026-04-22 14:27:21'),(6,4,'transfer',100.00,100.00,0.00,'Deposit at booking','2026-04-22 14:57:49'),(7,4,'cash',150.00,150.00,0.00,'สะอาดมาก','2026-04-22 14:59:28'),(8,5,'transfer',100.00,100.00,0.00,'Deposit at booking','2026-04-22 16:39:47'),(9,5,'cash',450.00,450.00,0.00,'','2026-04-22 16:43:35'),(10,6,'transfer',200.00,200.00,0.00,'Deposit at booking','2026-04-22 21:10:39'),(11,7,'transfer',2900.00,2900.00,0.00,'Deposit at booking','2026-04-22 21:18:06'),(12,7,'qr',35000.01,35000.01,0.00,'','2026-04-22 21:21:17'),(13,6,'cash',400.00,400.00,0.00,'','2026-04-23 09:54:17'),(14,8,'cash',900.00,900.00,0.00,'','2026-04-23 11:04:41'),(15,9,'cash',250.00,250.00,0.00,'','2026-04-23 11:40:06'),(16,10,'cash',500.00,500.00,0.00,'','2026-04-23 13:13:54'),(17,11,'card',10000.00,10000.00,0.00,'','2026-04-23 21:26:21'),(18,16,'cash',5900.00,5900.00,0.00,'','2026-04-28 17:18:50'),(19,20,'cash',350.00,350.00,0.00,'Quick Service payment','2026-05-04 12:50:22'),(20,21,'cash',200.00,200.00,0.00,'Quick Service payment','2026-05-04 12:59:19'),(21,22,'cash',120.00,120.00,0.00,'Quick Service payment','2026-05-04 13:01:31'),(22,23,'cash',200.00,200.00,0.00,'Quick Service payment','2026-05-04 13:01:45'),(23,24,'cash',200.00,500.00,300.00,'Quick Service hold payment','2026-05-04 14:32:04'),(24,25,'cash',100.00,100.00,0.00,'Quick Service hold payment','2026-05-04 14:50:26'),(25,25,'transfer',50.00,100.00,0.00,'Quick Service payment','2026-05-04 14:51:08'),(26,26,'transfer',200.00,300.00,0.00,'Quick Service payment','2026-05-04 17:16:34'),(27,28,'cash',100.00,100.00,0.00,'Quick Service hold payment','2026-05-04 17:28:26'),(28,28,'cash',100.00,100.00,0.00,'Quick Service payment','2026-05-04 17:31:07'),(29,29,'cash',50.00,50.00,0.00,'Quick Service hold payment','2026-05-04 17:31:30'),(30,29,'cash',150.00,200.00,50.00,'Quick Service payment','2026-05-04 17:32:07'),(31,30,'transfer',50.00,50.00,0.00,'Quick Service hold payment','2026-05-04 17:32:44'),(32,30,'transfer',150.00,200.00,0.00,'Quick Service hold payment','2026-05-04 17:33:03'),(33,31,'transfer',100.00,100.00,0.00,'Quick Service hold payment','2026-05-04 17:44:14'),(34,31,'transfer',100.00,150.00,0.00,'Quick Service hold payment','2026-05-04 17:44:33'),(35,32,'transfer',200.00,250.00,0.00,'Quick Service hold payment','2026-05-04 17:45:19'),(36,33,'transfer',150.00,150.00,0.00,'Quick Service hold payment','2026-05-04 17:47:37'),(37,33,'transfer',50.00,100.00,0.00,'Quick Service hold payment','2026-05-04 17:53:18'),(38,34,'transfer',100.00,100.00,0.00,'Quick Service payment','2026-05-04 18:05:17'),(39,34,'transfer',100.00,100.00,0.00,'Quick Service payment','2026-05-04 18:06:25'),(40,35,'transfer',99.98,99.98,0.00,'Quick Service payment','2026-05-04 18:06:36'),(41,35,'transfer',100.02,100.02,0.00,'Quick Service payment','2026-05-04 18:20:41'),(42,36,'transfer',100.00,100.00,0.00,'Quick Service payment','2026-05-04 18:20:51'),(43,37,'transfer',100.00,100.00,0.00,'Quick Service payment','2026-05-04 18:27:15'),(44,38,'transfer',100.00,100.00,0.00,'Quick Service payment','2026-05-04 18:27:56'),(45,38,'transfer',250.00,250.00,0.00,'Quick Service payment','2026-05-04 18:50:24'),(46,39,'cash',150.00,200.00,50.00,'Quick Service payment','2026-05-05 19:47:38'),(47,40,'transfer',2000.00,2000.00,0.00,'Admin deposit at booking','2026-05-05 21:58:31'),(48,41,'transfer',100.00,100.00,0.00,'Admin deposit at booking','2026-05-05 22:47:34'),(49,43,'transfer',3000.00,3000.00,0.00,'Admin deposit at booking','2026-05-07 17:02:57');

--
-- Table structure for table `positions`
--

CREATE TABLE `positions` (
  `position_id` int NOT NULL AUTO_INCREMENT,
  `position_name` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL,
  `role_key` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `branch_scope` enum('all','assigned') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'assigned',
  `permissions` text COLLATE utf8mb4_unicode_ci,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`position_id`),
  UNIQUE KEY `uniq_positions_role_key` (`role_key`)
) ENGINE=InnoDB AUTO_INCREMENT=19312 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `positions`
--

INSERT INTO `positions` VALUES (1,'Administrator','admin','all','[\"dashboard\",\"booking\",\"booking_deposit_admin\",\"booking_deposit_branch\",\"quick_service\",\"quick_service_payment\",\"queue\",\"queue_payment\",\"queue_start_waiting\",\"queue_cancel_waiting\",\"queue_bill_control\",\"queue_cancel_closed\",\"queue_cancel_open\",\"queue_edit_open\",\"bill_management\",\"services\",\"member\",\"audit_report\",\"report_service\",\"sale_report\",\"void_report\",\"loyalty\",\"employees\",\"maintenance_clear_log\",\"maintenance_clear_booking_queue\",\"maintenance_clear_sale\",\"maintenance_backup_database\",\"maintenance_restore_database\"]',1,'2026-04-22 16:23:55'),(2,'Branch Manager','manager','assigned','[\"dashboard\",\"queue\",\"queue_payment\",\"queue_start_waiting\",\"queue_cancel_waiting\"]',1,'2026-04-22 16:23:55'),(3,'Service Advisor','advisor','assigned','[\"dashboard\",\"quick_service\",\"queue\",\"queue_payment\",\"queue_start_waiting\",\"queue_cancel_waiting\",\"quick_service_payment\"]',1,'2026-04-22 16:23:55'),(4,'Accounting','accounting','assigned','[\"dashboard\",\"report_service\",\"sale_report\"]',1,'2026-04-22 16:23:55'),(5,'Viewer','viewer','assigned','[\"dashboard\",\"report_service\",\"sale_report\"]',1,'2026-04-22 16:23:55'),(14706,'Admin Sale','admin_sale','all','[\"dashboard\",\"booking\",\"booking_deposit_admin\",\"queue\",\"queue_start_waiting\",\"queue_cancel_waiting\",\"queue_edit_open\"]',1,'2026-05-05 21:54:37');

--
-- Table structure for table `products`
--

CREATE TABLE `products` (
  `product_id` int NOT NULL AUTO_INCREMENT,
  `product_name` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
  `stock` int NOT NULL DEFAULT '0',
  `cost` decimal(10,2) NOT NULL DEFAULT '0.00',
  `price` decimal(10,2) NOT NULL DEFAULT '0.00',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `products`
--


--
-- Table structure for table `queue`
--

CREATE TABLE `queue` (
  `queue_id` int NOT NULL AUTO_INCREMENT,
  `order_id` int NOT NULL,
  `queue_number` int NOT NULL,
  `status` enum('waiting','washing','done','cancelled') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'waiting',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `called_at` datetime DEFAULT NULL,
  `completed_at` datetime DEFAULT NULL,
  PRIMARY KEY (`queue_id`),
  KEY `idx_queue_order` (`order_id`),
  KEY `idx_queue_day` (`created_at`,`queue_number`),
  CONSTRAINT `fk_queue_order` FOREIGN KEY (`order_id`) REFERENCES `orders` (`order_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `queue`
--

INSERT INTO `queue` VALUES (1,1,1,'cancelled','2026-04-22 12:37:08','2026-04-23 11:41:45','2026-04-23 11:41:53'),(2,2,2,'done','2026-04-22 12:50:23','2026-04-22 12:51:27','2026-04-22 14:20:17'),(3,3,3,'done','2026-04-22 12:54:29','2026-04-23 11:25:31','2026-04-23 11:25:39'),(4,4,4,'cancelled','2026-04-22 14:57:49','2026-04-22 14:59:46','2026-04-22 14:59:48'),(5,5,5,'done','2026-04-22 16:39:47','2026-04-22 16:40:10','2026-04-22 16:43:45'),(6,6,6,'done','2026-04-22 21:10:39','2026-04-22 21:45:18','2026-04-22 21:46:16'),(7,7,7,'cancelled','2026-04-22 21:18:06','2026-04-22 21:20:10','2026-04-22 21:20:36'),(8,8,8,'done','2026-04-22 21:32:37','2026-04-23 11:03:23','2026-04-23 11:06:01'),(9,9,1,'done','2026-04-23 11:39:31','2026-04-23 20:19:09','2026-05-05 21:04:49'),(10,10,2,'done','2026-04-23 13:13:20','2026-04-23 13:13:46','2026-04-23 13:13:52'),(11,11,3,'done','2026-04-23 19:13:06','2026-04-23 20:38:35','2026-04-23 20:38:42'),(12,12,4,'done','2026-04-23 20:41:08','2026-04-23 20:58:02','2026-04-23 21:14:50'),(13,13,5,'done','2026-04-23 20:55:56','2026-04-23 20:57:35','2026-04-24 12:33:59'),(14,14,1,'done','2026-04-24 12:40:32','2026-04-30 16:33:03','2026-04-30 16:33:07'),(15,15,1,'done','2026-04-28 13:20:35','2026-04-28 13:20:51','2026-04-28 13:20:57'),(16,16,2,'done','2026-04-28 17:18:42','2026-04-28 17:18:45','2026-04-28 17:18:46'),(17,17,3,'done','2026-04-28 17:20:34','2026-04-28 17:20:37','2026-04-28 17:20:40'),(18,18,4,'done','2026-04-28 17:21:16','2026-04-28 17:21:18','2026-04-28 17:21:19'),(19,19,1,'done','2026-04-30 11:34:42','2026-04-30 11:34:44','2026-04-30 11:34:45'),(20,40,1,'cancelled','2026-05-05 21:58:31',NULL,NULL),(21,41,2,'waiting','2026-05-05 22:47:34',NULL,NULL),(22,42,1,'waiting','2026-05-06 15:45:17',NULL,NULL),(23,43,1,'waiting','2026-05-07 17:02:57',NULL,NULL);

--
-- Table structure for table `service_categories`
--

CREATE TABLE `service_categories` (
  `category_id` int NOT NULL AUTO_INCREMENT,
  `category_name` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`category_id`),
  UNIQUE KEY `uniq_service_categories_name` (`category_name`)
) ENGINE=InnoDB AUTO_INCREMENT=9219 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `service_categories`
--

INSERT INTO `service_categories` VALUES (1,'Add-on','2026-04-28 13:34:22'),(2,'Coating','2026-04-28 13:34:22'),(4,'Flim','2026-04-28 13:34:22'),(5,'Interior','2026-04-28 13:34:22'),(6,'Protection','2026-04-28 13:34:22'),(7,'Wash','2026-04-28 13:34:22');

--
-- Table structure for table `service_groups`
--

CREATE TABLE `service_groups` (
  `group_id` int NOT NULL AUTO_INCREMENT,
  `category_id` int NOT NULL,
  `main_service_id` int DEFAULT NULL,
  `group_name` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL,
  `show_window_film_details` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`group_id`),
  UNIQUE KEY `uniq_service_group_main` (`main_service_id`,`group_name`),
  KEY `idx_service_groups_category_id` (`category_id`),
  KEY `idx_service_groups_main_service_id` (`main_service_id`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `service_groups`
--

INSERT INTO `service_groups` VALUES (4,4,11,'V-Kool',1,'2026-04-28 16:59:09'),(6,4,11,'BLAUPUNKT',1,'2026-04-28 17:05:34'),(7,4,11,'3M',1,'2026-04-30 16:14:04'),(8,4,11,'AVERY',1,'2026-04-30 16:14:22'),(9,4,11,'HI-Kool',1,'2026-04-30 16:14:41'),(10,4,11,'Solar Gard',1,'2026-04-30 16:14:55'),(11,4,11,'Glasia',1,'2026-04-30 16:15:11'),(12,4,11,'Lamina',1,'2026-04-30 16:15:26'),(13,6,43,'VERTEK',0,'2026-04-30 16:28:31');

--
-- Table structure for table `service_package_items`
--

CREATE TABLE `service_package_items` (
  `package_item_id` int NOT NULL AUTO_INCREMENT,
  `package_service_id` int NOT NULL,
  `sub_service_id` int NOT NULL,
  `included_uses` int NOT NULL DEFAULT '1',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`package_item_id`),
  UNIQUE KEY `uniq_package_service_sub_service` (`package_service_id`,`sub_service_id`),
  KEY `idx_package_items_package_service` (`package_service_id`),
  KEY `idx_package_items_sub_service` (`sub_service_id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `service_package_items`
--

INSERT INTO `service_package_items` VALUES (4,15,7,5,'2026-04-30 11:29:33'),(5,15,3,5,'2026-04-30 11:29:33'),(6,15,1,10,'2026-04-30 11:29:33'),(7,16,1,2,'2026-04-30 11:33:25');

--
-- Table structure for table `services`
--

CREATE TABLE `services` (
  `service_id` int NOT NULL AUTO_INCREMENT,
  `service_name` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
  `service_type` enum('main_service','sub_service','package') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'sub_service',
  `category` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Detailing',
  `category_id` int DEFAULT NULL,
  `main_service_id` int DEFAULT NULL,
  `group_id` int DEFAULT NULL,
  `package_vehicle_scope` enum('member','car') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'member',
  `is_quick_service` tinyint(1) NOT NULL DEFAULT '0',
  `price` decimal(10,2) NOT NULL DEFAULT '0.00',
  `duration_minutes` int NOT NULL DEFAULT '60',
  `description` text COLLATE utf8mb4_unicode_ci,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`service_id`),
  KEY `idx_services_active` (`is_active`),
  KEY `idx_services_category` (`category`),
  KEY `idx_services_category_id` (`category_id`),
  KEY `idx_services_group_id` (`group_id`),
  KEY `idx_services_service_type` (`service_type`),
  KEY `idx_services_main_service_id` (`main_service_id`),
  KEY `idx_services_quick_service` (`is_quick_service`)
) ENGINE=InnoDB AUTO_INCREMENT=49 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `services`
--

INSERT INTO `services` VALUES (1,'Standard Wash','sub_service','Wash',7,NULL,NULL,'member',0,550.00,45,'Exterior wash, interior vacuum and quick finish.',1,'2026-04-21 13:57:10','2026-04-28 14:52:20'),(3,'Interior Deep Clean','sub_service','Flim',4,11,NULL,'member',0,3200.00,0,'Seat, carpet, panel and odor treatment for cabin care.',0,'2026-04-21 13:57:10','2026-04-28 17:14:12'),(4,'Glass Coating','sub_service','Flim',4,11,NULL,'member',0,12900.00,0,'Nano-ceramic glass coating with surface prep.',0,'2026-04-21 13:57:10','2026-04-28 17:13:02'),(5,'Ceramic Pro Gold Package','sub_service','Flim',4,11,NULL,'member',0,37900.00,0,'Multi-stage ceramic coating package with premium finish.',0,'2026-04-21 13:57:10','2026-04-28 17:12:43'),(6,'Paint Protection Film','sub_service','Flim',4,11,NULL,'member',0,45000.00,0,'Full body PPF installation and finishing inspection.',0,'2026-04-21 13:57:10','2026-04-28 17:14:32'),(7,'Engine Cleaning','sub_service','Flim',4,11,NULL,'member',0,800.00,0,'Engine bay cleaning and light dressing.',0,'2026-04-21 13:57:10','2026-04-28 17:12:05'),(8,'AC System Ozone','sub_service','Add-on',1,NULL,NULL,'member',0,500.00,30,'Ozone treatment for air conditioning and cabin odor.',0,'2026-04-21 13:57:10','2026-04-28 14:52:20'),(9,'ติดฟิล์มกรองแสง รอบคัน','sub_service','Flim',4,NULL,NULL,'member',0,100.00,300,'',1,'2026-04-22 17:15:44','2026-04-28 14:52:20'),(10,'V-Kool (V30)','sub_service','Flim',4,11,4,'member',0,1000.00,0,'',1,'2026-04-28 14:59:01','2026-04-28 16:59:47'),(11,'ติดฟิล์มกรองแสง','main_service','Flim',4,NULL,NULL,'member',0,5000.00,0,'',1,'2026-04-28 16:05:40','2026-04-28 16:05:40'),(12,'V-Kool (V05)','sub_service','Flim',4,11,4,'member',0,1000.00,0,'',1,'2026-04-28 16:11:45','2026-04-28 16:59:23'),(13,'V-Kool (V15)','sub_service','Flim',4,11,4,'member',0,1000.00,0,'',1,'2026-04-28 16:12:03','2026-04-28 16:59:39'),(14,'BLAUPUNKT (A35BK)','sub_service','Flim',4,11,6,'member',0,1000.00,0,'',1,'2026-04-28 16:15:16','2026-04-28 17:06:06'),(15,'เคลือบเซรามิค','package','Protection',6,NULL,NULL,'car',0,5900.00,0,'',1,'2026-04-28 17:18:03','2026-04-30 11:29:33'),(16,'Package wash 2000','package','Wash',7,NULL,NULL,'car',0,2000.00,0,'',1,'2026-04-30 11:33:25','2026-04-30 11:33:25'),(17,'V-Kool (VK30)','sub_service','Flim',4,11,4,'member',0,0.00,0,'',1,'2026-04-30 16:11:51','2026-04-30 16:11:51'),(18,'V-Kool (VK40)','sub_service','Flim',4,11,4,'member',0,0.00,0,'',1,'2026-04-30 16:12:10','2026-04-30 16:12:10'),(19,'V-Kool (VK55)','sub_service','Flim',4,11,4,'member',0,0.00,0,'',1,'2026-04-30 16:12:30','2026-04-30 16:12:30'),(20,'V-Kool (VK70)','sub_service','Flim',4,11,4,'member',0,0.00,0,'',1,'2026-04-30 16:12:46','2026-04-30 16:12:46'),(21,'BLAUPUNKT (A18BK)','sub_service','Flim',4,11,6,'member',0,0.00,0,'',1,'2026-04-30 16:13:20','2026-04-30 16:13:20'),(22,'BLAUPUNKT (A10BK)','sub_service','Flim',4,11,6,'member',0,0.00,0,'',1,'2026-04-30 16:13:34','2026-04-30 16:13:34'),(23,'3M (IR25)','sub_service','Flim',4,11,7,'member',0,0.00,0,'',1,'2026-04-30 16:15:55','2026-04-30 16:15:55'),(24,'3M (IR15)','sub_service','Flim',4,11,7,'member',0,0.00,0,'',1,'2026-04-30 16:16:08','2026-04-30 16:16:08'),(25,'3M (IR5)','sub_service','Flim',4,11,7,'member',0,0.00,0,'',1,'2026-04-30 16:16:21','2026-04-30 16:16:21'),(26,'AVERY (PRO35)','sub_service','Flim',4,11,8,'member',0,0.00,0,'',1,'2026-04-30 16:16:45','2026-04-30 16:16:45'),(27,'AVERY (PRO20)','sub_service','Flim',4,11,8,'member',0,0.00,0,'',1,'2026-04-30 16:17:03','2026-04-30 16:17:03'),(28,'AVERY (PRO10)','sub_service','Flim',4,11,8,'member',0,0.00,0,'',1,'2026-04-30 16:17:15','2026-04-30 16:17:15'),(29,'HI-Kool (BY30)','sub_service','Flim',4,11,9,'member',0,0.00,0,'',1,'2026-04-30 16:18:03','2026-04-30 16:18:03'),(30,'HI-Kool (BY20)','sub_service','Flim',4,11,9,'member',0,0.00,0,'',1,'2026-04-30 16:18:18','2026-04-30 16:18:18'),(31,'HI-Kool (BY15)','sub_service','Flim',4,11,9,'member',0,0.00,0,'',1,'2026-04-30 16:18:40','2026-04-30 16:18:40'),(32,'HI-Kool (BY05)','sub_service','Flim',4,11,9,'member',0,0.00,0,'',1,'2026-04-30 16:18:54','2026-04-30 16:18:54'),(33,'Solar Gard (BPh30)','sub_service','Flim',4,11,10,'member',0,0.00,0,'',1,'2026-04-30 16:20:27','2026-04-30 16:20:27'),(34,'Solar Gard (QSQ20)','sub_service','Flim',4,11,10,'member',0,0.00,0,'',1,'2026-04-30 16:21:04','2026-04-30 16:21:04'),(35,'Solar Gard (BPh15)','sub_service','Flim',4,11,10,'member',0,0.00,0,'',1,'2026-04-30 16:21:43','2026-04-30 16:22:25'),(36,'Solar Gard (BPh05)','sub_service','Flim',4,11,10,'member',0,0.00,0,'',1,'2026-04-30 16:22:50','2026-04-30 16:22:50'),(37,'Glasia (80)','sub_service','Flim',4,11,11,'member',0,0.00,0,'',1,'2026-04-30 16:23:11','2026-04-30 16:23:11'),(38,'Glasia (60)','sub_service','Flim',4,11,11,'member',0,0.00,0,'',1,'2026-04-30 16:23:24','2026-04-30 16:23:24'),(39,'Glasia (40)','sub_service','Flim',4,11,11,'member',0,0.00,0,'',1,'2026-04-30 16:23:38','2026-04-30 16:23:38'),(40,'Lamina (L30)','sub_service','Flim',4,11,12,'member',0,0.00,0,'',1,'2026-04-30 16:23:58','2026-04-30 16:23:58'),(41,'Lamina (L15)','sub_service','Flim',4,11,12,'member',0,0.00,0,'',1,'2026-04-30 16:24:14','2026-04-30 16:24:14'),(42,'Lamina (L05)','sub_service','Flim',4,11,12,'member',0,0.00,0,'',1,'2026-04-30 16:24:29','2026-04-30 16:24:29'),(43,'TPU','main_service','Protection',6,NULL,NULL,'member',0,0.00,0,'',1,'2026-04-30 16:25:43','2026-04-30 16:28:13'),(44,'VERTEK (หนา200 | ประกัน 4ปี)','sub_service','Protection',6,43,13,'member',0,0.00,0,'หนา 200 \r\nประกัน 4ปี',1,'2026-04-30 16:30:21','2026-04-30 16:30:21'),(45,'VERTEK (หนา220 | ประกัน 5ปี)','sub_service','Protection',6,43,13,'member',0,0.00,0,'หนา220\r\nประกัน 5ปี',1,'2026-04-30 16:30:58','2026-04-30 16:30:58'),(46,'VERTEK (หนา250 | ประกัน 7 ปี)','sub_service','Protection',6,43,13,'member',0,0.00,0,'หนา250\r\nประกัน 7 ปี',1,'2026-04-30 16:31:53','2026-04-30 16:31:53'),(47,'ล้างภายนอก + ดูดฝุ่น (S)','main_service','Wash',7,NULL,NULL,'member',1,150.00,0,'',1,'2026-05-04 12:48:44','2026-05-04 12:48:44'),(48,'ล้างภายนอก + ดูดฝุ่น (M)','main_service','Wash',7,NULL,NULL,'member',1,200.00,0,'',1,'2026-05-04 12:49:00','2026-05-04 12:49:00');

--
-- Table structure for table `system_maintenance_logs`
--

CREATE TABLE `system_maintenance_logs` (
  `maintenance_log_id` int NOT NULL AUTO_INCREMENT,
  `maintenance_type` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'completed',
  `actor_employee_id` int DEFAULT NULL,
  `actor_name` varchar(120) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `branch_name` varchar(120) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `snapshot_path` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `filters_json` longtext COLLATE utf8mb4_unicode_ci,
  `preview_json` longtext COLLATE utf8mb4_unicode_ci,
  `result_json` longtext COLLATE utf8mb4_unicode_ci,
  `note` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`maintenance_log_id`),
  KEY `idx_system_maintenance_created_at` (`created_at`),
  KEY `idx_system_maintenance_type` (`maintenance_type`),
  KEY `idx_system_maintenance_actor` (`actor_employee_id`),
  KEY `idx_system_maintenance_branch` (`branch_name`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `system_maintenance_logs`
--

INSERT INTO `system_maintenance_logs` VALUES (1,'backup_database','completed',2,'System Administrator',NULL,'storage/database_backups/manual_ccw_20260507_115132.sql','{\"database\":\"CCW\",\"backup_prefix\":\"manual\"}',NULL,'{\"file_name\":\"manual_ccw_20260507_115132.sql\",\"size_bytes\":64807}','Database backup created.','2026-05-07 11:51:32');

--
-- Dumping routines for database 'CCW'
--


