-- RMS Database Backup
-- Database: mjposliv_rms_anuradhapura
-- Generated: 2026-07-28 14:44:04


-- ----------------------------
-- Table structure for `attendance`
-- ----------------------------
CREATE TABLE `attendance` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `attendance_date` date NOT NULL,
  `check_in` time DEFAULT NULL,
  `check_out` time DEFAULT NULL,
  `status` enum('PRESENT','ABSENT','HALF_DAY','LEAVE') DEFAULT 'PRESENT',
  `notes` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_user_date` (`user_id`,`attendance_date`),
  CONSTRAINT `attendance_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `attendance`
-- ----------------------------
INSERT INTO `attendance` (`id`,`user_id`,`attendance_date`,`check_in`,`check_out`,`status`,`notes`) VALUES ('1','1','2026-07-21','08:33:00','17:25:00','PRESENT',NULL);
INSERT INTO `attendance` (`id`,`user_id`,`attendance_date`,`check_in`,`check_out`,`status`,`notes`) VALUES ('2','2','2026-07-21','08:31:00','17:37:00','PRESENT',NULL);

-- ----------------------------
-- Table structure for `audit_log`
-- ----------------------------
CREATE TABLE `audit_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `action` varchar(100) NOT NULL,
  `module_key` varchar(50) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `audit_log_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=271 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `audit_log`
