
--
-- Table structure for table `WIP`
--

CREATE TABLE `WIP` (
  `id` int NOT NULL AUTO_INCREMENT,
  `product_id` int NOT NULL,
  `part_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `new_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `uom` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `categorie_id` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `part_number` (`part_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `api_requests_log`
--

CREATE TABLE `api_requests_log` (
  `id` int NOT NULL AUTO_INCREMENT,
  `request_url` text NOT NULL,
  `request_method` varchar(10) NOT NULL,
  `request_headers` text,
  `request_body` text,
  `response_status` int DEFAULT NULL,
  `response_body` longtext,
  `response_time` float DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `order_sn` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `awb`
--

CREATE TABLE `awb` (
  `id` int NOT NULL AUTO_INCREMENT,
  `tanggal_pesenan_dibuat` datetime DEFAULT NULL,
  `invoice` varchar(255) NOT NULL,
  `resi` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `nama_toko` varchar(255) NOT NULL,
  `kurir` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `part_number` varchar(255) NOT NULL,
  `product_name` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `date_scan` date DEFAULT NULL,
  `quantity` int NOT NULL,
  `scan_in` datetime DEFAULT NULL,
  `scan_status` datetime DEFAULT NULL,
  `scan_retur` timestamp NULL DEFAULT NULL,
  `packer_no` int DEFAULT '0',
  `batas_pengiriman` datetime DEFAULT NULL,
  `uniq_code` varchar(255) NOT NULL,
  `unit_price` int NOT NULL,
  `total_price` int NOT NULL,
  `waktu_proses` datetime DEFAULT CURRENT_TIMESTAMP,
  `loc` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `urgent` int DEFAULT '0',
  `download` int DEFAULT '0',
  `is_api` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `resi` (`resi`(15)) USING BTREE,
  KEY `unique_code` (`uniq_code`(20)) USING BTREE,
  KEY `resi_2` (`resi`),
  KEY `idx_awb_invoice` (`invoice`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `awb_april`
--

CREATE TABLE `awb_april` (
  `id` int NOT NULL DEFAULT '0',
  `tanggal_pesenan_dibuat` datetime DEFAULT NULL,
  `invoice` varchar(255) CHARACTER SET latin1 NOT NULL,
  `resi` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `nama_toko` varchar(255) CHARACTER SET latin1 NOT NULL,
  `kurir` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `part_number` varchar(255) CHARACTER SET latin1 NOT NULL,
  `product_name` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `date_scan` date DEFAULT NULL,
  `quantity` int NOT NULL,
  `scan_in` datetime DEFAULT NULL,
  `scan_status` datetime DEFAULT NULL,
  `scan_retur` timestamp NULL DEFAULT NULL,
  `packer_no` int DEFAULT '0',
  `batas_pengiriman` datetime DEFAULT NULL,
  `uniq_code` varchar(255) CHARACTER SET latin1 NOT NULL,
  `unit_price` int NOT NULL,
  `total_price` int NOT NULL,
  `waktu_proses` datetime DEFAULT CURRENT_TIMESTAMP,
  `loc` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `urgent` int DEFAULT '0',
  `download` int DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `awb_data`
--

CREATE TABLE `awb_data` (
  `id` int NOT NULL AUTO_INCREMENT,
  `tanggal_pesenan_dibuat` datetime DEFAULT NULL,
  `invoice` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `resi` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `nama_toko` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `kurir` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `part_number` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `product_name` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `date_scan` date DEFAULT NULL,
  `quantity` int NOT NULL,
  `scan_in` datetime DEFAULT NULL,
  `scan_status` datetime DEFAULT NULL,
  `scan_retur` timestamp NULL DEFAULT NULL,
  `packer_no` int DEFAULT '0',
  `batas_pengiriman` datetime DEFAULT NULL,
  `uniq_code` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `unit_price` int NOT NULL,
  `total_price` int NOT NULL,
  `waktu_proses` datetime DEFAULT CURRENT_TIMESTAMP,
  `loc` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_resi` (`resi`),
  KEY `idx_invoice` (`invoice`),
  KEY `idx_part_number` (`part_number`),
  KEY `idx_date_scan` (`date_scan`),
  KEY `idx_scan_in` (`scan_in`),
  KEY `idx_loc` (`loc`),
  KEY `idx_loc_date` (`loc`,`date_scan`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `awb_data_cache`
--

CREATE TABLE `awb_data_cache` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(50) NOT NULL,
  `description` varchar(255) NOT NULL,
  `color` varchar(50) DEFAULT NULL,
  `unit_price` decimal(10,2) DEFAULT NULL,
  `unit_measurements` varchar(20) DEFAULT NULL,
  `last_updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `part_number` (`part_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `awb_urgent`
--

CREATE TABLE `awb_urgent` (
  `id` int NOT NULL AUTO_INCREMENT,
  `tanggal_pesenan_dibuat` datetime DEFAULT NULL,
  `invoice` varchar(255) NOT NULL,
  `resi` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `nama_toko` varchar(255) NOT NULL,
  `kurir` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `part_number` varchar(255) NOT NULL,
  `product_name` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `date_scan` date DEFAULT NULL,
  `quantity` int NOT NULL,
  `scan_in` datetime DEFAULT NULL,
  `scan_status` datetime DEFAULT NULL,
  `scan_retur` timestamp NULL DEFAULT NULL,
  `packer_no` int DEFAULT '0',
  `batas_pengiriman` datetime DEFAULT NULL,
  `uniq_code` varchar(255) NOT NULL,
  `unit_price` int NOT NULL,
  `total_price` int NOT NULL,
  `waktu_proses` datetime DEFAULT CURRENT_TIMESTAMP,
  `loc` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `urgent` int DEFAULT '0',
  `download` int DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `resi` (`resi`(15)) USING BTREE,
  KEY `unique_code` (`uniq_code`(20)) USING BTREE,
  KEY `resi_2` (`resi`),
  KEY `idx_awb_invoice` (`invoice`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `bathroom_usage`
--

CREATE TABLE `bathroom_usage` (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` int DEFAULT NULL,
  `bathroom_id` int NOT NULL,
  `check_in_time` timestamp NOT NULL,
  `check_out_time` timestamp NULL DEFAULT NULL,
  `status` enum('check_in','check_out') NOT NULL DEFAULT 'check_in',
  `bathroom_name` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `bazzar`
--

CREATE TABLE `bazzar` (
  `id` int NOT NULL AUTO_INCREMENT,
  `bazzar_sn` varchar(100) NOT NULL,
  `bazzar_sj` varchar(100) NOT NULL,
  `sales_man` varchar(100) NOT NULL,
  `customer_name` varchar(255) NOT NULL,
  `address` text NOT NULL,
  `phone` varchar(20) NOT NULL,
  `kurir` varchar(100) NOT NULL,
  `batas_kirim` date NOT NULL,
  `warehouse_id` int NOT NULL,
  `keterangan` text NOT NULL,
  `status` enum('Pending','Shipped','Completed','Cancelled','Returned') DEFAULT 'Pending',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `bazzar_detail`
--

CREATE TABLE `bazzar_detail` (
  `id` int NOT NULL AUTO_INCREMENT,
  `bazzar_id` int NOT NULL,
  `product_name` varchar(255) NOT NULL,
  `quantity` int NOT NULL,
  `price` decimal(10,2) NOT NULL,
  `subtotal` decimal(10,2) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `bazzar_id` (`bazzar_id`),
  CONSTRAINT `bazzar_detail_ibfk_1` FOREIGN KEY (`bazzar_id`) REFERENCES `bazzar` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `bazzar_return`
--

CREATE TABLE `bazzar_return` (
  `id` int NOT NULL AUTO_INCREMENT,
  `bazzar_id` int NOT NULL,
  `product_name` varchar(255) NOT NULL,
  `quantity` int NOT NULL,
  `reason` varchar(255) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `bazzar_id` (`bazzar_id`),
  CONSTRAINT `bazzar_return_ibfk_1` FOREIGN KEY (`bazzar_id`) REFERENCES `bazzar` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `bom_level`
--

CREATE TABLE `bom_level` (
  `id` int NOT NULL AUTO_INCREMENT,
  `parent_bom` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `child_bom` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `phantom_bom` varchar(1) COLLATE utf8mb4_general_ci NOT NULL,
  `level` int NOT NULL,
  `qty` decimal(10,4) DEFAULT NULL,
  `location` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `buy_price` decimal(10,2) DEFAULT NULL,
  `last_update` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_child_bom` (`child_bom`),
  KEY `idx_parent_bom` (`parent_bom`(50)) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `bom_level_rnd`
--

CREATE TABLE `bom_level_rnd` (
  `id` int NOT NULL AUTO_INCREMENT,
  `parent_bom` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `child_bom` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `phantom_bom` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `level` int NOT NULL,
  `qty` decimal(10,4) DEFAULT NULL,
  `location` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0',
  `buy_price` decimal(10,2) DEFAULT NULL,
  `last_update` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `branch_office`
--

CREATE TABLE `branch_office` (
  `id` int NOT NULL AUTO_INCREMENT,
  `branch_office` varchar(100) DEFAULT NULL,
  `kode` varchar(50) DEFAULT NULL,
  `type` varchar(50) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `contact_person` varchar(20) DEFAULT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `fax` varchar(20) DEFAULT NULL,
  `address` varchar(150) DEFAULT NULL,
  `description` text,
  `status` enum('Active','Not Active') DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `brands`
--

CREATE TABLE `brands` (
  `id` int NOT NULL AUTO_INCREMENT,
  `brand_name` varchar(255) NOT NULL,
  `logo_path` varchar(255) NOT NULL,
  `address` text NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `categories`
--

CREATE TABLE `categories` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(60) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Table structure for table `checklist`
--

CREATE TABLE `checklist` (
  `id` int NOT NULL AUTO_INCREMENT,
  `item` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `is_completed` tinyint(1) DEFAULT '0',
  `warehouse_location` varchar(100) NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `completion`
--

CREATE TABLE `completion` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(50) NOT NULL,
  `name` varchar(255) NOT NULL,
  `barcode` varchar(100) NOT NULL,
  `scanned_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `couriers`
--

CREATE TABLE `couriers` (
  `id` int NOT NULL AUTO_INCREMENT,
  `type` varchar(50) NOT NULL,
  `name` varchar(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `crm_contact`
--

CREATE TABLE `crm_contact` (
  `id` int NOT NULL AUTO_INCREMENT,
  `crm_group_contact_id` int DEFAULT NULL,
  `name` varchar(100) NOT NULL,
  `phone_number` varchar(15) NOT NULL,
  `email` varchar(100) DEFAULT NULL,
  `is_template` tinyint(1) DEFAULT '1',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `phone_number` (`phone_number`),
  KEY `crm_group_contact_id` (`crm_group_contact_id`),
  CONSTRAINT `crm_contact_ibfk_1` FOREIGN KEY (`crm_group_contact_id`) REFERENCES `crm_group_contact` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `crm_group_contact`
--

CREATE TABLE `crm_group_contact` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `crm_message`
--

CREATE TABLE `crm_message` (
  `id` int NOT NULL AUTO_INCREMENT,
  `facebook_msg_id` varchar(255) DEFAULT NULL,
  `sender_id` int NOT NULL,
  `receiver_id` int NOT NULL,
  `message_text` text NOT NULL,
  `sent_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `media_path` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `sender_id` (`sender_id`),
  KEY `receiver_id` (`receiver_id`),
  CONSTRAINT `crm_message_ibfk_1` FOREIGN KEY (`sender_id`) REFERENCES `crm_contact` (`id`),
  CONSTRAINT `crm_message_ibfk_2` FOREIGN KEY (`receiver_id`) REFERENCES `crm_contact` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `crm_template_message`
--

CREATE TABLE `crm_template_message` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `message` text NOT NULL,
  `tipe` enum('Internal','Marketing') NOT NULL,
  `status` enum('Disetujui','Menunggu Persetujuan') NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `delivery_material`
--

CREATE TABLE `delivery_material` (
  `id` int NOT NULL AUTO_INCREMENT,
  `request_number` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `product_id` int NOT NULL,
  `part_number` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `delivery_quantity` int NOT NULL,
  `delivery_date` date NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `email_list`
--

CREATE TABLE `email_list` (
  `id` int NOT NULL AUTO_INCREMENT,
  `email` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `employees`
--

CREATE TABLE `employees` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `position` varchar(50) DEFAULT NULL,
  `division` varchar(255) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `status` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `endorse`
--

CREATE TABLE `endorse` (
  `id` int NOT NULL AUTO_INCREMENT,
  `endorse_sn` varchar(100) NOT NULL,
  `endorse_sj` varchar(100) NOT NULL,
  `sales_man` varchar(100) NOT NULL,
  `customer_name` varchar(255) NOT NULL,
  `address` text,
  `phone` varchar(20) DEFAULT NULL,
  `kurir` varchar(100) DEFAULT NULL,
  `keterangan` text,
  `brand` enum('Wiselie','Bacuya') NOT NULL,
  `status` enum('Pending','Approved','Shipped','Completed') NOT NULL DEFAULT 'Pending',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `endorse_detail`
--

CREATE TABLE `endorse_detail` (
  `id` int NOT NULL AUTO_INCREMENT,
  `endorse_id` int NOT NULL,
  `part_number` varchar(100) NOT NULL,
  `quantity` int NOT NULL,
  `price` decimal(10,2) DEFAULT NULL,
  `subtotal` decimal(10,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `endorse_id` (`endorse_id`),
  CONSTRAINT `endorse_detail_ibfk_1` FOREIGN KEY (`endorse_id`) REFERENCES `endorse` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `files`
--

CREATE TABLE `files` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `generate_barcode`
--

CREATE TABLE `generate_barcode` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(50) NOT NULL,
  `name` varchar(255) NOT NULL,
  `barcode` varchar(100) NOT NULL,
  `quantity` int DEFAULT NULL,
  `uom` varchar(10) DEFAULT 'PCS',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `group_part_number`
--

CREATE TABLE `group_part_number` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) NOT NULL,
  `part_number_child` varchar(255) NOT NULL,
  `part_number_new` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_group_part_number` (`part_number`,`part_number_child`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `history_oos`
--

CREATE TABLE `history_oos` (
  `id` int NOT NULL AUTO_INCREMENT,
  `zipcode` varchar(10) NOT NULL,
  `order_sn` varchar(50) NOT NULL,
  `sku` varchar(50) NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `incoming_accurate`
--

CREATE TABLE `incoming_accurate` (
  `id` int NOT NULL AUTO_INCREMENT,
  `kode` varchar(50) NOT NULL,
  `nama` varchar(100) NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `uom` varchar(20) NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `incoming_goods`
--

CREATE TABLE `incoming_goods` (
  `id` int NOT NULL AUTO_INCREMENT,
  `product_id` varchar(100) NOT NULL,
  `part_number` varchar(255) NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `arrival_date` date NOT NULL,
  `categorie_id` int NOT NULL,
  `remark` text,
  `loc` varchar(25) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `incoming_wh_jakarta`
--

CREATE TABLE `incoming_wh_jakarta` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) NOT NULL,
  `quantity` int NOT NULL,
  `arrival_date` date NOT NULL,
  `remark` text,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `indirect_code`
--

CREATE TABLE `indirect_code` (
  `id` int NOT NULL AUTO_INCREMENT,
  `code` varchar(50) NOT NULL,
  `name` varchar(255) NOT NULL,
  `photo` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `input_makassar_record`
--

CREATE TABLE `input_makassar_record` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) NOT NULL,
  `quantity` int NOT NULL,
  `input_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `internal_resi`
--

CREATE TABLE `internal_resi` (
  `id` int NOT NULL AUTO_INCREMENT,
  `awb` varchar(20) NOT NULL,
  `sender` varchar(255) NOT NULL,
  `receiver` varchar(255) NOT NULL,
  `nama_barang` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `komplain_awb`
--

CREATE TABLE `komplain_awb` (
  `id` int NOT NULL AUTO_INCREMENT,
  `invoice` varchar(255) NOT NULL,
  `resi` varchar(255) NOT NULL,
  `packer_no` varchar(255) DEFAULT NULL,
  `deskripsi_komplain` text NOT NULL,
  `tanggal_komplain` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `nama_toko` varchar(255) NOT NULL,
  `loc` varchar(255) NOT NULL,
  `part_number` varchar(255) NOT NULL,
  `scan_status` varchar(50) DEFAULT NULL,
  `scan_in` datetime DEFAULT NULL,
  `scan_retur` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `kurir`
--

CREATE TABLE `kurir` (
  `id` int NOT NULL AUTO_INCREMENT,
  `kode_kurir` varchar(50) NOT NULL,
  `kurir` varchar(255) NOT NULL,
  `platform` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `line_process`
--

CREATE TABLE `line_process` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(50) NOT NULL,
  `process_no` int NOT NULL,
  `name_process` varchar(255) NOT NULL,
  `man_power` int NOT NULL,
  `std_time` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `list_consume_production`
--

CREATE TABLE `list_consume_production` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `consume_date` date NOT NULL,
  `remark` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `list_transfer_prod_loc`
--

CREATE TABLE `list_transfer_prod_loc` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `transfer_date` date NOT NULL,
  `remark` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `log_webhook`
--

CREATE TABLE `log_webhook` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `shop_id` int NOT NULL,
  `platform_id` int NOT NULL,
  `order_sn` varchar(100) DEFAULT NULL,
  `request_raw` text NOT NULL,
  `request_data` text,
  `response_data` text,
  `type_service` varchar(100) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `status_service` varchar(3) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `idx_log_webhook_shop_id` (`shop_id`),
  KEY `idx_log_webhook_platform_id` (`platform_id`),
  CONSTRAINT `fk_platform` FOREIGN KEY (`platform_id`) REFERENCES `platform` (`id`) ON DELETE RESTRICT,
  CONSTRAINT `fk_shop` FOREIGN KEY (`shop_id`) REFERENCES `shop` (`id`) ON DELETE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `log_webhook_temp`
--

CREATE TABLE `log_webhook_temp` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `shop_id` int NOT NULL,
  `platform_id` int NOT NULL,
  `order_sn` varchar(100) DEFAULT NULL,
  `request_raw` text NOT NULL,
  `request_data` text,
  `response_data` text,
  `type_service` varchar(100) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `status_service` varchar(3) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `idx_log_webhook_shop_id` (`shop_id`),
  KEY `idx_log_webhook_platform_id` (`platform_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `material_consumption_records`
--

CREATE TABLE `material_consumption_records` (
  `id` int NOT NULL AUTO_INCREMENT,
  `production_id` int NOT NULL COMMENT 'ID from production_output',
  `product_part` varchar(50) NOT NULL COMMENT 'Part number being produced',
  `component_part` varchar(50) NOT NULL COMMENT 'Component part number consumed',
  `component_name` varchar(255) NOT NULL,
  `uom` varchar(20) DEFAULT NULL COMMENT 'Unit of measure',
  `quantity_used` decimal(12,4) NOT NULL COMMENT 'Actual quantity consumed',
  `consumption_date` date NOT NULL COMMENT 'Date when material was consumed',
  `recorded_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `recorded_by` int NOT NULL COMMENT 'User who recorded this',
  PRIMARY KEY (`id`),
  KEY `production_id` (`production_id`),
  KEY `product_part` (`product_part`),
  KEY `component_part` (`component_part`),
  KEY `consumption_date` (`consumption_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Records of actual material consumption from production';

--
-- Table structure for table `material_forecasts`
--

CREATE TABLE `material_forecasts` (
  `id` int NOT NULL AUTO_INCREMENT,
  `forecast_month` int NOT NULL,
  `forecast_year` int NOT NULL,
  `part_number` varchar(50) NOT NULL,
  `quantity_ordered` decimal(10,2) NOT NULL,
  `component` varchar(50) NOT NULL,
  `new_code` varchar(50) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `uom` varchar(20) DEFAULT NULL,
  `quantity_needed` decimal(10,2) NOT NULL,
  `picking_no` varchar(50) DEFAULT NULL,
  `no_order` varchar(50) NOT NULL,
  `schedule_date` date DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `printed` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `forecast_period` (`forecast_month`,`forecast_year`),
  KEY `component` (`component`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Table structure for table `media`
--

CREATE TABLE `media` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `file_name` varchar(255) NOT NULL,
  `file_type` varchar(100) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `menu_items`
--

CREATE TABLE `menu_items` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `url` varchar(255) DEFAULT NULL,
  `icon` varchar(255) DEFAULT NULL,
  `visible` tinyint(1) DEFAULT '1',
  `parent_id` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `mrp`
--

CREATE TABLE `mrp` (
  `id` int NOT NULL AUTO_INCREMENT,
  `no_order` varchar(55) COLLATE utf8mb4_general_ci NOT NULL,
  `part_number` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `calculation_date` date DEFAULT NULL,
  `total_requirement` decimal(10,2) DEFAULT NULL,
  `uom` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `total_requirement_kg` decimal(10,1) DEFAULT NULL,
  UNIQUE KEY `part_number` (`part_number`),
  UNIQUE KEY `no_order` (`part_number`) USING BTREE,
  KEY `id` (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `mrp_baru`
--

CREATE TABLE `mrp_baru` (
  `no_order` varchar(55) COLLATE utf8mb4_general_ci NOT NULL,
  `parent_bom` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
  `part_number` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `phantom_bom` tinyint(1) NOT NULL,
  `level` int NOT NULL,
  `total_requirement` decimal(10,2) DEFAULT NULL,
  `quantity_order` int NOT NULL,
  `calculate` decimal(20,2) DEFAULT NULL,
  `calculation_date` date DEFAULT NULL,
  KEY `parentbom` (`parent_bom`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `mrp_so`
--

CREATE TABLE `mrp_so` (
  `id` int NOT NULL AUTO_INCREMENT,
  `parent_bom` varchar(255) DEFAULT NULL,
  `part_number` varchar(255) DEFAULT NULL,
  `phantom_bom` int DEFAULT NULL,
  `level` int DEFAULT NULL,
  `total_requirement` decimal(10,2) DEFAULT NULL,
  `quantity_order` decimal(10,2) DEFAULT NULL,
  `calculate` decimal(10,2) DEFAULT NULL,
  `no_order` varchar(255) DEFAULT NULL,
  `calculation_date` date DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `online_products`
--

CREATE TABLE `online_products` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `quantity` varchar(50) DEFAULT NULL,
  `UoM` text NOT NULL,
  `buy_price` decimal(25,2) DEFAULT NULL,
  `categorie_id` int unsigned NOT NULL,
  `media_id` int DEFAULT '0',
  `date` date DEFAULT NULL,
  `part_number` varchar(255) NOT NULL,
  `lead_time` int NOT NULL,
  `loc_id` varchar(25) NOT NULL,
  `quantity_boked` int DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `online_products_bali`
--

CREATE TABLE `online_products_bali` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `quantity` decimal(10,2) DEFAULT NULL,
  `UoM` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `buy_price` decimal(25,2) DEFAULT NULL,
  `categorie_id` int unsigned DEFAULT NULL,
  `media_id` int DEFAULT '0',
  `date` date DEFAULT NULL,
  `part_number` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `new_code` varchar(11) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0',
  `lead_time` int DEFAULT '0',
  `loc_id` varchar(25) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0',
  `quantity_boked` int DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `name` (`name`),
  KEY `categorie_id` (`categorie_id`),
  KEY `part_number` (`part_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `online_products_bandung`
--

CREATE TABLE `online_products_bandung` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `quantity` decimal(10,2) DEFAULT NULL,
  `UoM` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `buy_price` decimal(25,2) DEFAULT NULL,
  `categorie_id` int unsigned DEFAULT NULL,
  `media_id` int DEFAULT '0',
  `date` date DEFAULT NULL,
  `part_number` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `new_code` varchar(11) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT '0',
  `lead_time` int DEFAULT '0',
  `loc_id` varchar(25) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0',
  `quantity_boked` int DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `name` (`name`),
  KEY `categorie_id` (`categorie_id`),
  KEY `part_number` (`part_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `online_products_jakarta`
--

CREATE TABLE `online_products_jakarta` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `quantity` decimal(10,2) DEFAULT NULL,
  `UoM` varchar(50) DEFAULT NULL,
  `buy_price` decimal(25,2) DEFAULT NULL,
  `categorie_id` int unsigned DEFAULT NULL,
  `media_id` int DEFAULT '0',
  `date` date DEFAULT NULL,
  `part_number` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `new_code` varchar(11) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0',
  `lead_time` int NOT NULL DEFAULT '0',
  `loc_id` varchar(25) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0',
  `quantity_boked` int DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `name` (`name`),
  KEY `categorie_id` (`categorie_id`),
  KEY `part_number` (`part_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `online_products_makassar`
--

CREATE TABLE `online_products_makassar` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `quantity` decimal(10,2) DEFAULT NULL,
  `UoM` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `buy_price` decimal(25,2) DEFAULT NULL,
  `categorie_id` int unsigned DEFAULT NULL,
  `media_id` int DEFAULT '0',
  `date` date DEFAULT NULL,
  `part_number` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `new_code` varchar(11) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0',
  `lead_time` int DEFAULT '0',
  `loc_id` varchar(25) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0',
  `quantity_boked` int DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `name` (`name`),
  KEY `categorie_id` (`categorie_id`),
  KEY `part_number` (`part_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `online_products_semarang`
--

CREATE TABLE `online_products_semarang` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `quantity` decimal(10,2) DEFAULT NULL,
  `UoM` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `buy_price` decimal(25,2) DEFAULT NULL,
  `categorie_id` int unsigned DEFAULT NULL,
  `media_id` int DEFAULT '0',
  `date` date DEFAULT NULL,
  `part_number` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `new_code` varchar(11) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT '0',
  `lead_time` int DEFAULT '0',
  `loc_id` varchar(25) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0',
  `quantity_boked` int DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `name` (`name`),
  KEY `categorie_id` (`categorie_id`),
  KEY `part_number` (`part_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `order_detail`
--

CREATE TABLE `order_detail` (
  `id` int NOT NULL AUTO_INCREMENT,
  `order_id` int NOT NULL,
  `order_sn` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `order_item_id` bigint DEFAULT NULL,
  `item_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `model_id` bigint DEFAULT NULL,
  `model_quantity_purchased` bigint DEFAULT NULL,
  `model_discounted_price` decimal(10,2) DEFAULT NULL,
  `model_original_price` decimal(10,2) DEFAULT NULL,
  `image_url` text COLLATE utf8mb4_unicode_ci,
  `model_sku` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `item_sku` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `weight` decimal(10,2) DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `order_id` (`order_id`),
  CONSTRAINT `order_detail_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `order_import`
--

CREATE TABLE `order_import` (
  `order_id` varchar(200) DEFAULT NULL,
  `order_status` varchar(200) DEFAULT NULL,
  `order_substatus` varchar(200) DEFAULT NULL,
  `cancelation_return_type` varchar(200) DEFAULT NULL,
  `normal_or_pre_order` varchar(200) DEFAULT NULL,
  `sku_id` varchar(200) DEFAULT NULL,
  `seller_sku` varchar(200) DEFAULT NULL,
  `product_name` varchar(255) DEFAULT NULL,
  `variation` varchar(200) DEFAULT NULL,
  `quantity` varchar(200) DEFAULT NULL,
  `sku_quantity_of_return` varchar(200) DEFAULT NULL,
  `sku_unit_original_price` varchar(200) DEFAULT NULL,
  `sku_subtotal_before_discount` varchar(200) DEFAULT NULL,
  `sku_platform_discount` varchar(200) DEFAULT NULL,
  `sku_seller_discount` varchar(200) DEFAULT NULL,
  `sku_subtotal_after_discount` varchar(200) DEFAULT NULL,
  `shipping_fee_after_discount` varchar(200) DEFAULT NULL,
  `original_shipping_fee` varchar(200) DEFAULT NULL,
  `shipping_fee_seller_discount` varchar(200) DEFAULT NULL,
  `shipping_fee_platform_discount` varchar(200) DEFAULT NULL,
  `payment_platform_discount` varchar(200) DEFAULT NULL,
  `buyer_service_fee` varchar(200) DEFAULT NULL,
  `handling_fee` varchar(200) DEFAULT NULL,
  `shipping_insurance` varchar(200) DEFAULT NULL,
  `item_insurance` varchar(200) DEFAULT NULL,
  `order_amount` varchar(200) DEFAULT NULL,
  `order_refund_amount` varchar(200) DEFAULT NULL,
  `created_time` varchar(200) DEFAULT NULL,
  `paid_time` varchar(200) DEFAULT NULL,
  `rts_time` varchar(200) DEFAULT NULL,
  `shipped_time` varchar(200) DEFAULT NULL,
  `delivered_time` varchar(200) DEFAULT NULL,
  `cancelled_time` varchar(200) DEFAULT NULL,
  `cancel_by` varchar(200) DEFAULT NULL,
  `cancel_reason` varchar(255) DEFAULT NULL,
  `fulfillment_type` varchar(200) DEFAULT NULL,
  `warehouse_name` varchar(100) DEFAULT NULL,
  `tracking_id` varchar(200) DEFAULT NULL,
  `delivery_option` varchar(200) DEFAULT NULL,
  `shipping_provider_name` varchar(100) DEFAULT NULL,
  `buyer_message` text,
  `buyer_username` varchar(200) DEFAULT NULL,
  `recipient` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `phone_number` varchar(200) DEFAULT NULL,
  `zipcode` varchar(200) DEFAULT NULL,
  `country` varchar(200) DEFAULT NULL,
  `province` varchar(200) DEFAULT NULL,
  `regency_and_city` varchar(200) DEFAULT NULL,
  `districts` varchar(200) DEFAULT NULL,
  `villages` varchar(200) DEFAULT NULL,
  `detail_address` text,
  `additional_address_information` text,
  `payment_method` varchar(200) DEFAULT NULL,
  `weight_kg` varchar(200) DEFAULT NULL,
  `product_category` varchar(200) DEFAULT NULL,
  `package_id` varchar(200) DEFAULT NULL,
  `purchase_channel` varchar(200) DEFAULT NULL,
  `seller_note` text,
  `checked_status` varchar(200) DEFAULT NULL,
  `checked_marked_by` varchar(200) DEFAULT NULL,
  `tokopedia_invoice_number` varchar(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `order_numbers`
--

CREATE TABLE `order_numbers` (
  `id` int NOT NULL AUTO_INCREMENT,
  `order_number` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

CREATE TABLE `orders` (
  `id` int NOT NULL AUTO_INCREMENT,
  `order_sn` varchar(50) NOT NULL,
  `shop_id` varchar(100) DEFAULT NULL,
  `buyer_user_id` bigint DEFAULT NULL,
  `id_packing_list` bigint DEFAULT NULL,
  `buyer_username` varchar(100) DEFAULT NULL,
  `order_status` varchar(50) NOT NULL,
  `payment_method` varchar(50) DEFAULT NULL,
  `total_amount` decimal(10,2) DEFAULT NULL,
  `currency` varchar(10) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `pay_time` datetime DEFAULT NULL,
  `ship_by_date` datetime DEFAULT NULL,
  `zipcode` varchar(10) DEFAULT NULL,
  `awb_url` varchar(255) DEFAULT NULL,
  `loc` varchar(255) DEFAULT NULL,
  `product_location_id` varchar(255) DEFAULT NULL,
  `shipping_carrier` varchar(255) DEFAULT NULL,
  `address_id` bigint DEFAULT NULL,
  `last_call` datetime DEFAULT NULL,
  `recipient_name` varchar(255) DEFAULT NULL,
  `phone_number` varchar(20) DEFAULT NULL,
  `delivery_address` text,
  `city` varchar(100) DEFAULT NULL,
  `province` varchar(100) DEFAULT NULL,
  `status` enum('new','progress','cancel','retur','done') DEFAULT 'new',
  PRIMARY KEY (`id`),
  UNIQUE KEY `order_sn` (`order_sn`),
  KEY `idx_orders_shop_id` (`shop_id`),
  KEY `idx_orders_order_sn` (`order_sn`),
  KEY `idx_orders_zipcode` (`zipcode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `orders_fake_queue`
--

CREATE TABLE `orders_fake_queue` (
  `id` int NOT NULL AUTO_INCREMENT,
  `order_sn` varchar(255) NOT NULL,
  `processed` int DEFAULT '0',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_order_sn` (`order_sn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `orders_history`
--

CREATE TABLE `orders_history` (
  `id` int NOT NULL AUTO_INCREMENT,
  `order_sn` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `old_zipcode` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `new_zipcode` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `old_sku` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `new_sku` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `changed_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `approve_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `keterangan` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `orders_offline`
--

CREATE TABLE `orders_offline` (
  `id` int NOT NULL AUTO_INCREMENT,
  `order_sn` varchar(100) NOT NULL,
  `sales_man` varchar(100) NOT NULL,
  `customer_name` varchar(100) NOT NULL,
  `address` text NOT NULL,
  `phone` varchar(20) NOT NULL,
  `kurir` varchar(100) NOT NULL,
  `batas_kirim` date NOT NULL,
  `approve_by` varchar(100) DEFAULT NULL,
  `ongkos_kirim` decimal(10,2) DEFAULT '0.00',
  `status_pembayaran` enum('Pending','Lunas','DP') DEFAULT 'Pending',
  `type_pembayaran` varchar(100) DEFAULT NULL,
  `warehouse_id` int NOT NULL,
  `is_stok_checked` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `edited_at` datetime DEFAULT NULL,
  `kode_js` varchar(250) DEFAULT NULL,
  `scan_in` datetime DEFAULT NULL,
  `scan_out` datetime DEFAULT NULL,
  `is_ppn` int DEFAULT '1',
  `deleted_at` datetime DEFAULT NULL,
  `updated_by` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `orders_offline_detail`
--

CREATE TABLE `orders_offline_detail` (
  `id` int NOT NULL AUTO_INCREMENT,
  `order_id` int NOT NULL,
  `product_name` varchar(255) NOT NULL,
  `type_box` varchar(100) NOT NULL,
  `box` int NOT NULL DEFAULT '1',
  `quantity` int NOT NULL DEFAULT '1',
  `price` decimal(10,2) NOT NULL,
  `subtotal` decimal(10,2) NOT NULL,
  `code_batch_product` varchar(250) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `order_id` (`order_id`),
  CONSTRAINT `orders_offline_detail_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders_offline` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `orders_packing_queue`
--

CREATE TABLE `orders_packing_queue` (
  `id` int NOT NULL AUTO_INCREMENT,
  `order_sn` varchar(50) NOT NULL,
  `zipcode` varchar(255) NOT NULL,
  `awb_url` varchar(255) NOT NULL,
  `resi` varchar(255) NOT NULL,
  `processed` tinyint(1) DEFAULT '0',
  `stok_failed` tinyint(1) DEFAULT '0',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `platform_id` int DEFAULT NULL,
  `approve_required` tinyint(1) DEFAULT '0',
  `is_changes_sku` tinyint(1) DEFAULT '0',
  `is_download_failed` tinyint(1) DEFAULT '0',
  `is_fake` int DEFAULT NULL,
  `is_oos` int DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `is_ndd` int DEFAULT NULL,
  `is_oos_sku` int DEFAULT NULL,
  `last_call` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_order_sn` (`order_sn`),
  KEY `idx_orders_packing_queue_order_sn` (`order_sn`),
  KEY `idx_opq_zipcode_created` (`zipcode`,`created_at`),
  KEY `idx_opq_resi` (`resi`),
  FULLTEXT KEY `idx_opq_resi_ft` (`resi`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `output_schedule`
--

CREATE TABLE `output_schedule` (
  `id` int NOT NULL AUTO_INCREMENT,
  `schedule_id` int NOT NULL,
  `part_number` varchar(255) DEFAULT NULL,
  `output_quantity` int NOT NULL,
  `output_date` date NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `schedule_id` (`schedule_id`),
  CONSTRAINT `output_schedule_ibfk_1` FOREIGN KEY (`schedule_id`) REFERENCES `production_schedule` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `overtime_attendance`
--

CREATE TABLE `overtime_attendance` (
  `id` int NOT NULL AUTO_INCREMENT,
  `employee_id` int NOT NULL,
  `overtime_date` date NOT NULL,
  `hours_worked` decimal(5,2) NOT NULL,
  `reason` varchar(255) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `start_time` time NOT NULL,
  `end_time` time NOT NULL,
  PRIMARY KEY (`id`),
  KEY `employee_id` (`employee_id`),
  CONSTRAINT `overtime_attendance_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `packing_list`
--

CREATE TABLE `packing_list` (
  `id` int NOT NULL AUTO_INCREMENT,
  `code` varchar(255) NOT NULL,
  `zipcode` varchar(255) NOT NULL,
  `file_url` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `created_by` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `paket_bundling`
--

CREATE TABLE `paket_bundling` (
  `id` int NOT NULL AUTO_INCREMENT,
  `bundling_code` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `part_number` varchar(255) NOT NULL,
  `quantity` int NOT NULL,
  `date_active` date NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `pelanggan`
--

CREATE TABLE `pelanggan` (
  `id` int NOT NULL AUTO_INCREMENT,
  `nama_toko` varchar(255) NOT NULL,
  `pic` varchar(255) NOT NULL,
  `alamat` text NOT NULL,
  `nomor_telp` varchar(25) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `peminjaman`
--

CREATE TABLE `peminjaman` (
  `id` int NOT NULL AUTO_INCREMENT,
  `nama_peminjam` varchar(100) DEFAULT NULL,
  `tanggal_pinjam` date DEFAULT NULL,
  `status` enum('Pending','Di Terima','Completed','Cancelled') DEFAULT 'Pending',
  `keterangan` text NOT NULL,
  `warehouse_id` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `peminjaman_detail`
--

CREATE TABLE `peminjaman_detail` (
  `id` int NOT NULL AUTO_INCREMENT,
  `peminjaman_id` int DEFAULT NULL,
  `barang` varchar(100) DEFAULT NULL,
  `jumlah` int DEFAULT NULL,
  `tanggal_kembali` date DEFAULT NULL,
  `tanggal_in` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `peminjaman_id` (`peminjaman_id`),
  CONSTRAINT `peminjaman_detail_ibfk_1` FOREIGN KEY (`peminjaman_id`) REFERENCES `peminjaman` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `peminjaman_riwayat_perpanjangan`
--

CREATE TABLE `peminjaman_riwayat_perpanjangan` (
  `id` int NOT NULL AUTO_INCREMENT,
  `peminjaman_detail_id` int DEFAULT NULL,
  `tanggal_perpanjangan` date DEFAULT NULL,
  `keterangan` varchar(255) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `peminjaman_detail_id` (`peminjaman_detail_id`),
  CONSTRAINT `peminjaman_riwayat_perpanjangan_ibfk_1` FOREIGN KEY (`peminjaman_detail_id`) REFERENCES `peminjaman_detail` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `platform`
--

CREATE TABLE `platform` (
  `id` int NOT NULL AUTO_INCREMENT,
  `platform_name` varchar(100) NOT NULL,
  `description` text,
  `credential_test` text,
  `credential_live` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `print_history`
--

CREATE TABLE `print_history` (
  `id` int NOT NULL AUTO_INCREMENT,
  `print_date` datetime NOT NULL,
  `picking_no` varchar(50) NOT NULL,
  `part_number` varchar(50) NOT NULL,
  `part_name` varchar(100) NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `uom` varchar(20) NOT NULL,
  `specification` text,
  `printed_by` int NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_picking_no` (`picking_no`),
  KEY `idx_print_date` (`print_date`),
  KEY `idx_part_number` (`part_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `prod_loc`
--

CREATE TABLE `prod_loc` (
  `id` int NOT NULL AUTO_INCREMENT,
  `product_id` int NOT NULL,
  `part_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `new_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `uom` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `categorie_id` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `part_number` (`part_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `product_pricing_offline`
--

CREATE TABLE `product_pricing_offline` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) NOT NULL,
  `type_box_id` int NOT NULL,
  `qty_per_box` int NOT NULL,
  `min_box` int NOT NULL,
  `price` decimal(10,2) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `production_output`
--

CREATE TABLE `production_output` (
  `id` int NOT NULL AUTO_INCREMENT,
  `no_order` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `part_number` varchar(50) NOT NULL,
  `categorie_id` int DEFAULT NULL,
  `quantity_produced` int NOT NULL,
  `production_date` date NOT NULL,
  `input_date` date DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `production_schedule`
--

CREATE TABLE `production_schedule` (
  `id` int NOT NULL AUTO_INCREMENT,
  `no_order` varchar(20) COLLATE utf8mb4_general_ci NOT NULL,
  `client` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `part_number` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
  `quantity_order` int NOT NULL,
  `delivery_date` date NOT NULL,
  `input_date` date DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_part_number` (`part_number`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`wiselie`@`localhost`*/ /*!50003 TRIGGER `update_mrp_baru_after_insert` AFTER INSERT ON `production_schedule` FOR EACH ROW BEGIN
    UPDATE mrp_baru AS mb
    JOIN bom_level AS bl ON NEW.part_number = bl.parent_bom
    SET
        mb.parent_bom = NEW.part_number,
        mb.part_number = bl.child_bom,
        mb.phantom_bom = bl.phantom_bom,
        mb.level = bl.level,
        mb.total_requirement = (bl.qty * NEW.quantity_order),
        mb.quantity_order = NEW.quantity_order,
        mb.calculate = (bl.qty * NEW.quantity_order / 1000)
    WHERE mb.part_number = NEW.part_number;
END */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`wiselie`@`localhost`*/ /*!50003 TRIGGER `delete_mrp_data` AFTER DELETE ON `production_schedule` FOR EACH ROW BEGIN
    DELETE FROM mrp_baru WHERE parent_bom = OLD.part_number;
END */;;
DELIMITER ;

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

CREATE TABLE `products` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `quantity` decimal(10,2) DEFAULT NULL,
  `UoM` text NOT NULL,
  `buy_price` decimal(25,2) DEFAULT NULL,
  `categorie_id` int unsigned NOT NULL,
  `media_id` int DEFAULT '0',
  `date` date DEFAULT NULL,
  `part_number` varchar(255) NOT NULL,
  `new_code` varchar(11) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0',
  `volume` int NOT NULL,
  `lead_time` int NOT NULL DEFAULT '0',
  `loc_id` varchar(25) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0',
  `barcode_id` varchar(250) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`),
  UNIQUE KEY `part_number` (`part_number`) USING BTREE,
  KEY `categorie_id` (`categorie_id`) USING BTREE,
  CONSTRAINT `FK_products` FOREIGN KEY (`categorie_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Table structure for table `project_timeline`
--

CREATE TABLE `project_timeline` (
  `id` int NOT NULL AUTO_INCREMENT,
  `project_name` varchar(255) NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `status` enum('Not Started','In Progress','Completed') NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `purchase_indirect`
--

CREATE TABLE `purchase_indirect` (
  `id` int NOT NULL AUTO_INCREMENT,
  `request_number` varchar(255) NOT NULL,
  `request_date` date NOT NULL,
  `department` enum('Produksi','Maintenance','PPIC','Purchasing','Sales','Marketing','Warehouse Bali','Warehouse Jakarta','Warehouse Surabaya','Warehouse Makassar','Warehouse Semarang','Warehouse Bandung','HRGA','QC/QA') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `product_name` varchar(255) NOT NULL,
  `quantity` int NOT NULL,
  `uom` varchar(50) NOT NULL,
  `remark` text,
  `status` enum('Pending','Approved','Rejected') DEFAULT 'Pending',
  `job` varchar(255) NOT NULL,
  `approval_date` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `date_needed` date DEFAULT NULL,
  `purchasing_remark` text,
  PRIMARY KEY (`id`),
  UNIQUE KEY `request_number` (`request_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `purchase_request_header`
--

CREATE TABLE `purchase_request_header` (
  `id` int NOT NULL AUTO_INCREMENT,
  `pr_code` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
  `request_date` datetime NOT NULL,
  `requested_by_user_id` int NOT NULL,
  `status` enum('Pending','Approved','Rejected','Partially Received','Completed') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'Pending',
  `for_month` int NOT NULL,
  `for_year` int NOT NULL,
  `notes` text COLLATE utf8mb4_general_ci,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pr_code` (`pr_code`),
  KEY `idx_requested_by_user_id` (`requested_by_user_id`),
  KEY `idx_for_month_year` (`for_month`,`for_year`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `purchase_request_items`
--

CREATE TABLE `purchase_request_items` (
  `id` int NOT NULL AUTO_INCREMENT,
  `request_number` varchar(50) NOT NULL,
  `part_number` varchar(50) NOT NULL,
  `product_name` varchar(255) NOT NULL,
  `quantity_needed` int NOT NULL,
  `due_date` date NOT NULL,
  `uom` varchar(50) NOT NULL,
  `incoming` int NOT NULL DEFAULT '0',
  `status` varchar(50) NOT NULL DEFAULT 'pending',
  `remark` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_request_number` (`request_number`),
  CONSTRAINT `fk_request_number` FOREIGN KEY (`request_number`) REFERENCES `purchase_requests` (`request_number`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `purchase_request_items_plan`
--

CREATE TABLE `purchase_request_items_plan` (
  `id` int NOT NULL AUTO_INCREMENT,
  `pr_header_id` int NOT NULL,
  `part_number` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `requested_quantity` decimal(10,2) NOT NULL,
  `unit_price` decimal(10,2) NOT NULL,
  `total_item_price` decimal(12,2) GENERATED ALWAYS AS ((`requested_quantity` * `unit_price`)) STORED,
  `notes` text COLLATE utf8mb4_general_ci,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_pr_header_id` (`pr_header_id`),
  KEY `idx_part_number` (`part_number`),
  CONSTRAINT `fk_pr_items_header` FOREIGN KEY (`pr_header_id`) REFERENCES `purchase_request_header` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `purchase_requests`
--

CREATE TABLE `purchase_requests` (
  `id` int NOT NULL AUTO_INCREMENT,
  `request_number` varchar(50) NOT NULL,
  `request_date` date NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_request_number` (`request_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `queue_shipment`
--

CREATE TABLE `queue_shipment` (
  `id` int NOT NULL AUTO_INCREMENT,
  `order_sn` varchar(50) NOT NULL,
  `shop_id` varchar(100) DEFAULT NULL,
  `access_token` varchar(255) NOT NULL,
  `refresh_token` varchar(255) NOT NULL,
  `log_json` json DEFAULT NULL,
  `platform_id` int NOT NULL,
  `flag_delete` tinyint(1) DEFAULT '0',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `shop_cipher` varchar(255) DEFAULT NULL,
  `shop_name` varchar(255) DEFAULT NULL,
  `region` varchar(50) DEFAULT NULL,
  `type` int DEFAULT NULL,
  `packageId` varchar(255) DEFAULT NULL,
  `zipcode` varchar(20) DEFAULT NULL,
  `tracking_number` varchar(255) DEFAULT NULL,
  `is_instant` tinyint(1) DEFAULT '0',
  `is_approve` tinyint(1) DEFAULT '0',
  `picktime` tinyint(1) DEFAULT '0',
  `is_cancel` int DEFAULT '0',
  `is_flagging` int DEFAULT '0',
  `order_data` json DEFAULT NULL,
  `exists_orders` tinyint(1) NOT NULL DEFAULT '0',
  `exists_awb` tinyint(1) NOT NULL DEFAULT '0',
  `exists_orders_packing_queue` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_order_sn` (`order_sn`),
  KEY `platform_id` (`platform_id`),
  CONSTRAINT `queue_shipment_ibfk_1` FOREIGN KEY (`platform_id`) REFERENCES `platform` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `raw_material_requests`
--

CREATE TABLE `raw_material_requests` (
  `id` int NOT NULL AUTO_INCREMENT,
  `request_date` date NOT NULL,
  `requested_by` varchar(100) NOT NULL,
  `material_name` varchar(255) NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `unit` varchar(50) NOT NULL,
  `required_by_date` date DEFAULT NULL,
  `status` enum('Pending','Approved','Rejected') DEFAULT 'Pending',
  `notes` text,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `reject_area`
--

CREATE TABLE `reject_area` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `name` varchar(255) NOT NULL,
  `quantity` int NOT NULL,
  `buy_price` decimal(10,2) NOT NULL,
  `categorie_id` int NOT NULL,
  `date` date NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `part_number` (`part_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `reject_history_transfer`
--

CREATE TABLE `reject_history_transfer` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) NOT NULL,
  `quantity` int NOT NULL,
  `from_table` varchar(50) NOT NULL COMMENT 'Tabel asal (products)',
  `to_table` varchar(50) NOT NULL COMMENT 'Tabel tujuan (reject_area)',
  `reason` text,
  `transfer_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `user_id` int NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_part_number` (`part_number`),
  KEY `idx_transfer_date` (`transfer_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `reject_prod_loc`
--

CREATE TABLE `reject_prod_loc` (
  `id` int NOT NULL AUTO_INCREMENT,
  `product_id` varchar(100) NOT NULL,
  `part_number` varchar(255) NOT NULL,
  `quantity` int NOT NULL,
  `input_date` date NOT NULL,
  `remark` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Table structure for table `reject_transfer_area`
--

CREATE TABLE `reject_transfer_area` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(50) NOT NULL,
  `quantity` int NOT NULL,
  `notes` text,
  `date` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `request_material`
--

CREATE TABLE `request_material` (
  `id` int NOT NULL AUTO_INCREMENT,
  `request_number` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `product_id` int NOT NULL,
  `requested_quantity` int NOT NULL,
  `delivery_quantity` int DEFAULT '0',
  `request_date` date NOT NULL,
  `status` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'pending',
  `remark` text COLLATE utf8mb4_general_ci,
  `approve_date` date DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `resi`
--

CREATE TABLE `resi` (
  `id` int NOT NULL AUTO_INCREMENT,
  `resi` varchar(50) NOT NULL,
  `id_warehouse` int NOT NULL,
  `scan_in` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `scan_out` datetime DEFAULT NULL,
  `id_packer` int DEFAULT NULL,
  `is_proses` int DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `resi` (`resi`),
  KEY `id_warehouse` (`id_warehouse`),
  CONSTRAINT `resi_ibfk_1` FOREIGN KEY (`id_warehouse`) REFERENCES `warehouse` (`warehouse_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `resi_barcodes`
--

CREATE TABLE `resi_barcodes` (
  `id` int NOT NULL AUTO_INCREMENT,
  `resi_id` int NOT NULL,
  `barcode` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `resi_id` (`resi_id`),
  CONSTRAINT `resi_barcodes_ibfk_1` FOREIGN KEY (`resi_id`) REFERENCES `resi_uploads` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `resi_data`
--

CREATE TABLE `resi_data` (
  `id` int NOT NULL AUTO_INCREMENT,
  `resi` varchar(50) NOT NULL,
  `id_warehouse` int NOT NULL,
  `scan_in` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `scan_out` datetime DEFAULT NULL,
  `id_packer` int DEFAULT NULL,
  `is_proses` int DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `resi` (`resi`),
  KEY `id_warehouse` (`id_warehouse`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `resi_uploads`
--

CREATE TABLE `resi_uploads` (
  `id` int NOT NULL AUTO_INCREMENT,
  `file_name` varchar(255) NOT NULL,
  `upload_date` date NOT NULL,
  `upload_time` time NOT NULL,
  `print_times` int DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `resi_uploads_surabaya`
--

CREATE TABLE `resi_uploads_surabaya` (
  `id` int NOT NULL AUTO_INCREMENT,
  `file_name` varchar(255) NOT NULL,
  `upload_date` date NOT NULL,
  `upload_time` time NOT NULL,
  `print_times` int DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `retur_video`
--

CREATE TABLE `retur_video` (
  `id` int NOT NULL AUTO_INCREMENT,
  `awb_resi` varchar(255) NOT NULL,
  `file_name` varchar(255) NOT NULL,
  `file_path` varchar(255) NOT NULL,
  `upload_date` datetime DEFAULT CURRENT_TIMESTAMP,
  `catatan` text,
  PRIMARY KEY (`id`),
  KEY `awb_resi` (`awb_resi`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `role_menu_permissions`
--

CREATE TABLE `role_menu_permissions` (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_groups_id` int NOT NULL,
  `menu_item_id` int NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `user_groups_id` (`user_groups_id`,`menu_item_id`),
  KEY `menu_item_id` (`menu_item_id`),
  CONSTRAINT `role_menu_permissions_ibfk_1` FOREIGN KEY (`user_groups_id`) REFERENCES `user_groups` (`id`) ON DELETE CASCADE,
  CONSTRAINT `role_menu_permissions_ibfk_2` FOREIGN KEY (`menu_item_id`) REFERENCES `menu_items` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `sales`
--

CREATE TABLE `sales` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `product_id` int unsigned NOT NULL,
  `part_number` varchar(255) NOT NULL,
  `qty` decimal(11,2) NOT NULL,
  `date` date NOT NULL,
  `categorie_id` int NOT NULL,
  `remark` varchar(255) NOT NULL,
  `loc` varchar(15) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `product_id` (`product_id`),
  KEY `qty` (`qty`),
  KEY `date` (`id`),
  KEY `part_number` (`part_number`(5)),
  CONSTRAINT `SK` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Table structure for table `sales_bali`
--

CREATE TABLE `sales_bali` (
  `id` int NOT NULL AUTO_INCREMENT,
  `product_id` int NOT NULL,
  `part_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `qty` decimal(11,0) NOT NULL,
  `date` date NOT NULL,
  `categorie_id` int DEFAULT NULL,
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `loc` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `sales_bandung`
--

CREATE TABLE `sales_bandung` (
  `id` int NOT NULL AUTO_INCREMENT,
  `product_id` int NOT NULL,
  `part_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `qty` decimal(11,0) NOT NULL,
  `date` date NOT NULL,
  `categorie_id` int DEFAULT NULL,
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `loc` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `sales_jakarta`
--

CREATE TABLE `sales_jakarta` (
  `id` int NOT NULL AUTO_INCREMENT,
  `product_id` int NOT NULL,
  `part_number` varchar(255) NOT NULL,
  `qty` decimal(11,0) NOT NULL,
  `date` date NOT NULL,
  `categorie_id` int DEFAULT NULL,
  `remark` varchar(255) DEFAULT NULL,
  `loc` varchar(15) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `sales_makassar`
--

CREATE TABLE `sales_makassar` (
  `id` int NOT NULL AUTO_INCREMENT,
  `product_id` int NOT NULL,
  `part_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `qty` decimal(11,0) NOT NULL,
  `date` date NOT NULL,
  `categorie_id` int DEFAULT NULL,
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `loc` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `sales_requests`
--

CREATE TABLE `sales_requests` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(50) NOT NULL,
  `quantity` int NOT NULL,
  `request_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `sales_review`
--

CREATE TABLE `sales_review` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(50) NOT NULL,
  `product_name` varchar(255) NOT NULL,
  `category_name` varchar(255) NOT NULL,
  `total_quantity` int NOT NULL,
  `resi_count` int NOT NULL,
  `stock` int NOT NULL,
  `location` varchar(50) NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `sales_semarang`
--

CREATE TABLE `sales_semarang` (
  `id` int NOT NULL AUTO_INCREMENT,
  `product_id` int NOT NULL,
  `part_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `qty` decimal(11,0) NOT NULL,
  `date` date NOT NULL,
  `categorie_id` int DEFAULT NULL,
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `loc` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `scan_status_update`
--

CREATE TABLE `scan_status_update` (
  `id` int NOT NULL AUTO_INCREMENT,
  `resi` varchar(255) DEFAULT NULL,
  `kurir` varchar(255) DEFAULT NULL,
  `part_number` varchar(255) DEFAULT NULL,
  `date_scan` datetime DEFAULT NULL,
  `quantity` int DEFAULT NULL,
  `scan_in` datetime DEFAULT NULL,
  `scan_status` datetime DEFAULT NULL,
  `loc` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `schema_migrations`
--

CREATE TABLE `schema_migrations` (
  `version` varchar(128) NOT NULL,
  PRIMARY KEY (`version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `session_times`
--

CREATE TABLE `session_times` (
  `id` int NOT NULL AUTO_INCREMENT,
  `start_time` time NOT NULL,
  `end_time` time NOT NULL,
  `session_name` varchar(50) NOT NULL,
  `zipcode` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_st_zipcode_start_end` (`zipcode`,`start_time`,`end_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `settings`
--

CREATE TABLE `settings` (
  `id` int NOT NULL AUTO_INCREMENT,
  `setting_key` varchar(255) NOT NULL,
  `setting_value` text NOT NULL,
  `description` text NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `setting_key` (`setting_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `shop`
--

CREATE TABLE `shop` (
  `id` int NOT NULL AUTO_INCREMENT,
  `shop_id` varchar(100) DEFAULT NULL,
  `platform_id` int NOT NULL,
  `shop_logo` text,
  `description` text,
  `shop_name` varchar(255) DEFAULT NULL,
  `code` varchar(255) DEFAULT NULL,
  `kode` varchar(50) DEFAULT NULL,
  `address` varchar(150) DEFAULT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `max_awb` int DEFAULT NULL,
  `warehouse` varchar(50) DEFAULT NULL,
  `refresh_token` varchar(255) DEFAULT NULL,
  `access_token` varchar(255) DEFAULT NULL,
  `expire_in` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `last_call` datetime DEFAULT NULL,
  `shop_cipher` varchar(255) DEFAULT NULL,
  `region` varchar(50) DEFAULT NULL,
  `type` int DEFAULT NULL,
  `users_id` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_shop_platform_id` (`platform_id`),
  CONSTRAINT `shop_ibfk_1` FOREIGN KEY (`platform_id`) REFERENCES `platform` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `shop_action`
--

CREATE TABLE `shop_action` (
  `id` int NOT NULL AUTO_INCREMENT,
  `shop_code` varchar(255) NOT NULL,
  `shop_id` varchar(255) NOT NULL,
  `shop_group` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_shop_id` (`shop_code`,`shop_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `sku_city_summary`
--

CREATE TABLE `sku_city_summary` (
  `id` int NOT NULL AUTO_INCREMENT,
  `year_month` varchar(7) NOT NULL COMMENT 'Format YYYY-MM',
  `part_number` varchar(50) NOT NULL,
  `location` varchar(50) NOT NULL,
  `quantity` int NOT NULL DEFAULT '0',
  `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_summary` (`year_month`,`part_number`,`location`),
  KEY `idx_part_number` (`part_number`),
  KEY `idx_year_month` (`year_month`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `std_time`
--

CREATE TABLE `std_time` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(50) NOT NULL,
  `time_filling` decimal(10,2) DEFAULT NULL,
  `time_label` decimal(10,2) DEFAULT NULL,
  `time_seal` decimal(10,2) DEFAULT NULL,
  `time_packing` decimal(10,2) DEFAULT NULL,
  `time_shrink` decimal(10,2) DEFAULT NULL,
  `description` text,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `part_number` (`part_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Table structure for table `stock_history`
--

CREATE TABLE `stock_history` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(100) NOT NULL,
  `warehouse` varchar(100) NOT NULL,
  `status` enum('IN','OUT') NOT NULL,
  `qty_change` int NOT NULL,
  `prev_qty` int NOT NULL,
  `new_qty` int NOT NULL,
  `transfer_id` int DEFAULT NULL,
  `from_warehouse_id` int DEFAULT NULL,
  `to_warehouse_id` int DEFAULT NULL,
  `reason` varchar(255) DEFAULT NULL,
  `category` enum('MOVE','SALE','COUNT','OTHER') NOT NULL DEFAULT 'OTHER',
  `created_by` varchar(100) NOT NULL DEFAULT 'SYSTEM',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `stock_opname_prod_loc`
--

CREATE TABLE `stock_opname_prod_loc` (
  `id` int NOT NULL AUTO_INCREMENT,
  `product_id` int NOT NULL,
  `part_number` varchar(50) NOT NULL,
  `new_code` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `quantity` decimal(10,0) NOT NULL,
  `uom` int NOT NULL,
  `categorie_id` int NOT NULL,
  `opname_date` date NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `stock_taking`
--

CREATE TABLE `stock_taking` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `date` date NOT NULL,
  `actual_quantity` int NOT NULL,
  `difference` int DEFAULT NULL,
  `notes` text COLLATE utf8mb4_general_ci,
  `warehouse` varchar(20) COLLATE utf8mb4_general_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `stock_taking_online`
--

CREATE TABLE `stock_taking_online` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `date` date NOT NULL,
  `actual_quantity` int NOT NULL,
  `difference` int NOT NULL,
  `notes` text COLLATE utf8mb4_general_ci,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `tasks`
--

CREATE TABLE `tasks` (
  `id` int NOT NULL AUTO_INCREMENT,
  `task_name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `division` varchar(100) NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `temp_order_shopee`
--

CREATE TABLE `temp_order_shopee` (
  `order_sn` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `test_qc`
--

CREATE TABLE `test_qc` (
  `id` int NOT NULL AUTO_INCREMENT,
  `nama` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `soal` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `jawaban` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `tanggal` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `test_spv_warehouse`
--

CREATE TABLE `test_spv_warehouse` (
  `id` int NOT NULL AUTO_INCREMENT,
  `nama` varchar(100) NOT NULL,
  `soal` text NOT NULL,
  `jawaban` text NOT NULL,
  `tanggal` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `tiktok_order`
--

CREATE TABLE `tiktok_order` (
  `Order ID` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
  `Order Status` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Order Substatus` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Cancelation/Return Type` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Normal or Pre-order` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `SKU ID` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Seller SKU` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Product Name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Variation` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Quantity` int DEFAULT NULL,
  `Sku Quantity of return` int DEFAULT NULL,
  `SKU Unit Original Price` decimal(15,2) DEFAULT NULL,
  `SKU Subtotal Before Discount` decimal(15,2) DEFAULT NULL,
  `SKU Platform Discount` decimal(15,2) DEFAULT NULL,
  `SKU Seller Discount` decimal(15,2) DEFAULT NULL,
  `SKU Subtotal After Discount` decimal(15,2) DEFAULT NULL,
  `Shipping Fee After Discount` decimal(15,2) DEFAULT NULL,
  `Original Shipping Fee` decimal(15,2) DEFAULT NULL,
  `Shipping Fee Seller Discount` decimal(15,2) DEFAULT NULL,
  `Shipping Fee Platform Discount` decimal(15,2) DEFAULT NULL,
  `Payment platform discount` decimal(15,2) DEFAULT NULL,
  `Buyer Service Fee` decimal(15,2) DEFAULT NULL,
  `Handling Fee` decimal(15,2) DEFAULT NULL,
  `Shipping Insurance` decimal(15,2) DEFAULT NULL,
  `Item Insurance` decimal(15,2) DEFAULT NULL,
  `Order Amount` decimal(15,2) DEFAULT NULL,
  `Order Refund Amount` decimal(15,2) DEFAULT NULL,
  `Created Time` datetime DEFAULT NULL,
  `Paid Time` datetime DEFAULT NULL,
  `RTS Time` datetime DEFAULT NULL,
  `Shipped Time` datetime DEFAULT NULL,
  `Delivered Time` datetime DEFAULT NULL,
  `Cancelled Time` datetime DEFAULT NULL,
  `Cancel By` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Cancel Reason` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Fulfillment Type` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Warehouse Name` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Tracking ID` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Delivery Option` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Shipping Provider Name` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Buyer Message` text COLLATE utf8mb4_general_ci,
  `Buyer Username` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Recipient` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Phone #` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Zipcode` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Country` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Province` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Regency and City` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Districts` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Villages` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Detail Address` text COLLATE utf8mb4_general_ci,
  `Additional address information` text COLLATE utf8mb4_general_ci,
  `Payment Method` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Weight(kg)` decimal(10,2) DEFAULT NULL,
  `Product Category` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Package ID` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Purchase Channel` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Seller Note` text COLLATE utf8mb4_general_ci,
  `Checked Status` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Checked Marked by` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `Tokopedia Invoice Number` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  PRIMARY KEY (`Order ID`),
  KEY `idx_tracking_id` (`Tracking ID`),
  KEY `idx_order_status` (`Order Status`),
  KEY `idx_delivered_time` (`Delivered Time`),
  KEY `idx_sku_id` (`SKU ID`),
  KEY `idx_seller_sku` (`Seller SKU`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `transfer_bali_record`
--

CREATE TABLE `transfer_bali_record` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `quantity` int NOT NULL,
  `transfer_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `user_id` int DEFAULT NULL,
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `transfer_bandung_record`
--

CREATE TABLE `transfer_bandung_record` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) NOT NULL,
  `quantity` int NOT NULL,
  `transfer_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `user_id` int DEFAULT NULL,
  `remark` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `transfer_jakarta_record`
--

CREATE TABLE `transfer_jakarta_record` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) NOT NULL,
  `quantity` int NOT NULL,
  `transfer_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `user_id` int DEFAULT NULL,
  `remark` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `transfer_makassar_record`
--

CREATE TABLE `transfer_makassar_record` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `quantity` int NOT NULL,
  `transfer_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `user_id` int DEFAULT NULL,
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `transfer_online`
--

CREATE TABLE `transfer_online` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `quantity` int NOT NULL,
  `transfer_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `transfer_prod_loc`
--

CREATE TABLE `transfer_prod_loc` (
  `id` int NOT NULL AUTO_INCREMENT,
  `product_id` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `part_number` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `quantity` int NOT NULL,
  `transfer_date` date NOT NULL,
  `categorie_id` int NOT NULL,
  `remark` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `loc` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `transfer_record_bali`
--

CREATE TABLE `transfer_record_bali` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `quantity` int NOT NULL,
  `transfer_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `user_id` int DEFAULT NULL,
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `part_number_idx` (`part_number`),
  KEY `user_id_idx` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `transfer_records`
--

CREATE TABLE `transfer_records` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) NOT NULL,
  `quantity` int NOT NULL,
  `transfer_date` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `transfer_reject_history`
--

CREATE TABLE `transfer_reject_history` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) NOT NULL,
  `quantity` int NOT NULL,
  `reason` text,
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `user_id` int NOT NULL,
  PRIMARY KEY (`id`),
  KEY `part_number` (`part_number`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `transfer_semarang_record`
--

CREATE TABLE `transfer_semarang_record` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) NOT NULL,
  `quantity` int NOT NULL,
  `transfer_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `user_id` int DEFAULT NULL,
  `remark` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `type_box`
--

CREATE TABLE `type_box` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `unit_price_update`
--

CREATE TABLE `unit_price_update` (
  `id` int NOT NULL AUTO_INCREMENT,
  `product_id` int NOT NULL,
  `new_price` decimal(10,2) NOT NULL,
  `updated_at` date NOT NULL,
  `processed` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `upload_resi_bali`
--

CREATE TABLE `upload_resi_bali` (
  `id` int NOT NULL AUTO_INCREMENT,
  `file_name` varchar(255) NOT NULL,
  `upload_date` date NOT NULL,
  `upload_time` time NOT NULL,
  `print_times` int DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `upload_resi_bandung`
--

CREATE TABLE `upload_resi_bandung` (
  `id` int NOT NULL AUTO_INCREMENT,
  `file_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `upload_date` date NOT NULL,
  `upload_time` time NOT NULL,
  `print_times` int DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `upload_resi_makassar`
--

CREATE TABLE `upload_resi_makassar` (
  `id` int NOT NULL AUTO_INCREMENT,
  `file_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `upload_date` date NOT NULL,
  `upload_time` time NOT NULL,
  `print_times` int DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `upload_resi_semarang`
--

CREATE TABLE `upload_resi_semarang` (
  `id` int NOT NULL AUTO_INCREMENT,
  `file_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `upload_date` date NOT NULL,
  `upload_time` time NOT NULL,
  `print_times` int DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `user_groups`
--

CREATE TABLE `user_groups` (
  `id` int NOT NULL AUTO_INCREMENT,
  `group_name` varchar(150) NOT NULL,
  `group_level` int NOT NULL,
  `group_status` int NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `group_level` (`group_level`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(60) NOT NULL,
  `username` varchar(50) NOT NULL,
  `password` varchar(255) NOT NULL,
  `user_level` int NOT NULL,
  `image` varchar(255) DEFAULT 'no_image.jpg',
  `status` int NOT NULL,
  `last_login` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `user_level` (`user_level`),
  CONSTRAINT `FK_user` FOREIGN KEY (`user_level`) REFERENCES `user_groups` (`group_level`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `vendor_list`
--

CREATE TABLE `vendor_list` (
  `id` int NOT NULL AUTO_INCREMENT,
  `vendor_name` varchar(255) NOT NULL,
  `contact_info` varchar(255) DEFAULT NULL,
  `address` text,
  `phone_number` varchar(20) DEFAULT NULL,
  `email` varchar(100) DEFAULT NULL,
  `bank_account` varchar(100) DEFAULT NULL,
  `bank_name` varchar(100) DEFAULT NULL,
  `term_of_payment` varchar(255) DEFAULT NULL,
  `attachment` varchar(255) DEFAULT NULL,
  `date_added` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `video_retur`
--

CREATE TABLE `video_retur` (
  `id` int NOT NULL AUTO_INCREMENT,
  `awb_resi` varchar(50) NOT NULL,
  `video_path` varchar(255) NOT NULL,
  `upload_date` datetime DEFAULT CURRENT_TIMESTAMP,
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `confirmation` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `volume`
--

CREATE TABLE `volume` (
  `id` int NOT NULL AUTO_INCREMENT,
  `volume` decimal(10,2) NOT NULL,
  `isi_pcs` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `warehouse`
--

CREATE TABLE `warehouse` (
  `warehouse_id` int NOT NULL AUTO_INCREMENT,
  `warehouse_name` varchar(255) NOT NULL,
  `location` varchar(255) NOT NULL,
  `zipcode` varchar(20) NOT NULL,
  `capacity` int NOT NULL,
  `status` enum('ACTIVE','INACTIVE','MAINTENANCE') NOT NULL DEFAULT 'ACTIVE',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `btn_class` varchar(50) NOT NULL,
  `user_level` int DEFAULT '0',
  `tables` varchar(50) DEFAULT NULL,
  `tables_wh` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`warehouse_id`),
  KEY `idx_warehouse_zipcode` (`zipcode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `wh_bali`
--

CREATE TABLE `wh_bali` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `quantity` decimal(10,2) DEFAULT NULL,
  `UoM` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `buy_price` decimal(25,2) DEFAULT NULL,
  `categorie_id` int unsigned NOT NULL,
  `media_id` int DEFAULT '0',
  `date` date DEFAULT NULL,
  `part_number` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `new_code` varchar(11) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0',
  `lead_time` int NOT NULL DEFAULT '0',
  `loc_id` varchar(25) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `name_index` (`name`),
  KEY `categorie_id_index` (`categorie_id`),
  KEY `part_number_index` (`part_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `wh_bandung`
--

CREATE TABLE `wh_bandung` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `quantity` decimal(10,2) DEFAULT NULL,
  `UoM` text NOT NULL,
  `buy_price` decimal(25,2) DEFAULT NULL,
  `categorie_id` int unsigned NOT NULL,
  `media_id` int DEFAULT '0',
  `date` date DEFAULT NULL,
  `part_number` varchar(255) NOT NULL,
  `new_code` varchar(11) DEFAULT '0',
  `lead_time` int NOT NULL DEFAULT '0',
  `loc_id` varchar(25) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `name` (`name`),
  KEY `categorie_id` (`categorie_id`),
  KEY `part_number` (`part_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `wh_jakarta`
--

CREATE TABLE `wh_jakarta` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `quantity` decimal(10,2) DEFAULT NULL,
  `UoM` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `buy_price` decimal(25,2) DEFAULT NULL,
  `categorie_id` int unsigned NOT NULL,
  `media_id` int DEFAULT '0',
  `date` date DEFAULT NULL,
  `part_number` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `new_code` varchar(11) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0',
  `lead_time` int NOT NULL DEFAULT '0',
  `loc_id` varchar(25) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `name` (`name`),
  KEY `categorie_id` (`categorie_id`),
  KEY `part_number` (`part_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `wh_makassar`
--

CREATE TABLE `wh_makassar` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `quantity` decimal(10,2) DEFAULT NULL,
  `UoM` text NOT NULL,
  `buy_price` decimal(25,2) DEFAULT NULL,
  `categorie_id` int unsigned NOT NULL,
  `media_id` int DEFAULT '0',
  `date` date DEFAULT NULL,
  `part_number` varchar(255) NOT NULL,
  `new_code` varchar(11) NOT NULL DEFAULT '0',
  `lead_time` int NOT NULL DEFAULT '0',
  `loc_id` varchar(25) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `name` (`name`),
  KEY `categorie_id` (`categorie_id`),
  KEY `part_number` (`part_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Table structure for table `wh_semarang`
--

CREATE TABLE `wh_semarang` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `quantity` decimal(10,2) DEFAULT NULL,
  `UoM` text NOT NULL,
  `buy_price` decimal(25,2) DEFAULT NULL,
  `categorie_id` int unsigned NOT NULL,
  `media_id` int DEFAULT '0',
  `date` date DEFAULT NULL,
  `part_number` varchar(255) NOT NULL,
  `new_code` varchar(11) DEFAULT '0',
  `lead_time` int NOT NULL DEFAULT '0',
  `loc_id` varchar(25) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `name` (`name`),
  KEY `categorie_id` (`categorie_id`),
  KEY `part_number` (`part_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Table structure for table `wh_transfer`
--

CREATE TABLE `wh_transfer` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `location` enum('wh_jakarta','wh_makassar','wh_bali','wh_semarang','wh_bandung') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `remark` text,
  `transfer_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `part_number` (`part_number`),
  CONSTRAINT `wh_transfer_ibfk_1` FOREIGN KEY (`part_number`) REFERENCES `products` (`part_number`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Table structure for table `wh_transfer_pending`
--

CREATE TABLE `wh_transfer_pending` (
  `id` int NOT NULL AUTO_INCREMENT,
  `part_number` varchar(255) NOT NULL,
  `quantity` decimal(11,2) NOT NULL,
  `location` varchar(50) NOT NULL,
  `remark` varchar(255) DEFAULT NULL,
  `transfer_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `status` enum('pending','confirmed') DEFAULT 'pending',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping routines for database 'wiselie_inventory'
--



--
-- Dbmate schema migrations
--

INSERT INTO `schema_migrations` (version) VALUES
  ('20241111013624'),
  ('20241111013651'),
  ('20241111014542'),
  ('20241111645259'),
  ('20241113010215'),
  ('20241114010316'),
  ('20241118131902'),
  ('20241119033345'),
  ('20241119044920'),
  ('20241120012110'),
  ('20241121031034'),
  ('20241121045059'),
  ('20241123021159'),
  ('20241123051513'),
  ('20241123052733'),
  ('20241126020842'),
  ('20241128084433'),
  ('20241128084844'),
  ('20241129080822'),
  ('20241129083021'),
  ('20241129111700'),
  ('20241129123609'),
  ('20241129123953'),
  ('20241130015816'),
  ('20241203022758'),
  ('20241203033422'),
  ('20241203050046'),
  ('20241210062606'),
  ('20241224091504'),
  ('20241227091823'),
  ('20241227092326'),
  ('20250106021813'),
  ('20250106032819'),
  ('20250106034714'),
  ('20250107031947'),
  ('20250107035824'),
  ('20250111045440'),
  ('20250117080024'),
  ('20250121071457'),
  ('20250122084716'),
  ('20250201040025'),
  ('20250205033205'),
  ('20250205043130'),
  ('20250205043140'),
  ('20250208050309'),
  ('20250210022933'),
  ('20250210065745'),
  ('20250210070327'),
  ('20250210070704'),
  ('20250210071324'),
  ('20250210071536'),
  ('20250211081242'),
  ('20250212040444'),
  ('20250213040320'),
  ('20250213050852'),
  ('20250214084955'),
  ('20250217033246'),
  ('20250219025756'),
  ('20250220061318'),
  ('20250221091436'),
  ('20250222031011'),
  ('20250222031125'),
  ('20250222031219'),
  ('20250224025330'),
  ('20250225042254'),
  ('20250225042718'),
  ('20250225051622'),
  ('20250226023027'),
  ('20250226063500'),
  ('20250226063552'),
  ('20250226083923'),
  ('20250226084026'),
  ('20250226084141'),
  ('20250228043006'),
  ('20250228081604'),
  ('20250305042950'),
  ('20250305084008'),
  ('20250314042357'),
  ('20250314042417'),
  ('20250314042528'),
  ('20250314072809'),
  ('20250319080711'),
  ('20250321083645'),
  ('20250326020536'),
  ('20250326081412'),
  ('20250326082845'),
  ('20250328032624'),
  ('20250405024321'),
  ('20250405024625'),
  ('20250405043031'),
  ('20250408045336'),
  ('20250409084129'),
  ('20250409084221'),
  ('20250409084229'),
  ('20250409084237'),
  ('20250409084246'),
  ('20250409084254'),
  ('20250414075246'),
  ('20250415024246'),
  ('20250415035140'),
  ('20250416012302'),
  ('20250416033829'),
  ('20250416104245'),
  ('20250416132317'),
  ('20250417012537'),
  ('20250417023113'),
  ('20250422121212'),
  ('20250425071248'),
  ('20250701033946');
