-- Table structure for rental_type_values
-- ----------------------------
CREATE TABLE `rental_type_values`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `rental_type_values_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `rental_type_values_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `rental_type_values_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `rental_type_values_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `rental_type_values_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rental_type_values_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rental_type_values_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rental_type_values_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of rental_type_values
-- ----------------------------
INSERT INTO `rental_type_values` VALUES (1, 'سيارات', '1', 'Cars', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:53', '2025-06-12 14:05:53', NULL);
INSERT INTO `rental_type_values` VALUES (2, 'مباني', '2', 'Building', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:53', '2025-06-12 14:05:53', NULL);

-- ----------------------------
-- Table structure for rental_types
-- ----------------------------
CREATE TABLE `rental_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `rental_type_value_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `rental_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `rental_types_rental_type_value_id_foreign`(`rental_type_value_id` ASC) USING BTREE,
  INDEX `rental_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `rental_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `rental_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `rental_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rental_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rental_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rental_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rental_types_rental_type_value_id_foreign` FOREIGN KEY (`rental_type_value_id`) REFERENCES `rental_type_values` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of rental_types
-- ----------------------------
INSERT INTO `rental_types` VALUES (1, 'ملك', '1', 'Owned', 2, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:54', '2025-06-12 14:05:54', NULL);
INSERT INTO `rental_types` VALUES (2, 'تأجير', '1', 'Rental', 2, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:54', '2025-06-12 14:05:54', NULL);

-- ----------------------------
-- Table structure for request_for_checks
-- ----------------------------
CREATE TABLE `request_for_checks`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `request_for_checks_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `request_for_checks_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `request_for_checks_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `request_for_checks_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `request_for_checks_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_checks_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_checks_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_checks_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of request_for_checks
-- ----------------------------
INSERT INTO `request_for_checks` VALUES (1, 'value', '1', 'value', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);

-- ----------------------------
-- Table structure for request_for_quotation_lines
-- ----------------------------
CREATE TABLE `request_for_quotation_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `material_requisition_id` int UNSIGNED NULL DEFAULT NULL,
  `request_for_quotation_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `user_id` int UNSIGNED NOT NULL,
  `quantity` double NOT NULL,
  `in_date_tax` double NULL DEFAULT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `in_date_currency_rate` double NOT NULL,
  `price` double NULL DEFAULT NULL,
  `price_with_cost` double NULL DEFAULT NULL,
  `date` date NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `request_for_quotation_lines_request_for_quotation_id_foreign`(`request_for_quotation_id` ASC) USING BTREE,
  INDEX `request_for_quotation_lines_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `request_for_quotation_lines_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `request_for_quotation_lines_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `request_for_quotation_lines_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `request_for_quotation_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `request_for_quotation_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `request_for_quotation_lines_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `request_for_quotation_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `request_for_quotation_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `request_for_quotation_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotation_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotation_lines_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotation_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotation_lines_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotation_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotation_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotation_lines_request_for_quotation_id_foreign` FOREIGN KEY (`request_for_quotation_id`) REFERENCES `request_for_quotations` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotation_lines_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotation_lines_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of request_for_quotation_lines
-- ----------------------------

-- ----------------------------
-- Table structure for request_for_quotation_status
-- ----------------------------
CREATE TABLE `request_for_quotation_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `request_for_quotation_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `request_for_quotation_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `request_for_quotation_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `request_for_quotation_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `request_for_quotation_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotation_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotation_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotation_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of request_for_quotation_status
-- ----------------------------
INSERT INTO `request_for_quotation_status` VALUES (1, 'قيد الانشاء', '1', 'Pending', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:50', '2025-06-12 14:05:50', NULL);
INSERT INTO `request_for_quotation_status` VALUES (2, 'تم التحويل الى امر شراء', '1', 'Transfered to purchase order', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:50', '2025-06-12 14:05:50', NULL);
INSERT INTO `request_for_quotation_status` VALUES (3, 'الغي', '1', 'Canceled', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:50', '2025-06-12 14:05:50', NULL);

-- ----------------------------
-- Table structure for request_for_quotation_types
-- ----------------------------
CREATE TABLE `request_for_quotation_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `numbering_type_id` int UNSIGNED NULL DEFAULT NULL,
  `next_number` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `request_for_quotation_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `request_for_quotation_types_numbering_type_id_foreign`(`numbering_type_id` ASC) USING BTREE,
  INDEX `request_for_quotation_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `request_for_quotation_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `request_for_quotation_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `request_for_quotation_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotation_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotation_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotation_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotation_types_numbering_type_id_foreign` FOREIGN KEY (`numbering_type_id`) REFERENCES `numbering_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of request_for_quotation_types
-- ----------------------------
INSERT INTO `request_for_quotation_types` VALUES (1, 'طلب عرض سعر', '1', 'Request for Quotation', 1, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:50', '2025-06-12 14:05:50', NULL);

-- ----------------------------
-- Table structure for request_for_quotations
-- ----------------------------
CREATE TABLE `request_for_quotations`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `material_requisition_id` int UNSIGNED NULL DEFAULT NULL,
  `request_for_quotation_type_id` int UNSIGNED NOT NULL,
  `request_for_quotation_state_id` int UNSIGNED NOT NULL,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `tax_state_id` int UNSIGNED NULL DEFAULT NULL,
  `date` date NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `in_date_currency_rate` double UNSIGNED NOT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `request_for_quotations_material_requisition_id_foreign`(`material_requisition_id` ASC) USING BTREE,
  INDEX `request_for_quotations_request_for_quotation_type_id_foreign`(`request_for_quotation_type_id` ASC) USING BTREE,
  INDEX `request_for_quotations_request_for_quotation_state_id_foreign`(`request_for_quotation_state_id` ASC) USING BTREE,
  INDEX `request_for_quotations_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `request_for_quotations_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `request_for_quotations_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `request_for_quotations_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `request_for_quotations_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `request_for_quotations_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `request_for_quotations_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `request_for_quotations_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotations_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotations_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotations_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotations_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotations_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotations_material_requisition_id_foreign` FOREIGN KEY (`material_requisition_id`) REFERENCES `material_requisitions` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotations_request_for_quotation_state_id_foreign` FOREIGN KEY (`request_for_quotation_state_id`) REFERENCES `request_for_quotation_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotations_request_for_quotation_type_id_foreign` FOREIGN KEY (`request_for_quotation_type_id`) REFERENCES `request_for_quotation_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotations_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of request_for_quotations
-- ----------------------------

-- ----------------------------
-- Table structure for request_for_quotations_mrs
-- ----------------------------
CREATE TABLE `request_for_quotations_mrs`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `request_for_quotation_id` int UNSIGNED NOT NULL,
  `material_requisition_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `request_for_quotations_mrs_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `request_for_quotations_mrs_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `request_for_quotations_mrs_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `request_for_quotations_mrs_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `request_for_quotations_mrs_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotations_mrs_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotations_mrs_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `request_for_quotations_mrs_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of request_for_quotations_mrs
-- ----------------------------

-- ----------------------------
-- Table structure for reservation_groups
-- ----------------------------
CREATE TABLE `reservation_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `reservation_group_id` int UNSIGNED NULL DEFAULT NULL,
  `main_child_zeros` int NULL DEFAULT NULL,
  `main_child_counter` int NULL DEFAULT NULL,
  `sub_child_zeros` int NULL DEFAULT NULL,
  `sub_child_counter` int NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `reservation_groups_reservation_group_id_foreign`(`reservation_group_id` ASC) USING BTREE,
  INDEX `reservation_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `reservation_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `reservation_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `reservation_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reservation_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reservation_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reservation_groups_reservation_group_id_foreign` FOREIGN KEY (`reservation_group_id`) REFERENCES `reservation_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of reservation_groups
-- ----------------------------