-- ----------------------------
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('1','1','LOGIN','auth','User logged in','::1','2026-07-19 15:43:56');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('2','1','LOGIN','auth','User logged in','::1','2026-07-21 12:42:48');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('3','1','LOGOUT','auth','User logged out','::1','2026-07-21 12:42:59');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('4','1','LOGIN','auth','User logged in','::1','2026-07-21 12:43:03');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('5','1','ORDER_CREATE','orders','Created order #1 (ONLINE_DELIVERY), total LKR 1,800.00','::1','2026-07-21 12:57:39');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('6','1','ORDER_STATUS_UPDATE','orders','Order #1 -> CONFIRMED','::1','2026-07-21 12:58:20');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('7','1','ORDER_STATUS_UPDATE','orders','Order #1 -> PREPARING','::1','2026-07-21 12:58:42');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('8','1','ORDER_STATUS_UPDATE','orders','Order #1 -> READY','::1','2026-07-21 12:58:44');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('9','1','ORDER_STATUS_UPDATE','orders','Order #1 -> OUT_FOR_DELIVERY','::1','2026-07-21 12:58:50');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('10','1','DELIVERY_PICKED_UP','delivery','Delivery #1 picked up','::1','2026-07-21 13:08:11');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('11','1','RIDER_CREATE','delivery','Added delivery rider: Nimal Perera','::1','2026-07-21 13:16:03');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('12','1','ORDER_STATUS_UPDATE','orders','Order #1 -> COMPLETED','::1','2026-07-21 13:16:13');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('13','1','ORDER_CREATE','orders','Created order #2 (ONLINE_DELIVERY), total LKR 2,500.00','::1','2026-07-21 13:16:47');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('14','1','DELIVERY_ASSIGN','delivery','Order #2 - rider assigned at order creation','::1','2026-07-21 13:16:47');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('15','1','DELIVERY_DELIVERED','delivery','Delivery #1 delivered','::1','2026-07-21 13:16:56');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('16','1','ORDER_STATUS_UPDATE','orders','Order #2 -> CONFIRMED','::1','2026-07-21 13:17:05');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('17','1','ORDER_STATUS_UPDATE','orders','Order #2 -> PREPARING','::1','2026-07-21 13:18:01');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('18','1','ORDER_STATUS_UPDATE','orders','Order #2 -> READY','::1','2026-07-21 13:18:42');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('19','1','DELIVERY_PICKED_UP','delivery','Delivery #2 picked up','::1','2026-07-21 13:18:50');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('20','1','ORDER_STATUS_UPDATE','orders','Order #2 -> COMPLETED','::1','2026-07-21 13:18:57');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('21','1','MENU_CATEGORY_TOGGLE','menu','Category #2 active -> 0','::1','2026-07-21 13:27:19');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('22','1','MENU_CATEGORY_TOGGLE','menu','Category #2 active -> 1','::1','2026-07-21 13:27:20');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('23','1','MENU_CATEGORY_TOGGLE','menu','Category #1 active -> 0','::1','2026-07-21 13:27:21');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('24','1','MENU_CATEGORY_TOGGLE','menu','Category #1 active -> 1','::1','2026-07-21 13:27:21');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('25','1','MENU_ITEM_TOGGLE','menu','Item #1 available -> 0','::1','2026-07-21 13:28:02');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('26','1','MENU_ITEM_TOGGLE','menu','Item #1 available -> 1','::1','2026-07-21 13:28:03');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('27','1','MENU_ITEM_TOGGLE','menu','Item #1 available -> 0','::1','2026-07-21 13:28:04');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('28','1','MENU_ITEM_TOGGLE','menu','Item #1 available -> 1','::1','2026-07-21 13:28:05');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('29','1','MENU_ITEM_TOGGLE','menu','Item #1 available -> 0','::1','2026-07-21 13:28:07');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('30','1','MENU_ITEM_TOGGLE','menu','Item #2 available -> 0','::1','2026-07-21 13:28:10');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('31','1','MENU_ITEM_TOGGLE','menu','Item #1 available -> 1','::1','2026-07-21 13:28:20');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('32','1','MENU_ITEM_TOGGLE','menu','Item #2 available -> 1','::1','2026-07-21 13:28:21');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('33','1','MENU_ITEM_CREATE','menu','Added menu item: Tuna Fish','::1','2026-07-21 13:32:25');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('34','1','MENU_VARIANT_CREATE','menu','Added variant \'Prawns Devel\' to item #3','::1','2026-07-21 13:33:36');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('35','1','MENU_VARIANT_CREATE','menu','Added variant \'Pork Curry\' to item #3','::1','2026-07-21 13:33:51');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('36','1','MENU_ITEM_UPDATE','menu','Updated menu item #3','::1','2026-07-21 13:33:52');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('37','1','MENU_ITEM_UPDATE','menu','Updated menu item #3','::1','2026-07-21 13:33:55');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('38','1','MENU_ITEM_UPDATE','menu','Updated menu item #3','::1','2026-07-21 13:34:28');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('39','1','MENU_ITEM_UPDATE','menu','Updated menu item #3','::1','2026-07-21 13:34:30');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('40','1','MENU_VARIANT_DELETE','menu','Deleted variant #2','::1','2026-07-21 13:35:01');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('41','1','MENU_VARIANT_DELETE','menu','Deleted variant #1','::1','2026-07-21 13:35:02');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('42','1','MENU_ITEM_UPDATE','menu','Updated menu item #3','::1','2026-07-21 13:35:08');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('43','1','MENU_ITEM_UPDATE','menu','Updated menu item #1','::1','2026-07-21 13:38:53');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('44','1','MENU_ITEM_CREATE','menu','Added menu item: Chicken Stew Rice & Curry','::1','2026-07-21 13:40:04');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('45','1','MENU_ITEM_UPDATE','menu','Updated menu item #4','::1','2026-07-21 13:40:27');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('46','1','MENU_ITEM_UPDATE','menu','Updated menu item #2','::1','2026-07-21 13:40:50');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('47','1','MENU_ITEM_CREATE','menu','Added menu item: Boiled Egg Rice & Curry','::1','2026-07-21 13:41:46');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('48','1','MENU_ITEM_UPDATE','menu','Updated menu item #5','::1','2026-07-21 13:41:48');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('49','1','MENU_ITEM_UPDATE','menu','Updated menu item #5','::1','2026-07-21 13:42:11');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('50','1','MENU_ITEM_CREATE','menu','Added menu item: Fish Rice & Curry (LAKE FISH)','::1','2026-07-21 13:42:59');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('51','1','MENU_ITEM_UPDATE','menu','Updated menu item #5','::1','2026-07-21 13:49:43');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('52','1','ORDER_CREATE','orders','Created order #3 (ONLINE_DELIVERY), total LKR 800.00','::1','2026-07-21 13:50:40');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('53','1','DELIVERY_ASSIGN','delivery','Order #3 - rider assigned at order creation','::1','2026-07-21 13:50:40');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('54','1','ORDER_STATUS_UPDATE','orders','Order #3 -> CONFIRMED','::1','2026-07-21 13:50:41');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('55','1','MENU_ITEM_UPDATE','menu','Updated menu item #5','::1','2026-07-21 13:52:31');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('56','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-21 13:54:16');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('57','1','MENU_ITEM_UPDATE','menu','Updated menu item #1','::1','2026-07-21 13:54:59');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('58','1','RIDER_UPDATE','delivery','Updated rider #2','::1','2026-07-21 14:03:01');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('59','1','MENU_ITEM_UPDATE','menu','Updated menu item #4','::1','2026-07-21 14:04:22');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('60','1','MENU_ITEM_UPDATE','menu','Updated menu item #4','::1','2026-07-21 14:04:24');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('61','1','MENU_ITEM_UPDATE','menu','Updated menu item #6','::1','2026-07-21 14:05:59');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('62','1','MENU_ITEM_UPDATE','menu','Updated menu item #3','::1','2026-07-21 14:08:08');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('63','1','MENU_ITEM_UPDATE','menu','Updated menu item #2','::1','2026-07-21 14:11:16');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('64','1','MENU_ITEM_TOGGLE','menu','Item #5 available -> 0','::1','2026-07-21 14:33:48');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('65','1','MENU_ITEM_TOGGLE','menu','Item #5 available -> 1','::1','2026-07-21 14:33:50');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('66','1','SUPPLIER_CREATE','suppliers','Added supplier: JF Cheken','::1','2026-07-21 17:07:24');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('67','1','SUPPLIER_CREATE','suppliers','Added supplier: DM Vegitables','::1','2026-07-21 17:08:12');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('68','1','STOCK_MATERIAL_CREATE','stock','Added raw material: Chicken Drumstick','::1','2026-07-21 17:09:12');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('69','1','STOCK_MATERIAL_CREATE','stock','Added raw material: Araliya Kiri Samba','::1','2026-07-21 17:09:43');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('70','1','STOCK_MATERIAL_CREATE','stock','Added raw material: Carrot','::1','2026-07-21 17:10:00');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('71','1','PO_CREATE','purchasing','Created purchase order #1','::1','2026-07-21 17:10:35');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('72','1','PO_PAYMENT','purchasing','Paid LKR 155,000.00 for PO #1','::1','2026-07-21 17:10:53');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('73','1','PO_RECEIVE','purchasing','Received goods for PO #1','::1','2026-07-21 17:10:58');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('74','1','PO_RECEIVE','purchasing','Received goods for PO #1','::1','2026-07-21 17:11:01');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('75','1','PO_RECEIVE','purchasing','Received goods for PO #1','::1','2026-07-21 17:11:36');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('76','1','STOCK_MATERIAL_CREATE','stock','Added raw material: Loku Lunu','::1','2026-07-21 17:12:32');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('77','1','STOCK_MATERIAL_CREATE','stock','Added raw material: Leks','::1','2026-07-21 17:12:44');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('78','1','PO_CREATE','purchasing','Created purchase order #2','::1','2026-07-21 17:13:28');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('79','1','PO_RECEIVE','purchasing','Received goods for PO #2','::1','2026-07-21 17:13:42');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('80','1','PO_PAYMENT','purchasing','Paid LKR 15,100.00 for PO #2','::1','2026-07-21 17:13:47');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('81','1','SUPPLIER_CREATE','suppliers','Added supplier: Arliya Rice Mill','::1','2026-07-21 17:14:37');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('82','1','PO_CREATE','purchasing','Created purchase order #3','::1','2026-07-21 17:15:06');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('83','1','PO_RECEIVE','purchasing','Received goods for PO #3','::1','2026-07-21 17:15:10');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('84','1','PO_PAYMENT','purchasing','Paid LKR 27,000.00 for PO #3','::1','2026-07-21 17:15:11');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('85','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-21 17:16:31');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('86','1','LOGOUT','auth','User logged out','::1','2026-07-21 17:16:33');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('87','1','LOGIN','auth','User logged in','::1','2026-07-21 17:16:36');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('88','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-21 17:17:07');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('89','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-21 17:22:14');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('90','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-21 17:22:31');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('91','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-21 17:24:14');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('92','1','LOGOUT','auth','User logged out','::1','2026-07-21 17:24:17');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('93','1','LOGIN','auth','User logged in','::1','2026-07-21 17:24:21');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('94','1','USER_UPDATE','users','Updated user #1','::1','2026-07-21 17:25:28');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('95','1','LOGOUT','auth','User logged out','::1','2026-07-21 17:25:31');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('96','1','LOGIN','auth','User logged in','::1','2026-07-21 17:25:32');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('97','1','KITCHEN_ISSUE_CREATE','stock','Issued stock to kitchen — issue #1','::1','2026-07-21 17:26:47');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('98','1','ORDER_STATUS_UPDATE','orders','Order #3 -> PREPARING','::1','2026-07-21 18:07:32');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('99','1','ORDER_STATUS_UPDATE','orders','Order #3 -> READY','::1','2026-07-21 18:07:33');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('100','1','ORDER_STATUS_UPDATE','orders','Order #3 -> OUT_FOR_DELIVERY','::1','2026-07-21 18:07:34');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('101','1','ORDER_STATUS_UPDATE','orders','Order #3 -> COMPLETED','::1','2026-07-21 18:07:34');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('102','1','ORDER_CREATE','orders','Created order #4 (ONLINE_DELIVERY), total LKR 2,250.00','::1','2026-07-21 18:07:56');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('103','1','DELIVERY_ASSIGN','delivery','Order #4 - rider assigned at order creation','::1','2026-07-21 18:07:56');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('104','1','PAYMENT_RECORD','payments','Payment LKR 2,250.00 for order #4','::1','2026-07-21 18:07:59');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('105','1','ORDER_STATUS_UPDATE','orders','Order #4 -> CONFIRMED','::1','2026-07-21 18:08:02');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('106','1','DELIVERY_ZONE_CREATE','delivery','Added delivery zone: New Bus Stand Anuradapura','::1','2026-07-21 18:13:33');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('107','1','DELIVERY_ZONE_UPDATE','delivery','Updated delivery zone #1','::1','2026-07-21 18:14:10');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('108','1','DELIVERY_ZONE_UPDATE','delivery','Updated delivery zone #1','::1','2026-07-21 18:14:34');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('109','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-21 18:17:37');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('110','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-21 18:17:49');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('111','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-21 18:19:24');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('112','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-21 18:20:19');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('113','1','LOGOUT','auth','User logged out','::1','2026-07-21 18:21:08');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('114','1','LOGIN','auth','User logged in','::1','2026-07-21 18:21:13');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('115','1','ATTENDANCE_MARK','attendance','Marked attendance for 2026-07-21','::1','2026-07-21 18:31:37');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('116','1','ATTENDANCE_MARK','attendance','Marked attendance for 2026-07-21','::1','2026-07-21 18:31:58');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('117','1','PAYROLL_GENERATE','payroll','Generated payroll run for 7/2026','::1','2026-07-21 18:32:32');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('118','1','PAYROLL_FINALIZE','payroll','Finalized payroll run #1','::1','2026-07-21 18:32:36');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('119','1','ORDER_CREATE','orders','Created order #5 (ONLINE_DELIVERY), total LKR 1,850.00','::1','2026-07-21 18:52:08');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('120','1','DELIVERY_ASSIGN','delivery','Order #5 - rider assigned at order creation','::1','2026-07-21 18:52:08');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('121','1','ORDER_STATUS_UPDATE','orders','Order #5 -> CONFIRMED','::1','2026-07-21 18:52:35');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('122','1','MENU_ITEM_UPDATE','menu','Updated menu item #5','::1','2026-07-21 19:46:40');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('123','1','MENU_ITEM_UPDATE','menu','Updated menu item #1','::1','2026-07-21 19:47:10');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('124','1','MENU_ITEM_UPDATE','menu','Updated menu item #1','::1','2026-07-21 19:47:13');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('125','1','MENU_ITEM_UPDATE','menu','Updated menu item #5','::1','2026-07-21 19:50:20');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('126','1','MENU_RECIPE_UPDATE','menu','Recipe line saved for item #5, material #2','::1','2026-07-21 20:03:36');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('127','1','MENU_RECIPE_UPDATE','menu','Recipe line saved for item #5, material #3','::1','2026-07-21 20:03:49');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('128','1','MENU_RECIPE_UPDATE','menu','Recipe line saved for item #5, material #1','::1','2026-07-21 20:03:59');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('129','1','MENU_RECIPE_UPDATE','menu','Recipe line saved for item #5, material #5','::1','2026-07-21 20:04:04');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('130','1','MENU_ITEM_UPDATE','menu','Updated menu item #5','::1','2026-07-21 20:04:15');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('131','1','MENU_RECIPE_UPDATE','menu','Recipe line saved for item #1, material #2','::1','2026-07-21 20:04:42');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('132','1','MENU_RECIPE_UPDATE','menu','Recipe line saved for item #1, material #3','::1','2026-07-21 20:04:48');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('133','1','MENU_RECIPE_UPDATE','menu','Recipe line saved for item #1, material #5','::1','2026-07-21 20:04:54');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('134','1','MENU_RECIPE_UPDATE','menu','Recipe line saved for item #1, material #1','::1','2026-07-21 20:05:33');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('135','1','MENU_ITEM_UPDATE','menu','Updated menu item #1','::1','2026-07-21 20:05:38');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('136','1','KITCHEN_ISSUE_CREATE','stock','Issued stock to kitchen — issue #2','::1','2026-07-21 20:08:39');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('137','1','KITCHEN_ISSUE_UPDATE','stock','Edited kitchen issue #2','::1','2026-07-21 20:15:32');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('138','1','LOGOUT','auth','User logged out','::1','2026-07-21 20:49:16');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('139','1','LOGIN','auth','User logged in','::1','2026-07-21 20:49:18');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('140','1','LOGIN','auth','User logged in','::1','2026-07-26 09:58:40');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('141',NULL,'CUSTOMER_APP_ORDER','orders','Customer app order #6, total LKR 350.00','::1','2026-07-26 10:22:03');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('142',NULL,'CUSTOMER_APP_ORDER','orders','Customer app order #7, total LKR 2,550.00','192.168.43.207','2026-07-26 11:31:18');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('143','1','ORDER_CANCEL','orders','Order #7 cancelled, stock restored','::1','2026-07-26 11:32:47');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('144',NULL,'CUSTOMER_APP_ORDER','orders','Customer app order #8, total LKR 350.00','::1','2026-07-26 11:33:31');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('145',NULL,'CUSTOMER_APP_ORDER','orders','Customer app order #9, total LKR 350.00','::1','2026-07-26 11:55:13');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('146','1','ORDER_STATUS_UPDATE','orders','Order #9 -> CONFIRMED','::1','2026-07-26 11:55:31');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('147','1','PAYMENT_RECORD','payments','Payment LKR 350.00 for order #9','::1','2026-07-26 11:55:45');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('148','1','ORDER_STATUS_UPDATE','orders','Order #9 -> PREPARING','::1','2026-07-26 11:59:01');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('149','1','ORDER_STATUS_UPDATE','orders','Order #9 -> READY','::1','2026-07-26 11:59:29');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('150','1','ORDER_STATUS_UPDATE','orders','Order #9 -> OUT_FOR_DELIVERY','::1','2026-07-26 11:59:41');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('151','1','ORDER_STATUS_UPDATE','orders','Order #9 -> COMPLETED','::1','2026-07-26 11:59:52');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('152',NULL,'CUSTOMER_APP_ORDER','orders','Customer app order #10, total LKR 1,550.00','192.168.43.207','2026-07-26 12:04:36');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('153','1','ORDER_STATUS_UPDATE','orders','Order #10 -> CONFIRMED','::1','2026-07-26 12:04:53');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('154','1','ORDER_STATUS_UPDATE','orders','Order #10 -> PREPARING','::1','2026-07-26 12:05:00');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('155','1','ORDER_STATUS_UPDATE','orders','Order #10 -> READY','::1','2026-07-26 12:05:05');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('156','1','ORDER_STATUS_UPDATE','orders','Order #10 -> OUT_FOR_DELIVERY','::1','2026-07-26 12:05:13');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('157','1','ORDER_STATUS_UPDATE','orders','Order #10 -> COMPLETED','::1','2026-07-26 12:05:20');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('158','1','PAYMENT_RECORD','payments','Payment LKR 1,550.00 for order #10','::1','2026-07-26 12:05:25');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('159','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-26 12:55:00');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('160',NULL,'CUSTOMER_APP_ORDER','orders','Customer app order #11, total LKR 700.00','192.168.43.207','2026-07-26 13:04:21');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('161','1','PAYMENT_RECORD','payments','Payment LKR 700.00 for order #11','::1','2026-07-26 13:04:39');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('162','1','PROMOTION_CREATE','menu','Added promotion: Enjoy 10% OFF on CurryPot Foods','::1','2026-07-26 13:33:19');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('163','1','PROMOTION_UPDATE','menu','Updated promotion #1','::1','2026-07-26 13:34:14');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('164','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-26 13:40:27');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('165','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-26 14:30:15');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('166',NULL,'CUSTOMER_APP_ORDER','orders','Customer app order #12, total LKR 1,050.00','::1','2026-07-26 14:30:54');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('167','1','ORDER_CANCEL','orders','Order #12 cancelled, stock restored','::1','2026-07-26 14:31:54');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('168','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-26 14:34:55');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('169','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-26 14:46:32');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('170','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-26 14:51:36');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('171','1','SETTINGS_UPDATE','settings','Updated system settings','::1','2026-07-26 14:51:51');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('172',NULL,'CUSTOMER_APP_ORDER','orders','Customer app order #13, total LKR 350.00','192.168.43.207','2026-07-26 14:54:11');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('173','1','LOGOUT','auth','User logged out','::1','2026-07-26 14:56:48');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('174','1','LOGIN','auth','User logged in','::1','2026-07-26 14:58:47');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('175','1','LOGIN','auth','User logged in','203.189.185.246','2026-07-26 16:55:41');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('176','1','SETTINGS_UPDATE','settings','Updated system settings','203.189.185.246','2026-07-26 16:57:43');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('177','1','LOGOUT','auth','User logged out','203.189.185.246','2026-07-26 16:58:38');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('178','1','LOGIN','auth','User logged in','175.157.126.202','2026-07-26 16:59:58');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('179','1','LOGIN','auth','User logged in','203.189.185.246','2026-07-26 17:11:29');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('180','1','ORDER_STATUS_UPDATE','orders','Order #13 -> CONFIRMED','203.189.185.246','2026-07-26 17:11:49');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('181','1','ORDER_STATUS_UPDATE','orders','Order #13 -> PREPARING','203.189.185.246','2026-07-26 17:11:54');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('182','1','ORDER_STATUS_UPDATE','orders','Order #13 -> READY','203.189.185.246','2026-07-26 17:12:01');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('183','1','ORDER_STATUS_UPDATE','orders','Order #13 -> OUT_FOR_DELIVERY','203.189.185.246','2026-07-26 17:12:03');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('184','1','ORDER_STATUS_UPDATE','orders','Order #13 -> COMPLETED','203.189.185.246','2026-07-26 17:12:04');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('185','1','PAYMENT_RECORD','payments','Payment LKR 350.00 for order #13','203.189.185.246','2026-07-26 17:12:07');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('186',NULL,'CUSTOMER_APP_ORDER','orders','Customer app order #14, total LKR 350.00','203.189.185.246','2026-07-26 17:12:54');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('187','1','ORDER_STATUS_UPDATE','orders','Order #14 -> CONFIRMED','203.189.185.246','2026-07-26 17:13:12');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('188','1','DELIVERY_ASSIGN','delivery','Order #14 - rider assigned at order creation','203.189.185.246','2026-07-26 17:19:50');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('189','1','DELIVERY_RIDER_ASSIGN','orders','Rider #2 assigned to order #14','203.189.185.246','2026-07-26 17:19:51');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('190','1','ORDER_STATUS_UPDATE','orders','Order #14 -> PREPARING','203.189.185.246','2026-07-26 17:20:07');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('191','1','ORDER_STATUS_UPDATE','orders','Order #14 -> READY','203.189.185.246','2026-07-26 17:20:15');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('192','1','ORDER_STATUS_UPDATE','orders','Order #14 -> OUT_FOR_DELIVERY','203.189.185.246','2026-07-26 17:20:22');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('193','1','ORDER_STATUS_UPDATE','orders','Order #14 -> COMPLETED','203.189.185.246','2026-07-26 17:20:32');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('194','1','PAYMENT_RECORD','payments','Payment LKR 350.00 for order #14','203.189.185.246','2026-07-26 17:20:34');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('195','1','LOGIN','auth','User logged in','203.189.185.246','2026-07-26 20:40:52');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('196','1','LOGOUT','auth','User logged out','203.189.185.246','2026-07-26 20:41:33');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('197','1','LOGIN','auth','User logged in','203.189.185.246','2026-07-26 20:43:57');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('198','1','LOGIN','auth','User logged in','175.157.61.98','2026-07-26 21:14:28');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('199','1','LOGOUT','auth','User logged out','175.157.61.98','2026-07-26 21:17:12');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('200','1','LOGIN','auth','User logged in','203.189.185.246','2026-07-26 22:34:44');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('201','1','LOGIN','auth','User logged in','203.189.185.246','2026-07-26 23:12:55');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('202','1','SETTINGS_UPDATE','settings','Updated system settings','203.189.185.246','2026-07-26 23:13:22');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('203',NULL,'CUSTOMER_APP_ORDER','orders','Customer app order #15, total LKR 1,350.00','175.157.126.202','2026-07-26 23:13:55');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('204','1','RIDER_UPDATE','delivery','Updated rider #2','203.189.185.246','2026-07-26 23:15:31');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('205','1','DELIVERY_ASSIGN','delivery','Order #15 - rider assigned at order creation','203.189.185.246','2026-07-26 23:16:40');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('206','1','DELIVERY_RIDER_ASSIGN','orders','Rider #2 assigned to order #15','203.189.185.246','2026-07-26 23:16:40');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('207','1','ORDER_STATUS_UPDATE','orders','Order #15 -> CONFIRMED','203.189.185.246','2026-07-26 23:16:43');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('208','1','ORDER_STATUS_UPDATE','orders','Order #15 -> PREPARING','203.189.185.246','2026-07-26 23:16:45');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('209','1','ORDER_STATUS_UPDATE','orders','Order #15 -> READY','203.189.185.246','2026-07-26 23:18:33');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('210',NULL,'DELIVERY_SELF_CLAIM','delivery','Rider #2 scanned QR and confirmed pickup of assigned order #15 — status set to OUT_FOR_DELIVERY','175.157.126.202','2026-07-26 23:18:49');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('211',NULL,'DELIVERY_FAILED','delivery','Delivery #2 failed: Marked failed by rider','175.157.126.202','2026-07-26 23:19:21');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('212',NULL,'DELIVERY_FAILED','delivery','Delivery #3 failed: Marked failed by rider','175.157.126.202','2026-07-26 23:19:24');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('213',NULL,'DELIVERY_FAILED','delivery','Delivery #4 failed: Marked failed by rider','175.157.126.202','2026-07-26 23:19:27');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('214',NULL,'DELIVERY_FAILED','delivery','Delivery #5 failed: Marked failed by rider','175.157.126.202','2026-07-26 23:19:29');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('215',NULL,'DELIVERY_FAILED','delivery','Delivery #9 failed: Marked failed by rider','175.157.126.202','2026-07-26 23:19:32');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('216',NULL,'RIDER_COD_COLLECTED','payments','Rider #2 collected COD LKR 1,350.00 for order #15','175.157.126.202','2026-07-26 23:20:21');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('217',NULL,'DELIVERY_DELIVERED','delivery','Delivery #10 delivered','175.157.126.202','2026-07-26 23:20:21');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('218',NULL,'CUSTOMER_APP_ORDER','orders','Customer app order #16, total LKR 2,100.00','175.157.126.202','2026-07-26 23:23:40');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('219','1','DELIVERY_ASSIGN','delivery','Order #16 - rider assigned at order creation','203.189.185.246','2026-07-26 23:25:48');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('220','1','DELIVERY_RIDER_ASSIGN','orders','Rider #2 assigned to order #16','203.189.185.246','2026-07-26 23:25:48');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('221','1','ORDER_STATUS_UPDATE','orders','Order #16 -> CONFIRMED','203.189.185.246','2026-07-26 23:25:50');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('222','1','ORDER_STATUS_UPDATE','orders','Order #16 -> PREPARING','203.189.185.246','2026-07-26 23:25:54');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('223','1','ORDER_STATUS_UPDATE','orders','Order #16 -> READY','203.189.185.246','2026-07-26 23:26:16');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('224',NULL,'DELIVERY_PICKED_UP','delivery','Delivery #11 picked up','175.157.126.202','2026-07-26 23:26:45');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('225',NULL,'RIDER_COD_COLLECTED','payments','Rider #2 collected COD LKR 2,100.00 for order #16','175.157.126.202','2026-07-26 23:27:42');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('226',NULL,'DELIVERY_DELIVERED','delivery','Delivery #11 delivered','175.157.126.202','2026-07-26 23:27:42');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('227','2','LOGIN','auth','User logged in','203.189.185.246','2026-07-27 12:25:59');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('228','2','LOGOUT','auth','User logged out','203.189.185.246','2026-07-27 12:26:16');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('229','1','LOGIN','auth','User logged in','203.189.185.246','2026-07-27 12:26:28');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('230',NULL,'CUSTOMER_APP_ORDER','orders','Customer app order #17, total LKR 700.00','203.189.185.246','2026-07-27 12:28:08');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('231','1','ORDER_STATUS_UPDATE','orders','Order #17 -> CONFIRMED','203.189.185.246','2026-07-27 12:28:59');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('232','1','ORDER_STATUS_UPDATE','orders','Order #17 -> PREPARING','203.189.185.246','2026-07-27 12:29:03');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('233','1','ORDER_STATUS_UPDATE','orders','Order #17 -> READY','203.189.185.246','2026-07-27 12:30:01');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('234','1','DELIVERY_ASSIGN','delivery','Delivery #12 assigned to rider #2','203.189.185.246','2026-07-27 12:30:26');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('235','1','DELIVERY_RIDER_ASSIGN','orders','Rider #2 assigned to order #17','203.189.185.246','2026-07-27 12:30:26');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('236',NULL,'DELIVERY_SELF_CLAIM','delivery','Rider #2 scanned QR and confirmed pickup of assigned order #17 — status set to OUT_FOR_DELIVERY','175.157.126.202','2026-07-27 12:31:54');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('237',NULL,'RIDER_COD_COLLECTED','payments','Rider #2 collected COD LKR 700.00 for order #17','175.157.126.202','2026-07-27 12:32:12');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('238',NULL,'DELIVERY_DELIVERED','delivery','Delivery #12 delivered','175.157.126.202','2026-07-27 12:32:12');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('239','1','LOGIN','auth','User logged in','103.21.164.207','2026-07-28 13:28:32');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('240','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:29:00');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('241','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:29:23');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('242','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:30:18');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('243','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:30:33');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('244','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:31:30');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('245','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:32:00');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('246','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:32:44');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('247','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:33:08');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('248','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:33:37');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('249','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:34:17');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('250','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:34:31');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('251','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:34:56');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('252','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:35:38');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('253',NULL,'CUSTOMER_APP_ORDER','orders','Customer app order #18, total LKR 1,400.00','103.21.164.207','2026-07-28 13:37:31');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('254','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:43:17');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('255','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:49:35');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('256','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:53:00');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('257','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:53:57');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('258','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 13:54:52');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('259','1','ROLE_PERMISSIONS_UPDATE','roles','Updated permissions for role #5','103.21.164.207','2026-07-28 13:59:14');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('260','1','LOGOUT','auth','User logged out','103.21.164.207','2026-07-28 13:59:16');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('261','2','LOGIN','auth','User logged in','103.21.164.207','2026-07-28 13:59:21');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('262','2','LOGOUT','auth','User logged out','103.21.164.207','2026-07-28 13:59:50');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('263','1','LOGIN','auth','User logged in','103.21.164.207','2026-07-28 14:00:03');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('264','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 14:00:42');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('265','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 14:03:27');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('266','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 14:03:43');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('267','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 14:05:54');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('268','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 14:20:17');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('269','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 14:22:46');
INSERT INTO `audit_log` (`id`,`user_id`,`action`,`module_key`,`description`,`ip_address`,`created_at`) VALUES ('270','1','SETTINGS_UPDATE','settings','Updated system settings','103.21.164.207','2026-07-28 14:33:16');