-- ----------------------------
-- Table structure for reservation_status
-- ----------------------------
CREATE TABLE `reservation_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `reservation_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `reservation_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `reservation_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `reservation_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `reservation_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reservation_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reservation_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reservation_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of reservation_status
-- ----------------------------
INSERT INTO `reservation_status` VALUES (1, 'قيد الانشاء', '1', 'Pending', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:03', '2025-06-12 14:06:03', NULL);
INSERT INTO `reservation_status` VALUES (2, 'تم بنجاح', '2', 'Successed', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:03', '2025-06-12 14:06:03', NULL);
INSERT INTO `reservation_status` VALUES (3, 'الغي من العميل', '3', 'Canceled by customer', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:03', '2025-06-12 14:06:03', NULL);

-- ----------------------------
-- Table structure for reservations
-- ----------------------------
CREATE TABLE `reservations`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `reservation_group_id` int UNSIGNED NOT NULL,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `mobile` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `date` date NULL DEFAULT NULL,
  `from_datetime` datetime NULL DEFAULT NULL,
  `to_datetime` datetime NULL DEFAULT NULL,
  `sales_person_user_id` int UNSIGNED NULL DEFAULT NULL,
  `reservation_state_id` int UNSIGNED NOT NULL,
  `journal_entry_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `reservations_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `reservations_reservation_group_id_foreign`(`reservation_group_id` ASC) USING BTREE,
  INDEX `reservations_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `reservations_reservation_state_id_foreign`(`reservation_state_id` ASC) USING BTREE,
  INDEX `reservations_sales_person_user_id_foreign`(`sales_person_user_id` ASC) USING BTREE,
  INDEX `reservations_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `reservations_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `reservations_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `reservations_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reservations_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reservations_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reservations_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reservations_reservation_group_id_foreign` FOREIGN KEY (`reservation_group_id`) REFERENCES `reservation_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reservations_reservation_state_id_foreign` FOREIGN KEY (`reservation_state_id`) REFERENCES `reservation_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reservations_sales_person_user_id_foreign` FOREIGN KEY (`sales_person_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reservations_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of reservations
-- ----------------------------

-- ----------------------------
-- Table structure for reserve_material_order_groups
-- ----------------------------
CREATE TABLE `reserve_material_order_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `main_child_zeros` double NULL DEFAULT 10,
  `main_child_counter` double NULL DEFAULT NULL,
  `sub_child_zeros` double NULL DEFAULT 1000,
  `sub_child_counter` double NULL DEFAULT NULL,
  `reserve_material_order_group_id` int UNSIGNED NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `reserve_material_order_groups_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `reserve_material_order_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `reserve_material_order_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `reserve_material_order_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `reserve_material_order_groups_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of reserve_material_order_groups
-- ----------------------------
INSERT INTO `reserve_material_order_groups` VALUES (1, 'داخلي', '1', 'Internal', 10, NULL, 1000, NULL, NULL, 1, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:57', '2025-06-12 14:05:57', NULL);
INSERT INTO `reserve_material_order_groups` VALUES (2, 'خارجي', '2', 'External', 10, NULL, 1000, NULL, NULL, 1, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:57', '2025-06-12 14:05:57', NULL);

-- ----------------------------
-- Table structure for reserve_material_order_lines
-- ----------------------------
CREATE TABLE `reserve_material_order_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `date` date NOT NULL,
  `reserve_material_order_id` int UNSIGNED NOT NULL,
  `reserve_material_order_state_id` int UNSIGNED NOT NULL,
  `work_order_id` int UNSIGNED NULL DEFAULT NULL,
  `working_contract_id` int UNSIGNED NULL DEFAULT NULL,
  `reserve_note_voucher_id` int UNSIGNED NULL DEFAULT NULL,
  `warehouse_id` int UNSIGNED NOT NULL,
  `work_order_line_step_id` int UNSIGNED NULL DEFAULT NULL,
  `reserve_material_order_group_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `quantity` double UNSIGNED NOT NULL,
  `note_voucher_line_id` int UNSIGNED NULL DEFAULT NULL,
  `remain` double UNSIGNED NULL DEFAULT NULL,
  `losses` double UNSIGNED NULL DEFAULT NULL,
  `damage` double UNSIGNED NULL DEFAULT NULL,
  `delivered_quantity` double UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `reserve_material_order_lines_reserve_material_order_id_foreign`(`reserve_material_order_id` ASC) USING BTREE,
  INDEX `reserve_material_order_lines_work_order_id_foreign`(`work_order_id` ASC) USING BTREE,
  INDEX `reserve_material_order_lines_working_contract_id_foreign`(`working_contract_id` ASC) USING BTREE,
  INDEX `reserve_material_order_lines_reserve_note_voucher_id_foreign`(`reserve_note_voucher_id` ASC) USING BTREE,
  INDEX `reserve_material_order_lines_warehouse_id_foreign`(`warehouse_id` ASC) USING BTREE,
  INDEX `reserve_material_order_lines_work_order_line_step_id_foreign`(`work_order_line_step_id` ASC) USING BTREE,
  INDEX `reserve_material_order_lines_note_voucher_line_id_foreign`(`note_voucher_line_id` ASC) USING BTREE,
  INDEX `reserve_material_order_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `reserve_material_order_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `reserve_material_order_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `reserve_material_order_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `reserve_material_order_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_lines_note_voucher_line_id_foreign` FOREIGN KEY (`note_voucher_line_id`) REFERENCES `note_voucher_lines` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_lines_reserve_material_order_id_foreign` FOREIGN KEY (`reserve_material_order_id`) REFERENCES `reserve_material_orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_lines_reserve_note_voucher_id_foreign` FOREIGN KEY (`reserve_note_voucher_id`) REFERENCES `note_vouchers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_lines_warehouse_id_foreign` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouses` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_lines_work_order_id_foreign` FOREIGN KEY (`work_order_id`) REFERENCES `work_orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_lines_work_order_line_step_id_foreign` FOREIGN KEY (`work_order_line_step_id`) REFERENCES `work_order_line_steps` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_lines_working_contract_id_foreign` FOREIGN KEY (`working_contract_id`) REFERENCES `working_contracts` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of reserve_material_order_lines
-- ----------------------------

-- ----------------------------
-- Table structure for reserve_material_order_note_vouchers
-- ----------------------------
CREATE TABLE `reserve_material_order_note_vouchers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `reserve_material_order_id` int UNSIGNED NOT NULL,
  `note_voucher_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `reserve_material_order_note_vouchers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `reserve_material_order_note_vouchers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `reserve_material_order_note_vouchers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `reserve_material_order_note_vouchers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `reserve_material_order_note_vouchers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_note_vouchers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_note_vouchers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_note_vouchers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of reserve_material_order_note_vouchers
-- ----------------------------

-- ----------------------------
-- Table structure for reserve_material_order_status
-- ----------------------------
CREATE TABLE `reserve_material_order_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `reserve_material_order_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `reserve_material_order_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `reserve_material_order_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `reserve_material_order_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `reserve_material_order_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of reserve_material_order_status
-- ----------------------------
INSERT INTO `reserve_material_order_status` VALUES (1, 'بأنتظار الصرف', '1', 'Pending reserve', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:57', '2025-06-12 14:05:57', NULL);
INSERT INTO `reserve_material_order_status` VALUES (2, 'تم الصرف عليه', '2', 'Finshed', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:57', '2025-06-12 14:05:57', NULL);
INSERT INTO `reserve_material_order_status` VALUES (3, 'تم الصرف عليه والانتهاء منه', '3', 'Finshed', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:57', '2025-06-12 14:05:57', NULL);
INSERT INTO `reserve_material_order_status` VALUES (4, 'ملغي', '4', 'Canceled', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:57', '2025-06-12 14:05:57', NULL);

-- ----------------------------
-- Table structure for reserve_material_order_vouchers
-- ----------------------------
CREATE TABLE `reserve_material_order_vouchers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `reserve_material_order_id` int UNSIGNED NOT NULL,
  `note_voucher_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `reserve_material_order_vouchers_note_voucher_id_foreign`(`note_voucher_id` ASC) USING BTREE,
  INDEX `reserve_material_order_vouchers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `reserve_material_order_vouchers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `reserve_material_order_vouchers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `reserve_material_order_vouchers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `reserve_material_order_vouchers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_vouchers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_vouchers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_vouchers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_order_vouchers_note_voucher_id_foreign` FOREIGN KEY (`note_voucher_id`) REFERENCES `note_vouchers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of reserve_material_order_vouchers
-- ----------------------------

-- ----------------------------
-- Table structure for reserve_material_orders
-- ----------------------------
CREATE TABLE `reserve_material_orders`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `date` date NOT NULL,
  `reserve_material_order_state_id` int UNSIGNED NOT NULL,
  `work_order_id` int UNSIGNED NULL DEFAULT NULL,
  `working_contract_id` int UNSIGNED NULL DEFAULT NULL,
  `reserve_note_voucher_id` int UNSIGNED NULL DEFAULT NULL,
  `warehouse_id` int UNSIGNED NOT NULL,
  `work_order_line_step_id` int UNSIGNED NULL DEFAULT NULL,
  `reserve_material_order_group_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `reserve_material_orders_reserve_material_order_state_id_foreign`(`reserve_material_order_state_id` ASC) USING BTREE,
  INDEX `reserve_material_orders_work_order_id_foreign`(`work_order_id` ASC) USING BTREE,
  INDEX `reserve_material_orders_working_contract_id_foreign`(`working_contract_id` ASC) USING BTREE,
  INDEX `reserve_material_orders_reserve_note_voucher_id_foreign`(`reserve_note_voucher_id` ASC) USING BTREE,
  INDEX `reserve_material_orders_warehouse_id_foreign`(`warehouse_id` ASC) USING BTREE,
  INDEX `reserve_material_orders_work_order_line_step_id_foreign`(`work_order_line_step_id` ASC) USING BTREE,
  INDEX `reserve_material_orders_reserve_material_order_group_id_foreign`(`reserve_material_order_group_id` ASC) USING BTREE,
  INDEX `reserve_material_orders_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `reserve_material_orders_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `reserve_material_orders_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `reserve_material_orders_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `reserve_material_orders_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_orders_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_orders_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_orders_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_orders_reserve_material_order_group_id_foreign` FOREIGN KEY (`reserve_material_order_group_id`) REFERENCES `reserve_material_order_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_orders_reserve_material_order_state_id_foreign` FOREIGN KEY (`reserve_material_order_state_id`) REFERENCES `reserve_material_order_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_orders_reserve_note_voucher_id_foreign` FOREIGN KEY (`reserve_note_voucher_id`) REFERENCES `note_vouchers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_orders_warehouse_id_foreign` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouses` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_orders_work_order_id_foreign` FOREIGN KEY (`work_order_id`) REFERENCES `work_orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_orders_work_order_line_step_id_foreign` FOREIGN KEY (`work_order_line_step_id`) REFERENCES `work_order_line_steps` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_material_orders_working_contract_id_foreign` FOREIGN KEY (`working_contract_id`) REFERENCES `working_contracts` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of reserve_material_orders
-- ----------------------------

-- ----------------------------
-- Table structure for reserve_template_lines
-- ----------------------------
CREATE TABLE `reserve_template_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `reserve_template_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `quantity` double UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `reserve_template_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `reserve_template_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `reserve_template_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `reserve_template_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `reserve_template_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_template_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_template_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_template_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of reserve_template_lines
-- ----------------------------

-- ----------------------------
-- Table structure for reserve_templates
-- ----------------------------
CREATE TABLE `reserve_templates`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `reserve_templates_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `reserve_templates_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `reserve_templates_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `reserve_templates_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `reserve_templates_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_templates_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_templates_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reserve_templates_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of reserve_templates
-- ----------------------------

-- ----------------------------
-- Table structure for rewards
-- ----------------------------
CREATE TABLE `rewards`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `value` double NULL DEFAULT NULL,
  `percentage_from_main_salary` double NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `rewards_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `rewards_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `rewards_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `rewards_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `rewards_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rewards_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rewards_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rewards_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of rewards
-- ----------------------------
INSERT INTO `rewards` VALUES (1, '10 % على الراتب الاساسي', '1', '10 Percentage on main salary reward', NULL, 10, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);
INSERT INTO `rewards` VALUES (2, 'مكافئة 10 دنانير', '2', '10 Jd reward', 10, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);

-- ----------------------------
-- Table structure for safe_deposit_status
-- ----------------------------
CREATE TABLE `safe_deposit_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `safe_deposit_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `safe_deposit_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `safe_deposit_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `safe_deposit_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `safe_deposit_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `safe_deposit_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `safe_deposit_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `safe_deposit_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of safe_deposit_status
-- ----------------------------
INSERT INTO `safe_deposit_status` VALUES (1, 'مع الموظف', '1', 'With the Employee', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);
INSERT INTO `safe_deposit_status` VALUES (2, 'تم الارجاع', '2', 'Returned', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);
INSERT INTO `safe_deposit_status` VALUES (3, 'تم الارجاع ولكن به عطل', '3', 'Returned with issue', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);

-- ----------------------------
-- Table structure for safe_deposits
-- ----------------------------
CREATE TABLE `safe_deposits`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `employee_user_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NULL DEFAULT NULL,
  `unit_id` int UNSIGNED NULL DEFAULT NULL,
  `safe_deposit_state_id` int UNSIGNED NOT NULL,
  `note_voucher_id` int UNSIGNED NULL DEFAULT NULL,
  `quantity` double UNSIGNED NULL DEFAULT NULL,
  `received_date` date NOT NULL,
  `return_back_date` date NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `safe_deposits_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `safe_deposits_note_voucher_id_foreign`(`note_voucher_id` ASC) USING BTREE,
  INDEX `safe_deposits_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `safe_deposits_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `safe_deposits_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `safe_deposits_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `safe_deposits_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `safe_deposits_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `safe_deposits_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `safe_deposits_note_voucher_id_foreign` FOREIGN KEY (`note_voucher_id`) REFERENCES `note_vouchers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of safe_deposits
-- ----------------------------

-- ----------------------------
-- Table structure for salary_cutoffs
-- ----------------------------
CREATE TABLE `salary_cutoffs`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `salary_cutoffs_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `salary_cutoffs_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `salary_cutoffs_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `salary_cutoffs_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `salary_cutoffs_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `salary_cutoffs_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `salary_cutoffs_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `salary_cutoffs_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of salary_cutoffs
-- ----------------------------
INSERT INTO `salary_cutoffs` VALUES (1, 'تأمين صحي', '1', 'Health insurance', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:53', '2025-06-12 14:05:53', NULL);

-- ----------------------------
-- Table structure for sales_order_lines
-- ----------------------------
CREATE TABLE `sales_order_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `date` date NOT NULL,
  `expire_date` date NULL DEFAULT NULL,
  `sales_order_id` int UNSIGNED NOT NULL,
  `customer_id` int UNSIGNED NOT NULL,
  `sales_order_type_id` int UNSIGNED NOT NULL,
  `sales_order_state_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `price` double NOT NULL,
  `price_with_cost` double NOT NULL,
  `discount_percentage` double NULL DEFAULT NULL,
  `discount_value` double NULL DEFAULT NULL,
  `in_date_tax` double NULL DEFAULT NULL,
  `quantity` double UNSIGNED NOT NULL,
  `delivered_quantity` double UNSIGNED NULL DEFAULT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `default_currency` int UNSIGNED NOT NULL,
  `in_date_currency_rate` double NOT NULL,
  `total` double NULL DEFAULT NULL,
  `journal_entry_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sales_order_lines_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `sales_order_lines_default_currency_foreign`(`default_currency` ASC) USING BTREE,
  INDEX `sales_order_lines_sales_order_id_foreign`(`sales_order_id` ASC) USING BTREE,
  INDEX `sales_order_lines_customer_id_foreign`(`customer_id` ASC) USING BTREE,
  INDEX `sales_order_lines_sales_order_type_id_foreign`(`sales_order_type_id` ASC) USING BTREE,
  INDEX `sales_order_lines_sales_order_state_id_foreign`(`sales_order_state_id` ASC) USING BTREE,
  INDEX `sales_order_lines_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `sales_order_lines_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `sales_order_lines_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `sales_order_lines_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `sales_order_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sales_order_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sales_order_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sales_order_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sales_order_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_lines_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_lines_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_lines_customer_id_foreign` FOREIGN KEY (`customer_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_lines_default_currency_foreign` FOREIGN KEY (`default_currency`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_lines_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_lines_sales_order_id_foreign` FOREIGN KEY (`sales_order_id`) REFERENCES `sales_orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_lines_sales_order_state_id_foreign` FOREIGN KEY (`sales_order_state_id`) REFERENCES `sales_order_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_lines_sales_order_type_id_foreign` FOREIGN KEY (`sales_order_type_id`) REFERENCES `sales_order_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_lines_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sales_order_lines
-- ----------------------------

-- ----------------------------
-- Table structure for sales_order_status
-- ----------------------------
CREATE TABLE `sales_order_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sales_order_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sales_order_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sales_order_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sales_order_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sales_order_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sales_order_status
-- ----------------------------
INSERT INTO `sales_order_status` VALUES (1, 'قيد الانشاء', '1', 'Pending', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `sales_order_status` VALUES (2, 'مرفوض', '2', 'Rejected', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `sales_order_status` VALUES (3, 'انتهت الصلاحية', '3', 'Expired', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `sales_order_status` VALUES (4, 'تم بنجاح', '4', 'Successed', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);

-- ----------------------------
-- Table structure for sales_order_types
-- ----------------------------
CREATE TABLE `sales_order_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `numbering_type_id` int UNSIGNED NOT NULL,
  `next_number` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sales_order_types_numbering_type_id_foreign`(`numbering_type_id` ASC) USING BTREE,
  INDEX `sales_order_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sales_order_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sales_order_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sales_order_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sales_order_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_order_types_numbering_type_id_foreign` FOREIGN KEY (`numbering_type_id`) REFERENCES `numbering_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sales_order_types
-- ----------------------------
INSERT INTO `sales_order_types` VALUES (1, 'مواد تصنيع', '1', 'Bon', 1, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `sales_order_types` VALUES (2, 'اثاث', '2', 'Furniture', 1, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);

-- ----------------------------
-- Table structure for sales_orders
-- ----------------------------
CREATE TABLE `sales_orders`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `date` date NOT NULL,
  `expire_date` date NULL DEFAULT NULL,
  `sales_order_type_id` int UNSIGNED NOT NULL,
  `sales_order_state_id` int UNSIGNED NOT NULL,
  `customer_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `amount` double NULL DEFAULT NULL,
  `tax` double NULL DEFAULT NULL,
  `discount` double NULL DEFAULT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `default_currency` int UNSIGNED NOT NULL,
  `in_date_currency_rate` double NOT NULL,
  `journal_entry_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sales_orders_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `sales_orders_default_currency_foreign`(`default_currency` ASC) USING BTREE,
  INDEX `sales_orders_sales_order_type_id_foreign`(`sales_order_type_id` ASC) USING BTREE,
  INDEX `sales_orders_sales_order_state_id_foreign`(`sales_order_state_id` ASC) USING BTREE,
  INDEX `sales_orders_customer_id_foreign`(`customer_id` ASC) USING BTREE,
  INDEX `sales_orders_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `sales_orders_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `sales_orders_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sales_orders_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sales_orders_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sales_orders_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sales_orders_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_orders_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_orders_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_orders_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_orders_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_orders_customer_id_foreign` FOREIGN KEY (`customer_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_orders_default_currency_foreign` FOREIGN KEY (`default_currency`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_orders_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_orders_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_orders_sales_order_state_id_foreign` FOREIGN KEY (`sales_order_state_id`) REFERENCES `sales_order_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_orders_sales_order_type_id_foreign` FOREIGN KEY (`sales_order_type_id`) REFERENCES `sales_order_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sales_orders
-- ----------------------------

-- ----------------------------
-- Table structure for sales_person_journal_entries
-- ----------------------------
CREATE TABLE `sales_person_journal_entries`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` int UNSIGNED NOT NULL,
  `journal_entry_id` int UNSIGNED NOT NULL,
  `amount` double NULL DEFAULT NULL,
  `date` date NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sales_person_journal_entries_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sales_person_journal_entries_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sales_person_journal_entries_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sales_person_journal_entries_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sales_person_journal_entries_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_person_journal_entries_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_person_journal_entries_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_person_journal_entries_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sales_person_journal_entries
-- ----------------------------

-- ----------------------------
-- Table structure for sales_person_product_percentages
-- ----------------------------
CREATE TABLE `sales_person_product_percentages`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NULL DEFAULT NULL,
  `category_id` int UNSIGNED NULL DEFAULT NULL,
  `customer_main_account_id` int UNSIGNED NULL DEFAULT NULL,
  `from_date` date NULL DEFAULT NULL,
  `to_date` date NULL DEFAULT NULL,
  `percentage` double NULL DEFAULT NULL,
  `value` double NULL DEFAULT NULL,
  `value_above` double NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sales_person_product_percentages_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `sales_person_product_percentages_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sales_person_product_percentages_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sales_person_product_percentages_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sales_person_product_percentages_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sales_person_product_percentages_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_person_product_percentages_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_person_product_percentages_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_person_product_percentages_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_person_product_percentages_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sales_person_product_percentages
-- ----------------------------

-- ----------------------------
-- Table structure for sales_persons
-- ----------------------------
CREATE TABLE `sales_persons`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `sales_team_id` int UNSIGNED NOT NULL,
  `permission_id` int UNSIGNED NOT NULL,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `percentage` double UNSIGNED NULL DEFAULT NULL,
  `target` double UNSIGNED NULL DEFAULT NULL,
  `number_of_working_in_month` double UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sales_persons_sales_team_id_foreign`(`sales_team_id` ASC) USING BTREE,
  INDEX `sales_persons_permission_id_foreign`(`permission_id` ASC) USING BTREE,
  INDEX `sales_persons_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `sales_persons_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `sales_persons_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sales_persons_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sales_persons_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sales_persons_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sales_persons_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_persons_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_persons_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_persons_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_persons_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_persons_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_persons_sales_team_id_foreign` FOREIGN KEY (`sales_team_id`) REFERENCES `sales_teams` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_persons_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sales_persons
-- ----------------------------

-- ----------------------------
-- Table structure for sales_quotation_lines
-- ----------------------------
CREATE TABLE `sales_quotation_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `date` date NOT NULL,
  `expire_date` date NULL DEFAULT NULL,
  `sales_quotation_id` int UNSIGNED NOT NULL,
  `customer_id` int UNSIGNED NOT NULL,
  `sales_quotation_type_id` int UNSIGNED NOT NULL,
  `sales_quotation_state_id` int UNSIGNED NOT NULL,
  `sales_order_id` int UNSIGNED NULL DEFAULT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `price` double NOT NULL,
  `price_with_cost` double NULL DEFAULT NULL,
  `discount_percentage` double NULL DEFAULT NULL,
  `discount_value` double NULL DEFAULT NULL,
  `in_date_tax` double NULL DEFAULT NULL,
  `quantity` double UNSIGNED NOT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `default_currency` int UNSIGNED NOT NULL,
  `in_date_currency_rate` double NOT NULL,
  `total` double NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sales_quotation_lines_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `sales_quotation_lines_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `sales_quotation_lines_default_currency_foreign`(`default_currency` ASC) USING BTREE,
  INDEX `sales_quotation_lines_sales_quotation_id_foreign`(`sales_quotation_id` ASC) USING BTREE,
  INDEX `sales_quotation_lines_customer_id_foreign`(`customer_id` ASC) USING BTREE,
  INDEX `sales_quotation_lines_sales_quotation_type_id_foreign`(`sales_quotation_type_id` ASC) USING BTREE,
  INDEX `sales_quotation_lines_sales_quotation_state_id_foreign`(`sales_quotation_state_id` ASC) USING BTREE,
  INDEX `sales_quotation_lines_sales_order_id_foreign`(`sales_order_id` ASC) USING BTREE,
  INDEX `sales_quotation_lines_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `sales_quotation_lines_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `sales_quotation_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sales_quotation_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sales_quotation_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sales_quotation_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sales_quotation_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_lines_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_lines_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_lines_customer_id_foreign` FOREIGN KEY (`customer_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_lines_default_currency_foreign` FOREIGN KEY (`default_currency`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_lines_sales_order_id_foreign` FOREIGN KEY (`sales_order_id`) REFERENCES `sales_orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_lines_sales_quotation_id_foreign` FOREIGN KEY (`sales_quotation_id`) REFERENCES `sales_quotations` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_lines_sales_quotation_state_id_foreign` FOREIGN KEY (`sales_quotation_state_id`) REFERENCES `sales_quotation_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_lines_sales_quotation_type_id_foreign` FOREIGN KEY (`sales_quotation_type_id`) REFERENCES `sales_quotation_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_lines_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sales_quotation_lines
-- ----------------------------

-- ----------------------------
-- Table structure for sales_quotation_status
-- ----------------------------
CREATE TABLE `sales_quotation_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sales_quotation_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sales_quotation_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sales_quotation_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sales_quotation_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sales_quotation_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sales_quotation_status
-- ----------------------------
INSERT INTO `sales_quotation_status` VALUES (1, 'قيد الانشاء', '1', 'Pending', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `sales_quotation_status` VALUES (2, 'مرفوض', '2', 'Rejected', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `sales_quotation_status` VALUES (3, 'انتهت الصلاحية', '3', 'Expired', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `sales_quotation_status` VALUES (4, 'تم بنجاح', '4', 'Successed', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);

-- ----------------------------
-- Table structure for sales_quotation_types
-- ----------------------------
CREATE TABLE `sales_quotation_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `numbering_type_id` int UNSIGNED NOT NULL,
  `next_number` int UNSIGNED NULL DEFAULT NULL,
  `header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sales_quotation_types_numbering_type_id_foreign`(`numbering_type_id` ASC) USING BTREE,
  INDEX `sales_quotation_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sales_quotation_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sales_quotation_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sales_quotation_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sales_quotation_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotation_types_numbering_type_id_foreign` FOREIGN KEY (`numbering_type_id`) REFERENCES `numbering_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sales_quotation_types
-- ----------------------------
INSERT INTO `sales_quotation_types` VALUES (1, 'داخلي', '1', 'Local', 1, NULL, '\r\n            <div class=\"row\">\r\n                <div class=\"col-5 center\">\r\n                    <div class=\"bold\" style=\"font-size:30px\">اسم الشركة</div>\r\n                </div>\r\n                <div class=\"col-2 center\">\r\n                    <img width=\"180px\" height=\"100px\" src=\"https://softya.com/demo/public/storage/logo.png\" />\r\n                </div>\r\n                <div class=\"col-5 center\">\r\n                    <div class=\"bold\" style=\"font-size:30px\">Company name</div>\r\n                </div>\r\n            </div>\r\n        ', NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `sales_quotation_types` VALUES (2, 'مستورد', '2', 'External', 1, NULL, '\r\n            <div class=\"row\">\r\n                <div class=\"col-5 center\">\r\n                    <div class=\"bold\" style=\"font-size:30px\">اسم الشركة</div>\r\n                </div>\r\n                <div class=\"col-2 center\">\r\n                    <img width=\"180px\" height=\"100px\" src=\"https://softya.com/demo/public/storage/logo.png\" />\r\n                </div>\r\n                <div class=\"col-5 center\">\r\n                    <div class=\"bold\" style=\"font-size:30px\">Company name</div>\r\n                </div>\r\n            </div>\r\n        ', NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);

-- ----------------------------
-- Table structure for sales_quotations
-- ----------------------------
CREATE TABLE `sales_quotations`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `date` date NOT NULL,
  `expire_date` date NULL DEFAULT NULL,
  `sales_quotation_type_id` int UNSIGNED NOT NULL,
  `sales_quotation_state_id` int UNSIGNED NOT NULL,
  `customer_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `amount` double NULL DEFAULT NULL,
  `tax` double NULL DEFAULT NULL,
  `discount` double NULL DEFAULT NULL,
  `tax_state_id` int UNSIGNED NOT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `default_currency` int UNSIGNED NOT NULL,
  `in_date_currency_rate` double NOT NULL,
  `sales_order_id` int UNSIGNED NULL DEFAULT NULL,
  `journal_entry_id` int UNSIGNED NULL DEFAULT NULL,
  `price_offer_id` int UNSIGNED NULL DEFAULT NULL,
  `working_contract_id` int UNSIGNED NULL DEFAULT NULL,
  `sales_quotation_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sales_quotations_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `sales_quotations_tax_state_id_foreign`(`tax_state_id` ASC) USING BTREE,
  INDEX `sales_quotations_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `sales_quotations_default_currency_foreign`(`default_currency` ASC) USING BTREE,
  INDEX `sales_quotations_sales_quotation_type_id_foreign`(`sales_quotation_type_id` ASC) USING BTREE,
  INDEX `sales_quotations_sales_quotation_state_id_foreign`(`sales_quotation_state_id` ASC) USING BTREE,
  INDEX `sales_quotations_customer_id_foreign`(`customer_id` ASC) USING BTREE,
  INDEX `sales_quotations_sales_order_id_foreign`(`sales_order_id` ASC) USING BTREE,
  INDEX `sales_quotations_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sales_quotations_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sales_quotations_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sales_quotations_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sales_quotations_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotations_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotations_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotations_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotations_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotations_customer_id_foreign` FOREIGN KEY (`customer_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotations_default_currency_foreign` FOREIGN KEY (`default_currency`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotations_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotations_sales_order_id_foreign` FOREIGN KEY (`sales_order_id`) REFERENCES `sales_orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotations_sales_quotation_state_id_foreign` FOREIGN KEY (`sales_quotation_state_id`) REFERENCES `sales_quotation_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotations_sales_quotation_type_id_foreign` FOREIGN KEY (`sales_quotation_type_id`) REFERENCES `sales_quotation_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_quotations_tax_state_id_foreign` FOREIGN KEY (`tax_state_id`) REFERENCES `tax_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sales_quotations
-- ----------------------------

-- ----------------------------
-- Table structure for sales_settings
-- ----------------------------
CREATE TABLE `sales_settings`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `sales_quotations_header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `sales_quotations_footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `price_offers_header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `price_offers_footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sales_settings_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sales_settings_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sales_settings_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sales_settings_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sales_settings_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_settings_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_settings_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_settings_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sales_settings
-- ----------------------------
INSERT INTO `sales_settings` VALUES (1, '', '', '', '', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:58', '2025-06-12 14:05:58', NULL);

-- ----------------------------
-- Table structure for sales_teams
-- ----------------------------
CREATE TABLE `sales_teams`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `sales_team_id` int UNSIGNED NULL DEFAULT NULL,
  `main_child_zeros` int NULL DEFAULT NULL,
  `main_child_counter` int NULL DEFAULT NULL,
  `sub_child_zeros` int NULL DEFAULT NULL,
  `sub_child_counter` int NULL DEFAULT NULL,
  `branch_id` int NULL DEFAULT NULL,
  `percentage` double UNSIGNED NULL DEFAULT NULL,
  `target` double UNSIGNED NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sales_teams_sales_team_id_foreign`(`sales_team_id` ASC) USING BTREE,
  INDEX `sales_teams_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sales_teams_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sales_teams_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sales_teams_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sales_teams_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_teams_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_teams_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_teams_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_teams_sales_team_id_foreign` FOREIGN KEY (`sales_team_id`) REFERENCES `sales_teams` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sales_teams
-- ----------------------------
INSERT INTO `sales_teams` VALUES (1, 'فريق مبيعات اثاث', 'Sales team 1', '1', NULL, 10, NULL, 1000, NULL, 1, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);
INSERT INTO `sales_teams` VALUES (2, 'فريق مبيعات مباني', 'Sales team 2', '2', NULL, 10, NULL, 1000, NULL, 1, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);

-- ----------------------------
-- Table structure for searchable_categories
-- ----------------------------
CREATE TABLE `searchable_categories`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `product_category_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `searchable_categories_product_category_id_foreign`(`product_category_id` ASC) USING BTREE,
  INDEX `searchable_categories_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `searchable_categories_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `searchable_categories_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `searchable_categories_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `searchable_categories_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `searchable_categories_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `searchable_categories_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `searchable_categories_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `searchable_categories_product_category_id_foreign` FOREIGN KEY (`product_category_id`) REFERENCES `product_categories` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of searchable_categories
-- ----------------------------

-- ----------------------------
-- Table structure for second_cost_centers
-- ----------------------------
CREATE TABLE `second_cost_centers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `second_cost_center_id` int UNSIGNED NULL DEFAULT NULL,
  `main_child_zeros` int NULL DEFAULT NULL,
  `main_child_counter` int NULL DEFAULT NULL,
  `sub_child_zeros` int NULL DEFAULT NULL,
  `sub_child_counter` int NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `second_cost_centers_second_cost_center_id_foreign`(`second_cost_center_id` ASC) USING BTREE,
  INDEX `second_cost_centers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `second_cost_centers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `second_cost_centers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `second_cost_centers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `second_cost_centers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `second_cost_centers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `second_cost_centers_second_cost_center_id_foreign` FOREIGN KEY (`second_cost_center_id`) REFERENCES `second_cost_centers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of second_cost_centers
-- ----------------------------

-- ----------------------------
-- Table structure for sell_cost_types
-- ----------------------------
CREATE TABLE `sell_cost_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sell_cost_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sell_cost_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sell_cost_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sell_cost_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sell_cost_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sell_cost_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sell_cost_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sell_cost_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sell_cost_types
-- ----------------------------
INSERT INTO `sell_cost_types` VALUES (1, 'بيع', '1', 'Sell', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:05', '2025-06-12 14:06:05', NULL);
INSERT INTO `sell_cost_types` VALUES (2, 'كلفة', '1', 'Cost', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:05', '2025-06-12 14:06:05', NULL);

-- ----------------------------
-- Table structure for shabak_types
-- ----------------------------
CREATE TABLE `shabak_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `shabak_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `shabak_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `shabak_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `shabak_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `shabak_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shabak_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shabak_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shabak_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of shabak_types
-- ----------------------------

-- ----------------------------
-- Table structure for shift_holidays
-- ----------------------------
CREATE TABLE `shift_holidays`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` int UNSIGNED NULL DEFAULT NULL,
  `shift_id` int UNSIGNED NOT NULL,
  `holiday_id` int UNSIGNED NOT NULL,
  `date` date NULL DEFAULT NULL,
  `from_date` date NULL DEFAULT NULL,
  `to_date` date NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `shift_holidays_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `shift_holidays_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `shift_holidays_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `shift_holidays_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `shift_holidays_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shift_holidays_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shift_holidays_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shift_holidays_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of shift_holidays
-- ----------------------------

-- ----------------------------
-- Table structure for shifts
-- ----------------------------
CREATE TABLE `shifts`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `forgiving_check_in` double NULL DEFAULT NULL,
  `forgiving_check_out` double NULL DEFAULT NULL,
  `overtime_state` int UNSIGNED NOT NULL,
  `start_count_overtime_after` double NOT NULL,
  `overtime_percentage` double NOT NULL,
  `late_percentage` double NOT NULL,
  `holiday_percentage` double NOT NULL,
  `missed_percentage` double NOT NULL,
  `working_hours_in_day` double NOT NULL,
  `days_in_month` double NOT NULL,
  `saturday_state` int UNSIGNED NOT NULL,
  `saturday_start` time NOT NULL,
  `saturday_end` time NOT NULL,
  `sunday_state` int UNSIGNED NOT NULL,
  `sunday_start` time NOT NULL,
  `sunday_end` time NOT NULL,
  `monday_state` int UNSIGNED NOT NULL,
  `monday_start` time NOT NULL,
  `monday_end` time NOT NULL,
  `tuesday_state` int UNSIGNED NOT NULL,
  `tuesday_start` time NOT NULL,
  `tuesday_end` time NOT NULL,
  `wednesday_state` int UNSIGNED NOT NULL,
  `wednesday_start` time NOT NULL,
  `wednesday_end` time NOT NULL,
  `thursday_state` int UNSIGNED NOT NULL,
  `thursday_start` time NOT NULL,
  `thursday_end` time NOT NULL,
  `friday_state` int UNSIGNED NOT NULL,
  `friday_start` time NOT NULL,
  `friday_end` time NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `shifts_overtime_state_foreign`(`overtime_state` ASC) USING BTREE,
  INDEX `shifts_saturday_state_foreign`(`saturday_state` ASC) USING BTREE,
  INDEX `shifts_sunday_state_foreign`(`sunday_state` ASC) USING BTREE,
  INDEX `shifts_monday_state_foreign`(`monday_state` ASC) USING BTREE,
  INDEX `shifts_tuesday_state_foreign`(`tuesday_state` ASC) USING BTREE,
  INDEX `shifts_wednesday_state_foreign`(`wednesday_state` ASC) USING BTREE,
  INDEX `shifts_thursday_state_foreign`(`thursday_state` ASC) USING BTREE,
  INDEX `shifts_friday_state_foreign`(`friday_state` ASC) USING BTREE,
  INDEX `shifts_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `shifts_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `shifts_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `shifts_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `shifts_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shifts_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shifts_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shifts_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shifts_friday_state_foreign` FOREIGN KEY (`friday_state`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shifts_monday_state_foreign` FOREIGN KEY (`monday_state`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shifts_overtime_state_foreign` FOREIGN KEY (`overtime_state`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shifts_saturday_state_foreign` FOREIGN KEY (`saturday_state`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shifts_sunday_state_foreign` FOREIGN KEY (`sunday_state`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shifts_thursday_state_foreign` FOREIGN KEY (`thursday_state`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shifts_tuesday_state_foreign` FOREIGN KEY (`tuesday_state`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shifts_wednesday_state_foreign` FOREIGN KEY (`wednesday_state`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of shifts
-- ----------------------------
INSERT INTO `shifts` VALUES (1, 'وردية 1', '1', 'Shift 1', 10, 10, 1, 20, 1.25, 1.25, 2, 1.5, 8, 30, 1, '08:00:00', '16:00:00', 1, '08:00:00', '16:00:00', 1, '08:00:00', '16:00:00', 1, '08:00:00', '16:00:00', 1, '08:00:00', '16:00:00', 1, '08:00:00', '16:00:00', 1, '08:00:00', '16:00:00', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);

-- ----------------------------
-- Table structure for shipping_banks
-- ----------------------------
CREATE TABLE `shipping_banks`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `account_user_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `shipping_banks_account_user_id_foreign`(`account_user_id` ASC) USING BTREE,
  INDEX `shipping_banks_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `shipping_banks_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `shipping_banks_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `shipping_banks_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `shipping_banks_account_user_id_foreign` FOREIGN KEY (`account_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_banks_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_banks_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_banks_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_banks_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of shipping_banks
-- ----------------------------

-- ----------------------------
-- Table structure for shipping_companies
-- ----------------------------
CREATE TABLE `shipping_companies`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `account_user_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `shipping_companies_account_user_id_foreign`(`account_user_id` ASC) USING BTREE,
  INDEX `shipping_companies_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `shipping_companies_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `shipping_companies_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `shipping_companies_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `shipping_companies_account_user_id_foreign` FOREIGN KEY (`account_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_companies_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_companies_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_companies_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_companies_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of shipping_companies
-- ----------------------------

-- ----------------------------
-- Table structure for shipping_expenses_types
-- ----------------------------
CREATE TABLE `shipping_expenses_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `account_user_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `shipping_expenses_types_account_user_id_foreign`(`account_user_id` ASC) USING BTREE,
  INDEX `shipping_expenses_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `shipping_expenses_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `shipping_expenses_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `shipping_expenses_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `shipping_expenses_types_account_user_id_foreign` FOREIGN KEY (`account_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_expenses_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_expenses_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_expenses_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_expenses_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of shipping_expenses_types
-- ----------------------------

-- ----------------------------
-- Table structure for shipping_income_types
-- ----------------------------
CREATE TABLE `shipping_income_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `account_user_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `shipping_income_types_account_user_id_foreign`(`account_user_id` ASC) USING BTREE,
  INDEX `shipping_income_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `shipping_income_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `shipping_income_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `shipping_income_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `shipping_income_types_account_user_id_foreign` FOREIGN KEY (`account_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_income_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_income_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_income_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_income_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of shipping_income_types
-- ----------------------------

-- ----------------------------
-- Table structure for shipping_invoice_groups
-- ----------------------------
CREATE TABLE `shipping_invoice_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `shipping_invoice_group_id` int UNSIGNED NULL DEFAULT NULL,
  `main_child_zeros` int NULL DEFAULT NULL,
  `main_child_counter` int NULL DEFAULT NULL,
  `sub_child_zeros` int NULL DEFAULT NULL,
  `sub_child_counter` int NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `shipping_invoice_groups_shipping_invoice_group_id_foreign`(`shipping_invoice_group_id` ASC) USING BTREE,
  INDEX `shipping_invoice_groups_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `shipping_invoice_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `shipping_invoice_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `shipping_invoice_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `shipping_invoice_groups_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_groups_shipping_invoice_group_id_foreign` FOREIGN KEY (`shipping_invoice_group_id`) REFERENCES `shipping_invoice_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of shipping_invoice_groups
-- ----------------------------

-- ----------------------------
-- Table structure for shipping_invoice_lines
-- ----------------------------
CREATE TABLE `shipping_invoice_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `sell_cost_type_id` int UNSIGNED NOT NULL,
  `customer_user_id` int UNSIGNED NOT NULL,
  `shipping_invoice_id` int UNSIGNED NOT NULL,
  `shipping_expenses_type_id` int UNSIGNED NULL DEFAULT NULL,
  `shipping_income_type_id` int UNSIGNED NULL DEFAULT NULL,
  `journal_entry_id` int UNSIGNED NULL DEFAULT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `default_currency_id` int UNSIGNED NOT NULL,
  `date` date NULL DEFAULT NULL,
  `amount` double UNSIGNED NOT NULL,
  `in_date_currency_rate` double UNSIGNED NOT NULL,
  `product` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `shipping_invoice_lines_customer_user_id_foreign`(`customer_user_id` ASC) USING BTREE,
  INDEX `shipping_invoice_lines_sell_cost_type_id_foreign`(`sell_cost_type_id` ASC) USING BTREE,
  INDEX `shipping_invoice_lines_shipping_invoice_id_foreign`(`shipping_invoice_id` ASC) USING BTREE,
  INDEX `shipping_invoice_lines_shipping_expenses_type_id_foreign`(`shipping_expenses_type_id` ASC) USING BTREE,
  INDEX `shipping_invoice_lines_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `shipping_invoice_lines_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `shipping_invoice_lines_default_currency_id_foreign`(`default_currency_id` ASC) USING BTREE,
  INDEX `shipping_invoice_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `shipping_invoice_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `shipping_invoice_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `shipping_invoice_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `shipping_invoice_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_lines_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_lines_customer_user_id_foreign` FOREIGN KEY (`customer_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_lines_default_currency_id_foreign` FOREIGN KEY (`default_currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_lines_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_lines_sell_cost_type_id_foreign` FOREIGN KEY (`sell_cost_type_id`) REFERENCES `sell_cost_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_lines_shipping_expenses_type_id_foreign` FOREIGN KEY (`shipping_expenses_type_id`) REFERENCES `shipping_expenses_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_lines_shipping_invoice_id_foreign` FOREIGN KEY (`shipping_invoice_id`) REFERENCES `shipping_invoices` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of shipping_invoice_lines
-- ----------------------------

-- ----------------------------
-- Table structure for shipping_invoice_status
-- ----------------------------
CREATE TABLE `shipping_invoice_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `shipping_invoice_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `shipping_invoice_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `shipping_invoice_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `shipping_invoice_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `shipping_invoice_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoice_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of shipping_invoice_status
-- ----------------------------
INSERT INTO `shipping_invoice_status` VALUES (1, 'جديد', '1', 'New', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:05', '2025-06-12 14:06:05', NULL);
INSERT INTO `shipping_invoice_status` VALUES (2, 'ملغي', '2', 'Canceled', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:05', '2025-06-12 14:06:05', NULL);
INSERT INTO `shipping_invoice_status` VALUES (3, 'تم بنجاح', '3', 'Successful', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:05', '2025-06-12 14:06:05', NULL);
INSERT INTO `shipping_invoice_status` VALUES (4, 'موقوف', '4', 'Pending', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:05', '2025-06-12 14:06:05', NULL);

-- ----------------------------
-- Table structure for shipping_invoices
-- ----------------------------
CREATE TABLE `shipping_invoices`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `date` date NOT NULL,
  `estimated_time_of_arrival` date NULL DEFAULT NULL,
  `acutal_time_of_arrival` date NULL DEFAULT NULL,
  `weight_gross` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `shipping_invoice_group_id` int UNSIGNED NOT NULL,
  `import_export_type_id` int UNSIGNED NOT NULL,
  `customer_user_id` int UNSIGNED NOT NULL,
  `sales_person_id` int UNSIGNED NULL DEFAULT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `default_currency_id` int UNSIGNED NOT NULL,
  `mbl_type_id` int UNSIGNED NOT NULL,
  `from_country_id` int UNSIGNED NOT NULL,
  `to_country_id` int UNSIGNED NOT NULL,
  `shipping_invoice_state_id` int UNSIGNED NOT NULL,
  `shipping_bank_id` int UNSIGNED NULL DEFAULT NULL,
  `journal_entry_id` int UNSIGNED NULL DEFAULT NULL,
  `in_date_currency_rate` double UNSIGNED NOT NULL,
  `mbl_type_first_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `mbl_type_second_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `weight_volume` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `number_of_boxs` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `job_file_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `customer_reference` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `containers_numbers` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `declaration_numbers` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `shipping_invoices_shipping_invoice_group_id_foreign`(`shipping_invoice_group_id` ASC) USING BTREE,
  INDEX `shipping_invoices_import_export_type_id_foreign`(`import_export_type_id` ASC) USING BTREE,
  INDEX `shipping_invoices_customer_user_id_foreign`(`customer_user_id` ASC) USING BTREE,
  INDEX `shipping_invoices_sales_person_id_foreign`(`sales_person_id` ASC) USING BTREE,
  INDEX `shipping_invoices_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `shipping_invoices_default_currency_id_foreign`(`default_currency_id` ASC) USING BTREE,
  INDEX `shipping_invoices_mbl_type_id_foreign`(`mbl_type_id` ASC) USING BTREE,
  INDEX `shipping_invoices_from_country_id_foreign`(`from_country_id` ASC) USING BTREE,
  INDEX `shipping_invoices_to_country_id_foreign`(`to_country_id` ASC) USING BTREE,
  INDEX `shipping_invoices_shipping_invoice_state_id_foreign`(`shipping_invoice_state_id` ASC) USING BTREE,
  INDEX `shipping_invoices_shipping_bank_id_foreign`(`shipping_bank_id` ASC) USING BTREE,
  INDEX `shipping_invoices_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `shipping_invoices_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `shipping_invoices_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `shipping_invoices_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `shipping_invoices_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `shipping_invoices_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoices_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoices_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoices_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoices_customer_user_id_foreign` FOREIGN KEY (`customer_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoices_default_currency_id_foreign` FOREIGN KEY (`default_currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoices_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoices_from_country_id_foreign` FOREIGN KEY (`from_country_id`) REFERENCES `countries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoices_import_export_type_id_foreign` FOREIGN KEY (`import_export_type_id`) REFERENCES `import_export_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoices_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoices_mbl_type_id_foreign` FOREIGN KEY (`mbl_type_id`) REFERENCES `mbl_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoices_sales_person_id_foreign` FOREIGN KEY (`sales_person_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoices_shipping_bank_id_foreign` FOREIGN KEY (`shipping_bank_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoices_shipping_invoice_group_id_foreign` FOREIGN KEY (`shipping_invoice_group_id`) REFERENCES `shipping_invoice_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoices_shipping_invoice_state_id_foreign` FOREIGN KEY (`shipping_invoice_state_id`) REFERENCES `shipping_invoice_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `shipping_invoices_to_country_id_foreign` FOREIGN KEY (`to_country_id`) REFERENCES `countries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of shipping_invoices
-- ----------------------------

-- ----------------------------
-- Table structure for signatures_on_models
-- ----------------------------
CREATE TABLE `signatures_on_models`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `model_id` int UNSIGNED NULL DEFAULT NULL,
  `subject_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `signatures_on_models_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `signatures_on_models_model_id_foreign`(`model_id` ASC) USING BTREE,
  INDEX `signatures_on_models_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `signatures_on_models_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `signatures_on_models_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `signatures_on_models_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `signatures_on_models_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `signatures_on_models_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `signatures_on_models_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `signatures_on_models_model_id_foreign` FOREIGN KEY (`model_id`) REFERENCES `models` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of signatures_on_models
-- ----------------------------
INSERT INTO `signatures_on_models` VALUES (1, 38, 359, 'عوني عيسى الطباخي', 71, NULL, NULL, NULL, NULL, '2025-07-14 09:41:36', '2025-07-14 09:41:36', NULL);
INSERT INTO `signatures_on_models` VALUES (2, 38, 422, NULL, 71, NULL, NULL, NULL, NULL, '2025-07-16 10:50:52', '2025-07-16 10:50:52', NULL);
INSERT INTO `signatures_on_models` VALUES (3, 38, 422, 'عوني الطباخي', 71, NULL, NULL, NULL, NULL, '2025-07-16 10:53:24', '2025-07-16 10:53:24', NULL);

-- ----------------------------
-- Table structure for slow_moving_products
-- ----------------------------
CREATE TABLE `slow_moving_products`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `warehouse_id` int UNSIGNED NOT NULL,
  `number_of_days` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `slow_moving_products_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `slow_moving_products_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `slow_moving_products_warehouse_id_foreign`(`warehouse_id` ASC) USING BTREE,
  INDEX `slow_moving_products_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `slow_moving_products_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `slow_moving_products_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `slow_moving_products_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `slow_moving_products_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `slow_moving_products_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `slow_moving_products_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `slow_moving_products_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `slow_moving_products_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `slow_moving_products_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `slow_moving_products_warehouse_id_foreign` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouses` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of slow_moving_products
-- ----------------------------

-- ----------------------------
-- Table structure for sms_list_numbers
-- ----------------------------
CREATE TABLE `sms_list_numbers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `sms_list_id` int UNSIGNED NOT NULL,
  `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `state_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sms_list_numbers_state_id_foreign`(`state_id` ASC) USING BTREE,
  INDEX `sms_list_numbers_sms_list_id_foreign`(`sms_list_id` ASC) USING BTREE,
  INDEX `sms_list_numbers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sms_list_numbers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sms_list_numbers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sms_list_numbers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sms_list_numbers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sms_list_numbers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sms_list_numbers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sms_list_numbers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sms_list_numbers_sms_list_id_foreign` FOREIGN KEY (`sms_list_id`) REFERENCES `sms_lists` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sms_list_numbers_state_id_foreign` FOREIGN KEY (`state_id`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sms_list_numbers
-- ----------------------------

-- ----------------------------
-- Table structure for sms_lists
-- ----------------------------
CREATE TABLE `sms_lists`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `main_child_zeros` int UNSIGNED NOT NULL,
  `main_child_counter` int NULL DEFAULT NULL,
  `sms_list_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sms_lists_sms_list_id_foreign`(`sms_list_id` ASC) USING BTREE,
  INDEX `sms_lists_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sms_lists_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sms_lists_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sms_lists_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sms_lists_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sms_lists_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sms_lists_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sms_lists_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sms_lists_sms_list_id_foreign` FOREIGN KEY (`sms_list_id`) REFERENCES `sms_lists` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sms_lists
-- ----------------------------

-- ----------------------------
-- Table structure for sms_marketing_settings
-- ----------------------------
CREATE TABLE `sms_marketing_settings`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `releans_api_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `releans_api_from_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `sms_provider_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sms_marketing_settings_sms_provider_id_foreign`(`sms_provider_id` ASC) USING BTREE,
  INDEX `sms_marketing_settings_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sms_marketing_settings_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sms_marketing_settings_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sms_marketing_settings_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sms_marketing_settings_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sms_marketing_settings_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sms_marketing_settings_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sms_marketing_settings_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sms_marketing_settings_sms_provider_id_foreign` FOREIGN KEY (`sms_provider_id`) REFERENCES `sms_providers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sms_marketing_settings
-- ----------------------------
INSERT INTO `sms_marketing_settings` VALUES (1, '321a6f1d70ef92c10128237d95906762', 'Awad', 1, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);

-- ----------------------------
-- Table structure for sms_providers
-- ----------------------------
CREATE TABLE `sms_providers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sms_providers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `sms_providers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `sms_providers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `sms_providers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `sms_providers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sms_providers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sms_providers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sms_providers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sms_providers
-- ----------------------------
INSERT INTO `sms_providers` VALUES (1, 'Releans', '1', 'Releans', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);

-- ----------------------------
-- Table structure for stage_users
-- ----------------------------
CREATE TABLE `stage_users`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `stage_id` int UNSIGNED NOT NULL,
  `user_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `stage_users_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `stage_users_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `stage_users_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `stage_users_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `stage_users_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stage_users_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stage_users_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stage_users_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of stage_users
-- ----------------------------

-- ----------------------------
-- Table structure for stages
-- ----------------------------
CREATE TABLE `stages`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `rank` int NULL DEFAULT NULL,
  `total_expected_revenue` double NULL DEFAULT NULL,
  `next_stage_id` int UNSIGNED NULL DEFAULT NULL,
  `is_won` int UNSIGNED NULL DEFAULT NULL,
  `sales_team_id` int UNSIGNED NULL DEFAULT NULL,
  `price_offer_is_required` int UNSIGNED NULL DEFAULT NULL,
  `without_journal_entires` int UNSIGNED NULL DEFAULT NULL,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `has_coupon` int UNSIGNED NULL DEFAULT NULL,
  `coupon` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `email_as_notification` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `number_of_days_to_notification` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `requirements` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `stages_price_offer_is_required_foreign`(`price_offer_is_required` ASC) USING BTREE,
  INDEX `stages_without_journal_entires_foreign`(`without_journal_entires` ASC) USING BTREE,
  INDEX `stages_next_stage_id_foreign`(`next_stage_id` ASC) USING BTREE,
  INDEX `stages_is_won_foreign`(`is_won` ASC) USING BTREE,
  INDEX `stages_sales_team_id_foreign`(`sales_team_id` ASC) USING BTREE,
  INDEX `stages_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `stages_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `stages_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `stages_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `stages_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `stages_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stages_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stages_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stages_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stages_is_won_foreign` FOREIGN KEY (`is_won`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stages_next_stage_id_foreign` FOREIGN KEY (`next_stage_id`) REFERENCES `stages` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stages_price_offer_is_required_foreign` FOREIGN KEY (`price_offer_is_required`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stages_sales_team_id_foreign` FOREIGN KEY (`sales_team_id`) REFERENCES `sales_teams` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stages_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stages_without_journal_entires_foreign` FOREIGN KEY (`without_journal_entires`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of stages
-- ----------------------------

-- ----------------------------
-- Table structure for status
-- ----------------------------
CREATE TABLE `status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of status
-- ----------------------------
INSERT INTO `status` VALUES (1, 'فعال', 'active', '1', 1, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);
INSERT INTO `status` VALUES (2, 'غير فعال', 'deactivate', '2', 1, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);

-- ----------------------------
-- Table structure for stocktaking_lines
-- ----------------------------
CREATE TABLE `stocktaking_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `stocktaking_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `quantity` int NOT NULL,
  `date` date NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `note_voucher_line_id` int NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `stocktaking_lines_stocktaking_id_foreign`(`stocktaking_id` ASC) USING BTREE,
  INDEX `stocktaking_lines_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `stocktaking_lines_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `stocktaking_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `stocktaking_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `stocktaking_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `stocktaking_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `stocktaking_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktaking_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktaking_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktaking_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktaking_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktaking_lines_stocktaking_id_foreign` FOREIGN KEY (`stocktaking_id`) REFERENCES `stocktakings` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktaking_lines_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of stocktaking_lines
-- ----------------------------

-- ----------------------------
-- Table structure for stocktaking_note_vouchers
-- ----------------------------
CREATE TABLE `stocktaking_note_vouchers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `stocktaking_id` int UNSIGNED NOT NULL,
  `note_voucher_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `stocktaking_note_vouchers_stocktaking_id_foreign`(`stocktaking_id` ASC) USING BTREE,
  INDEX `stocktaking_note_vouchers_note_voucher_id_foreign`(`note_voucher_id` ASC) USING BTREE,
  INDEX `stocktaking_note_vouchers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `stocktaking_note_vouchers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `stocktaking_note_vouchers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `stocktaking_note_vouchers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `stocktaking_note_vouchers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktaking_note_vouchers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktaking_note_vouchers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktaking_note_vouchers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktaking_note_vouchers_note_voucher_id_foreign` FOREIGN KEY (`note_voucher_id`) REFERENCES `note_vouchers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktaking_note_vouchers_stocktaking_id_foreign` FOREIGN KEY (`stocktaking_id`) REFERENCES `stocktakings` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of stocktaking_note_vouchers
-- ----------------------------

-- ----------------------------
-- Table structure for stocktakings
-- ----------------------------
CREATE TABLE `stocktakings`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `warehouse_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `zero_ather_values` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `stocktakings_warehouse_id_foreign`(`warehouse_id` ASC) USING BTREE,
  INDEX `stocktakings_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `stocktakings_zero_ather_values_foreign`(`zero_ather_values` ASC) USING BTREE,
  INDEX `stocktakings_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `stocktakings_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `stocktakings_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `stocktakings_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `stocktakings_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktakings_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktakings_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktakings_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktakings_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktakings_warehouse_id_foreign` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouses` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `stocktakings_zero_ather_values_foreign` FOREIGN KEY (`zero_ather_values`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of stocktakings
-- ----------------------------

-- ----------------------------
-- Table structure for student_attendance_types
-- ----------------------------
CREATE TABLE `student_attendance_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `student_attendance_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `student_attendance_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `student_attendance_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `student_attendance_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `student_attendance_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_attendance_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_attendance_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_attendance_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of student_attendance_types
-- ----------------------------
INSERT INTO `student_attendance_types` VALUES (1, 'حضور', '1', 'Present', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:55', '2025-06-12 14:05:55', NULL);
INSERT INTO `student_attendance_types` VALUES (2, 'غائب', '2', 'Absent', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:55', '2025-06-12 14:05:55', NULL);
INSERT INTO `student_attendance_types` VALUES (3, 'متأخر', '3', 'Late', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:55', '2025-06-12 14:05:55', NULL);
INSERT INTO `student_attendance_types` VALUES (4, 'تأخر مع عذر', '4', 'Late with excuse', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:55', '2025-06-12 14:05:55', NULL);
INSERT INTO `student_attendance_types` VALUES (5, 'انصراف باكر', '5', 'Early Dismissal', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:55', '2025-06-12 14:05:55', NULL);

-- ----------------------------
-- Table structure for student_attendances
-- ----------------------------
CREATE TABLE `student_attendances`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `student_user_id` int UNSIGNED NOT NULL,
  `class_id` int UNSIGNED NOT NULL,
  `student_attendance_type_id` int UNSIGNED NOT NULL,
  `rank` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `student_attendances_student_user_id_foreign`(`student_user_id` ASC) USING BTREE,
  INDEX `student_attendances_class_id_foreign`(`class_id` ASC) USING BTREE,
  INDEX `student_attendances_student_attendance_type_id_foreign`(`student_attendance_type_id` ASC) USING BTREE,
  INDEX `student_attendances_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `student_attendances_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `student_attendances_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `student_attendances_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `student_attendances_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_attendances_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_attendances_class_id_foreign` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_attendances_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_attendances_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_attendances_student_attendance_type_id_foreign` FOREIGN KEY (`student_attendance_type_id`) REFERENCES `student_attendance_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_attendances_student_user_id_foreign` FOREIGN KEY (`student_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of student_attendances
-- ----------------------------

-- ----------------------------
-- Table structure for student_classes
-- ----------------------------
CREATE TABLE `student_classes`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `student_user_id` int UNSIGNED NOT NULL,
  `class_id` int UNSIGNED NOT NULL,
  `from_date` date NULL DEFAULT NULL,
  `to_date` date NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `student_classes_student_user_id_foreign`(`student_user_id` ASC) USING BTREE,
  INDEX `student_classes_class_id_foreign`(`class_id` ASC) USING BTREE,
  INDEX `student_classes_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `student_classes_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `student_classes_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `student_classes_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `student_classes_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_classes_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_classes_class_id_foreign` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_classes_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_classes_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_classes_student_user_id_foreign` FOREIGN KEY (`student_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of student_classes
-- ----------------------------

-- ----------------------------
-- Table structure for student_exams
-- ----------------------------
CREATE TABLE `student_exams`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `online_exam_id` int UNSIGNED NOT NULL,
  `question_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `student_exams_online_exam_id_foreign`(`online_exam_id` ASC) USING BTREE,
  INDEX `student_exams_question_id_foreign`(`question_id` ASC) USING BTREE,
  INDEX `student_exams_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `student_exams_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `student_exams_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `student_exams_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `student_exams_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_exams_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_exams_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_exams_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_exams_online_exam_id_foreign` FOREIGN KEY (`online_exam_id`) REFERENCES `online_exams` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_exams_question_id_foreign` FOREIGN KEY (`question_id`) REFERENCES `questions` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of student_exams
-- ----------------------------

-- ----------------------------
-- Table structure for student_groups
-- ----------------------------
CREATE TABLE `student_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `main_child_zeros` double NULL DEFAULT 10,
  `main_child_counter` double NULL DEFAULT NULL,
  `sub_child_zeros` double NULL DEFAULT 1000,
  `sub_child_counter` double NULL DEFAULT NULL,
  `student_group_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `student_groups_student_group_id_foreign`(`student_group_id` ASC) USING BTREE,
  INDEX `student_groups_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `student_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `student_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `student_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `student_groups_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_groups_student_group_id_foreign` FOREIGN KEY (`student_group_id`) REFERENCES `student_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of student_groups
-- ----------------------------
INSERT INTO `student_groups` VALUES (1, 'ابتدائي', '1', NULL, 10, NULL, 1000, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:55', '2025-06-12 14:05:55', NULL);
INSERT INTO `student_groups` VALUES (2, 'اعدادي', '2', NULL, 10, NULL, 100, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:55', '2025-06-12 14:05:55', NULL);
INSERT INTO `student_groups` VALUES (3, 'ثانوي', '3', NULL, 10, NULL, 100, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:55', '2025-06-12 14:05:55', NULL);

-- ----------------------------
-- Table structure for student_homework_results
-- ----------------------------
CREATE TABLE `student_homework_results`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `student_user_id` int UNSIGNED NOT NULL,
  `student_homework_id` int UNSIGNED NOT NULL,
  `value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `date` date NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `student_homework_results_student_user_id_foreign`(`student_user_id` ASC) USING BTREE,
  INDEX `student_homework_results_student_homework_id_foreign`(`student_homework_id` ASC) USING BTREE,
  INDEX `student_homework_results_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `student_homework_results_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `student_homework_results_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `student_homework_results_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `student_homework_results_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_homework_results_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_homework_results_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_homework_results_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_homework_results_student_homework_id_foreign` FOREIGN KEY (`student_homework_id`) REFERENCES `student_homeworks` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_homework_results_student_user_id_foreign` FOREIGN KEY (`student_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of student_homework_results
-- ----------------------------

-- ----------------------------
-- Table structure for student_homeworks
-- ----------------------------
CREATE TABLE `student_homeworks`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `submission_date` date NOT NULL,
  `end_submission_date` date NOT NULL,
  `class_id` int UNSIGNED NOT NULL,
  `subject_id` int UNSIGNED NOT NULL,
  `student_user_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `student_homeworks_class_id_foreign`(`class_id` ASC) USING BTREE,
  INDEX `student_homeworks_subject_id_foreign`(`subject_id` ASC) USING BTREE,
  INDEX `student_homeworks_student_user_id_foreign`(`student_user_id` ASC) USING BTREE,
  INDEX `student_homeworks_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `student_homeworks_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `student_homeworks_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `student_homeworks_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `student_homeworks_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_homeworks_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_homeworks_class_id_foreign` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_homeworks_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_homeworks_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_homeworks_student_user_id_foreign` FOREIGN KEY (`student_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `student_homeworks_subject_id_foreign` FOREIGN KEY (`subject_id`) REFERENCES `subjects` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of student_homeworks
-- ----------------------------

-- ----------------------------
-- Table structure for students
-- ----------------------------
CREATE TABLE `students`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `religion` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `national_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `biometric_id` int NULL DEFAULT NULL,
  `gender_id` int UNSIGNED NOT NULL,
  `student_group_id` int UNSIGNED NOT NULL,
  `user_id` int UNSIGNED NOT NULL,
  `class_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `students_gender_id_foreign`(`gender_id` ASC) USING BTREE,
  INDEX `students_student_group_id_foreign`(`student_group_id` ASC) USING BTREE,
  INDEX `students_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `students_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `students_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `students_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `students_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `students_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `students_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `students_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `students_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `students_gender_id_foreign` FOREIGN KEY (`gender_id`) REFERENCES `genders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `students_student_group_id_foreign` FOREIGN KEY (`student_group_id`) REFERENCES `student_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `students_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of students
-- ----------------------------

-- ----------------------------
-- Table structure for subject_groups
-- ----------------------------
CREATE TABLE `subject_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `main_child_zeros` double NULL DEFAULT 10,
  `main_child_counter` double NULL DEFAULT NULL,
  `sub_child_zeros` double NULL DEFAULT 1000,
  `sub_child_counter` double NULL DEFAULT NULL,
  `subject_group_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `subject_groups_subject_group_id_foreign`(`subject_group_id` ASC) USING BTREE,
  INDEX `subject_groups_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `subject_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `subject_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `subject_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `subject_groups_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subject_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subject_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subject_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subject_groups_subject_group_id_foreign` FOREIGN KEY (`subject_group_id`) REFERENCES `subject_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of subject_groups
-- ----------------------------
INSERT INTO `subject_groups` VALUES (1, 'العواشر', '1', NULL, 10, NULL, 1000, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:54', '2025-06-12 14:05:54', NULL);

-- ----------------------------
-- Table structure for subject_teachers
-- ----------------------------
CREATE TABLE `subject_teachers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `subject_id` int UNSIGNED NOT NULL,
  `teacher_user_id` int UNSIGNED NOT NULL,
  `class_id` int UNSIGNED NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `subject_teachers_subject_id_foreign`(`subject_id` ASC) USING BTREE,
  INDEX `subject_teachers_teacher_user_id_foreign`(`teacher_user_id` ASC) USING BTREE,
  INDEX `subject_teachers_class_id_foreign`(`class_id` ASC) USING BTREE,
  INDEX `subject_teachers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `subject_teachers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `subject_teachers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `subject_teachers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `subject_teachers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subject_teachers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subject_teachers_class_id_foreign` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subject_teachers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subject_teachers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subject_teachers_subject_id_foreign` FOREIGN KEY (`subject_id`) REFERENCES `subjects` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subject_teachers_teacher_user_id_foreign` FOREIGN KEY (`teacher_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of subject_teachers
-- ----------------------------

-- ----------------------------
-- Table structure for subjects
-- ----------------------------
CREATE TABLE `subjects`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `pass_grade` double NULL DEFAULT NULL,
  `final_grade` double NULL DEFAULT NULL,
  `classe_group_id` int UNSIGNED NOT NULL,
  `subject_group_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `subjects_classe_group_id_foreign`(`classe_group_id` ASC) USING BTREE,
  INDEX `subjects_subject_group_id_foreign`(`subject_group_id` ASC) USING BTREE,
  INDEX `subjects_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `subjects_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `subjects_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `subjects_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `subjects_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subjects_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subjects_classe_group_id_foreign` FOREIGN KEY (`classe_group_id`) REFERENCES `classe_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subjects_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subjects_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subjects_subject_group_id_foreign` FOREIGN KEY (`subject_group_id`) REFERENCES `subject_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of subjects
-- ----------------------------

-- ----------------------------
-- Table structure for subscription_groups
-- ----------------------------
CREATE TABLE `subscription_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `subscription_group_id` int UNSIGNED NULL DEFAULT NULL,
  `main_child_zeros` int NULL DEFAULT NULL,
  `main_child_counter` int NULL DEFAULT NULL,
  `sub_child_zeros` int NULL DEFAULT NULL,
  `sub_child_counter` int NULL DEFAULT NULL,
  `branch_id` int NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `subscription_groups_subscription_group_id_foreign`(`subscription_group_id` ASC) USING BTREE,
  INDEX `subscription_groups_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `subscription_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `subscription_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `subscription_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `subscription_groups_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subscription_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subscription_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subscription_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subscription_groups_subscription_group_id_foreign` FOREIGN KEY (`subscription_group_id`) REFERENCES `subscription_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of subscription_groups
-- ----------------------------
INSERT INTO `subscription_groups` VALUES (1, 'اشتراكات رجال  1', NULL, '1', NULL, 10, NULL, 1000, NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, '2025-06-12 14:06:01', '2025-06-12 14:06:01', NULL);
INSERT INTO `subscription_groups` VALUES (2, 'اشتراكات نساء  1', NULL, '2', NULL, 10, NULL, 1000, NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, '2025-06-12 14:06:01', '2025-06-12 14:06:01', NULL);

-- ----------------------------
-- Table structure for subscriptions
-- ----------------------------
CREATE TABLE `subscriptions`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `amount` double NULL DEFAULT NULL,
  `number_of_visits` double NULL DEFAULT NULL,
  `number_of_minits` double NULL DEFAULT NULL,
  `subscription_group_id` int UNSIGNED NULL DEFAULT NULL,
  `product_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `subscriptions_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `subscriptions_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `subscriptions_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `subscriptions_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `subscriptions_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subscriptions_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subscriptions_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `subscriptions_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of subscriptions
-- ----------------------------

-- ----------------------------
-- Table structure for summary_invoice_groups
-- ----------------------------
CREATE TABLE `summary_invoice_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `summary_invoice_group_id` int UNSIGNED NULL DEFAULT NULL,
  `main_child_zeros` int NULL DEFAULT NULL,
  `main_child_counter` int NULL DEFAULT NULL,
  `sub_child_zeros` int NULL DEFAULT NULL,
  `sub_child_counter` int NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `income_user_id` int UNSIGNED NULL DEFAULT NULL,
  `purchases_user_id` int UNSIGNED NULL DEFAULT NULL,
  `vendor_main_account_id` int UNSIGNED NULL DEFAULT NULL,
  `header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `purchase_invoice_header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `purchase_invoice_footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `summary_invoice_groups_summary_invoice_group_id_foreign`(`summary_invoice_group_id` ASC) USING BTREE,
  INDEX `summary_invoice_groups_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `summary_invoice_groups_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `summary_invoice_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `summary_invoice_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `summary_invoice_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `summary_invoice_groups_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_groups_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_groups_summary_invoice_group_id_foreign` FOREIGN KEY (`summary_invoice_group_id`) REFERENCES `summary_invoice_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of summary_invoice_groups
-- ----------------------------

-- ----------------------------
-- Table structure for summary_invoice_journal_entries
-- ----------------------------
CREATE TABLE `summary_invoice_journal_entries`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `summary_invoice_id` int UNSIGNED NOT NULL,
  `journal_entry_id` int UNSIGNED NOT NULL,
  `journal_kind_id` int UNSIGNED NOT NULL,
  `is_it_final` int UNSIGNED NULL DEFAULT NULL,
  `user_id` int UNSIGNED NOT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `summary_invoice_journal_entries_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `summary_invoice_journal_entries_summary_invoice_id_foreign`(`summary_invoice_id` ASC) USING BTREE,
  INDEX `summary_invoice_journal_entries_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `summary_invoice_journal_entries_journal_kind_id_foreign`(`journal_kind_id` ASC) USING BTREE,
  INDEX `summary_invoice_journal_entries_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `summary_invoice_journal_entries_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `summary_invoice_journal_entries_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `summary_invoice_journal_entries_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_journal_entries_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_journal_entries_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_journal_entries_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_journal_entries_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_journal_entries_journal_kind_id_foreign` FOREIGN KEY (`journal_kind_id`) REFERENCES `journal_kinds` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_journal_entries_summary_invoice_id_foreign` FOREIGN KEY (`summary_invoice_id`) REFERENCES `summary_invoices` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of summary_invoice_journal_entries
-- ----------------------------

-- ----------------------------
-- Table structure for summary_invoice_lines
-- ----------------------------
CREATE TABLE `summary_invoice_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `summary_invoice_group_id` int UNSIGNED NOT NULL,
  `summary_invoice_state_id` int UNSIGNED NOT NULL,
  `summary_invoice_id` int UNSIGNED NOT NULL,
  `customer_user_id` int UNSIGNED NULL DEFAULT NULL,
  `sales_person_user_id` int UNSIGNED NULL DEFAULT NULL,
  `item_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `total_carton` int NULL DEFAULT NULL,
  `quantity_in_carton` int NULL DEFAULT NULL,
  `unit_name` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `quantity` int NULL DEFAULT NULL,
  `cbm` double NULL DEFAULT NULL,
  `product` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `unit` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `price` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `vendor` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `date` date NULL DEFAULT NULL,
  `currency_id` int UNSIGNED NULL DEFAULT NULL,
  `default_currency_id` int UNSIGNED NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `in_date_currency_rate` double UNSIGNED NULL DEFAULT NULL,
  `fail_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `delivery_datetime` datetime NULL DEFAULT NULL,
  `cost` double NULL DEFAULT NULL,
  `weight` double NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `summary_invoice_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `summary_invoice_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `summary_invoice_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `summary_invoice_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `summary_invoice_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of summary_invoice_lines
-- ----------------------------

-- ----------------------------
-- Table structure for summary_invoice_status
-- ----------------------------
CREATE TABLE `summary_invoice_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `is_it_success` int UNSIGNED NOT NULL,
  `is_it_pending` int UNSIGNED NOT NULL,
  `is_it_archive` int UNSIGNED NOT NULL,
  `is_it_fail` int UNSIGNED NOT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `summary_invoice_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `summary_invoice_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `summary_invoice_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `summary_invoice_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `summary_invoice_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoice_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of summary_invoice_status
-- ----------------------------

-- ----------------------------
-- Table structure for summary_invoices
-- ----------------------------
CREATE TABLE `summary_invoices`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `summary_invoice_state_id` int UNSIGNED NOT NULL,
  `summary_invoice_group_id` int UNSIGNED NOT NULL,
  `customer_user_id` int UNSIGNED NULL DEFAULT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `default_currency_id` int UNSIGNED NOT NULL,
  `tax_state_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `sales_person_user_id` int UNSIGNED NULL DEFAULT NULL,
  `in_date_currency_rate` double UNSIGNED NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `date` date NOT NULL,
  `amount` double NULL DEFAULT NULL,
  `discount` double NULL DEFAULT NULL,
  `net_amount` double NULL DEFAULT NULL,
  `cost` double NULL DEFAULT NULL,
  `profit` double NULL DEFAULT NULL,
  `fail_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `summary_invoices_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `summary_invoices_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `summary_invoices_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `summary_invoices_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `summary_invoices_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoices_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoices_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `summary_invoices_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of summary_invoices
-- ----------------------------

-- ----------------------------
-- Table structure for task_employees
-- ----------------------------
CREATE TABLE `task_employees`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `task_id` int UNSIGNED NOT NULL,
  `rank` int UNSIGNED NULL DEFAULT NULL,
  `employee_user_id` int UNSIGNED NOT NULL,
  `task_state_id` int UNSIGNED NOT NULL,
  `is_leader` int UNSIGNED NOT NULL,
  `start_datetime` datetime NULL DEFAULT NULL,
  `end_datetime` datetime NULL DEFAULT NULL,
  `lat` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `long` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `task_employees_task_id_foreign`(`task_id` ASC) USING BTREE,
  INDEX `task_employees_employee_user_id_foreign`(`employee_user_id` ASC) USING BTREE,
  INDEX `task_employees_task_state_id_foreign`(`task_state_id` ASC) USING BTREE,
  INDEX `task_employees_is_leader_foreign`(`is_leader` ASC) USING BTREE,
  INDEX `task_employees_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `task_employees_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `task_employees_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `task_employees_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `task_employees_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `task_employees_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `task_employees_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `task_employees_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `task_employees_employee_user_id_foreign` FOREIGN KEY (`employee_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `task_employees_is_leader_foreign` FOREIGN KEY (`is_leader`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `task_employees_task_id_foreign` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `task_employees_task_state_id_foreign` FOREIGN KEY (`task_state_id`) REFERENCES `task_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of task_employees
-- ----------------------------

-- ----------------------------
-- Table structure for task_groups
-- ----------------------------
CREATE TABLE `task_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `task_group_id` int UNSIGNED NULL DEFAULT NULL,
  `main_child_zeros` int NULL DEFAULT NULL,
  `main_child_counter` int NULL DEFAULT NULL,
  `sub_child_zeros` int NULL DEFAULT NULL,
  `sub_child_counter` int NULL DEFAULT NULL,
  `number_of_hours_to_auto_close` int NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `task_groups_task_group_id_foreign`(`task_group_id` ASC) USING BTREE,
  INDEX `task_groups_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `task_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `task_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `task_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `task_groups_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `task_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `task_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `task_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `task_groups_task_group_id_foreign` FOREIGN KEY (`task_group_id`) REFERENCES `task_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of task_groups
-- ----------------------------

-- ----------------------------
-- Table structure for task_status
-- ----------------------------
CREATE TABLE `task_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `is_it_created` int UNSIGNED NOT NULL,
  `is_it_won` int UNSIGNED NOT NULL,
  `is_it_fail` int UNSIGNED NOT NULL,
  `is_it_archive` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `task_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `task_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `task_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `task_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `task_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `task_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `task_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `task_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of task_status
-- ----------------------------

-- ----------------------------
-- Table structure for tasks
-- ----------------------------
CREATE TABLE `tasks`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `task_group_id` int UNSIGNED NULL DEFAULT NULL,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `start_datetime` datetime NULL DEFAULT NULL,
  `end_datetime` datetime NULL DEFAULT NULL,
  `employee_team_id` int UNSIGNED NULL DEFAULT NULL,
  `task_state_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `tasks_task_group_id_foreign`(`task_group_id` ASC) USING BTREE,
  INDEX `tasks_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `tasks_employee_team_id_foreign`(`employee_team_id` ASC) USING BTREE,
  INDEX `tasks_task_state_id_foreign`(`task_state_id` ASC) USING BTREE,
  INDEX `tasks_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `tasks_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `tasks_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `tasks_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `tasks_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tasks_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tasks_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tasks_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tasks_employee_team_id_foreign` FOREIGN KEY (`employee_team_id`) REFERENCES `employee_teams` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tasks_task_group_id_foreign` FOREIGN KEY (`task_group_id`) REFERENCES `task_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tasks_task_state_id_foreign` FOREIGN KEY (`task_state_id`) REFERENCES `task_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tasks_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of tasks
-- ----------------------------

-- ----------------------------
-- Table structure for tax_status
-- ----------------------------
CREATE TABLE `tax_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `tax_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `tax_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `tax_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tax_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of tax_status
-- ----------------------------
INSERT INTO `tax_status` VALUES (1, 'ضريبي', 'Taxable', '1', 1, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);
INSERT INTO `tax_status` VALUES (2, 'معفي', 'Non taxable', '2', 1, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);
INSERT INTO `tax_status` VALUES (3, 'صفري', 'Zero tax', '3', 1, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);
INSERT INTO `tax_status` VALUES (4, 'تصدير', 'Trans', '4', 1, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);
INSERT INTO `tax_status` VALUES (5, 'غير مسجل', 'Not registered', '5', 1, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);

-- ----------------------------
-- Table structure for tenant_status
-- ----------------------------
CREATE TABLE `tenant_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `tenant_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `tenant_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `tenant_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `tenant_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `tenant_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tenant_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tenant_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tenant_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of tenant_status
-- ----------------------------
INSERT INTO `tenant_status` VALUES (1, 'فعال', '1', 'Active', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:07', '2025-06-12 14:06:07', NULL);
INSERT INTO `tenant_status` VALUES (2, 'غير فعال', '2', 'Deactive', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:07', '2025-06-12 14:06:07', NULL);

-- ----------------------------
-- Table structure for tenants
-- ----------------------------
CREATE TABLE `tenants`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `domain` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `database` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `user_id` int NULL DEFAULT NULL,
  `tenant_state_id` int UNSIGNED NULL DEFAULT NULL,
  `sale_price` decimal(10, 2) NULL DEFAULT NULL,
  `renewal_price` decimal(10, 2) NULL DEFAULT NULL,
  `start_date` date NULL DEFAULT NULL,
  `end_date` date NULL DEFAULT NULL,
  `user_limit` int NULL DEFAULT NULL,
  `monthly_invoice_limit` int NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `tenants_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `tenants_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `tenants_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `tenants_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `tenants_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tenants_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tenants_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tenants_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of tenants
-- ----------------------------

-- ----------------------------
-- Table structure for terminals
-- ----------------------------
CREATE TABLE `terminals`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `terminals_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `terminals_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `terminals_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `terminals_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `terminals_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `terminals_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `terminals_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `terminals_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of terminals
-- ----------------------------

-- ----------------------------
-- Table structure for ticket_departments
-- ----------------------------
CREATE TABLE `ticket_departments`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `ticket_departments_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `ticket_departments_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `ticket_departments_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `ticket_departments_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `ticket_departments_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `ticket_departments_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `ticket_departments_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `ticket_departments_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ticket_departments
-- ----------------------------

-- ----------------------------
-- Table structure for ticket_replys
-- ----------------------------
CREATE TABLE `ticket_replys`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `ticket_id` int UNSIGNED NOT NULL,
  `user_id` int UNSIGNED NOT NULL,
  `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `ticket_replys_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `ticket_replys_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `ticket_replys_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `ticket_replys_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `ticket_replys_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `ticket_replys_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `ticket_replys_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `ticket_replys_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ticket_replys
-- ----------------------------

-- ----------------------------
-- Table structure for ticket_status
-- ----------------------------
CREATE TABLE `ticket_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `ticket_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `ticket_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `ticket_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `ticket_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `ticket_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `ticket_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `ticket_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `ticket_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ticket_status
-- ----------------------------
INSERT INTO `ticket_status` VALUES (1, 'مفتوحة تنتضر الرد من الشركة', '1', 'Opened waiting replay from company', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:08', '2025-06-12 14:06:08', NULL);
INSERT INTO `ticket_status` VALUES (2, 'مفتوحة تنتضر الرد من العميل', '2', 'Opened waiting replay from customer', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:08', '2025-06-12 14:06:08', NULL);
INSERT INTO `ticket_status` VALUES (3, 'اغلقت', '3', 'Closed', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:08', '2025-06-12 14:06:08', NULL);

-- ----------------------------
-- Table structure for tickets
-- ----------------------------
CREATE TABLE `tickets`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `ticket_department_id` int UNSIGNED NULL DEFAULT NULL,
  `ticket_state_id` int UNSIGNED NULL DEFAULT NULL,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `replay_turn` int UNSIGNED NULL DEFAULT NULL,
  `rating` int UNSIGNED NULL DEFAULT NULL,
  `estimated_hours` double UNSIGNED NULL DEFAULT NULL,
  `actual_hours` double UNSIGNED NULL DEFAULT NULL,
  `subject` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `tickets_ticket_department_id_foreign`(`ticket_department_id` ASC) USING BTREE,
  INDEX `tickets_ticket_state_id_foreign`(`ticket_state_id` ASC) USING BTREE,
  INDEX `tickets_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `tickets_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `tickets_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `tickets_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `tickets_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `tickets_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tickets_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tickets_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tickets_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tickets_ticket_department_id_foreign` FOREIGN KEY (`ticket_department_id`) REFERENCES `ticket_departments` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tickets_ticket_state_id_foreign` FOREIGN KEY (`ticket_state_id`) REFERENCES `ticket_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `tickets_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of tickets
-- ----------------------------

-- ----------------------------