-- ----------------------------
-- Table structure for `backup_log`
-- ----------------------------
CREATE TABLE `backup_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `file_name` varchar(255) NOT NULL,
  `file_size_kb` int(11) DEFAULT 0,
  `created_by` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `created_by` (`created_by`),
  CONSTRAINT `backup_log_ibfk_1` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Table structure for `deliveries`
-- ----------------------------
CREATE TABLE `deliveries` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `order_id` int(11) NOT NULL,
  `rider_id` int(11) DEFAULT NULL,
  `status` enum('UNASSIGNED','ASSIGNED','PICKED_UP','DELIVERED','FAILED') DEFAULT 'UNASSIGNED',
  `assigned_at` timestamp NULL DEFAULT NULL,
  `picked_up_at` timestamp NULL DEFAULT NULL,
  `delivered_at` timestamp NULL DEFAULT NULL,
  `notes` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `order_id` (`order_id`),
  KEY `rider_id` (`rider_id`),
  CONSTRAINT `deliveries_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `deliveries_ibfk_2` FOREIGN KEY (`rider_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `deliveries`
-- ----------------------------
INSERT INTO `deliveries` (`id`,`order_id`,`rider_id`,`status`,`assigned_at`,`picked_up_at`,`delivered_at`,`notes`) VALUES ('1','1',NULL,'DELIVERED','2026-07-21 12:58:50','2026-07-21 13:08:11','2026-07-21 13:16:56',NULL);
INSERT INTO `deliveries` (`id`,`order_id`,`rider_id`,`status`,`assigned_at`,`picked_up_at`,`delivered_at`,`notes`) VALUES ('2','2','2','FAILED','2026-07-21 13:16:47','2026-07-21 13:18:50',NULL,'Marked failed by rider');
INSERT INTO `deliveries` (`id`,`order_id`,`rider_id`,`status`,`assigned_at`,`picked_up_at`,`delivered_at`,`notes`) VALUES ('3','3','2','FAILED','2026-07-21 13:50:40',NULL,NULL,'Marked failed by rider');
INSERT INTO `deliveries` (`id`,`order_id`,`rider_id`,`status`,`assigned_at`,`picked_up_at`,`delivered_at`,`notes`) VALUES ('4','4','2','FAILED','2026-07-21 18:07:56',NULL,NULL,'Marked failed by rider');
INSERT INTO `deliveries` (`id`,`order_id`,`rider_id`,`status`,`assigned_at`,`picked_up_at`,`delivered_at`,`notes`) VALUES ('5','5','2','FAILED','2026-07-21 18:52:08',NULL,NULL,'Marked failed by rider');
INSERT INTO `deliveries` (`id`,`order_id`,`rider_id`,`status`,`assigned_at`,`picked_up_at`,`delivered_at`,`notes`) VALUES ('6','9',NULL,'UNASSIGNED',NULL,NULL,NULL,NULL);
INSERT INTO `deliveries` (`id`,`order_id`,`rider_id`,`status`,`assigned_at`,`picked_up_at`,`delivered_at`,`notes`) VALUES ('7','10',NULL,'UNASSIGNED',NULL,NULL,NULL,NULL);
INSERT INTO `deliveries` (`id`,`order_id`,`rider_id`,`status`,`assigned_at`,`picked_up_at`,`delivered_at`,`notes`) VALUES ('8','13',NULL,'UNASSIGNED',NULL,NULL,NULL,NULL);
INSERT INTO `deliveries` (`id`,`order_id`,`rider_id`,`status`,`assigned_at`,`picked_up_at`,`delivered_at`,`notes`) VALUES ('9','14','2','FAILED','2026-07-26 17:19:50',NULL,NULL,'Marked failed by rider');
INSERT INTO `deliveries` (`id`,`order_id`,`rider_id`,`status`,`assigned_at`,`picked_up_at`,`delivered_at`,`notes`) VALUES ('10','15','2','DELIVERED','2026-07-26 23:16:40','2026-07-26 23:18:49','2026-07-26 23:20:21',NULL);
INSERT INTO `deliveries` (`id`,`order_id`,`rider_id`,`status`,`assigned_at`,`picked_up_at`,`delivered_at`,`notes`) VALUES ('11','16','2','DELIVERED','2026-07-26 23:25:48','2026-07-26 23:26:45','2026-07-26 23:27:42',NULL);
INSERT INTO `deliveries` (`id`,`order_id`,`rider_id`,`status`,`assigned_at`,`picked_up_at`,`delivered_at`,`notes`) VALUES ('12','17','2','DELIVERED','2026-07-27 12:30:26','2026-07-27 12:31:54','2026-07-27 12:32:12',NULL);

-- ----------------------------
-- Table structure for `delivery_zones`
-- ----------------------------
CREATE TABLE `delivery_zones` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `zone_name` varchar(100) NOT NULL,
  `center_latitude` decimal(10,7) DEFAULT NULL,
  `center_longitude` decimal(10,7) DEFAULT NULL,
  `radius_km` decimal(5,2) DEFAULT 3.00,
  `is_free_delivery` tinyint(1) DEFAULT 1,
  `delivery_fee` decimal(10,2) DEFAULT 0.00,
  `is_active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `delivery_zones`
-- ----------------------------
INSERT INTO `delivery_zones` (`id`,`zone_name`,`center_latitude`,`center_longitude`,`radius_km`,`is_free_delivery`,`delivery_fee`,`is_active`,`created_at`) VALUES ('1','Anuradhapura Old Bus stand (Free Delivery)',NULL,NULL,'5.00','1','0.00','1','2026-07-19 15:41:30');
INSERT INTO `delivery_zones` (`id`,`zone_name`,`center_latitude`,`center_longitude`,`radius_km`,`is_free_delivery`,`delivery_fee`,`is_active`,`created_at`) VALUES ('2','Outside Town (Charged)',NULL,NULL,'15.00','0','200.00','1','2026-07-19 15:41:30');
INSERT INTO `delivery_zones` (`id`,`zone_name`,`center_latitude`,`center_longitude`,`radius_km`,`is_free_delivery`,`delivery_fee`,`is_active`,`created_at`) VALUES ('3','New Bus Stand Anuradapura',NULL,NULL,'5.00','1','0.00','1','2026-07-21 18:13:33');

-- ----------------------------
-- Table structure for `expenses`
-- ----------------------------
CREATE TABLE `expenses` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `expense_category` varchar(100) NOT NULL,
  `amount` decimal(12,2) NOT NULL,
  `finance_account_id` int(11) NOT NULL,
  `expense_date` date NOT NULL,
  `notes` varchar(255) DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `finance_account_id` (`finance_account_id`),
  KEY `created_by` (`created_by`),
  CONSTRAINT `expenses_ibfk_1` FOREIGN KEY (`finance_account_id`) REFERENCES `finance_accounts` (`id`),
  CONSTRAINT `expenses_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Table structure for `finance_accounts`
-- ----------------------------
CREATE TABLE `finance_accounts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `account_name` varchar(100) NOT NULL,
  `account_type` enum('CASH','BANK','OTHER') DEFAULT 'CASH',
  `current_balance` decimal(14,2) DEFAULT 0.00,
  `is_active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `finance_accounts`
-- ----------------------------
INSERT INTO `finance_accounts` (`id`,`account_name`,`account_type`,`current_balance`,`is_active`,`created_at`) VALUES ('1','Cash in Hand','CASH','-170550.00','1','2026-07-19 15:41:30');
INSERT INTO `finance_accounts` (`id`,`account_name`,`account_type`,`current_balance`,`is_active`,`created_at`) VALUES ('2','Bank Account','BANK','-14050.00','1','2026-07-19 15:41:30');
INSERT INTO `finance_accounts` (`id`,`account_name`,`account_type`,`current_balance`,`is_active`,`created_at`) VALUES ('3','Card Settlement Account','BANK','0.00','1','2026-07-19 15:41:30');

-- ----------------------------
-- Table structure for `finance_transactions`
-- ----------------------------
CREATE TABLE `finance_transactions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `finance_account_id` int(11) NOT NULL,
  `transaction_type` enum('CREDIT','DEBIT') NOT NULL,
  `amount` decimal(14,2) NOT NULL,
  `category` varchar(50) NOT NULL,
  `reference_type` varchar(50) DEFAULT NULL,
  `reference_id` int(11) DEFAULT NULL,
  `description` varchar(255) DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `finance_account_id` (`finance_account_id`),
  KEY `created_by` (`created_by`),
  CONSTRAINT `finance_transactions_ibfk_1` FOREIGN KEY (`finance_account_id`) REFERENCES `finance_accounts` (`id`),
  CONSTRAINT `finance_transactions_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `finance_transactions`
-- ----------------------------
INSERT INTO `finance_transactions` (`id`,`finance_account_id`,`transaction_type`,`amount`,`category`,`reference_type`,`reference_id`,`description`,`created_by`,`created_at`) VALUES ('1','1','CREDIT','1800.00','SALES','ORDER','1','Payment for order #1 via CASH','1','2026-07-21 12:57:39');
INSERT INTO `finance_transactions` (`id`,`finance_account_id`,`transaction_type`,`amount`,`category`,`reference_type`,`reference_id`,`description`,`created_by`,`created_at`) VALUES ('2','1','CREDIT','2500.00','SALES','ORDER','2','Payment for order #2 via CASH','1','2026-07-21 13:16:47');
INSERT INTO `finance_transactions` (`id`,`finance_account_id`,`transaction_type`,`amount`,`category`,`reference_type`,`reference_id`,`description`,`created_by`,`created_at`) VALUES ('3','1','CREDIT','800.00','SALES','ORDER','3','Payment for order #3 via CASH','1','2026-07-21 13:50:40');
INSERT INTO `finance_transactions` (`id`,`finance_account_id`,`transaction_type`,`amount`,`category`,`reference_type`,`reference_id`,`description`,`created_by`,`created_at`) VALUES ('4','1','DEBIT','155000.00','PURCHASE','PURCHASE_ORDER','1','Payment for PO-20260721-0001','1','2026-07-21 17:10:53');
INSERT INTO `finance_transactions` (`id`,`finance_account_id`,`transaction_type`,`amount`,`category`,`reference_type`,`reference_id`,`description`,`created_by`,`created_at`) VALUES ('5','2','DEBIT','15100.00','PURCHASE','PURCHASE_ORDER','2','Payment for PO-20260721-0002','1','2026-07-21 17:13:47');
INSERT INTO `finance_transactions` (`id`,`finance_account_id`,`transaction_type`,`amount`,`category`,`reference_type`,`reference_id`,`description`,`created_by`,`created_at`) VALUES ('6','1','DEBIT','27000.00','PURCHASE','PURCHASE_ORDER','3','Payment for PO-20260721-0003','1','2026-07-21 17:15:11');
INSERT INTO `finance_transactions` (`id`,`finance_account_id`,`transaction_type`,`amount`,`category`,`reference_type`,`reference_id`,`description`,`created_by`,`created_at`) VALUES ('7','1','CREDIT','2250.00','SALES','ORDER','4','Payment for order #4 via CASH','1','2026-07-21 18:07:59');
INSERT INTO `finance_transactions` (`id`,`finance_account_id`,`transaction_type`,`amount`,`category`,`reference_type`,`reference_id`,`description`,`created_by`,`created_at`) VALUES ('8','1','CREDIT','1850.00','SALES','ORDER','5','Payment for order #5 via CASH','1','2026-07-21 18:52:08');
INSERT INTO `finance_transactions` (`id`,`finance_account_id`,`transaction_type`,`amount`,`category`,`reference_type`,`reference_id`,`description`,`created_by`,`created_at`) VALUES ('9','2','CREDIT','350.00','SALES','ORDER','9','Payment for order #9 via ONLINE_TRANSFER','1','2026-07-26 11:55:45');
INSERT INTO `finance_transactions` (`id`,`finance_account_id`,`transaction_type`,`amount`,`category`,`reference_type`,`reference_id`,`description`,`created_by`,`created_at`) VALUES ('10','1','CREDIT','1550.00','SALES','ORDER','10','Payment for order #10 via CASH','1','2026-07-26 12:05:25');
INSERT INTO `finance_transactions` (`id`,`finance_account_id`,`transaction_type`,`amount`,`category`,`reference_type`,`reference_id`,`description`,`created_by`,`created_at`) VALUES ('11','2','CREDIT','700.00','SALES','ORDER','11','Payment for order #11 via ONLINE_TRANSFER','1','2026-07-26 13:04:39');
INSERT INTO `finance_transactions` (`id`,`finance_account_id`,`transaction_type`,`amount`,`category`,`reference_type`,`reference_id`,`description`,`created_by`,`created_at`) VALUES ('12','1','CREDIT','350.00','SALES','ORDER','13','Payment for order #13 via CASH','1','2026-07-26 17:12:07');
INSERT INTO `finance_transactions` (`id`,`finance_account_id`,`transaction_type`,`amount`,`category`,`reference_type`,`reference_id`,`description`,`created_by`,`created_at`) VALUES ('13','1','CREDIT','350.00','SALES','ORDER','14','Payment for order #14 via CASH','1','2026-07-26 17:20:34');

-- ----------------------------
-- Table structure for `kitchen_issue_items`
-- ----------------------------
CREATE TABLE `kitchen_issue_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `kitchen_issue_id` int(11) NOT NULL,
  `raw_material_id` int(11) NOT NULL,
  `quantity` decimal(12,3) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `kitchen_issue_id` (`kitchen_issue_id`),
  KEY `raw_material_id` (`raw_material_id`),
  CONSTRAINT `kitchen_issue_items_ibfk_1` FOREIGN KEY (`kitchen_issue_id`) REFERENCES `kitchen_issues` (`id`) ON DELETE CASCADE,
  CONSTRAINT `kitchen_issue_items_ibfk_2` FOREIGN KEY (`raw_material_id`) REFERENCES `raw_materials` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `kitchen_issue_items`
-- ----------------------------
INSERT INTO `kitchen_issue_items` (`id`,`kitchen_issue_id`,`raw_material_id`,`quantity`) VALUES ('1','1','2','20.000');
INSERT INTO `kitchen_issue_items` (`id`,`kitchen_issue_id`,`raw_material_id`,`quantity`) VALUES ('2','1','3','5.000');
INSERT INTO `kitchen_issue_items` (`id`,`kitchen_issue_id`,`raw_material_id`,`quantity`) VALUES ('3','1','1','10.000');
INSERT INTO `kitchen_issue_items` (`id`,`kitchen_issue_id`,`raw_material_id`,`quantity`) VALUES ('4','1','4','2.000');
INSERT INTO `kitchen_issue_items` (`id`,`kitchen_issue_id`,`raw_material_id`,`quantity`) VALUES ('5','1','5','2.000');
INSERT INTO `kitchen_issue_items` (`id`,`kitchen_issue_id`,`raw_material_id`,`quantity`) VALUES ('9','2','2','1.000');
INSERT INTO `kitchen_issue_items` (`id`,`kitchen_issue_id`,`raw_material_id`,`quantity`) VALUES ('10','2','3','1.000');
INSERT INTO `kitchen_issue_items` (`id`,`kitchen_issue_id`,`raw_material_id`,`quantity`) VALUES ('11','2','5','1.000');
INSERT INTO `kitchen_issue_items` (`id`,`kitchen_issue_id`,`raw_material_id`,`quantity`) VALUES ('12','2','1','1.000');

-- ----------------------------
-- Table structure for `kitchen_issues`
-- ----------------------------
CREATE TABLE `kitchen_issues` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `issue_date` date NOT NULL,
  `notes` varchar(255) DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `created_by` (`created_by`),
  CONSTRAINT `kitchen_issues_ibfk_1` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `kitchen_issues`
-- ----------------------------
INSERT INTO `kitchen_issues` (`id`,`issue_date`,`notes`,`created_by`,`created_at`) VALUES ('1','2026-07-21','Today menu','1','2026-07-21 17:26:47');
INSERT INTO `kitchen_issues` (`id`,`issue_date`,`notes`,`created_by`,`created_at`) VALUES ('2','2026-07-21','Today menu 1','1','2026-07-21 20:08:39');

-- ----------------------------
-- Table structure for `menu_categories`
-- ----------------------------
CREATE TABLE `menu_categories` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `category_name` varchar(100) NOT NULL,
  `display_order` int(11) DEFAULT 0,
  `is_active` tinyint(1) DEFAULT 1,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `menu_categories`
-- ----------------------------
INSERT INTO `menu_categories` (`id`,`category_name`,`display_order`,`is_active`) VALUES ('1','Rice & Curry','1','1');
INSERT INTO `menu_categories` (`id`,`category_name`,`display_order`,`is_active`) VALUES ('2','Beverages','2','1');

-- ----------------------------
-- Table structure for `menu_item_variants`
-- ----------------------------
CREATE TABLE `menu_item_variants` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `menu_item_id` int(11) NOT NULL,
  `variant_name` varchar(100) NOT NULL,
  `price_adjustment` decimal(10,2) DEFAULT 0.00,
  `is_default` tinyint(1) DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `menu_item_id` (`menu_item_id`),
  CONSTRAINT `menu_item_variants_ibfk_1` FOREIGN KEY (`menu_item_id`) REFERENCES `menu_items` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Table structure for `menu_items`
-- ----------------------------
CREATE TABLE `menu_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `category_id` int(11) NOT NULL,
  `item_name` varchar(150) NOT NULL,
  `description` text DEFAULT NULL,
  `image_path` varchar(255) DEFAULT NULL,
  `base_price` decimal(10,2) NOT NULL DEFAULT 0.00,
  `is_available` tinyint(1) DEFAULT 1,
  `track_stock` tinyint(1) DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `category_id` (`category_id`),
  CONSTRAINT `menu_items_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `menu_categories` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `menu_items`
-- ----------------------------
INSERT INTO `menu_items` (`id`,`category_id`,`item_name`,`description`,`image_path`,`base_price`,`is_available`,`track_stock`,`created_at`) VALUES ('1','1','Chicken Rice & Curry','Chicken Curry, Dal Curry, Potato Temperd, Brinjal Morgu, Green Beans, Mix Papadam','uploads/menu/menu_5fbf2162eca63611.jpg','450.00','1','1','2026-07-19 15:41:30');
INSERT INTO `menu_items` (`id`,`category_id`,`item_name`,`description`,`image_path`,`base_price`,`is_available`,`track_stock`,`created_at`) VALUES ('2','1','Vegetable Rice & Curry','Dal Curry, Potato Temperd, Brinjal Morgu, Green Beans, Mix Papadam','uploads/menu/menu_651d4c6d9c630848.png','350.00','1','1','2026-07-19 15:41:30');
INSERT INTO `menu_items` (`id`,`category_id`,`item_name`,`description`,`image_path`,`base_price`,`is_available`,`track_stock`,`created_at`) VALUES ('3','1','Fish Rice & Curry (TUNA)','Tuna Fish, Dal Curry, Potato Temperd, Brinjal Morgu, Green Beans, Mix Papadam','uploads/menu/menu_9b4077e13aeadbb7.png','450.00','1','1','2026-07-21 13:32:25');
INSERT INTO `menu_items` (`id`,`category_id`,`item_name`,`description`,`image_path`,`base_price`,`is_available`,`track_stock`,`created_at`) VALUES ('4','1','Chicken Stew Rice & Curry','Chicken Stew, Dal Curry, Potato Temperd, Brinjal Morgu, Green Beans, Mix Papadam','uploads/menu/menu_71ffc5b0d4f6f1df.png','500.00','1','1','2026-07-21 13:40:04');
INSERT INTO `menu_items` (`id`,`category_id`,`item_name`,`description`,`image_path`,`base_price`,`is_available`,`track_stock`,`created_at`) VALUES ('5','1','Boiled Egg Rice & Curry','Boiled Egg, Dal Curry, Potato Temperd, Brinjal Morgu, Green Beans, Mix Papadam','uploads/menu/menu_b4e95c4e98d4a8e3.jpg','350.00','1','1','2026-07-21 13:41:46');
INSERT INTO `menu_items` (`id`,`category_id`,`item_name`,`description`,`image_path`,`base_price`,`is_available`,`track_stock`,`created_at`) VALUES ('6','1','Fish Rice & Curry (LAKE FISH)','Lake Fish, Dal Curry, Potato Temperd, Brinjal Morgu, Green Beans, Mix Papadam','uploads/menu/menu_cc44d68267cdccc1.png','450.00','1','1','2026-07-21 13:42:59');

-- ----------------------------
-- Table structure for `order_items`
-- ----------------------------
CREATE TABLE `order_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `order_id` int(11) NOT NULL,
  `menu_item_id` int(11) NOT NULL,
  `variant_id` int(11) DEFAULT NULL,
  `item_name_snapshot` varchar(150) NOT NULL,
  `unit_price` decimal(10,2) NOT NULL,
  `quantity` int(11) NOT NULL DEFAULT 1,
  `line_total` decimal(12,2) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `order_id` (`order_id`),
  KEY `menu_item_id` (`menu_item_id`),
  KEY `variant_id` (`variant_id`),
  CONSTRAINT `order_items_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `order_items_ibfk_2` FOREIGN KEY (`menu_item_id`) REFERENCES `menu_items` (`id`),
  CONSTRAINT `order_items_ibfk_3` FOREIGN KEY (`variant_id`) REFERENCES `menu_item_variants` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `order_items`
-- ----------------------------
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('1','1','1',NULL,'Chicken Rice & Curry','450.00','4','1800.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('2','2','1',NULL,'Chicken Rice & Curry','450.00','4','1800.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('3','2','2',NULL,'Vegetable Rice & Curry','350.00','2','700.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('4','3','1',NULL,'Chicken Rice & Curry','450.00','1','450.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('5','3','5',NULL,'Boiled Egg Rice & Curry','350.00','1','350.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('6','4','1',NULL,'Chicken Rice & Curry','450.00','5','2250.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('7','5','4',NULL,'Chicken Stew Rice & Curry','500.00','1','500.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('8','5','1',NULL,'Chicken Rice & Curry','450.00','1','450.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('9','5','3',NULL,'Fish Rice & Curry (TUNA)','450.00','2','900.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('10','6','5',NULL,'Boiled Egg Rice & Curry','350.00','1','350.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('11','7','5',NULL,'Boiled Egg Rice & Curry','350.00','1','350.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('12','7','1',NULL,'Chicken Rice & Curry','450.00','1','450.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('13','7','4',NULL,'Chicken Stew Rice & Curry','500.00','1','500.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('14','7','6',NULL,'Fish Rice & Curry (LAKE FISH)','450.00','1','450.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('15','7','2',NULL,'Vegetable Rice & Curry','350.00','1','350.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('16','7','3',NULL,'Fish Rice & Curry (TUNA)','450.00','1','450.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('17','8','5',NULL,'Boiled Egg Rice & Curry','350.00','1','350.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('18','9','5',NULL,'Boiled Egg Rice & Curry','350.00','1','350.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('19','10','4',NULL,'Chicken Stew Rice & Curry','500.00','1','500.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('20','10','5',NULL,'Boiled Egg Rice & Curry','350.00','3','1050.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('21','11','5',NULL,'Boiled Egg Rice & Curry','350.00','2','700.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('22','12','5',NULL,'Boiled Egg Rice & Curry','350.00','3','1050.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('23','13','5',NULL,'Boiled Egg Rice & Curry','350.00','1','350.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('24','14','5',NULL,'Boiled Egg Rice & Curry','350.00','1','350.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('25','15','1',NULL,'Chicken Rice & Curry','450.00','3','1350.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('26','16','5',NULL,'Boiled Egg Rice & Curry','350.00','6','2100.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('27','17','5',NULL,'Boiled Egg Rice & Curry','350.00','2','700.00');
INSERT INTO `order_items` (`id`,`order_id`,`menu_item_id`,`variant_id`,`item_name_snapshot`,`unit_price`,`quantity`,`line_total`) VALUES ('28','18','5',NULL,'Boiled Egg Rice & Curry','350.00','4','1400.00');

-- ----------------------------
-- Table structure for `order_status_history`
-- ----------------------------
CREATE TABLE `order_status_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `order_id` int(11) NOT NULL,
  `status` varchar(30) NOT NULL,
  `changed_by` int(11) DEFAULT NULL,
  `changed_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `order_id` (`order_id`),
  KEY `changed_by` (`changed_by`),
  CONSTRAINT `order_status_history_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `order_status_history_ibfk_2` FOREIGN KEY (`changed_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `order_status_history`
-- ----------------------------
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('1','1','PENDING','1','2026-07-21 12:57:39');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('2','1','CONFIRMED','1','2026-07-21 12:58:20');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('3','1','PREPARING','1','2026-07-21 12:58:42');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('4','1','READY','1','2026-07-21 12:58:44');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('5','1','OUT_FOR_DELIVERY','1','2026-07-21 12:58:50');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('6','1','OUT_FOR_DELIVERY','1','2026-07-21 13:08:11');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('7','1','COMPLETED','1','2026-07-21 13:16:13');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('8','2','PENDING','1','2026-07-21 13:16:47');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('9','1','COMPLETED','1','2026-07-21 13:16:56');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('10','2','CONFIRMED','1','2026-07-21 13:17:05');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('11','2','PREPARING','1','2026-07-21 13:18:01');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('12','2','READY','1','2026-07-21 13:18:42');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('13','2','OUT_FOR_DELIVERY','1','2026-07-21 13:18:50');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('14','2','COMPLETED','1','2026-07-21 13:18:57');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('15','3','PENDING','1','2026-07-21 13:50:40');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('16','3','CONFIRMED','1','2026-07-21 13:50:41');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('17','3','PREPARING','1','2026-07-21 18:07:32');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('18','3','READY','1','2026-07-21 18:07:33');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('19','3','OUT_FOR_DELIVERY','1','2026-07-21 18:07:34');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('20','3','COMPLETED','1','2026-07-21 18:07:34');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('21','4','PENDING','1','2026-07-21 18:07:56');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('22','4','CONFIRMED','1','2026-07-21 18:08:02');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('23','5','PENDING','1','2026-07-21 18:52:08');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('24','5','CONFIRMED','1','2026-07-21 18:52:35');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('25','6','PENDING',NULL,'2026-07-26 10:22:03');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('26','7','PENDING',NULL,'2026-07-26 11:31:18');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('27','7','CANCELLED','1','2026-07-26 11:32:47');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('28','8','PENDING',NULL,'2026-07-26 11:33:31');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('29','9','PENDING',NULL,'2026-07-26 11:55:13');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('30','9','CONFIRMED','1','2026-07-26 11:55:31');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('31','9','PREPARING','1','2026-07-26 11:59:01');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('32','9','READY','1','2026-07-26 11:59:29');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('33','9','OUT_FOR_DELIVERY','1','2026-07-26 11:59:41');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('34','9','COMPLETED','1','2026-07-26 11:59:52');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('35','10','PENDING',NULL,'2026-07-26 12:04:36');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('36','10','CONFIRMED','1','2026-07-26 12:04:53');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('37','10','PREPARING','1','2026-07-26 12:05:00');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('38','10','READY','1','2026-07-26 12:05:05');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('39','10','OUT_FOR_DELIVERY','1','2026-07-26 12:05:13');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('40','10','COMPLETED','1','2026-07-26 12:05:20');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('41','11','PENDING',NULL,'2026-07-26 13:04:21');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('42','12','PENDING',NULL,'2026-07-26 14:30:54');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('43','12','CANCELLED','1','2026-07-26 14:31:54');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('44','13','PENDING',NULL,'2026-07-26 14:54:11');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('45','13','CONFIRMED','1','2026-07-26 17:11:49');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('46','13','PREPARING','1','2026-07-26 17:11:54');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('47','13','READY','1','2026-07-26 17:12:01');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('48','13','OUT_FOR_DELIVERY','1','2026-07-26 17:12:03');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('49','13','COMPLETED','1','2026-07-26 17:12:04');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('50','14','PENDING',NULL,'2026-07-26 17:12:54');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('51','14','CONFIRMED','1','2026-07-26 17:13:12');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('52','14','PREPARING','1','2026-07-26 17:20:07');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('53','14','READY','1','2026-07-26 17:20:15');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('54','14','OUT_FOR_DELIVERY','1','2026-07-26 17:20:22');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('55','14','COMPLETED','1','2026-07-26 17:20:32');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('56','15','PENDING',NULL,'2026-07-26 23:13:55');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('57','15','CONFIRMED','1','2026-07-26 23:16:43');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('58','15','PREPARING','1','2026-07-26 23:16:45');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('59','15','READY','1','2026-07-26 23:18:33');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('60','15','OUT_FOR_DELIVERY',NULL,'2026-07-26 23:18:49');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('61','15','COMPLETED',NULL,'2026-07-26 23:20:21');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('62','16','PENDING',NULL,'2026-07-26 23:23:40');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('63','16','CONFIRMED','1','2026-07-26 23:25:50');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('64','16','PREPARING','1','2026-07-26 23:25:54');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('65','16','READY','1','2026-07-26 23:26:16');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('66','16','OUT_FOR_DELIVERY',NULL,'2026-07-26 23:26:45');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('67','16','COMPLETED',NULL,'2026-07-26 23:27:42');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('68','17','PENDING',NULL,'2026-07-27 12:28:08');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('69','17','CONFIRMED','1','2026-07-27 12:28:59');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('70','17','PREPARING','1','2026-07-27 12:29:03');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('71','17','READY','1','2026-07-27 12:30:01');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('72','17','OUT_FOR_DELIVERY',NULL,'2026-07-27 12:31:54');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('73','17','COMPLETED',NULL,'2026-07-27 12:32:12');
INSERT INTO `order_status_history` (`id`,`order_id`,`status`,`changed_by`,`changed_at`) VALUES ('74','18','PENDING',NULL,'2026-07-28 13:37:30');

-- ----------------------------
-- Table structure for `orders`
-- ----------------------------
CREATE TABLE `orders` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `order_number` varchar(30) NOT NULL,
  `order_type` enum('DINE_IN','TAKEAWAY','ONLINE_DELIVERY') NOT NULL,
  `order_source` enum('APP','CALL','WHATSAPP','WALK_IN') DEFAULT NULL,
  `customer_id` int(11) DEFAULT NULL,
  `delivery_zone_id` int(11) DEFAULT NULL,
  `status` enum('PENDING','CONFIRMED','PREPARING','READY','OUT_FOR_DELIVERY','COMPLETED','CANCELLED') DEFAULT 'PENDING',
  `subtotal` decimal(12,2) NOT NULL DEFAULT 0.00,
  `delivery_fee` decimal(10,2) NOT NULL DEFAULT 0.00,
  `discount` decimal(10,2) NOT NULL DEFAULT 0.00,
  `total_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `delivery_address` text DEFAULT NULL,
  `delivery_latitude` decimal(10,7) DEFAULT NULL,
  `delivery_longitude` decimal(10,7) DEFAULT NULL,
  `notes` varchar(255) DEFAULT NULL,
  `payment_reference` varchar(100) DEFAULT NULL,
  `deposit_slip_path` varchar(255) DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `order_number` (`order_number`),
  KEY `customer_id` (`customer_id`),
  KEY `delivery_zone_id` (`delivery_zone_id`),
  KEY `created_by` (`created_by`),
  CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `orders_ibfk_2` FOREIGN KEY (`delivery_zone_id`) REFERENCES `delivery_zones` (`id`) ON DELETE SET NULL,
  CONSTRAINT `orders_ibfk_3` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `orders`
-- ----------------------------
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('1','ORD-20260721-0001','ONLINE_DELIVERY',NULL,'1','1','COMPLETED','1800.00','0.00','0.00','1800.00','DFCC bank Anuradapura',NULL,NULL,NULL,NULL,NULL,'1','2026-07-21 12:57:39','2026-07-21 13:16:13');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('2','ORD-20260721-0002','ONLINE_DELIVERY',NULL,'2','1','COMPLETED','2500.00','0.00','0.00','2500.00','BOC bank',NULL,NULL,NULL,NULL,NULL,'1','2026-07-21 13:16:47','2026-07-21 13:18:57');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('3','ORD-20260721-0003','ONLINE_DELIVERY',NULL,'3','1','COMPLETED','800.00','0.00','0.00','800.00','Bank Town Anuradapura',NULL,NULL,NULL,NULL,NULL,'1','2026-07-21 13:50:40','2026-07-21 18:07:34');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('4','ORD-20260721-0004','ONLINE_DELIVERY','WHATSAPP','1','1','CONFIRMED','2250.00','0.00','0.00','2250.00','No 17 Veyangoda Road, Ruwanwella',NULL,NULL,NULL,NULL,NULL,'1','2026-07-21 18:07:56','2026-07-21 18:08:02');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('5','ORD-20260721-0005','ONLINE_DELIVERY','CALL','4','3','CONFIRMED','1850.00','0.00','0.00','1850.00','21 New town Anuradapura',NULL,NULL,NULL,NULL,NULL,'1','2026-07-21 18:52:08','2026-07-21 18:52:35');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('6','ORD-20260726-0001','ONLINE_DELIVERY','APP','5','3','PENDING','350.00','0.00','0.00','350.00','BOC banak New town',NULL,NULL,NULL,NULL,NULL,NULL,'2026-07-26 10:22:03','2026-07-26 10:22:03');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('7','ORD-20260726-0002','ONLINE_DELIVERY','APP','6','1','CANCELLED','2550.00','0.00','0.00','2550.00','DFCC Bank',NULL,NULL,'Payment: Card on Delivery',NULL,NULL,NULL,'2026-07-26 11:31:18','2026-07-26 11:32:47');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('8','ORD-20260726-0003','ONLINE_DELIVERY','APP','6','3','PENDING','350.00','0.00','0.00','350.00','dasd',NULL,NULL,'Payment: Card on Delivery',NULL,NULL,NULL,'2026-07-26 11:33:31','2026-07-26 11:33:31');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('9','ORD-20260726-0004','ONLINE_DELIVERY','APP','6','1','COMPLETED','350.00','0.00','0.00','350.00','No 17 Veyangoda Road, Ruwanwella',NULL,NULL,'Payment: Bank Transfer','456982635','uploads/deposit_slips/slip_order9_1785047113.jpg',NULL,'2026-07-26 11:55:13','2026-07-26 11:59:52');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('10','ORD-20260726-0005','ONLINE_DELIVERY','APP','6','3','COMPLETED','1550.00','0.00','0.00','1550.00','Fhf',NULL,NULL,'Payment: Cash on Delivery',NULL,NULL,NULL,'2026-07-26 12:04:36','2026-07-26 12:05:20');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('11','ORD-20260726-0006','ONLINE_DELIVERY','APP','6','1','PENDING','700.00','0.00','0.00','700.00','DFCC Bank',NULL,NULL,'Payment: Bank Transfer','46478568','uploads/deposit_slips/slip_order11_1785051261.jpg',NULL,'2026-07-26 13:04:21','2026-07-26 13:04:21');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('12','ORD-20260726-0007','ONLINE_DELIVERY','APP','6','1','CANCELLED','1050.00','0.00','0.00','1050.00','DFCC Bank',NULL,NULL,'Payment: Cash on Delivery',NULL,NULL,NULL,'2026-07-26 14:30:54','2026-07-26 14:31:54');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('13','ORD-20260726-0008','ONLINE_DELIVERY','APP','7','1','COMPLETED','350.00','0.00','0.00','350.00','HNB Banak',NULL,NULL,'Payment: Cash on Delivery',NULL,NULL,NULL,'2026-07-26 14:54:11','2026-07-26 17:12:04');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('14','ORD-20260726-0009','ONLINE_DELIVERY','APP','6','3','COMPLETED','350.00','0.00','0.00','350.00','DFCC Bank',NULL,NULL,'Payment: Cash on Delivery',NULL,NULL,NULL,'2026-07-26 17:12:54','2026-07-26 17:20:32');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('15','ORD-20260726-0010','ONLINE_DELIVERY','APP','6','1','COMPLETED','1350.00','0.00','0.00','1350.00','DFCC Bank anuradhapura',NULL,NULL,'Payment: Cash on Delivery',NULL,NULL,NULL,'2026-07-26 23:13:55','2026-07-26 23:20:21');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('16','ORD-20260726-0011','ONLINE_DELIVERY','APP','6','3','COMPLETED','2100.00','0.00','0.00','2100.00','DFCC Bank - Anuradhapura',NULL,NULL,'Payment: Cash on Delivery',NULL,NULL,NULL,'2026-07-26 23:23:40','2026-07-26 23:27:42');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('17','ORD-20260727-0001','ONLINE_DELIVERY','APP','6','1','COMPLETED','700.00','0.00','0.00','700.00','DFCC Bank - Anuradhapura',NULL,NULL,'Payment: Cash on Delivery',NULL,NULL,NULL,'2026-07-27 12:28:08','2026-07-27 12:32:12');
INSERT INTO `orders` (`id`,`order_number`,`order_type`,`order_source`,`customer_id`,`delivery_zone_id`,`status`,`subtotal`,`delivery_fee`,`discount`,`total_amount`,`delivery_address`,`delivery_latitude`,`delivery_longitude`,`notes`,`payment_reference`,`deposit_slip_path`,`created_by`,`created_at`,`updated_at`) VALUES ('18','ORD-20260728-0001','ONLINE_DELIVERY','APP','6','3','PENDING','1400.00','0.00','0.00','1400.00','DFCC Bank - Anuradhapura',NULL,NULL,'Payment: Cash on Delivery',NULL,NULL,NULL,'2026-07-28 13:37:29','2026-07-28 13:37:29');

-- ----------------------------
-- Table structure for `payment_methods`
-- ----------------------------
CREATE TABLE `payment_methods` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `method_name` varchar(50) NOT NULL,
  `finance_account_id` int(11) DEFAULT NULL,
  `fee_percentage` decimal(5,2) DEFAULT 0.00,
  `is_active` tinyint(1) DEFAULT 1,
  PRIMARY KEY (`id`),
  UNIQUE KEY `method_name` (`method_name`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `payment_methods`
-- ----------------------------
INSERT INTO `payment_methods` (`id`,`method_name`,`finance_account_id`,`fee_percentage`,`is_active`) VALUES ('1','CASH','1','0.00','1');
INSERT INTO `payment_methods` (`id`,`method_name`,`finance_account_id`,`fee_percentage`,`is_active`) VALUES ('2','CARD','3','2.50','1');
INSERT INTO `payment_methods` (`id`,`method_name`,`finance_account_id`,`fee_percentage`,`is_active`) VALUES ('3','ONLINE_TRANSFER','2','0.00','1');
INSERT INTO `payment_methods` (`id`,`method_name`,`finance_account_id`,`fee_percentage`,`is_active`) VALUES ('4','COD',NULL,'0.00','1');

-- ----------------------------
-- Table structure for `payments`
-- ----------------------------
CREATE TABLE `payments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `order_id` int(11) NOT NULL,
  `payment_method_id` int(11) NOT NULL,
  `amount` decimal(12,2) NOT NULL,
  `fee_amount` decimal(10,2) DEFAULT 0.00,
  `status` enum('PENDING','PAID','REFUNDED') DEFAULT 'PAID',
  `paid_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `received_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `order_id` (`order_id`),
  KEY `payment_method_id` (`payment_method_id`),
  KEY `received_by` (`received_by`),
  CONSTRAINT `payments_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `payments_ibfk_2` FOREIGN KEY (`payment_method_id`) REFERENCES `payment_methods` (`id`),
  CONSTRAINT `payments_ibfk_3` FOREIGN KEY (`received_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `payments`
-- ----------------------------
INSERT INTO `payments` (`id`,`order_id`,`payment_method_id`,`amount`,`fee_amount`,`status`,`paid_at`,`received_by`) VALUES ('1','1','1','1800.00','0.00','PAID','2026-07-21 12:57:39','1');
INSERT INTO `payments` (`id`,`order_id`,`payment_method_id`,`amount`,`fee_amount`,`status`,`paid_at`,`received_by`) VALUES ('2','2','1','2500.00','0.00','PAID','2026-07-21 13:16:47','1');
INSERT INTO `payments` (`id`,`order_id`,`payment_method_id`,`amount`,`fee_amount`,`status`,`paid_at`,`received_by`) VALUES ('3','3','1','800.00','0.00','PAID','2026-07-21 13:50:40','1');
INSERT INTO `payments` (`id`,`order_id`,`payment_method_id`,`amount`,`fee_amount`,`status`,`paid_at`,`received_by`) VALUES ('4','4','1','2250.00','0.00','PAID','2026-07-21 18:07:59','1');
INSERT INTO `payments` (`id`,`order_id`,`payment_method_id`,`amount`,`fee_amount`,`status`,`paid_at`,`received_by`) VALUES ('5','5','1','1850.00','0.00','PAID','2026-07-21 18:52:08','1');
INSERT INTO `payments` (`id`,`order_id`,`payment_method_id`,`amount`,`fee_amount`,`status`,`paid_at`,`received_by`) VALUES ('6','9','3','350.00','0.00','PAID','2026-07-26 11:55:45','1');
INSERT INTO `payments` (`id`,`order_id`,`payment_method_id`,`amount`,`fee_amount`,`status`,`paid_at`,`received_by`) VALUES ('7','10','1','1550.00','0.00','PAID','2026-07-26 12:05:25','1');
INSERT INTO `payments` (`id`,`order_id`,`payment_method_id`,`amount`,`fee_amount`,`status`,`paid_at`,`received_by`) VALUES ('8','11','3','700.00','0.00','PAID','2026-07-26 13:04:39','1');
INSERT INTO `payments` (`id`,`order_id`,`payment_method_id`,`amount`,`fee_amount`,`status`,`paid_at`,`received_by`) VALUES ('9','13','1','350.00','0.00','PAID','2026-07-26 17:12:07','1');
INSERT INTO `payments` (`id`,`order_id`,`payment_method_id`,`amount`,`fee_amount`,`status`,`paid_at`,`received_by`) VALUES ('10','14','1','350.00','0.00','PAID','2026-07-26 17:20:34','1');
INSERT INTO `payments` (`id`,`order_id`,`payment_method_id`,`amount`,`fee_amount`,`status`,`paid_at`,`received_by`) VALUES ('11','15','4','1350.00','0.00','PAID','2026-07-26 23:20:21',NULL);
INSERT INTO `payments` (`id`,`order_id`,`payment_method_id`,`amount`,`fee_amount`,`status`,`paid_at`,`received_by`) VALUES ('12','16','4','2100.00','0.00','PAID','2026-07-26 23:27:42',NULL);
INSERT INTO `payments` (`id`,`order_id`,`payment_method_id`,`amount`,`fee_amount`,`status`,`paid_at`,`received_by`) VALUES ('13','17','4','700.00','0.00','PAID','2026-07-27 12:32:12',NULL);

-- ----------------------------
-- Table structure for `payroll_items`
-- ----------------------------
CREATE TABLE `payroll_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `payroll_run_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `days_present` int(11) DEFAULT 0,
  `days_absent` int(11) DEFAULT 0,
  `basic_amount` decimal(12,2) DEFAULT 0.00,
  `additions` decimal(12,2) DEFAULT 0.00,
  `deductions` decimal(12,2) DEFAULT 0.00,
  `net_pay` decimal(12,2) DEFAULT 0.00,
  `is_paid` tinyint(1) DEFAULT 0,
  `paid_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `payroll_run_id` (`payroll_run_id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `payroll_items_ibfk_1` FOREIGN KEY (`payroll_run_id`) REFERENCES `payroll_runs` (`id`) ON DELETE CASCADE,
  CONSTRAINT `payroll_items_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `payroll_items`
-- ----------------------------
INSERT INTO `payroll_items` (`id`,`payroll_run_id`,`user_id`,`days_present`,`days_absent`,`basic_amount`,`additions`,`deductions`,`net_pay`,`is_paid`,`paid_at`) VALUES ('1','1','1','1','0','0.00','0.00','0.00','0.00','0',NULL);
INSERT INTO `payroll_items` (`id`,`payroll_run_id`,`user_id`,`days_present`,`days_absent`,`basic_amount`,`additions`,`deductions`,`net_pay`,`is_paid`,`paid_at`) VALUES ('2','1','2','1','0','0.00','0.00','0.00','0.00','0',NULL);

-- ----------------------------
-- Table structure for `payroll_runs`
-- ----------------------------
CREATE TABLE `payroll_runs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `period_month` tinyint(4) NOT NULL,
  `period_year` smallint(6) NOT NULL,
  `status` enum('DRAFT','FINALIZED','PAID') DEFAULT 'DRAFT',
  `generated_by` int(11) DEFAULT NULL,
  `generated_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_period` (`period_month`,`period_year`),
  KEY `generated_by` (`generated_by`),
  CONSTRAINT `payroll_runs_ibfk_1` FOREIGN KEY (`generated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `payroll_runs`
-- ----------------------------
INSERT INTO `payroll_runs` (`id`,`period_month`,`period_year`,`status`,`generated_by`,`generated_at`) VALUES ('1','7','2026','FINALIZED','1','2026-07-21 18:32:32');

-- ----------------------------
-- Table structure for `permissions`
-- ----------------------------
CREATE TABLE `permissions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `module_key` varchar(50) NOT NULL,
  `module_label` varchar(100) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `module_key` (`module_key`)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `permissions`
-- ----------------------------
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('1','dashboard','Dashboard');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('2','orders','Orders');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('3','menu','Menu Management');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('4','stock','Stock / Raw Materials');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('5','delivery','Delivery Management');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('6','customers','Customers');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('7','payments','Payments');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('8','finance','Finance / Accounts');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('9','expenses','Expenses');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('10','payroll','Payroll');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('11','attendance','Attendance');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('12','reports','Reports');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('13','users','User Management');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('14','roles','Roles & Permissions');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('15','settings','System Settings');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('16','backups','Backups');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('17','audit_log','Audit Log');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('18','suppliers','Suppliers');
INSERT INTO `permissions` (`id`,`module_key`,`module_label`) VALUES ('19','purchasing','Purchasing');

-- ----------------------------
-- Table structure for `promotions`
-- ----------------------------
CREATE TABLE `promotions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(150) NOT NULL,
  `subtitle` varchar(255) DEFAULT NULL,
  `image_path` varchar(255) DEFAULT NULL,
  `button_text` varchar(50) DEFAULT 'Browse Menu',
  `display_order` int(11) DEFAULT 0,
  `is_active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `promotions`
-- ----------------------------
INSERT INTO `promotions` (`id`,`title`,`subtitle`,`image_path`,`button_text`,`display_order`,`is_active`,`created_at`) VALUES ('1','Enjoy 10% OFF on CurryPot Foods',NULL,'uploads/promotions/promo_44abe1515fc0caea.jpg','Browse Menu','1','1','2026-07-26 13:33:19');

-- ----------------------------
-- Table structure for `purchase_order_items`
-- ----------------------------
CREATE TABLE `purchase_order_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `purchase_order_id` int(11) NOT NULL,
  `raw_material_id` int(11) NOT NULL,
  `quantity_ordered` decimal(12,3) NOT NULL,
  `quantity_received` decimal(12,3) NOT NULL DEFAULT 0.000,
  `unit_cost` decimal(10,2) NOT NULL DEFAULT 0.00,
  `line_total` decimal(12,2) NOT NULL DEFAULT 0.00,
  PRIMARY KEY (`id`),
  KEY `purchase_order_id` (`purchase_order_id`),
  KEY `raw_material_id` (`raw_material_id`),
  CONSTRAINT `purchase_order_items_ibfk_1` FOREIGN KEY (`purchase_order_id`) REFERENCES `purchase_orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `purchase_order_items_ibfk_2` FOREIGN KEY (`raw_material_id`) REFERENCES `raw_materials` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `purchase_order_items`
-- ----------------------------
INSERT INTO `purchase_order_items` (`id`,`purchase_order_id`,`raw_material_id`,`quantity_ordered`,`quantity_received`,`unit_cost`,`line_total`) VALUES ('1','1','1','100.000','100.000','1550.00','155000.00');
INSERT INTO `purchase_order_items` (`id`,`purchase_order_id`,`raw_material_id`,`quantity_ordered`,`quantity_received`,`unit_cost`,`line_total`) VALUES ('2','2','3','50.000','50.000','150.00','7500.00');
INSERT INTO `purchase_order_items` (`id`,`purchase_order_id`,`raw_material_id`,`quantity_ordered`,`quantity_received`,`unit_cost`,`line_total`) VALUES ('3','2','4','20.000','20.000','130.00','2600.00');
INSERT INTO `purchase_order_items` (`id`,`purchase_order_id`,`raw_material_id`,`quantity_ordered`,`quantity_received`,`unit_cost`,`line_total`) VALUES ('4','2','5','50.000','50.000','100.00','5000.00');
INSERT INTO `purchase_order_items` (`id`,`purchase_order_id`,`raw_material_id`,`quantity_ordered`,`quantity_received`,`unit_cost`,`line_total`) VALUES ('5','3','2','100.000','100.000','270.00','27000.00');

-- ----------------------------
-- Table structure for `purchase_orders`
-- ----------------------------
CREATE TABLE `purchase_orders` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `po_number` varchar(30) NOT NULL,
  `supplier_id` int(11) NOT NULL,
  `status` enum('ORDERED','PARTIALLY_RECEIVED','RECEIVED','CANCELLED') DEFAULT 'ORDERED',
  `order_date` date NOT NULL,
  `expected_date` date DEFAULT NULL,
  `subtotal` decimal(12,2) NOT NULL DEFAULT 0.00,
  `paid_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `notes` varchar(255) DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `po_number` (`po_number`),
  KEY `supplier_id` (`supplier_id`),
  KEY `created_by` (`created_by`),
  CONSTRAINT `purchase_orders_ibfk_1` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`),
  CONSTRAINT `purchase_orders_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `purchase_orders`
-- ----------------------------
INSERT INTO `purchase_orders` (`id`,`po_number`,`supplier_id`,`status`,`order_date`,`expected_date`,`subtotal`,`paid_amount`,`notes`,`created_by`,`created_at`) VALUES ('1','PO-20260721-0001','1','RECEIVED','2026-07-21','2026-07-21','155000.00','155000.00',NULL,'1','2026-07-21 17:10:35');
INSERT INTO `purchase_orders` (`id`,`po_number`,`supplier_id`,`status`,`order_date`,`expected_date`,`subtotal`,`paid_amount`,`notes`,`created_by`,`created_at`) VALUES ('2','PO-20260721-0002','2','RECEIVED','2026-07-21','2026-07-21','15100.00','15100.00',NULL,'1','2026-07-21 17:13:28');
INSERT INTO `purchase_orders` (`id`,`po_number`,`supplier_id`,`status`,`order_date`,`expected_date`,`subtotal`,`paid_amount`,`notes`,`created_by`,`created_at`) VALUES ('3','PO-20260721-0003','3','RECEIVED','2026-07-21','2026-07-21','27000.00','27000.00',NULL,'1','2026-07-21 17:15:06');

-- ----------------------------
-- Table structure for `raw_materials`
-- ----------------------------
CREATE TABLE `raw_materials` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `material_name` varchar(150) NOT NULL,
  `unit` varchar(20) NOT NULL,
  `current_stock` decimal(12,3) DEFAULT 0.000,
  `reorder_level` decimal(12,3) DEFAULT 0.000,
  `unit_cost` decimal(10,2) DEFAULT 0.00,
  `expiry_date` date DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `raw_materials`
-- ----------------------------
INSERT INTO `raw_materials` (`id`,`material_name`,`unit`,`current_stock`,`reorder_level`,`unit_cost`,`expiry_date`,`is_active`,`created_at`) VALUES ('1','Chicken Drumstick','kg','87.750','0.000','1550.00',NULL,'1','2026-07-21 17:09:12');
INSERT INTO `raw_materials` (`id`,`material_name`,`unit`,`current_stock`,`reorder_level`,`unit_cost`,`expiry_date`,`is_active`,`created_at`) VALUES ('2','Araliya Kiri Samba','kg','76.500','0.000','270.00',NULL,'1','2026-07-21 17:09:43');
INSERT INTO `raw_materials` (`id`,`material_name`,`unit`,`current_stock`,`reorder_level`,`unit_cost`,`expiry_date`,`is_active`,`created_at`) VALUES ('3','Carrot','kg','43.500','0.000','150.00',NULL,'1','2026-07-21 17:10:00');
INSERT INTO `raw_materials` (`id`,`material_name`,`unit`,`current_stock`,`reorder_level`,`unit_cost`,`expiry_date`,`is_active`,`created_at`) VALUES ('4','Loku Lunu','kg','18.000','0.000','130.00',NULL,'1','2026-07-21 17:12:32');
INSERT INTO `raw_materials` (`id`,`material_name`,`unit`,`current_stock`,`reorder_level`,`unit_cost`,`expiry_date`,`is_active`,`created_at`) VALUES ('5','Leks','kg','46.500','0.000','100.00',NULL,'1','2026-07-21 17:12:44');

-- ----------------------------
-- Table structure for `recipes`
-- ----------------------------
CREATE TABLE `recipes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `menu_item_id` int(11) NOT NULL,
  `raw_material_id` int(11) NOT NULL,
  `quantity_required` decimal(12,3) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `menu_item_id` (`menu_item_id`),
  KEY `raw_material_id` (`raw_material_id`),
  CONSTRAINT `recipes_ibfk_1` FOREIGN KEY (`menu_item_id`) REFERENCES `menu_items` (`id`) ON DELETE CASCADE,
  CONSTRAINT `recipes_ibfk_2` FOREIGN KEY (`raw_material_id`) REFERENCES `raw_materials` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `recipes`
-- ----------------------------
INSERT INTO `recipes` (`id`,`menu_item_id`,`raw_material_id`,`quantity_required`) VALUES ('1','5','2','0.100');
INSERT INTO `recipes` (`id`,`menu_item_id`,`raw_material_id`,`quantity_required`) VALUES ('2','5','3','0.020');
INSERT INTO `recipes` (`id`,`menu_item_id`,`raw_material_id`,`quantity_required`) VALUES ('3','5','1','0.050');
INSERT INTO `recipes` (`id`,`menu_item_id`,`raw_material_id`,`quantity_required`) VALUES ('4','5','5','0.020');
INSERT INTO `recipes` (`id`,`menu_item_id`,`raw_material_id`,`quantity_required`) VALUES ('5','1','2','0.100');
INSERT INTO `recipes` (`id`,`menu_item_id`,`raw_material_id`,`quantity_required`) VALUES ('6','1','3','0.020');
INSERT INTO `recipes` (`id`,`menu_item_id`,`raw_material_id`,`quantity_required`) VALUES ('7','1','5','0.020');
INSERT INTO `recipes` (`id`,`menu_item_id`,`raw_material_id`,`quantity_required`) VALUES ('8','1','1','0.050');

-- ----------------------------
-- Table structure for `role_permissions`
-- ----------------------------
CREATE TABLE `role_permissions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `role_id` int(11) NOT NULL,
  `permission_id` int(11) NOT NULL,
  `can_view` tinyint(1) DEFAULT 0,
  `can_add` tinyint(1) DEFAULT 0,
  `can_edit` tinyint(1) DEFAULT 0,
  `can_delete` tinyint(1) DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_role_perm` (`role_id`,`permission_id`),
  KEY `permission_id` (`permission_id`),
  CONSTRAINT `role_permissions_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE,
  CONSTRAINT `role_permissions_ibfk_2` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `role_permissions`
-- ----------------------------
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('1','1','11','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('2','1','17','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('3','1','16','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('4','1','6','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('5','1','1','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('6','1','5','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('7','1','9','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('8','1','8','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('9','1','3','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('10','1','2','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('11','1','7','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('12','1','10','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('13','1','12','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('14','1','14','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('15','1','15','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('16','1','4','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('17','1','13','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('32','2','11','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('33','2','17','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('34','2','16','1','1','1','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('35','2','6','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('36','2','1','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('37','2','5','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('38','2','9','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('39','2','8','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('40','2','3','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('41','2','2','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('42','2','7','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('43','2','10','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('44','2','12','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('45','2','15','1','1','1','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('46','2','4','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('47','3','6','1','1','1','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('48','3','1','1','1','1','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('49','3','5','1','1','1','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('50','3','2','1','1','1','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('51','3','7','1','1','1','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('54','4','1','1','0','1','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('55','4','2','1','0','1','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('57','5','1','1','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('58','5','5','1','0','1','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('60','1','19','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('61','1','18','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('63','2','19','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('64','2','18','1','1','1','1');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('66','5','11','0','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('67','5','17','0','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('68','5','16','0','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('69','5','6','0','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('72','5','9','0','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('73','5','8','0','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('74','5','3','0','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('75','5','2','0','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('76','5','7','0','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('77','5','10','0','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('78','5','19','0','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('79','5','12','0','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('80','5','14','0','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('81','5','15','0','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('82','5','4','0','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('83','5','18','0','0','0','0');
INSERT INTO `role_permissions` (`id`,`role_id`,`permission_id`,`can_view`,`can_add`,`can_edit`,`can_delete`) VALUES ('84','5','13','0','0','0','0');

-- ----------------------------
-- Table structure for `roles`
-- ----------------------------
CREATE TABLE `roles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `role_name` varchar(50) NOT NULL,
  `description` varchar(255) DEFAULT NULL,
  `is_system` tinyint(1) DEFAULT 0,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `role_name` (`role_name`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `roles`
-- ----------------------------
INSERT INTO `roles` (`id`,`role_name`,`description`,`is_system`,`created_at`) VALUES ('1','OWNER','Full access to everything','1','2026-07-19 15:41:30');
INSERT INTO `roles` (`id`,`role_name`,`description`,`is_system`,`created_at`) VALUES ('2','MANAGER','Manages daily operations, stock, staff','0','2026-07-19 15:41:30');
INSERT INTO `roles` (`id`,`role_name`,`description`,`is_system`,`created_at`) VALUES ('3','CASHIER','Takes orders and payments','0','2026-07-19 15:41:30');
INSERT INTO `roles` (`id`,`role_name`,`description`,`is_system`,`created_at`) VALUES ('4','KITCHEN','Views orders for preparation','0','2026-07-19 15:41:30');
INSERT INTO `roles` (`id`,`role_name`,`description`,`is_system`,`created_at`) VALUES ('5','RIDER','Delivery rider - sees assigned deliveries only','0','2026-07-19 15:41:30');

-- ----------------------------
-- Table structure for `settings`
-- ----------------------------
CREATE TABLE `settings` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `setting_key` varchar(100) NOT NULL,
  `setting_value` text DEFAULT NULL,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `setting_key` (`setting_key`)
) ENGINE=InnoDB AUTO_INCREMENT=1026 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `settings`
-- ----------------------------
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('1','company_name','CurryPot','2026-07-26 12:55:00');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('2','company_address','Office Ground, Anuradhapura','2026-07-19 15:41:30');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('3','company_phone','071 444 555 1','2026-07-21 13:54:16');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('4','currency_symbol','LKR','2026-07-19 15:41:30');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('5','timezone','Asia/Colombo','2026-07-19 15:41:30');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('6','free_delivery_enabled','1','2026-07-19 15:41:30');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('7','default_delivery_radius_km','5','2026-07-19 15:41:30');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('8','logo_path','uploads/settings/logo_cdca94c3b063e352.png','2026-07-28 14:05:54');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('9','order_number_prefix','ORD','2026-07-19 15:41:30');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('18','tagline','Hurry up! Order Now for today\'s Lunch','2026-07-26 13:40:27');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('21','company_email','','2026-07-21 17:16:31');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('25','receipt_footer_note','','2026-07-21 17:16:31');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('26','show_tax_on_receipt','1','2026-07-21 17:16:31');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('27','show_logo_on_receipt','1','2026-07-21 17:16:31');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('28','login_background_path','uploads/settings/login_background_c7920924eaec9386.jpg','2026-07-21 17:24:14');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('130','public_base_url','','2026-07-26 12:55:00');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('131','bank_account_name','CurryPot (PVT) LTD','2026-07-28 13:49:35');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('132','bank_name','Commercal Bank','2026-07-28 13:49:35');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('133','bank_account_number','8430041150','2026-07-28 13:49:35');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('134','payhere_merchant_id','','2026-07-26 12:55:00');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('135','payhere_merchant_secret','','2026-07-26 12:55:00');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('136','payhere_mode','sandbox','2026-07-26 12:55:00');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('173','order_open_time','08:00','2026-07-26 14:30:15');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('174','order_close_time','00:30','2026-07-26 23:13:22');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('177','orders_manually_paused','0','2026-07-26 14:51:36');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('322','customer_app_primary_color','#0d0d0d','2026-07-28 13:34:17');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('323','customer_app_primary_dark','#303030','2026-07-28 13:35:38');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('324','customer_app_accent_color','#ffc90c','2026-07-28 13:35:38');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('325','rider_app_primary_color','#1d7a8c','2026-07-28 13:29:00');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('326','rider_app_primary_dark','#124d58','2026-07-28 13:29:00');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('327','rider_app_accent_color','#c1872e','2026-07-28 13:29:00');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('676','customer_app_button_color','#ffc90c','2026-07-28 13:43:17');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('677','customer_app_icon_color','#0d0d0d','2026-07-28 13:43:17');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('678','customer_app_font_color','#1e2430','2026-07-28 13:43:17');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('896','customer_app_icon_path','uploads/settings/customer_app_icon_4acedc8a93587f4e.png','2026-07-28 14:05:54');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('948','customer_app_title','CurryPot.lk','2026-07-28 14:22:46');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('954','rider_app_title','CurryPot Rider','2026-07-28 14:33:16');
INSERT INTO `settings` (`id`,`setting_key`,`setting_value`,`updated_at`) VALUES ('1025','rider_app_icon_path','uploads/settings/rider_app_icon_95d0963fcf8783e0.png','2026-07-28 14:33:16');

-- ----------------------------
-- Table structure for `stock_transactions`
-- ----------------------------
CREATE TABLE `stock_transactions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `raw_material_id` int(11) NOT NULL,
  `transaction_type` enum('PURCHASE_IN','SALE_DEDUCT','ADJUSTMENT','WASTAGE','KITCHEN_ISSUE') NOT NULL,
  `quantity` decimal(12,3) NOT NULL,
  `reference_type` varchar(50) DEFAULT NULL,
  `reference_id` int(11) DEFAULT NULL,
  `notes` varchar(255) DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `raw_material_id` (`raw_material_id`),
  KEY `created_by` (`created_by`),
  CONSTRAINT `stock_transactions_ibfk_1` FOREIGN KEY (`raw_material_id`) REFERENCES `raw_materials` (`id`),
  CONSTRAINT `stock_transactions_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=89 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `stock_transactions`
-- ----------------------------
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('1','1','PURCHASE_IN','100.000','PURCHASE_ORDER','1','Received against PO-20260721-0001','1','2026-07-21 17:11:36');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('2','3','PURCHASE_IN','50.000','PURCHASE_ORDER','2','Received against PO-20260721-0002','1','2026-07-21 17:13:42');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('3','4','PURCHASE_IN','20.000','PURCHASE_ORDER','2','Received against PO-20260721-0002','1','2026-07-21 17:13:42');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('4','5','PURCHASE_IN','50.000','PURCHASE_ORDER','2','Received against PO-20260721-0002','1','2026-07-21 17:13:42');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('5','2','PURCHASE_IN','100.000','PURCHASE_ORDER','3','Received against PO-20260721-0003','1','2026-07-21 17:15:10');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('6','2','KITCHEN_ISSUE','-20.000','KITCHEN_ISSUE','1','Issued to kitchen — Today menu','1','2026-07-21 17:26:47');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('7','3','KITCHEN_ISSUE','-5.000','KITCHEN_ISSUE','1','Issued to kitchen — Today menu','1','2026-07-21 17:26:47');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('8','1','KITCHEN_ISSUE','-10.000','KITCHEN_ISSUE','1','Issued to kitchen — Today menu','1','2026-07-21 17:26:47');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('9','4','KITCHEN_ISSUE','-2.000','KITCHEN_ISSUE','1','Issued to kitchen — Today menu','1','2026-07-21 17:26:47');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('10','5','KITCHEN_ISSUE','-2.000','KITCHEN_ISSUE','1','Issued to kitchen — Today menu','1','2026-07-21 17:26:47');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('11','2','KITCHEN_ISSUE','-1.000','KITCHEN_ISSUE','2','Issued to kitchen','1','2026-07-21 20:08:39');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('12','3','KITCHEN_ISSUE','-1.000','KITCHEN_ISSUE','2','Issued to kitchen','1','2026-07-21 20:08:39');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('13','5','KITCHEN_ISSUE','-1.000','KITCHEN_ISSUE','2','Issued to kitchen','1','2026-07-21 20:08:39');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('14','2','ADJUSTMENT','1.000','KITCHEN_ISSUE','2','Kitchen issue edited — original deduction reversed','1','2026-07-21 20:15:32');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('15','3','ADJUSTMENT','1.000','KITCHEN_ISSUE','2','Kitchen issue edited — original deduction reversed','1','2026-07-21 20:15:32');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('16','5','ADJUSTMENT','1.000','KITCHEN_ISSUE','2','Kitchen issue edited — original deduction reversed','1','2026-07-21 20:15:32');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('17','2','KITCHEN_ISSUE','-1.000','KITCHEN_ISSUE','2','Issued to kitchen (edited) — Today menu 1','1','2026-07-21 20:15:32');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('18','3','KITCHEN_ISSUE','-1.000','KITCHEN_ISSUE','2','Issued to kitchen (edited) — Today menu 1','1','2026-07-21 20:15:32');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('19','5','KITCHEN_ISSUE','-1.000','KITCHEN_ISSUE','2','Issued to kitchen (edited) — Today menu 1','1','2026-07-21 20:15:32');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('20','1','KITCHEN_ISSUE','-1.000','KITCHEN_ISSUE','2','Issued to kitchen (edited) — Today menu 1','1','2026-07-21 20:15:32');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('21','2','SALE_DEDUCT','-0.100','ORDER','6','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 10:22:03');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('22','3','SALE_DEDUCT','-0.020','ORDER','6','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 10:22:03');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('23','1','SALE_DEDUCT','-0.050','ORDER','6','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 10:22:03');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('24','5','SALE_DEDUCT','-0.020','ORDER','6','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 10:22:03');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('25','2','SALE_DEDUCT','-0.100','ORDER','7','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 11:31:18');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('26','3','SALE_DEDUCT','-0.020','ORDER','7','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 11:31:18');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('27','1','SALE_DEDUCT','-0.050','ORDER','7','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 11:31:18');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('28','5','SALE_DEDUCT','-0.020','ORDER','7','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 11:31:18');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('29','2','SALE_DEDUCT','-0.100','ORDER','7','Sold: Chicken Rice & Curry x1',NULL,'2026-07-26 11:31:18');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('30','3','SALE_DEDUCT','-0.020','ORDER','7','Sold: Chicken Rice & Curry x1',NULL,'2026-07-26 11:31:18');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('31','5','SALE_DEDUCT','-0.020','ORDER','7','Sold: Chicken Rice & Curry x1',NULL,'2026-07-26 11:31:18');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('32','1','SALE_DEDUCT','-0.050','ORDER','7','Sold: Chicken Rice & Curry x1',NULL,'2026-07-26 11:31:18');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('33','2','ADJUSTMENT','0.100','ORDER','7','Order cancelled - stock restored','1','2026-07-26 11:32:47');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('34','3','ADJUSTMENT','0.020','ORDER','7','Order cancelled - stock restored','1','2026-07-26 11:32:47');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('35','1','ADJUSTMENT','0.050','ORDER','7','Order cancelled - stock restored','1','2026-07-26 11:32:47');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('36','5','ADJUSTMENT','0.020','ORDER','7','Order cancelled - stock restored','1','2026-07-26 11:32:47');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('37','2','ADJUSTMENT','0.100','ORDER','7','Order cancelled - stock restored','1','2026-07-26 11:32:47');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('38','3','ADJUSTMENT','0.020','ORDER','7','Order cancelled - stock restored','1','2026-07-26 11:32:47');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('39','5','ADJUSTMENT','0.020','ORDER','7','Order cancelled - stock restored','1','2026-07-26 11:32:47');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('40','1','ADJUSTMENT','0.050','ORDER','7','Order cancelled - stock restored','1','2026-07-26 11:32:47');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('41','2','SALE_DEDUCT','-0.100','ORDER','8','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 11:33:31');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('42','3','SALE_DEDUCT','-0.020','ORDER','8','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 11:33:31');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('43','1','SALE_DEDUCT','-0.050','ORDER','8','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 11:33:31');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('44','5','SALE_DEDUCT','-0.020','ORDER','8','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 11:33:31');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('45','2','SALE_DEDUCT','-0.100','ORDER','9','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 11:55:13');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('46','3','SALE_DEDUCT','-0.020','ORDER','9','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 11:55:13');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('47','1','SALE_DEDUCT','-0.050','ORDER','9','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 11:55:13');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('48','5','SALE_DEDUCT','-0.020','ORDER','9','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 11:55:13');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('49','2','SALE_DEDUCT','-0.300','ORDER','10','Sold: Boiled Egg Rice & Curry x3',NULL,'2026-07-26 12:04:36');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('50','3','SALE_DEDUCT','-0.060','ORDER','10','Sold: Boiled Egg Rice & Curry x3',NULL,'2026-07-26 12:04:36');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('51','1','SALE_DEDUCT','-0.150','ORDER','10','Sold: Boiled Egg Rice & Curry x3',NULL,'2026-07-26 12:04:36');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('52','5','SALE_DEDUCT','-0.060','ORDER','10','Sold: Boiled Egg Rice & Curry x3',NULL,'2026-07-26 12:04:36');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('53','2','SALE_DEDUCT','-0.200','ORDER','11','Sold: Boiled Egg Rice & Curry x2',NULL,'2026-07-26 13:04:21');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('54','3','SALE_DEDUCT','-0.040','ORDER','11','Sold: Boiled Egg Rice & Curry x2',NULL,'2026-07-26 13:04:21');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('55','1','SALE_DEDUCT','-0.100','ORDER','11','Sold: Boiled Egg Rice & Curry x2',NULL,'2026-07-26 13:04:21');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('56','5','SALE_DEDUCT','-0.040','ORDER','11','Sold: Boiled Egg Rice & Curry x2',NULL,'2026-07-26 13:04:21');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('57','2','SALE_DEDUCT','-0.300','ORDER','12','Sold: Boiled Egg Rice & Curry x3',NULL,'2026-07-26 14:30:54');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('58','3','SALE_DEDUCT','-0.060','ORDER','12','Sold: Boiled Egg Rice & Curry x3',NULL,'2026-07-26 14:30:54');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('59','1','SALE_DEDUCT','-0.150','ORDER','12','Sold: Boiled Egg Rice & Curry x3',NULL,'2026-07-26 14:30:54');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('60','5','SALE_DEDUCT','-0.060','ORDER','12','Sold: Boiled Egg Rice & Curry x3',NULL,'2026-07-26 14:30:54');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('61','2','ADJUSTMENT','0.300','ORDER','12','Order cancelled - stock restored','1','2026-07-26 14:31:54');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('62','3','ADJUSTMENT','0.060','ORDER','12','Order cancelled - stock restored','1','2026-07-26 14:31:54');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('63','1','ADJUSTMENT','0.150','ORDER','12','Order cancelled - stock restored','1','2026-07-26 14:31:54');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('64','5','ADJUSTMENT','0.060','ORDER','12','Order cancelled - stock restored','1','2026-07-26 14:31:54');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('65','2','SALE_DEDUCT','-0.100','ORDER','13','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 14:54:11');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('66','3','SALE_DEDUCT','-0.020','ORDER','13','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 14:54:11');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('67','1','SALE_DEDUCT','-0.050','ORDER','13','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 14:54:11');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('68','5','SALE_DEDUCT','-0.020','ORDER','13','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 14:54:11');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('69','2','SALE_DEDUCT','-0.100','ORDER','14','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 17:12:54');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('70','3','SALE_DEDUCT','-0.020','ORDER','14','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 17:12:54');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('71','1','SALE_DEDUCT','-0.050','ORDER','14','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 17:12:54');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('72','5','SALE_DEDUCT','-0.020','ORDER','14','Sold: Boiled Egg Rice & Curry x1',NULL,'2026-07-26 17:12:54');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('73','2','SALE_DEDUCT','-0.300','ORDER','15','Sold: Chicken Rice & Curry x3',NULL,'2026-07-26 23:13:55');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('74','3','SALE_DEDUCT','-0.060','ORDER','15','Sold: Chicken Rice & Curry x3',NULL,'2026-07-26 23:13:55');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('75','5','SALE_DEDUCT','-0.060','ORDER','15','Sold: Chicken Rice & Curry x3',NULL,'2026-07-26 23:13:55');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('76','1','SALE_DEDUCT','-0.150','ORDER','15','Sold: Chicken Rice & Curry x3',NULL,'2026-07-26 23:13:55');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('77','2','SALE_DEDUCT','-0.600','ORDER','16','Sold: Boiled Egg Rice & Curry x6',NULL,'2026-07-26 23:23:40');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('78','3','SALE_DEDUCT','-0.120','ORDER','16','Sold: Boiled Egg Rice & Curry x6',NULL,'2026-07-26 23:23:40');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('79','1','SALE_DEDUCT','-0.300','ORDER','16','Sold: Boiled Egg Rice & Curry x6',NULL,'2026-07-26 23:23:40');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('80','5','SALE_DEDUCT','-0.120','ORDER','16','Sold: Boiled Egg Rice & Curry x6',NULL,'2026-07-26 23:23:40');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('81','2','SALE_DEDUCT','-0.200','ORDER','17','Sold: Boiled Egg Rice & Curry x2',NULL,'2026-07-27 12:28:08');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('82','3','SALE_DEDUCT','-0.040','ORDER','17','Sold: Boiled Egg Rice & Curry x2',NULL,'2026-07-27 12:28:08');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('83','1','SALE_DEDUCT','-0.100','ORDER','17','Sold: Boiled Egg Rice & Curry x2',NULL,'2026-07-27 12:28:08');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('84','5','SALE_DEDUCT','-0.040','ORDER','17','Sold: Boiled Egg Rice & Curry x2',NULL,'2026-07-27 12:28:08');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('85','2','SALE_DEDUCT','-0.400','ORDER','18','Sold: Boiled Egg Rice & Curry x4',NULL,'2026-07-28 13:37:30');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('86','3','SALE_DEDUCT','-0.080','ORDER','18','Sold: Boiled Egg Rice & Curry x4',NULL,'2026-07-28 13:37:30');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('87','1','SALE_DEDUCT','-0.200','ORDER','18','Sold: Boiled Egg Rice & Curry x4',NULL,'2026-07-28 13:37:30');
INSERT INTO `stock_transactions` (`id`,`raw_material_id`,`transaction_type`,`quantity`,`reference_type`,`reference_id`,`notes`,`created_by`,`created_at`) VALUES ('88','5','SALE_DEDUCT','-0.080','ORDER','18','Sold: Boiled Egg Rice & Curry x4',NULL,'2026-07-28 13:37:30');

-- ----------------------------
-- Table structure for `supplier_payments`
-- ----------------------------
CREATE TABLE `supplier_payments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `supplier_id` int(11) NOT NULL,
  `purchase_order_id` int(11) DEFAULT NULL,
  `amount` decimal(12,2) NOT NULL,
  `finance_account_id` int(11) NOT NULL,
  `paid_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `notes` varchar(255) DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `supplier_id` (`supplier_id`),
  KEY `purchase_order_id` (`purchase_order_id`),
  KEY `finance_account_id` (`finance_account_id`),
  KEY `created_by` (`created_by`),
  CONSTRAINT `supplier_payments_ibfk_1` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`),
  CONSTRAINT `supplier_payments_ibfk_2` FOREIGN KEY (`purchase_order_id`) REFERENCES `purchase_orders` (`id`) ON DELETE SET NULL,
  CONSTRAINT `supplier_payments_ibfk_3` FOREIGN KEY (`finance_account_id`) REFERENCES `finance_accounts` (`id`),
  CONSTRAINT `supplier_payments_ibfk_4` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `supplier_payments`
-- ----------------------------
INSERT INTO `supplier_payments` (`id`,`supplier_id`,`purchase_order_id`,`amount`,`finance_account_id`,`paid_at`,`notes`,`created_by`) VALUES ('1','1','1','155000.00','1','2026-07-21 17:10:53',NULL,'1');
INSERT INTO `supplier_payments` (`id`,`supplier_id`,`purchase_order_id`,`amount`,`finance_account_id`,`paid_at`,`notes`,`created_by`) VALUES ('2','2','2','15100.00','2','2026-07-21 17:13:47',NULL,'1');
INSERT INTO `supplier_payments` (`id`,`supplier_id`,`purchase_order_id`,`amount`,`finance_account_id`,`paid_at`,`notes`,`created_by`) VALUES ('3','3','3','27000.00','1','2026-07-21 17:15:11',NULL,'1');

-- ----------------------------
-- Table structure for `suppliers`
-- ----------------------------
CREATE TABLE `suppliers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `supplier_name` varchar(150) NOT NULL,
  `contact_person` varchar(100) DEFAULT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `email` varchar(100) DEFAULT NULL,
  `address` text DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Data for `suppliers`
-- ----------------------------
INSERT INTO `suppliers` (`id`,`supplier_name`,`contact_person`,`phone`,`email`,`address`,`is_active`,`created_at`) VALUES ('1','JF Cheken','Ajith P Perera','0714461702','Ajith@jfcheken.com','Colombo Road, Marawila','1','2026-07-21 17:07:24');
INSERT INTO `suppliers` (`id`,`supplier_name`,`contact_person`,`phone`,`email`,`address`,`is_active`,`created_at`) VALUES ('2','DM Vegitables','DM Presad','0774461706',NULL,'Negombo Road, Thoppuwa','1','2026-07-21 17:08:12');
INSERT INTO `suppliers` (`id`,`supplier_name`,`contact_person`,`phone`,`email`,`address`,`is_active`,`created_at`) VALUES ('3','Arliya Rice Mill','Dadlly Sirisena','0721054006','info@araliyaricemill.com','Polonnaruwa','1','2026-07-21 17:14:37');

