-- Table structure for poss
-- ----------------------------
CREATE TABLE `poss`  (
  `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,
  `turn` int UNSIGNED NULL DEFAULT NULL,
  `pos_turn` int UNSIGNED NULL DEFAULT NULL,
  `pos_number` int UNSIGNED NULL DEFAULT NULL,
  `pos_posting_type_id` int UNSIGNED NOT NULL,
  `is_e_invoice` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `warehouse_id` int UNSIGNED NOT NULL,
  `sales_account_id` int UNSIGNED NOT NULL,
  `refund_sales_account_id` int UNSIGNED NOT NULL,
  `cash_account_id` int UNSIGNED NOT NULL,
  `bank_account_id` int UNSIGNED NULL DEFAULT NULL,
  `close_account_id` int UNSIGNED NOT NULL,
  `petty_cash_account_id` int UNSIGNED NULL DEFAULT NULL,
  `customer_close_user_id` int UNSIGNED NULL DEFAULT NULL,
  `note_in_every_line` int UNSIGNED NULL DEFAULT NULL,
  `services_product_id` int UNSIGNED NULL DEFAULT NULL,
  `printing_state_id` int UNSIGNED NULL DEFAULT NULL,
  `has_price_checker` int UNSIGNED NULL DEFAULT NULL,
  `has_loyalty_point` int UNSIGNED NULL DEFAULT NULL,
  `has_number_of_items` int UNSIGNED NULL DEFAULT NULL,
  `main_printer_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `delivery_state_id` int UNSIGNED NOT NULL,
  `admin_user_id` int UNSIGNED NULL DEFAULT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `forced_discount_state_id` int UNSIGNED NOT NULL,
  `show_product_number` int UNSIGNED NOT NULL,
  `show_pos_cost_center_in_invoice` int UNSIGNED NOT NULL,
  `show_product_unit` int UNSIGNED NOT NULL,
  `product_at_same_line` int UNSIGNED NOT NULL,
  `check_images` int UNSIGNED NOT NULL,
  `portable_mode` int UNSIGNED NULL DEFAULT NULL,
  `is_it_only_waiting` int UNSIGNED NULL DEFAULT NULL,
  `dose_it_have_receipt` int UNSIGNED NULL DEFAULT NULL,
  `dose_it_have_order` int UNSIGNED NULL DEFAULT NULL,
  `active_add_without_print` int UNSIGNED NULL DEFAULT NULL,
  `maximum_turn_number` int UNSIGNED NULL DEFAULT NULL,
  `min_turn_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `can_search_waiting_invoices` int UNSIGNED NULL DEFAULT NULL,
  `open_balance` double UNSIGNED NULL DEFAULT NULL,
  `allowed_value_discount` double UNSIGNED NULL DEFAULT NULL,
  `allowed_percentage_discount` double UNSIGNED NULL DEFAULT NULL,
  `forced_discount` double UNSIGNED NULL DEFAULT NULL,
  `forced_discount_above` double UNSIGNED NULL DEFAULT NULL,
  `active_camera_as_barcode_reader` int UNSIGNED NULL DEFAULT NULL,
  `print_products_saparated_by_printer` int UNSIGNED NULL DEFAULT NULL,
  `can_be_sold_with_a_separator` int UNSIGNED NULL DEFAULT NULL,
  `weight_code` int UNSIGNED NULL DEFAULT NULL,
  `check_balance_password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `close_password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `refund_password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `discount_password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `sales_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `refund_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `transfer_sales_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `transfer_refund_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `last_closing_date` datetime NULL DEFAULT NULL,
  `pos_closing_state_id` int UNSIGNED NOT NULL DEFAULT 2,
  `has_screen` int UNSIGNED NOT NULL DEFAULT 2,
  `transfer_to_external_server` int UNSIGNED NOT NULL DEFAULT 2,
  `multiable_printers` int UNSIGNED NOT NULL DEFAULT 2,
  `cost_center_id` int UNSIGNED NULL DEFAULT NULL,
  `payment_journal_id` int UNSIGNED NULL DEFAULT NULL,
  `show_tax_percentages` int UNSIGNED NULL DEFAULT NULL,
  `option_to_remove_tax` int UNSIGNED NULL DEFAULT NULL,
  `return_from_invoice_id` int UNSIGNED NULL DEFAULT NULL,
  `card_point_percentage` double UNSIGNED NULL DEFAULT NULL,
  `header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `transfer_token` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `transfer_link` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `transfer_product_link` 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 `poss_check_images_foreign`(`check_images` ASC) USING BTREE,
  INDEX `poss_product_at_same_line_foreign`(`product_at_same_line` ASC) USING BTREE,
  INDEX `poss_show_pos_cost_center_in_invoice_foreign`(`show_pos_cost_center_in_invoice` ASC) USING BTREE,
  INDEX `poss_show_product_number_foreign`(`show_product_number` ASC) USING BTREE,
  INDEX `poss_pos_number_foreign`(`pos_number` ASC) USING BTREE,
  INDEX `poss_pos_turn_foreign`(`pos_turn` ASC) USING BTREE,
  INDEX `poss_pos_closing_state_id_foreign`(`pos_closing_state_id` ASC) USING BTREE,
  INDEX `poss_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `poss_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `poss_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `poss_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `poss_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `poss_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `poss_check_images_foreign` FOREIGN KEY (`check_images`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `poss_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `poss_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `poss_pos_closing_state_id_foreign` FOREIGN KEY (`pos_closing_state_id`) REFERENCES `pos_closing_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `poss_pos_number_foreign` FOREIGN KEY (`pos_number`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `poss_pos_turn_foreign` FOREIGN KEY (`pos_turn`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `poss_product_at_same_line_foreign` FOREIGN KEY (`product_at_same_line`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `poss_show_pos_cost_center_in_invoice_foreign` FOREIGN KEY (`show_pos_cost_center_in_invoice`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `poss_show_product_number_foreign` FOREIGN KEY (`show_product_number`) 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 poss
-- ----------------------------
INSERT INTO `poss` VALUES (1, 'نقطة بيع 1', '1', 'Point of sale 1', NULL, 1, 1, 1, 2, 1, 1, 37, 38, 2, 4, 2, 56, 68, 2, NULL, NULL, 2, 2, NULL, NULL, 1, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, NULL, NULL, 2, NULL, 2, 10, NULL, NULL, 2, 2, 1, NULL, '123456', '123456', '123456', '123456', NULL, NULL, NULL, NULL, NULL, 2, 2, 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, 'Pos header', '\r\n                Call us 0788888888\r\n                Address here\r\n\r\n            ', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);

-- ----------------------------
-- Table structure for posting_status
-- ----------------------------
CREATE TABLE `posting_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,
  `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 `posting_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `posting_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `posting_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `posting_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 posting_status
-- ----------------------------
INSERT INTO `posting_status` VALUES (1, 'مرحل', 'posted', '1', 1, NULL, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);
INSERT INTO `posting_status` VALUES (2, 'قيد المراجعة', 'pending', '2', 1, NULL, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);

-- ----------------------------
-- Table structure for prescription_lines
-- ----------------------------
CREATE TABLE `prescription_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `medicine_id` int UNSIGNED NULL DEFAULT NULL,
  `medicine_note` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `customer_user_id` int UNSIGNED NOT NULL,
  `prescription_id` int UNSIGNED NOT NULL,
  `date` date NOT NULL,
  `number` 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 `prescription_lines_medicine_id_foreign`(`medicine_id` ASC) USING BTREE,
  INDEX `prescription_lines_customer_user_id_foreign`(`customer_user_id` ASC) USING BTREE,
  INDEX `prescription_lines_prescription_id_foreign`(`prescription_id` ASC) USING BTREE,
  INDEX `prescription_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `prescription_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `prescription_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `prescription_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `prescription_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `prescription_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `prescription_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `prescription_lines_customer_user_id_foreign` FOREIGN KEY (`customer_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `prescription_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `prescription_lines_medicine_id_foreign` FOREIGN KEY (`medicine_id`) REFERENCES `medicines` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `prescription_lines_prescription_id_foreign` FOREIGN KEY (`prescription_id`) REFERENCES `prescriptions` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of prescription_lines
-- ----------------------------

-- ----------------------------
-- Table structure for prescription_types
-- ----------------------------
CREATE TABLE `prescription_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,
  `sub_child_zeros` int NULL DEFAULT NULL,
  `sub_child_counter` int 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 `prescription_types_numbering_type_id_foreign`(`numbering_type_id` ASC) USING BTREE,
  INDEX `prescription_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `prescription_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `prescription_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `prescription_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `prescription_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `prescription_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `prescription_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `prescription_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `prescription_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 prescription_types
-- ----------------------------
INSERT INTO `prescription_types` VALUES (1, 'Prescription', '1', 'value', 1, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);

-- ----------------------------
-- Table structure for prescriptions
-- ----------------------------
CREATE TABLE `prescriptions`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `date` date NOT NULL,
  `customer_user_id` int UNSIGNED NOT NULL,
  `clinic_room_appointment_id` int UNSIGNED NULL DEFAULT NULL,
  `prescription_type_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 `prescriptions_customer_user_id_foreign`(`customer_user_id` ASC) USING BTREE,
  INDEX `prescriptions_clinic_room_appointment_id_foreign`(`clinic_room_appointment_id` ASC) USING BTREE,
  INDEX `prescriptions_prescription_type_id_foreign`(`prescription_type_id` ASC) USING BTREE,
  INDEX `prescriptions_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `prescriptions_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `prescriptions_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `prescriptions_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `prescriptions_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `prescriptions_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `prescriptions_clinic_room_appointment_id_foreign` FOREIGN KEY (`clinic_room_appointment_id`) REFERENCES `clinic_room_appointments` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `prescriptions_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `prescriptions_customer_user_id_foreign` FOREIGN KEY (`customer_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `prescriptions_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `prescriptions_prescription_type_id_foreign` FOREIGN KEY (`prescription_type_id`) REFERENCES `prescription_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 prescriptions
-- ----------------------------

-- ----------------------------
-- Table structure for press_order_groups
-- ----------------------------
CREATE TABLE `press_order_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,
  `press_order_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,
  `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_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `press_order_groups_press_order_group_id_foreign`(`press_order_group_id` ASC) USING BTREE,
  INDEX `press_order_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `press_order_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `press_order_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `press_order_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_groups_press_order_group_id_foreign` FOREIGN KEY (`press_order_group_id`) REFERENCES `press_order_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 press_order_groups
-- ----------------------------

-- ----------------------------
-- Table structure for press_order_lines
-- ----------------------------
CREATE TABLE `press_order_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `press_order_id` int UNSIGNED NOT NULL,
  `quantity` double UNSIGNED NULL DEFAULT NULL,
  `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 `press_order_lines_press_order_id_foreign`(`press_order_id` ASC) USING BTREE,
  INDEX `press_order_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `press_order_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `press_order_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `press_order_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `press_order_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_lines_press_order_id_foreign` FOREIGN KEY (`press_order_id`) REFERENCES `press_orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of press_order_lines
-- ----------------------------

-- ----------------------------
-- Table structure for press_order_quantites
-- ----------------------------
CREATE TABLE `press_order_quantites`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `press_order_id` int UNSIGNED NOT NULL,
  `press_order_work_order_step_id` int UNSIGNED NULL DEFAULT NULL,
  `note_voucher_id` int UNSIGNED NULL DEFAULT NULL,
  `reserve_material_order_id` int UNSIGNED NULL DEFAULT NULL,
  `is_final` int UNSIGNED NULL DEFAULT NULL,
  `is_simi_final` int UNSIGNED NULL DEFAULT NULL,
  `damage` double UNSIGNED NULL DEFAULT NULL,
  `journal_entry_id` int UNSIGNED NULL DEFAULT NULL,
  `date` date NOT NULL,
  `quantity` 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 `press_order_quantites_press_order_id_foreign`(`press_order_id` ASC) USING BTREE,
  INDEX `press_order_quantites_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `press_order_quantites_note_voucher_id_foreign`(`note_voucher_id` ASC) USING BTREE,
  INDEX `press_order_quantites_reserve_material_order_id_foreign`(`reserve_material_order_id` ASC) USING BTREE,
  INDEX `press_order_quantites_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `press_order_quantites_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `press_order_quantites_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `press_order_quantites_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `press_order_quantites_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_quantites_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_quantites_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_quantites_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_quantites_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_quantites_note_voucher_id_foreign` FOREIGN KEY (`note_voucher_id`) REFERENCES `note_vouchers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_quantites_press_order_id_foreign` FOREIGN KEY (`press_order_id`) REFERENCES `press_orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_quantites_reserve_material_order_id_foreign` FOREIGN KEY (`reserve_material_order_id`) REFERENCES `reserve_material_orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of press_order_quantites
-- ----------------------------

-- ----------------------------
-- Table structure for press_order_status
-- ----------------------------
CREATE TABLE `press_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 `press_order_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `press_order_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `press_order_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `press_order_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `press_order_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_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 press_order_status
-- ----------------------------
INSERT INTO `press_order_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 `press_order_status` VALUES (2, 'موقوف', '2', 'Under Constrution', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:03', '2025-06-12 14:06:03', NULL);
INSERT INTO `press_order_status` VALUES (3, 'تم الانتاج', '3', 'Done', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:03', '2025-06-12 14:06:03', NULL);
INSERT INTO `press_order_status` VALUES (4, 'تم التحويل الى فاتورة', '4', 'Transfered to invoice', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:03', '2025-06-12 14:06:03', NULL);

-- ----------------------------
-- Table structure for press_order_work_order_steps
-- ----------------------------
CREATE TABLE `press_order_work_order_steps`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `press_order_id` int UNSIGNED NOT NULL,
  `work_order_step_id` int UNSIGNED NOT NULL,
  `press_order_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 `press_order_work_order_steps_press_order_id_foreign`(`press_order_id` ASC) USING BTREE,
  INDEX `press_order_work_order_steps_work_order_step_id_foreign`(`work_order_step_id` ASC) USING BTREE,
  INDEX `press_order_work_order_steps_press_order_state_id_foreign`(`press_order_state_id` ASC) USING BTREE,
  INDEX `press_order_work_order_steps_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `press_order_work_order_steps_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `press_order_work_order_steps_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `press_order_work_order_steps_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `press_order_work_order_steps_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_work_order_steps_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_work_order_steps_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_work_order_steps_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_work_order_steps_press_order_id_foreign` FOREIGN KEY (`press_order_id`) REFERENCES `press_orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_work_order_steps_press_order_state_id_foreign` FOREIGN KEY (`press_order_state_id`) REFERENCES `press_order_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_order_work_order_steps_work_order_step_id_foreign` FOREIGN KEY (`work_order_step_id`) REFERENCES `work_order_steps` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of press_order_work_order_steps
-- ----------------------------

-- ----------------------------
-- Table structure for press_orders
-- ----------------------------
CREATE TABLE `press_orders`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `date` date NOT NULL,
  `delivery_date` date NULL DEFAULT NULL,
  `press_order_group_id` int UNSIGNED NOT NULL,
  `press_template_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `user_id` int UNSIGNED NOT NULL,
  `press_order_state_id` int UNSIGNED NOT NULL,
  `printing_name_id` int UNSIGNED NOT NULL,
  `asset_id` int UNSIGNED NULL DEFAULT NULL,
  `printing_paper_id` int UNSIGNED NULL DEFAULT NULL,
  `core_diameter` double UNSIGNED NULL DEFAULT NULL,
  `number_of_label_in_roll` double UNSIGNED NULL DEFAULT NULL,
  `longitudinal_meter` double UNSIGNED NULL DEFAULT NULL,
  `price` double UNSIGNED NULL DEFAULT NULL,
  `quantity` double UNSIGNED NULL DEFAULT NULL,
  `remain` double UNSIGNED NULL DEFAULT NULL,
  `addones` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `repeats` double NULL DEFAULT NULL,
  `printing_width` double NULL DEFAULT NULL,
  `width` double NULL DEFAULT NULL,
  `height` double NULL DEFAULT NULL,
  `celender_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `dalta` 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 `press_orders_printing_paper_id_foreign`(`printing_paper_id` ASC) USING BTREE,
  INDEX `press_orders_press_order_group_id_foreign`(`press_order_group_id` ASC) USING BTREE,
  INDEX `press_orders_press_template_id_foreign`(`press_template_id` ASC) USING BTREE,
  INDEX `press_orders_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `press_orders_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `press_orders_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `press_orders_printing_name_id_foreign`(`printing_name_id` ASC) USING BTREE,
  INDEX `press_orders_asset_id_foreign`(`asset_id` ASC) USING BTREE,
  INDEX `press_orders_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `press_orders_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `press_orders_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `press_orders_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `press_orders_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_orders_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_orders_asset_id_foreign` FOREIGN KEY (`asset_id`) REFERENCES `assets` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_orders_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_orders_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_orders_press_order_group_id_foreign` FOREIGN KEY (`press_order_group_id`) REFERENCES `press_order_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_orders_press_template_id_foreign` FOREIGN KEY (`press_template_id`) REFERENCES `press_templates` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_orders_printing_name_id_foreign` FOREIGN KEY (`printing_name_id`) REFERENCES `printing_names` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_orders_printing_paper_id_foreign` FOREIGN KEY (`printing_paper_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_orders_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_orders_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_orders_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 press_orders
-- ----------------------------

-- ----------------------------
-- Table structure for press_template_status
-- ----------------------------
CREATE TABLE `press_template_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 `press_template_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `press_template_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `press_template_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `press_template_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `press_template_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_template_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_template_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_template_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 press_template_status
-- ----------------------------
INSERT INTO `press_template_status` VALUES (1, 'في التشغيل', '1', 'in progress', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:03', '2025-06-12 14:06:03', NULL);
INSERT INTO `press_template_status` VALUES (2, 'تم عمل عليه اكثر من طبعة', '1', 'Printed many times', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:03', '2025-06-12 14:06:03', NULL);
INSERT INTO `press_template_status` VALUES (3, 'خرب في الطبعة', '1', 'Damaged', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:03', '2025-06-12 14:06:03', NULL);

-- ----------------------------
-- Table structure for press_templates
-- ----------------------------
CREATE TABLE `press_templates`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` int NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `length` double NULL DEFAULT NULL,
  `width` double NULL DEFAULT NULL,
  `height` double NULL DEFAULT NULL,
  `press_template_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 `press_templates_press_template_state_id_foreign`(`press_template_state_id` ASC) USING BTREE,
  INDEX `press_templates_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `press_templates_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `press_templates_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `press_templates_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `press_templates_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_templates_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_templates_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_templates_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `press_templates_press_template_state_id_foreign` FOREIGN KEY (`press_template_state_id`) REFERENCES `press_template_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 press_templates
-- ----------------------------

-- ----------------------------
-- Table structure for price_list_lines
-- ----------------------------
CREATE TABLE `price_list_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `price_list_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `customer_main_account_id` int UNSIGNED NULL DEFAULT NULL,
  `day_id` int UNSIGNED NULL DEFAULT NULL,
  `price` double UNSIGNED NOT NULL,
  `quantity` double UNSIGNED NULL DEFAULT NULL,
  `in_date_tax` double UNSIGNED NULL DEFAULT NULL,
  `from_date` date NULL DEFAULT NULL,
  `to_date` date NULL DEFAULT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `default_currency` int UNSIGNED NOT NULL,
  `in_date_currency_rate` double 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 `price_list_lines_price_list_id_foreign`(`price_list_id` ASC) USING BTREE,
  INDEX `price_list_lines_customer_main_account_id_foreign`(`customer_main_account_id` ASC) USING BTREE,
  INDEX `price_list_lines_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `price_list_lines_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `price_list_lines_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `price_list_lines_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `price_list_lines_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `price_list_lines_default_currency_foreign`(`default_currency` ASC) USING BTREE,
  INDEX `price_list_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `price_list_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `price_list_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `price_list_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `price_list_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_list_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_list_lines_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_list_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_list_lines_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_list_lines_customer_main_account_id_foreign` FOREIGN KEY (`customer_main_account_id`) REFERENCES `customer_main_accounts` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_list_lines_default_currency_foreign` FOREIGN KEY (`default_currency`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_list_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_list_lines_price_list_id_foreign` FOREIGN KEY (`price_list_id`) REFERENCES `price_lists` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_list_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_list_lines_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_list_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 price_list_lines
-- ----------------------------

-- ----------------------------
-- Table structure for price_lists
-- ----------------------------
CREATE TABLE `price_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,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `customer_main_account_id` int UNSIGNED NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `default_currency` int UNSIGNED NOT NULL,
  `day_id` int UNSIGNED NULL DEFAULT NULL,
  `in_date_currency_rate` double 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 `price_lists_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `price_lists_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `price_lists_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `price_lists_default_currency_foreign`(`default_currency` ASC) USING BTREE,
  INDEX `price_lists_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `price_lists_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `price_lists_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `price_lists_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `price_lists_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_lists_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_lists_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_lists_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_lists_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_lists_default_currency_foreign` FOREIGN KEY (`default_currency`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_lists_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_lists_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 price_lists
-- ----------------------------

-- ----------------------------
-- Table structure for price_offer_line_components
-- ----------------------------
CREATE TABLE `price_offer_line_components`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `price_offer_line_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `quantity` double UNSIGNED NOT NULL,
  `is_required` int UNSIGNED NULL DEFAULT NULL,
  `can_change_balance` int UNSIGNED NULL DEFAULT NULL,
  `balance_is_required` int UNSIGNED NULL DEFAULT NULL,
  `title` 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 `price_offer_line_components_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `price_offer_line_components_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `price_offer_line_components_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `price_offer_line_components_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `price_offer_line_components_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `price_offer_line_components_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `price_offer_line_components_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_line_components_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_line_components_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_line_components_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_line_components_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_line_components_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 price_offer_line_components
-- ----------------------------

-- ----------------------------
-- Table structure for price_offer_line_specifications
-- ----------------------------
CREATE TABLE `price_offer_line_specifications`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `price_offer_line_id` int UNSIGNED NOT NULL,
  `product_specification_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `product_specification_value_id` int UNSIGNED NULL DEFAULT NULL,
  `value` 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 `price_offer_line_specifications_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `price_offer_line_specifications_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `price_offer_line_specifications_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `price_offer_line_specifications_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `price_offer_line_specifications_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_line_specifications_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_line_specifications_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_line_specifications_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 price_offer_line_specifications
-- ----------------------------

-- ----------------------------
-- Table structure for price_offer_lines
-- ----------------------------
CREATE TABLE `price_offer_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `price_offer_id` int UNSIGNED NOT NULL,
  `price_offer_type_id` int UNSIGNED NOT NULL,
  `price_offer_state_id` int UNSIGNED NOT NULL,
  `user_id` int UNSIGNED NOT NULL,
  `sales_quotation_id` int UNSIGNED NULL DEFAULT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `default_currency_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `in_date_currency_rate` double UNSIGNED NOT NULL,
  `quantity` double UNSIGNED NULL DEFAULT NULL,
  `in_date_tax` double UNSIGNED NULL DEFAULT NULL,
  `discount_percentage` double UNSIGNED NULL DEFAULT NULL,
  `discount_value` double UNSIGNED NULL DEFAULT NULL,
  `number` int UNSIGNED NOT NULL,
  `warehouse_id` int UNSIGNED NULL DEFAULT NULL,
  `date` date NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `price` double UNSIGNED NULL DEFAULT NULL,
  `price_with_cost` double UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `coupon` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `loading_person` 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,
  `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 `price_offer_lines_price_offer_id_foreign`(`price_offer_id` ASC) USING BTREE,
  INDEX `price_offer_lines_price_offer_type_id_foreign`(`price_offer_type_id` ASC) USING BTREE,
  INDEX `price_offer_lines_price_offer_state_id_foreign`(`price_offer_state_id` ASC) USING BTREE,
  INDEX `price_offer_lines_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `price_offer_lines_sales_quotation_id_foreign`(`sales_quotation_id` ASC) USING BTREE,
  INDEX `price_offer_lines_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `price_offer_lines_default_currency_id_foreign`(`default_currency_id` ASC) USING BTREE,
  INDEX `price_offer_lines_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `price_offer_lines_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `price_offer_lines_warehouse_id_foreign`(`warehouse_id` ASC) USING BTREE,
  INDEX `price_offer_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `price_offer_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `price_offer_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `price_offer_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `price_offer_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_lines_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_lines_default_currency_id_foreign` FOREIGN KEY (`default_currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_lines_price_offer_id_foreign` FOREIGN KEY (`price_offer_id`) REFERENCES `price_offers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_lines_price_offer_state_id_foreign` FOREIGN KEY (`price_offer_state_id`) REFERENCES `price_offer_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_lines_price_offer_type_id_foreign` FOREIGN KEY (`price_offer_type_id`) REFERENCES `price_offer_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_lines_sales_quotation_id_foreign` FOREIGN KEY (`sales_quotation_id`) REFERENCES `sales_quotations` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_lines_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_lines_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_lines_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 price_offer_lines
-- ----------------------------

-- ----------------------------
-- Table structure for price_offer_status
-- ----------------------------
CREATE TABLE `price_offer_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 `price_offer_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `price_offer_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `price_offer_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `price_offer_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `price_offer_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of price_offer_status
-- ----------------------------
INSERT INTO `price_offer_status` VALUES (1, 'قيد الانشاء', '1', 'Pending', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);
INSERT INTO `price_offer_status` VALUES (2, 'تم تحويله الى فاتورة اوليه', '2', 'Transformed to proformas invoice', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);
INSERT INTO `price_offer_status` VALUES (3, 'الغي من طرف الشركة', '3', 'Canceled by company', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);
INSERT INTO `price_offer_status` VALUES (4, 'الغي من طرف العميل', '4', 'Canceled by customer', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);
INSERT INTO `price_offer_status` VALUES (5, 'في التشغيل', '5', 'Under construction', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);
INSERT INTO `price_offer_status` VALUES (6, 'تم التحويل الى فاتورة مبيعات', '6', 'Transfer to sales invoice', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);
INSERT INTO `price_offer_status` VALUES (7, 'تم التحويل الى عقد عمل', '7', 'Transfer to working contract', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);

-- ----------------------------
-- Table structure for price_offer_type_users
-- ----------------------------
CREATE TABLE `price_offer_type_users`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `price_offer_type_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 `price_offer_type_users_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `price_offer_type_users_price_offer_type_id_foreign`(`price_offer_type_id` ASC) USING BTREE,
  INDEX `price_offer_type_users_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `price_offer_type_users_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `price_offer_type_users_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `price_offer_type_users_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `price_offer_type_users_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_type_users_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_type_users_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_type_users_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_type_users_price_offer_type_id_foreign` FOREIGN KEY (`price_offer_type_id`) REFERENCES `price_offer_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_type_users_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 price_offer_type_users
-- ----------------------------

-- ----------------------------
-- Table structure for price_offer_types
-- ----------------------------
CREATE TABLE `price_offer_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,
  `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `numbering_type_id` int UNSIGNED NOT NULL,
  `saparated_lines` int UNSIGNED NULL DEFAULT 2,
  `number_bwtween_open_and_close` int NULL DEFAULT NULL,
  `next_number` int NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `make_note_voucher` int UNSIGNED NULL DEFAULT NULL,
  `can_be_convert_to_invoice_multiable_time` 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,
  `terms` 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 `price_offer_types_numbering_type_id_foreign`(`numbering_type_id` ASC) USING BTREE,
  INDEX `price_offer_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `price_offer_types_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `price_offer_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `price_offer_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `price_offer_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `price_offer_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_types_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offer_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 price_offer_types
-- ----------------------------
INSERT INTO `price_offer_types` VALUES (1, 'عرض سعر محلي', '1', 'Local', NULL, 1, 2, NULL, NULL, 1, 2, 2, '\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, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);
INSERT INTO `price_offer_types` VALUES (2, 'عرض سعر خارجي', '2', 'Trans', NULL, 1, 2, NULL, NULL, NULL, 2, 2, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);

-- ----------------------------
-- Table structure for price_offers
-- ----------------------------
CREATE TABLE `price_offers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `price_offer_type_id` int UNSIGNED NOT NULL,
  `price_offer_state_id` int UNSIGNED NOT NULL,
  `user_id` int UNSIGNED NOT NULL,
  `sales_quotation_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,
  `branch_id` int UNSIGNED NOT NULL,
  `working_contract_id` int UNSIGNED NULL DEFAULT NULL,
  `in_date_currency_rate` double UNSIGNED NOT NULL,
  `tax_state_id` int UNSIGNED NOT NULL,
  `payment_term_id` int UNSIGNED NULL DEFAULT NULL,
  `note_voucher_id` int UNSIGNED NULL DEFAULT NULL,
  `sales_person_id` int UNSIGNED NULL DEFAULT NULL,
  `order_driver_user_id` int UNSIGNED NULL DEFAULT NULL,
  `delivery_area_id` int UNSIGNED NULL DEFAULT NULL,
  `number` int UNSIGNED NOT NULL,
  `amounts` double UNSIGNED NULL DEFAULT NULL,
  `project` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `cash_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `sales_person` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `loading_person` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `return_loading_person` int UNSIGNED NULL DEFAULT NULL,
  `date` date NOT NULL,
  `to_date` date NULL DEFAULT NULL,
  `delivery_date` datetime NULL DEFAULT NULL,
  `terms` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `header_before_lines` 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 `price_offers_tax_state_id_foreign`(`tax_state_id` ASC) USING BTREE,
  INDEX `price_offers_order_driver_user_id_foreign`(`order_driver_user_id` ASC) USING BTREE,
  INDEX `price_offers_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `price_offers_price_offer_type_id_foreign`(`price_offer_type_id` ASC) USING BTREE,
  INDEX `price_offers_price_offer_state_id_foreign`(`price_offer_state_id` ASC) USING BTREE,
  INDEX `price_offers_note_voucher_id_foreign`(`note_voucher_id` ASC) USING BTREE,
  INDEX `price_offers_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `price_offers_sales_quotation_id_foreign`(`sales_quotation_id` ASC) USING BTREE,
  INDEX `price_offers_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `price_offers_default_currency_id_foreign`(`default_currency_id` ASC) USING BTREE,
  INDEX `price_offers_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `price_offers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `price_offers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `price_offers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `price_offers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `price_offers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offers_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offers_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offers_default_currency_id_foreign` FOREIGN KEY (`default_currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offers_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offers_note_voucher_id_foreign` FOREIGN KEY (`note_voucher_id`) REFERENCES `note_vouchers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offers_order_driver_user_id_foreign` FOREIGN KEY (`order_driver_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offers_price_offer_state_id_foreign` FOREIGN KEY (`price_offer_state_id`) REFERENCES `price_offer_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offers_price_offer_type_id_foreign` FOREIGN KEY (`price_offer_type_id`) REFERENCES `price_offer_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offers_sales_quotation_id_foreign` FOREIGN KEY (`sales_quotation_id`) REFERENCES `sales_quotations` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offers_tax_state_id_foreign` FOREIGN KEY (`tax_state_id`) REFERENCES `tax_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `price_offers_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 price_offers
-- ----------------------------

-- ----------------------------
-- Table structure for printing_names
-- ----------------------------
CREATE TABLE `printing_names`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` int NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `press_template_id` int UNSIGNED NULL DEFAULT NULL,
  `product_id` int UNSIGNED NULL DEFAULT NULL,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `unit_id` int UNSIGNED NULL DEFAULT NULL,
  `winding_direction_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `celender_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `dalta` 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 `printing_names_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `printing_names_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `printing_names_press_template_id_foreign`(`press_template_id` ASC) USING BTREE,
  INDEX `printing_names_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `printing_names_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `printing_names_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `printing_names_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `printing_names_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `printing_names_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `printing_names_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `printing_names_press_template_id_foreign` FOREIGN KEY (`press_template_id`) REFERENCES `press_templates` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `printing_names_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of printing_names
-- ----------------------------

-- ----------------------------
-- Table structure for printing_papers
-- ----------------------------
CREATE TABLE `printing_papers`  (
  `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 `printing_papers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `printing_papers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `printing_papers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `printing_papers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `printing_papers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `printing_papers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `printing_papers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `printing_papers_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 printing_papers
-- ----------------------------

-- ----------------------------
-- Table structure for product_alternatives
-- ----------------------------
CREATE TABLE `product_alternatives`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `alternative_product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `quantity` double NOT 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 `product_alternatives_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `product_alternatives_alternative_product_id_foreign`(`alternative_product_id` ASC) USING BTREE,
  INDEX `product_alternatives_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `product_alternatives_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_alternatives_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_alternatives_alternative_product_id_foreign` FOREIGN KEY (`alternative_product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_alternatives_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_alternatives_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_alternatives_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_alternatives_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 product_alternatives
-- ----------------------------

-- ----------------------------
-- Table structure for product_averages
-- ----------------------------
CREATE TABLE `product_averages`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `date` date NOT NULL,
  `average` double NOT NULL,
  `note_voucher_line_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 `product_averages_note_voucher_line_id_foreign`(`note_voucher_line_id` ASC) USING BTREE,
  INDEX `product_averages_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `product_averages_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `product_averages_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_averages_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_averages_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_averages_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_averages_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_averages_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_averages_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_averages_note_voucher_line_id_foreign` FOREIGN KEY (`note_voucher_line_id`) REFERENCES `note_voucher_lines` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_averages_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of product_averages
-- ----------------------------

-- ----------------------------
-- Table structure for product_balances
-- ----------------------------
CREATE TABLE `product_balances`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `warehouse_id` int UNSIGNED NOT NULL,
  `balance` double NULL DEFAULT NULL,
  `in_date_quantity` 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,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `product_balances_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `product_balances_warehouse_id_foreign`(`warehouse_id` ASC) USING BTREE,
  INDEX `product_balances_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `product_balances_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_balances_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_balances_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_balances_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_balances_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_balances_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_balances_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_balances_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_balances_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 product_balances
-- ----------------------------

-- ----------------------------
-- Table structure for product_categories
-- ----------------------------
CREATE TABLE `product_categories`  (
  `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 NULL DEFAULT NULL,
  `main_child_counter` int NULL DEFAULT NULL,
  `sub_child_zeros` int NULL DEFAULT NULL,
  `sub_child_counter` int NULL DEFAULT NULL,
  `product_category_id` int UNSIGNED NULL DEFAULT NULL,
  `number_of_days_until_production_is_completed` double UNSIGNED NULL DEFAULT NULL,
  `production_capacity_per_day` 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 `product_categories_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_categories_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_categories_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  INDEX `product_categories_product_category_id_foreign`(`product_category_id` ASC) USING BTREE,
  CONSTRAINT `product_categories_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_categories_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_categories_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_categories_product_category_id_foreign` FOREIGN KEY (`product_category_id`) REFERENCES `product_categories` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of product_categories
-- ----------------------------
INSERT INTO `product_categories` VALUES (1, 'محلات', '1', 'test', 10, NULL, 1000, 28, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, '2025-06-12 14:05:48', '2025-07-08 15:41:30', NULL);
INSERT INTO `product_categories` VALUES (2, 'مشاغل', '2', NULL, 10, NULL, 1000, 5, NULL, NULL, NULL, 71, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:11:20', '2025-07-09 13:25:06', NULL);
INSERT INTO `product_categories` VALUES (3, 'سكن', '3', NULL, 10, NULL, 1000, 11, NULL, NULL, NULL, 71, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:11:24', '2025-07-09 13:20:48', NULL);
INSERT INTO `product_categories` VALUES (4, 'ارض فارغة', '4', NULL, 10, NULL, 1000, 1, NULL, NULL, NULL, 71, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:42:55', '2025-07-18 22:21:46', NULL);

-- ----------------------------
-- Table structure for product_category_relations
-- ----------------------------
CREATE TABLE `product_category_relations`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_category_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED 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 `product_category_relations_product_category_id_foreign`(`product_category_id` ASC) USING BTREE,
  INDEX `product_category_relations_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_category_relations_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_category_relations_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_category_relations_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_category_relations_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 product_category_relations
-- ----------------------------

-- ----------------------------
-- Table structure for product_components
-- ----------------------------
CREATE TABLE `product_components`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `main_product_id` int UNSIGNED NOT NULL,
  `component_product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `quantity` double NOT NULL,
  `is_required` int UNSIGNED NOT NULL,
  `can_change_balance` int UNSIGNED NOT NULL,
  `balance_is_required` int UNSIGNED NOT NULL,
  `title` 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,
  `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 `product_components_is_required_foreign`(`is_required` ASC) USING BTREE,
  INDEX `product_components_can_change_balance_foreign`(`can_change_balance` ASC) USING BTREE,
  INDEX `product_components_balance_is_required_foreign`(`balance_is_required` ASC) USING BTREE,
  INDEX `product_components_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `product_components_main_product_id_foreign`(`main_product_id` ASC) USING BTREE,
  INDEX `product_components_component_product_id_foreign`(`component_product_id` ASC) USING BTREE,
  INDEX `product_components_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_components_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_components_balance_is_required_foreign` FOREIGN KEY (`balance_is_required`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_components_can_change_balance_foreign` FOREIGN KEY (`can_change_balance`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_components_component_product_id_foreign` FOREIGN KEY (`component_product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_components_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_components_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_components_is_required_foreign` FOREIGN KEY (`is_required`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_components_main_product_id_foreign` FOREIGN KEY (`main_product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_components_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 product_components
-- ----------------------------

-- ----------------------------
-- Table structure for product_gifts
-- ----------------------------
CREATE TABLE `product_gifts`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `sold_product_id` int UNSIGNED NOT NULL,
  `gift_product_id` int UNSIGNED NOT NULL,
  `sold_product_unit_id` int UNSIGNED NOT NULL,
  `gift_product_unit_id` int UNSIGNED NOT NULL,
  `sold_product_quantity` double NOT NULL,
  `gift_product_quantity` double NOT NULL,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `from_date` datetime NULL DEFAULT NULL,
  `to_date` datetime NULL DEFAULT NULL,
  `state_id` int UNSIGNED NOT 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 `product_gifts_sold_product_id_foreign`(`sold_product_id` ASC) USING BTREE,
  INDEX `product_gifts_gift_product_id_foreign`(`gift_product_id` ASC) USING BTREE,
  INDEX `product_gifts_sold_product_unit_id_foreign`(`sold_product_unit_id` ASC) USING BTREE,
  INDEX `product_gifts_gift_product_unit_id_foreign`(`gift_product_unit_id` ASC) USING BTREE,
  INDEX `product_gifts_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `product_gifts_state_id_foreign`(`state_id` ASC) USING BTREE,
  INDEX `product_gifts_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_gifts_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_gifts_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_gifts_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_gifts_gift_product_id_foreign` FOREIGN KEY (`gift_product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_gifts_gift_product_unit_id_foreign` FOREIGN KEY (`gift_product_unit_id`) REFERENCES `units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_gifts_sold_product_id_foreign` FOREIGN KEY (`sold_product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_gifts_sold_product_unit_id_foreign` FOREIGN KEY (`sold_product_unit_id`) REFERENCES `units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_gifts_state_id_foreign` FOREIGN KEY (`state_id`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_gifts_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 product_gifts
-- ----------------------------

-- ----------------------------
-- Table structure for product_group_offers
-- ----------------------------
CREATE TABLE `product_group_offers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `first_product_id` int UNSIGNED NULL DEFAULT NULL,
  `second_product_id` int UNSIGNED NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `first_product_price` double NULL DEFAULT NULL,
  `second_product_price` double NULL DEFAULT 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 `product_group_offers_first_product_id_foreign`(`first_product_id` ASC) USING BTREE,
  INDEX `product_group_offers_second_product_id_foreign`(`second_product_id` ASC) USING BTREE,
  INDEX `product_group_offers_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `product_group_offers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `product_group_offers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_group_offers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_group_offers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_group_offers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_group_offers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_group_offers_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_group_offers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_group_offers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_group_offers_first_product_id_foreign` FOREIGN KEY (`first_product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_group_offers_second_product_id_foreign` FOREIGN KEY (`second_product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of product_group_offers
-- ----------------------------

-- ----------------------------
-- Table structure for product_id_categories
-- ----------------------------
CREATE TABLE `product_id_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,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `product_id_category_id` int UNSIGNED NULL DEFAULT NULL,
  `main_child_zeros` int NULL DEFAULT NULL,
  `main_child_counter` 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 `product_id_categories_product_id_category_id_foreign`(`product_id_category_id` ASC) USING BTREE,
  INDEX `product_id_categories_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_id_categories_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_id_categories_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_id_categories_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_id_categories_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_id_categories_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_id_categories_product_id_category_id_foreign` FOREIGN KEY (`product_id_category_id`) REFERENCES `product_id_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 product_id_categories
-- ----------------------------

-- ----------------------------
-- Table structure for product_id_relations
-- ----------------------------
CREATE TABLE `product_id_relations`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `product_id_id` int UNSIGNED NOT 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 `product_id_relations_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `product_id_relations_product_id_id_foreign`(`product_id_id` ASC) USING BTREE,
  INDEX `product_id_relations_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_id_relations_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_id_relations_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_id_relations_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_id_relations_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_id_relations_product_id_id_foreign` FOREIGN KEY (`product_id_id`) REFERENCES `product_ids` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of product_id_relations
-- ----------------------------

-- ----------------------------
-- Table structure for product_ids
-- ----------------------------
CREATE TABLE `product_ids`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id_category_id` int UNSIGNED NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci 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,
  `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 `product_ids_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_ids_product_id_category_id_foreign`(`product_id_category_id` ASC) USING BTREE,
  INDEX `product_ids_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_ids_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_ids_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_ids_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_ids_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_ids_product_id_category_id_foreign` FOREIGN KEY (`product_id_category_id`) REFERENCES `product_id_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 product_ids
-- ----------------------------

-- ----------------------------
-- Table structure for product_insurances
-- ----------------------------
CREATE TABLE `product_insurances`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `amount` 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 `product_insurances_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `product_insurances_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_insurances_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_insurances_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_insurances_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_insurances_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_insurances_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_insurances_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 product_insurances
-- ----------------------------

-- ----------------------------
-- Table structure for product_manufacturing_relations
-- ----------------------------
CREATE TABLE `product_manufacturing_relations`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `main_product_id` int UNSIGNED NOT NULL,
  `produced_product_id` int UNSIGNED NOT NULL,
  `work_order_line_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 `product_manufacturing_relations_main_product_id_foreign`(`main_product_id` ASC) USING BTREE,
  INDEX `product_manufacturing_relations_produced_product_id_foreign`(`produced_product_id` ASC) USING BTREE,
  INDEX `product_manufacturing_relations_work_order_line_id_foreign`(`work_order_line_id` ASC) USING BTREE,
  INDEX `product_manufacturing_relations_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `product_manufacturing_relations_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_manufacturing_relations_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_manufacturing_relations_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_manufacturing_relations_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_manufacturing_relations_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_manufacturing_relations_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_manufacturing_relations_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_manufacturing_relations_main_product_id_foreign` FOREIGN KEY (`main_product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_manufacturing_relations_produced_product_id_foreign` FOREIGN KEY (`produced_product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_manufacturing_relations_work_order_line_id_foreign` FOREIGN KEY (`work_order_line_id`) REFERENCES `work_order_lines` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of product_manufacturing_relations
-- ----------------------------

-- ----------------------------
-- Table structure for product_offers
-- ----------------------------
CREATE TABLE `product_offers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `smallest_unit_selling_price` double UNSIGNED NULL DEFAULT NULL,
  `smallest_unit_selling_price_above` double UNSIGNED NULL DEFAULT NULL,
  `smallest_unit_selling_price_above_price` double UNSIGNED NULL DEFAULT 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 `product_offers_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `product_offers_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `product_offers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `product_offers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_offers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_offers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_offers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_offers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_offers_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_offers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_offers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_offers_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of product_offers
-- ----------------------------

-- ----------------------------
-- Table structure for product_orders
-- ----------------------------
CREATE TABLE `product_orders`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `warehouse_id` int UNSIGNED NOT NULL,
  `min` double NOT NULL,
  `max` double NOT NULL,
  `reorder` double NOT NULL,
  `from_date` datetime NULL DEFAULT NULL,
  `to_date` datetime 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 `product_orders_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `product_orders_warehouse_id_foreign`(`warehouse_id` ASC) USING BTREE,
  INDEX `product_orders_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_orders_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_orders_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_orders_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_orders_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_orders_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 product_orders
-- ----------------------------

-- ----------------------------
-- Table structure for product_policies
-- ----------------------------
CREATE TABLE `product_policies`  (
  `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 NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci 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
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of product_policies
-- ----------------------------
INSERT INTO `product_policies` VALUES (1, 'سلعة ملموسة', 'Product', '1', '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);
INSERT INTO `product_policies` VALUES (2, 'سلعة خدمية', 'Services', '2', '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);

-- ----------------------------
-- Table structure for product_printers
-- ----------------------------
CREATE TABLE `product_printers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `pos_printer_id` int UNSIGNED NOT NULL,
  `number` 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 `product_printers_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `product_printers_pos_printer_id_foreign`(`pos_printer_id` ASC) USING BTREE,
  INDEX `product_printers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `product_printers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_printers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_printers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_printers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_printers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_printers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_printers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_printers_pos_printer_id_foreign` FOREIGN KEY (`pos_printer_id`) REFERENCES `pos_printers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_printers_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of product_printers
-- ----------------------------

-- ----------------------------
-- Table structure for product_quantitys
-- ----------------------------
CREATE TABLE `product_quantitys`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `warehouse_id` int UNSIGNED NOT NULL,
  `quantity` 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 `product_quantitys_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `product_quantitys_warehouse_id_foreign`(`warehouse_id` ASC) USING BTREE,
  INDEX `product_quantitys_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `product_quantitys_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_quantitys_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_quantitys_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_quantitys_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_quantitys_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_quantitys_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_quantitys_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_quantitys_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_quantitys_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 product_quantitys
-- ----------------------------

-- ----------------------------
-- Table structure for product_relations
-- ----------------------------
CREATE TABLE `product_relations`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `first_product_id` int UNSIGNED NOT NULL,
  `second_product_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 `product_relations_first_product_id_foreign`(`first_product_id` ASC) USING BTREE,
  INDEX `product_relations_second_product_id_foreign`(`second_product_id` ASC) USING BTREE,
  INDEX `product_relations_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `product_relations_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_relations_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_relations_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_relations_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_relations_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_relations_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_relations_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_relations_first_product_id_foreign` FOREIGN KEY (`first_product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_relations_second_product_id_foreign` FOREIGN KEY (`second_product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of product_relations
-- ----------------------------

-- ----------------------------
-- Table structure for product_schedule_lines
-- ----------------------------
CREATE TABLE `product_schedule_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_schedule_id` int UNSIGNED NOT NULL,
  `asset_it` int UNSIGNED NULL DEFAULT NULL,
  `product_id` int UNSIGNED NULL DEFAULT NULL,
  `user_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,
  `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 `product_schedule_lines_product_schedule_id_foreign`(`product_schedule_id` ASC) USING BTREE,
  INDEX `product_schedule_lines_asset_it_foreign`(`asset_it` ASC) USING BTREE,
  INDEX `product_schedule_lines_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `product_schedule_lines_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `product_schedule_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `product_schedule_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_schedule_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_schedule_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_schedule_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_schedule_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_schedule_lines_asset_it_foreign` FOREIGN KEY (`asset_it`) REFERENCES `assets` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_schedule_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_schedule_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_schedule_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_schedule_lines_product_schedule_id_foreign` FOREIGN KEY (`product_schedule_id`) REFERENCES `product_schedules` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_schedule_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 product_schedule_lines
-- ----------------------------

-- ----------------------------
-- Table structure for product_schedules
-- ----------------------------
CREATE TABLE `product_schedules`  (
  `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 `product_schedules_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `product_schedules_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_schedules_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_schedules_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_schedules_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_schedules_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_schedules_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_schedules_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 product_schedules
-- ----------------------------

-- ----------------------------
-- Table structure for product_specification_relations
-- ----------------------------
CREATE TABLE `product_specification_relations`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `product_specification_id` int UNSIGNED NOT NULL,
  `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `state_id` int UNSIGNED NULL DEFAULT NULL,
  `value_id` int UNSIGNED NULL DEFAULT NULL,
  `number` int UNSIGNED NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED 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 `product_specification_relations_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `product_specification_relations_product_specification_id_foreign`(`product_specification_id` ASC) USING BTREE,
  INDEX `product_specification_relations_value_id_foreign`(`value_id` ASC) USING BTREE,
  INDEX `product_specification_relations_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_specification_relations_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_specification_relations_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specification_relations_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specification_relations_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specification_relations_product_specification_id_foreign` FOREIGN KEY (`product_specification_id`) REFERENCES `product_specifications` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specification_relations_value_id_foreign` FOREIGN KEY (`value_id`) REFERENCES `product_specification_values` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 117 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of product_specification_relations
-- ----------------------------
INSERT INTO `product_specification_relations` VALUES (71, 45, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 10:57:44', '2025-07-20 10:57:44', NULL);
INSERT INTO `product_specification_relations` VALUES (72, 44, 1, NULL, 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:01:08', '2025-07-20 11:01:08', NULL);
INSERT INTO `product_specification_relations` VALUES (73, 43, 1, NULL, 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:01:36', '2025-07-20 11:01:36', NULL);
INSERT INTO `product_specification_relations` VALUES (74, 42, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:02:02', '2025-07-20 11:02:02', NULL);
INSERT INTO `product_specification_relations` VALUES (75, 41, 1, NULL, 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:02:35', '2025-07-20 11:02:35', NULL);
INSERT INTO `product_specification_relations` VALUES (76, 40, 1, NULL, 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:02:57', '2025-07-20 11:02:57', NULL);
INSERT INTO `product_specification_relations` VALUES (77, 39, 1, NULL, 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:03:19', '2025-07-20 11:03:19', NULL);
INSERT INTO `product_specification_relations` VALUES (78, 38, 1, NULL, 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:03:31', '2025-07-20 11:03:31', NULL);
INSERT INTO `product_specification_relations` VALUES (79, 37, 1, NULL, 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:03:46', '2025-07-20 11:03:46', NULL);
INSERT INTO `product_specification_relations` VALUES (80, 36, 1, NULL, 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:04:00', '2025-07-20 11:04:00', NULL);
INSERT INTO `product_specification_relations` VALUES (81, 35, 1, NULL, 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:04:31', '2025-07-20 11:04:31', NULL);
INSERT INTO `product_specification_relations` VALUES (82, 34, 1, NULL, 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:04:44', '2025-07-20 11:04:44', NULL);
INSERT INTO `product_specification_relations` VALUES (83, 33, 1, NULL, 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:04:57', '2025-07-20 11:04:57', NULL);
INSERT INTO `product_specification_relations` VALUES (84, 32, 1, NULL, 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:05:17', '2025-07-20 11:05:17', NULL);
INSERT INTO `product_specification_relations` VALUES (85, 31, 1, NULL, 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:05:30', '2025-07-20 11:05:30', NULL);
INSERT INTO `product_specification_relations` VALUES (86, 30, 1, NULL, 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:05:45', '2025-07-20 11:05:45', NULL);
INSERT INTO `product_specification_relations` VALUES (87, 29, 1, NULL, 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:05:58', '2025-07-20 11:05:58', NULL);
INSERT INTO `product_specification_relations` VALUES (88, 28, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:06:12', '2025-07-20 11:06:12', NULL);
INSERT INTO `product_specification_relations` VALUES (89, 27, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:06:25', '2025-07-20 11:06:25', NULL);
INSERT INTO `product_specification_relations` VALUES (90, 26, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:06:39', '2025-07-20 11:06:39', NULL);
INSERT INTO `product_specification_relations` VALUES (91, 25, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:06:55', '2025-07-20 11:06:55', NULL);
INSERT INTO `product_specification_relations` VALUES (92, 24, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:07:12', '2025-07-20 11:07:12', NULL);
INSERT INTO `product_specification_relations` VALUES (93, 23, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:07:25', '2025-07-20 11:07:25', NULL);
INSERT INTO `product_specification_relations` VALUES (94, 22, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:07:54', '2025-07-20 11:07:54', NULL);
INSERT INTO `product_specification_relations` VALUES (95, 21, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:08:12', '2025-07-20 11:08:12', NULL);
INSERT INTO `product_specification_relations` VALUES (97, 19, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:08:55', '2025-07-20 11:08:55', NULL);
INSERT INTO `product_specification_relations` VALUES (98, 20, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:09:13', '2025-07-20 11:09:13', NULL);
INSERT INTO `product_specification_relations` VALUES (99, 18, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:09:28', '2025-07-20 11:09:28', NULL);
INSERT INTO `product_specification_relations` VALUES (100, 17, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:09:44', '2025-07-20 11:09:44', NULL);
INSERT INTO `product_specification_relations` VALUES (101, 16, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:09:57', '2025-07-20 11:09:57', NULL);
INSERT INTO `product_specification_relations` VALUES (102, 15, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:10:19', '2025-07-20 11:10:19', NULL);
INSERT INTO `product_specification_relations` VALUES (103, 14, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:10:34', '2025-07-20 11:10:34', NULL);
INSERT INTO `product_specification_relations` VALUES (104, 13, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:10:49', '2025-07-20 11:10:49', NULL);
INSERT INTO `product_specification_relations` VALUES (105, 12, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:11:05', '2025-07-20 11:11:05', NULL);
INSERT INTO `product_specification_relations` VALUES (106, 11, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:11:24', '2025-07-20 11:11:24', NULL);
INSERT INTO `product_specification_relations` VALUES (107, 10, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:11:38', '2025-07-20 11:11:38', NULL);
INSERT INTO `product_specification_relations` VALUES (108, 9, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:13:08', '2025-07-20 11:13:08', NULL);
INSERT INTO `product_specification_relations` VALUES (109, 8, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:13:26', '2025-07-20 11:13:26', NULL);
INSERT INTO `product_specification_relations` VALUES (110, 7, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:13:43', '2025-07-20 11:13:43', NULL);
INSERT INTO `product_specification_relations` VALUES (111, 6, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:14:05', '2025-07-20 11:14:05', NULL);
INSERT INTO `product_specification_relations` VALUES (112, 5, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:14:28', '2025-07-20 11:14:28', NULL);
INSERT INTO `product_specification_relations` VALUES (113, 4, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:14:47', '2025-07-20 11:14:47', NULL);
INSERT INTO `product_specification_relations` VALUES (114, 3, 1, NULL, 2, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:15:04', '2025-07-20 11:15:04', NULL);
INSERT INTO `product_specification_relations` VALUES (115, 2, 1, '40', 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:15:25', '2025-07-20 11:15:25', NULL);
INSERT INTO `product_specification_relations` VALUES (116, 1, 1, '50', 1, NULL, 1, NULL, NULL, NULL, '2025-07-20 11:15:40', '2025-07-20 11:15:40', NULL);

-- ----------------------------
-- Table structure for product_specification_template_lines
-- ----------------------------
CREATE TABLE `product_specification_template_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_specification_template_id` int UNSIGNED NULL DEFAULT NULL,
  `product_specification_id` int UNSIGNED NULL DEFAULT NULL,
  `rank` 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 `product_specification_template_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `product_specification_template_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_specification_template_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_specification_template_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_specification_template_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specification_template_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specification_template_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specification_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 product_specification_template_lines
-- ----------------------------

-- ----------------------------
-- Table structure for product_specification_templates
-- ----------------------------
CREATE TABLE `product_specification_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 `product_specification_templates_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `product_specification_templates_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_specification_templates_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_specification_templates_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_specification_templates_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specification_templates_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specification_templates_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specification_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 product_specification_templates
-- ----------------------------

-- ----------------------------
-- Table structure for product_specification_types
-- ----------------------------
CREATE TABLE `product_specification_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,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` 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 `product_specification_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_specification_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_specification_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specification_types_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 product_specification_types
-- ----------------------------
INSERT INTO `product_specification_types` VALUES (1, 'كتابة', '1', 'Text', 1, NULL, NULL, '2025-06-12 14:05:50', '2025-06-12 14:05:50', NULL);
INSERT INTO `product_specification_types` VALUES (2, 'اختيار من متعدد', '2', 'Selects', 1, NULL, NULL, '2025-06-12 14:05:50', '2025-06-12 14:05:50', NULL);
INSERT INTO `product_specification_types` VALUES (3, 'من الى', '3', 'Range', 1, NULL, NULL, '2025-06-12 14:05:50', '2025-06-12 14:05:50', NULL);

-- ----------------------------
-- Table structure for product_specification_values
-- ----------------------------
CREATE TABLE `product_specification_values`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `product_specification_id` int UNSIGNED NOT NULL,
  `product_specification_value_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,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `product_specification_values_product_specification_id_foreign`(`product_specification_id` ASC) USING BTREE,
  INDEX `product_specification_values_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_specification_values_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_specification_values_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specification_values_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specification_values_product_specification_id_foreign` FOREIGN KEY (`product_specification_id`) REFERENCES `product_specifications` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of product_specification_values
-- ----------------------------

-- ----------------------------
-- Table structure for product_specifications
-- ----------------------------
CREATE TABLE `product_specifications`  (
  `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,
  `validation` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `product_specification_type_id` int UNSIGNED NOT NULL,
  `available_on_reports` int UNSIGNED NOT NULL,
  `available_on_invoices` int UNSIGNED NOT NULL,
  `available_on_invoices_purchases` 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,
  `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 `product_specifications_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `product_specifications_available_on_reports_foreign`(`available_on_reports` ASC) USING BTREE,
  INDEX `product_specifications_available_on_invoices_foreign`(`available_on_invoices` ASC) USING BTREE,
  INDEX `product_specifications_product_specification_type_id_foreign`(`product_specification_type_id` ASC) USING BTREE,
  INDEX `product_specifications_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_specifications_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_specifications_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specifications_available_on_invoices_foreign` FOREIGN KEY (`available_on_invoices`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specifications_available_on_reports_foreign` FOREIGN KEY (`available_on_reports`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specifications_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specifications_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_specifications_product_specification_type_id_foreign` FOREIGN KEY (`product_specification_type_id`) REFERENCES `product_specification_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 product_specifications
-- ----------------------------
INSERT INTO `product_specifications` VALUES (1, 'المساحة', '1', NULL, 'null|text', 1, 1, 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:15:34', '2025-07-08 15:15:34', NULL);

-- ----------------------------
-- Table structure for product_total_quantitys
-- ----------------------------
CREATE TABLE `product_total_quantitys`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `in_date_unit_rate` double NOT NULL,
  `quantity` double NOT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` 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 `product_total_quantitys_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `product_total_quantitys_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `product_total_quantitys_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_total_quantitys_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_total_quantitys_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_total_quantitys_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_total_quantitys_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_total_quantitys_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 product_total_quantitys
-- ----------------------------

-- ----------------------------
-- Table structure for product_types
-- ----------------------------
CREATE TABLE `product_types`  (
  `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,
  `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 `product_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_types_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 product_types
-- ----------------------------
INSERT INTO `product_types` VALUES (1, 'سلعة مخزنة', 'Storable product', '1', 1, NULL, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);
INSERT INTO `product_types` VALUES (2, 'سلعة خدمية', 'Service', '2', 1, NULL, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);
INSERT INTO `product_types` VALUES (3, 'سلعة توزين', 'Consumable', '3', 1, NULL, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);
INSERT INTO `product_types` VALUES (4, 'بكج', 'Package', '3', 1, NULL, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);

-- ----------------------------
-- Table structure for product_unit_types
-- ----------------------------
CREATE TABLE `product_unit_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,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` 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 `product_unit_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_unit_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_unit_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_unit_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 product_unit_types
-- ----------------------------
INSERT INTO `product_unit_types` VALUES (1, 'عادي', '1', 'normal', 1, NULL, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);
INSERT INTO `product_unit_types` VALUES (2, 'تجميعي', '1', 'totaly', 1, NULL, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);

-- ----------------------------
-- Table structure for product_units
-- ----------------------------
CREATE TABLE `product_units`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `unit_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `barcode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `smallest_unit_relation` double NOT NULL,
  `price` double NULL DEFAULT NULL,
  `cost` double NULL DEFAULT NULL,
  `available_on_pos` int 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 `product_units_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `product_units_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `product_units_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `product_units_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `product_units_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_units_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_units_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `product_units_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 product_units
-- ----------------------------

-- ----------------------------
-- Table structure for products
-- ----------------------------
CREATE TABLE `products`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `sales_invoice_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `purchases_invoice_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,
  `product_id` 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,
  `can_be_sold` int UNSIGNED NOT NULL,
  `can_be_purchased` int UNSIGNED NOT NULL,
  `can_be_rented` int UNSIGNED NOT NULL,
  `available_on_pos` int UNSIGNED NOT NULL,
  `pos_quick_lunch` int UNSIGNED NULL DEFAULT NULL,
  `pos_saparated_state_id` int UNSIGNED NULL DEFAULT NULL,
  `available_on_manufacture` int UNSIGNED NOT NULL,
  `product_category_id` int UNSIGNED NULL DEFAULT NULL,
  `product_unit_type_id` int UNSIGNED NULL DEFAULT NULL,
  `location_id` int UNSIGNED NULL DEFAULT NULL,
  `area_id` int UNSIGNED NULL DEFAULT NULL,
  `has_been_sold_from_car_auctions` int UNSIGNED NULL DEFAULT NULL,
  `number_of_days_until_production_is_completed` double UNSIGNED NULL DEFAULT NULL,
  `production_capacity_per_day` double UNSIGNED NULL DEFAULT NULL,
  `discount_value` double NULL DEFAULT NULL,
  `balance` double NULL DEFAULT NULL,
  `smallest_unit_id` int UNSIGNED NOT NULL,
  `smallest_unit_barcode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `smallest_unit_selling_price` double NULL DEFAULT NULL,
  `min_selling_price` double NULL DEFAULT NULL,
  `max_selling_price` double NULL DEFAULT NULL,
  `min_smallest_unit_selling_price` double NULL DEFAULT NULL,
  `smallest_unit_cost` double NULL DEFAULT NULL,
  `smallest_unit_selling_price_above` double NULL DEFAULT NULL,
  `smallest_unit_selling_price_above_price` double NULL DEFAULT NULL,
  `tax_value` double NULL DEFAULT NULL,
  `state_id` int UNSIGNED NOT NULL,
  `warehouse_id` int UNSIGNED NULL DEFAULT NULL,
  `product_type_id` int UNSIGNED NOT NULL,
  `product_policy_id` int UNSIGNED NULL DEFAULT NULL,
  `tax_user_id` int UNSIGNED NULL DEFAULT NULL,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `get_specification_on_lines` int UNSIGNED NULL DEFAULT NULL,
  `methods_of_disbursement_of_good_id` int UNSIGNED NULL DEFAULT NULL,
  `is_products_has_expire_date` int UNSIGNED NULL DEFAULT NULL,
  `is_products_has_patch_number` int UNSIGNED NULL DEFAULT NULL,
  `is_products_has_serial_number` int UNSIGNED NULL DEFAULT NULL,
  `last_zero_note_voucher_id` int UNSIGNED NULL DEFAULT NULL,
  `can_change_price_with_no_permission` int UNSIGNED NULL DEFAULT NULL,
  `offer_end_date` date NULL DEFAULT NULL,
  `offer_start_date` date NULL DEFAULT NULL,
  `last_purchase_date` date NULL DEFAULT NULL,
  `last_purchase_purchase` double NULL DEFAULT NULL,
  `last_purchase_price` double NULL DEFAULT NULL,
  `last_purchase_discount` double NULL DEFAULT NULL,
  `custom_percentage` double NULL DEFAULT NULL,
  `last_calc_cost` datetime 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,
  `dose_it_have_warranty` int NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `products_can_be_sold_foreign`(`can_be_sold` ASC) USING BTREE,
  INDEX `products_methods_of_disbursement_of_good_id_foreign`(`methods_of_disbursement_of_good_id` ASC) USING BTREE,
  INDEX `products_can_be_purchased_foreign`(`can_be_purchased` ASC) USING BTREE,
  INDEX `products_can_be_rented_foreign`(`can_be_rented` ASC) USING BTREE,
  INDEX `products_available_on_pos_foreign`(`available_on_pos` ASC) USING BTREE,
  INDEX `products_pos_quick_lunch_foreign`(`pos_quick_lunch` ASC) USING BTREE,
  INDEX `products_available_on_manufacture_foreign`(`available_on_manufacture` ASC) USING BTREE,
  INDEX `products_warehouse_id_foreign`(`warehouse_id` ASC) USING BTREE,
  INDEX `products_product_policy_id_foreign`(`product_policy_id` ASC) USING BTREE,
  INDEX `products_product_type_id_foreign`(`product_type_id` ASC) USING BTREE,
  INDEX `products_tax_user_id_foreign`(`tax_user_id` ASC) USING BTREE,
  INDEX `products_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `products_get_specification_on_lines_foreign`(`get_specification_on_lines` ASC) USING BTREE,
  INDEX `products_state_id_foreign`(`state_id` ASC) USING BTREE,
  INDEX `products_product_category_id_foreign`(`product_category_id` ASC) USING BTREE,
  INDEX `products_product_unit_type_id_foreign`(`product_unit_type_id` ASC) USING BTREE,
  INDEX `products_is_products_has_expire_date_foreign`(`is_products_has_expire_date` ASC) USING BTREE,
  INDEX `products_is_products_has_patch_number_foreign`(`is_products_has_patch_number` ASC) USING BTREE,
  INDEX `products_is_products_has_serial_number_foreign`(`is_products_has_serial_number` ASC) USING BTREE,
  INDEX `products_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `products_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `products_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `products_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_available_on_manufacture_foreign` FOREIGN KEY (`available_on_manufacture`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_available_on_pos_foreign` FOREIGN KEY (`available_on_pos`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_can_be_purchased_foreign` FOREIGN KEY (`can_be_purchased`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_can_be_rented_foreign` FOREIGN KEY (`can_be_rented`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_can_be_sold_foreign` FOREIGN KEY (`can_be_sold`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_get_specification_on_lines_foreign` FOREIGN KEY (`get_specification_on_lines`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_is_products_has_expire_date_foreign` FOREIGN KEY (`is_products_has_expire_date`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_is_products_has_patch_number_foreign` FOREIGN KEY (`is_products_has_patch_number`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_is_products_has_serial_number_foreign` FOREIGN KEY (`is_products_has_serial_number`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_methods_of_disbursement_of_good_id_foreign` FOREIGN KEY (`methods_of_disbursement_of_good_id`) REFERENCES `methods_of_disbursement_of_goods` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_pos_quick_lunch_foreign` FOREIGN KEY (`pos_quick_lunch`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_product_category_id_foreign` FOREIGN KEY (`product_category_id`) REFERENCES `product_categories` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_product_policy_id_foreign` FOREIGN KEY (`product_policy_id`) REFERENCES `product_policies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_product_type_id_foreign` FOREIGN KEY (`product_type_id`) REFERENCES `product_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_product_unit_type_id_foreign` FOREIGN KEY (`product_unit_type_id`) REFERENCES `product_unit_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_state_id_foreign` FOREIGN KEY (`state_id`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_tax_user_id_foreign` FOREIGN KEY (`tax_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `products_warehouse_id_foreign` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouses` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 46 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of products
-- ----------------------------
INSERT INTO `products` VALUES (1, 'محل رقم 1 + 2', NULL, NULL, '1001', NULL, 'Product', 1, 1, 1, 1, 1, 2, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, 500, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, 1, 1, 2, 1, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-06-12 14:05:49', '2025-07-20 11:15:40', NULL, 1);
INSERT INTO `products` VALUES (2, 'محل رقم 3', NULL, NULL, '1002', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1002', 300, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:19:04', '2025-07-20 11:15:25', NULL, 2);
INSERT INTO `products` VALUES (3, 'محل رقم 4', NULL, NULL, '1003', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1003', 300, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:21:08', '2025-07-20 11:15:04', NULL, 2);
INSERT INTO `products` VALUES (4, 'محل رقم 5', NULL, NULL, '1004', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1004', 125, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:21:35', '2025-07-20 11:14:47', NULL, 2);
INSERT INTO `products` VALUES (5, 'محل رقم 6+7', NULL, NULL, '1005', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1005', 300, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:21:53', '2025-07-20 11:14:28', NULL, 2);
INSERT INTO `products` VALUES (6, 'محل رقم 8', NULL, NULL, '1006', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1006', 125, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:22:08', '2025-07-20 11:14:05', NULL, 2);
INSERT INTO `products` VALUES (7, 'محل رقم 9', NULL, NULL, '1007', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1007', 225, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:22:27', '2025-07-20 11:13:43', NULL, 2);
INSERT INTO `products` VALUES (8, 'محل رقم 10', NULL, NULL, '1008', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1008', 225, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:22:43', '2025-07-20 11:13:26', NULL, 2);
INSERT INTO `products` VALUES (9, 'محل رقم 11', NULL, NULL, '1009', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1009', 225, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:34:21', '2025-07-20 11:13:08', NULL, 2);
INSERT INTO `products` VALUES (10, 'محل رقم 12', NULL, NULL, '1010', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1010', 170, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:34:37', '2025-07-20 11:11:38', NULL, 2);
INSERT INTO `products` VALUES (11, 'محل رقم 13', NULL, NULL, '1011', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1011', 225, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:34:51', '2025-07-20 11:11:24', NULL, 2);
INSERT INTO `products` VALUES (12, 'محل رقم 14', NULL, NULL, '1012', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1012', 210, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:35:01', '2025-07-20 11:11:05', NULL, 2);
INSERT INTO `products` VALUES (13, 'محل رقم 15', NULL, NULL, '1013', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1013', 225, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:36:58', '2025-07-20 11:10:49', NULL, 2);
INSERT INTO `products` VALUES (14, 'محل رقم 16', NULL, NULL, '1014', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1014', 225, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:37:16', '2025-07-20 11:10:34', NULL, 2);
INSERT INTO `products` VALUES (15, 'محل رقم 17', NULL, NULL, '1015', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1015', 350, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:37:27', '2025-07-20 11:10:19', NULL, 2);
INSERT INTO `products` VALUES (16, 'محل رقم 18', NULL, NULL, '1016', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1016', 175, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:37:38', '2025-07-20 11:09:57', NULL, 2);
INSERT INTO `products` VALUES (17, 'محل رقم 19', NULL, NULL, '1017', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1017', 175, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:37:51', '2025-07-20 11:09:44', NULL, 2);
INSERT INTO `products` VALUES (18, 'محل رقم 20', NULL, NULL, '1018', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1018', 175, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:38:03', '2025-07-20 11:09:28', NULL, 2);
INSERT INTO `products` VALUES (19, 'محل رقم 21+22', NULL, NULL, '1019', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1019', 250, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:38:58', '2025-07-20 11:08:55', NULL, 2);
INSERT INTO `products` VALUES (20, 'محل 23+24', NULL, NULL, '1020', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1020', 250, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:39:19', '2025-07-20 11:09:13', NULL, 2);
INSERT INTO `products` VALUES (21, 'محل رقم 25', NULL, NULL, '1021', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1021', 80, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:40:04', '2025-07-20 11:08:12', NULL, 2);
INSERT INTO `products` VALUES (22, 'محل رقم 26', NULL, NULL, '1022', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1022', 150, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:40:14', '2025-07-20 11:07:54', NULL, 2);
INSERT INTO `products` VALUES (23, 'محل رقم 27', NULL, NULL, '1023', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1023', 150, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:40:29', '2025-07-20 11:07:25', NULL, 2);
INSERT INTO `products` VALUES (24, 'محل رقم 28', NULL, NULL, '1024', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1024', 150, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:40:42', '2025-07-20 11:07:12', NULL, 2);
INSERT INTO `products` VALUES (25, 'محل رقم 29', NULL, NULL, '1025', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1025', 150, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:40:53', '2025-07-20 11:06:55', NULL, 2);
INSERT INTO `products` VALUES (26, 'محل رقم 30', NULL, NULL, '1026', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1026', 150, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:41:04', '2025-07-20 11:06:39', NULL, 2);
INSERT INTO `products` VALUES (27, 'محل رقم 31', NULL, NULL, '1027', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1027', 150, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:41:15', '2025-07-20 11:06:25', NULL, 2);
INSERT INTO `products` VALUES (28, 'محل رقم 32+33', NULL, NULL, '1028', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '1028', 300, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-08 15:41:30', '2025-07-20 11:06:12', NULL, 2);
INSERT INTO `products` VALUES (29, 'سكن غرفة رقم 1 / خلف المكتب', NULL, NULL, '3001', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '3001', 80, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-09 13:06:39', '2025-07-20 11:05:58', NULL, 2);
INSERT INTO `products` VALUES (30, 'سكن غرفة رقم 2 / فوق محل 1+2', NULL, NULL, '3002', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '3002', 175, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-09 13:07:43', '2025-07-20 11:05:45', NULL, 2);
INSERT INTO `products` VALUES (31, 'سكن غرفة رقم 3 / فوق محل رقم 4', NULL, NULL, '3003', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '3003', 70, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-09 13:08:18', '2025-07-20 11:05:30', NULL, 2);
INSERT INTO `products` VALUES (32, 'سكن غرفة رقم 4 / فوق محل 3+4', NULL, NULL, '3004', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '3004', 125, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-09 13:09:38', '2025-07-20 11:05:17', NULL, 2);
INSERT INTO `products` VALUES (33, 'سكن غرفة رقم 5 / طابق اول يمين', NULL, NULL, '3005', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '3005', 80, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-09 13:10:53', '2025-07-20 11:04:57', NULL, 2);
INSERT INTO `products` VALUES (34, 'سكن فرفة رقم 6 / طابق اول يمين', NULL, NULL, '3006', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '3006', 80, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-09 13:11:35', '2025-07-20 11:04:44', NULL, 2);
INSERT INTO `products` VALUES (35, 'سكن غرفة رقم 7 / طابق اول يمين', NULL, NULL, '3007', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '3007', 85, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-09 13:12:09', '2025-07-20 11:04:31', NULL, 2);
INSERT INTO `products` VALUES (36, 'سكن غرفة رقم 8 / طابق ثاني شمال', NULL, NULL, '3008', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '3008', 70, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-09 13:19:13', '2025-07-20 11:04:00', NULL, 2);
INSERT INTO `products` VALUES (37, 'سكن فرغة رقم 9 / طابق ثاني شمال', NULL, NULL, '3009', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '3009', 70, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-09 13:19:43', '2025-07-20 11:03:46', NULL, 2);
INSERT INTO `products` VALUES (38, 'سكن غرفة رقم 10 / طابق ثاني شمال', NULL, NULL, '3010', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '3010', 70, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-09 13:20:12', '2025-07-20 11:03:31', NULL, 2);
INSERT INTO `products` VALUES (39, 'سكن غرفة رقم 11 / طابق ثاني شمال', NULL, NULL, '3011', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '3011', 70, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-09 13:20:48', '2025-07-20 11:03:19', NULL, 2);
INSERT INTO `products` VALUES (40, 'مشغل طابق اول يمين', NULL, NULL, '2001', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '2001', 166.667, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-09 13:22:39', '2025-07-20 11:02:57', NULL, 2);
INSERT INTO `products` VALUES (41, 'مشغل طابق اول شمال', NULL, NULL, '2002', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '2002', 333.334, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-09 13:23:18', '2025-07-20 11:02:35', NULL, 2);
INSERT INTO `products` VALUES (42, 'مشغل طابق ثاني يمين', NULL, NULL, '2003', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '2003', 333.334, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-09 13:23:52', '2025-07-20 11:02:02', NULL, 2);
INSERT INTO `products` VALUES (43, 'مشغل طابق ثاني شمال', NULL, NULL, '2004', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '2004', 166.667, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-09 13:24:21', '2025-07-20 11:01:36', NULL, 2);
INSERT INTO `products` VALUES (44, 'مشغل طابق ثالث شمال / هنجر', NULL, NULL, '2005', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '2005', 300, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-09 13:25:06', '2025-07-20 11:01:08', NULL, 2);
INSERT INTO `products` VALUES (45, 'الارض الفارغة', NULL, NULL, '4001', NULL, NULL, 1, 1, 1, 1, NULL, 1, 2, 4, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, '4001', 300, 0, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-07-18 22:21:46', '2025-07-20 10:57:44', NULL, 2);

-- ----------------------------
-- Table structure for profit_and_loss_settings
-- ----------------------------
CREATE TABLE `profit_and_loss_settings`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `main_account_id` int NULL DEFAULT NULL,
  `is_it_goods_at_the_beginning_of_the_period` int UNSIGNED NULL DEFAULT NULL,
  `is_it_goods_at_the_ending_of_the_period` int UNSIGNED NULL DEFAULT NULL,
  `is_it_title` int UNSIGNED NULL DEFAULT NULL,
  `is_it_account` int UNSIGNED NULL DEFAULT NULL,
  `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `formula` 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 `profit_and_loss_settings_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `profit_and_loss_settings_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `profit_and_loss_settings_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `profit_and_loss_settings_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `profit_and_loss_settings_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `profit_and_loss_settings_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `profit_and_loss_settings_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `profit_and_loss_settings_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 111 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of profit_and_loss_settings
-- ----------------------------
INSERT INTO `profit_and_loss_settings` VALUES (102, 'الايراد', NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-08-06 22:33:40', '2025-08-06 22:33:40', NULL);
INSERT INTO `profit_and_loss_settings` VALUES (103, 'ايرادات', 21, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-08-06 22:33:40', '2025-08-06 22:33:40', NULL);
INSERT INTO `profit_and_loss_settings` VALUES (104, 'مجمل صافي الربح', 21, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-08-06 22:33:40', '2025-08-06 22:33:40', NULL);
INSERT INTO `profit_and_loss_settings` VALUES (105, 'مصاريف', NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-08-06 22:33:40', '2025-08-06 22:33:40', NULL);
INSERT INTO `profit_and_loss_settings` VALUES (106, 'المصاريف', 26, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-08-06 22:33:40', '2025-08-06 22:33:40', NULL);
INSERT INTO `profit_and_loss_settings` VALUES (107, 'صافي الربح', NULL, NULL, NULL, NULL, NULL, NULL, 'مجمل صافي الربح,+,المصاريف', NULL, 1, NULL, NULL, NULL, NULL, '2025-08-06 22:33:40', '2025-08-06 22:33:40', NULL);
INSERT INTO `profit_and_loss_settings` VALUES (108, 'حصة الشريك عيسى الطباخي', NULL, NULL, NULL, NULL, NULL, NULL, 'صافي الربح,*,0.3955', NULL, 1, NULL, NULL, NULL, NULL, '2025-08-06 22:33:40', '2025-08-06 22:33:40', NULL);
INSERT INTO `profit_and_loss_settings` VALUES (109, 'حصة الشريك نزار القريوتي', NULL, NULL, NULL, NULL, NULL, NULL, 'صافي الربح,*,0.3955', NULL, 1, NULL, NULL, NULL, NULL, '2025-08-06 22:33:40', '2025-08-06 22:33:40', NULL);
INSERT INTO `profit_and_loss_settings` VALUES (110, 'حصة الشريك جمال الشلبي', NULL, NULL, NULL, NULL, NULL, NULL, 'صافي الربح,*,0.209', NULL, 1, NULL, NULL, NULL, NULL, '2025-08-06 22:33:40', '2025-08-06 22:33:40', NULL);

-- ----------------------------
-- Table structure for purchase_order_line_specifications
-- ----------------------------
CREATE TABLE `purchase_order_line_specifications`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `purchase_order_line_id` int UNSIGNED NOT NULL,
  `product_specification_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `product_specification_value_id` int UNSIGNED NULL DEFAULT NULL,
  `value` 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 `purchase_order_line_specifications_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `purchase_order_line_specifications_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `purchase_order_line_specifications_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `purchase_order_line_specifications_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `purchase_order_line_specifications_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `purchase_order_line_specifications_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_line_specifications_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_line_specifications_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_line_specifications_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_line_specifications_product_id_foreign` FOREIGN KEY (`product_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 purchase_order_line_specifications
-- ----------------------------

-- ----------------------------
-- Table structure for purchase_order_lines
-- ----------------------------
CREATE TABLE `purchase_order_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `purchase_order_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `quantity` double UNSIGNED NOT NULL,
  `in_date_tax` double NULL DEFAULT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `in_date_currency_rate` double NOT NULL,
  `price` double UNSIGNED NULL DEFAULT NULL,
  `price_with_cost` double UNSIGNED NULL DEFAULT NULL,
  `date` date NOT NULL,
  `expire_date` date NULL DEFAULT NULL,
  `brand` 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,
  `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 `purchase_order_lines_purchase_order_id_foreign`(`purchase_order_id` ASC) USING BTREE,
  INDEX `purchase_order_lines_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `purchase_order_lines_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `purchase_order_lines_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `purchase_order_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `purchase_order_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `purchase_order_lines_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `purchase_order_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `purchase_order_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `purchase_order_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_lines_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_lines_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_lines_purchase_order_id_foreign` FOREIGN KEY (`purchase_order_id`) REFERENCES `purchase_orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_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 purchase_order_lines
-- ----------------------------

-- ----------------------------
-- Table structure for purchase_order_note_vouchers
-- ----------------------------
CREATE TABLE `purchase_order_note_vouchers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `note_voucher_id` int UNSIGNED NOT NULL,
  `purchase_order_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 `purchase_order_note_vouchers_purchase_order_id_foreign`(`purchase_order_id` ASC) USING BTREE,
  INDEX `purchase_order_note_vouchers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `purchase_order_note_vouchers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `purchase_order_note_vouchers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `purchase_order_note_vouchers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `purchase_order_note_vouchers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_note_vouchers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_note_vouchers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_note_vouchers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_note_vouchers_purchase_order_id_foreign` FOREIGN KEY (`purchase_order_id`) REFERENCES `purchase_orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of purchase_order_note_vouchers
-- ----------------------------

-- ----------------------------
-- Table structure for purchase_order_status
-- ----------------------------
CREATE TABLE `purchase_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 `purchase_order_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `purchase_order_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `purchase_order_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `purchase_order_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `purchase_order_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_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 purchase_order_status
-- ----------------------------
INSERT INTO `purchase_order_status` VALUES (1, 'مفتوح', '1', 'Open', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:54', '2025-06-12 14:05:54', NULL);
INSERT INTO `purchase_order_status` VALUES (2, 'قيد التحويل الى فاتورة', '2', 'Pending transfer to invoice', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:54', '2025-06-12 14:05:54', NULL);
INSERT INTO `purchase_order_status` VALUES (3, 'اغلق', '3', 'Close', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:54', '2025-06-12 14:05:54', NULL);

-- ----------------------------
-- Table structure for purchase_order_types
-- ----------------------------
CREATE TABLE `purchase_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 NULL DEFAULT NULL,
  `has_custom_field` int UNSIGNED NULL DEFAULT NULL,
  `next_number` int UNSIGNED NULL DEFAULT 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 `purchase_order_types_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `purchase_order_types_has_custom_field_foreign`(`has_custom_field` ASC) USING BTREE,
  INDEX `purchase_order_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `purchase_order_types_numbering_type_id_foreign`(`numbering_type_id` ASC) USING BTREE,
  INDEX `purchase_order_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `purchase_order_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `purchase_order_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `purchase_order_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_types_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_order_types_has_custom_field_foreign` FOREIGN KEY (`has_custom_field`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_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 purchase_order_types
-- ----------------------------
INSERT INTO `purchase_order_types` VALUES (1, 'امر شراء محلي', '1', 'Internal purchase order', 1, NULL, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:50', '2025-06-12 14:05:50', NULL);
INSERT INTO `purchase_order_types` VALUES (2, 'امر شراء استيراد', '2', 'External purchase order', 1, NULL, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:50', '2025-06-12 14:05:50', NULL);

-- ----------------------------
-- Table structure for purchase_orders
-- ----------------------------
CREATE TABLE `purchase_orders`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `delivery_date` date NULL DEFAULT NULL,
  `user_id` int UNSIGNED NOT NULL,
  `purchase_order_type_id` int UNSIGNED NOT NULL,
  `request_for_quotation_id` int UNSIGNED NULL DEFAULT NULL,
  `material_requisition_id` int UNSIGNED NULL DEFAULT NULL,
  `purchase_order_state_id` int UNSIGNED NOT NULL,
  `payment_term_id` int UNSIGNED NULL DEFAULT NULL,
  `delivery_type_id` int UNSIGNED NULL DEFAULT NULL,
  `working_contract_id` int UNSIGNED NULL DEFAULT NULL,
  `note_voucher_id` int UNSIGNED NULL DEFAULT NULL,
  `tax_state_id` int UNSIGNED NULL DEFAULT NULL,
  `date` date NOT NULL,
  `terms` 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,
  `branch_id` int UNSIGNED NOT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `in_date_currency_rate` double 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 `purchase_orders_purchase_order_type_id_foreign`(`purchase_order_type_id` ASC) USING BTREE,
  INDEX `purchase_orders_request_for_quotation_id_foreign`(`request_for_quotation_id` ASC) USING BTREE,
  INDEX `purchase_orders_material_requisition_id_foreign`(`material_requisition_id` ASC) USING BTREE,
  INDEX `purchase_orders_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `purchase_orders_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `purchase_orders_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `purchase_orders_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `purchase_orders_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `purchase_orders_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `purchase_orders_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `purchase_orders_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_orders_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_orders_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_orders_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_orders_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_orders_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_orders_material_requisition_id_foreign` FOREIGN KEY (`material_requisition_id`) REFERENCES `material_requisitions` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_orders_purchase_order_type_id_foreign` FOREIGN KEY (`purchase_order_type_id`) REFERENCES `purchase_order_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_orders_request_for_quotation_id_foreign` FOREIGN KEY (`request_for_quotation_id`) REFERENCES `request_for_quotations` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_orders_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 purchase_orders
-- ----------------------------

-- ----------------------------
-- Table structure for purchase_orders_material_requisitions
-- ----------------------------
CREATE TABLE `purchase_orders_material_requisitions`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `purchase_order_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 `purchase_orders_material_requisitions_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `purchase_orders_material_requisitions_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `purchase_orders_material_requisitions_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `purchase_orders_material_requisitions_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `purchase_orders_material_requisitions_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_orders_material_requisitions_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_orders_material_requisitions_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_orders_material_requisitions_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 purchase_orders_material_requisitions
-- ----------------------------

-- ----------------------------
-- Table structure for purchase_orders_request_for_quotations
-- ----------------------------
CREATE TABLE `purchase_orders_request_for_quotations`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `purchase_order_id` int UNSIGNED NOT NULL,
  `request_for_quotation_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 `purchase_orders_request_for_quotations_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `purchase_orders_request_for_quotations_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `purchase_orders_request_for_quotations_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `purchase_orders_request_for_quotations_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `purchase_orders_request_for_quotations_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_orders_request_for_quotations_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_orders_request_for_quotations_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_orders_request_for_quotations_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 purchase_orders_request_for_quotations
-- ----------------------------

-- ----------------------------
-- Table structure for purchase_settings
-- ----------------------------
CREATE TABLE `purchase_settings`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `purchase_order_header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `purchase_order_footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `foreign_order_user_id` int UNSIGNED NULL DEFAULT NULL,
  `external_purchases_account_id` int UNSIGNED NULL DEFAULT NULL,
  `can_have_more_than_one_partner_in_foreign_order` int UNSIGNED NULL DEFAULT NULL,
  `custom_user_id` int UNSIGNED NULL DEFAULT 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 `purchase_settings_external_purchases_account_id_foreign`(`external_purchases_account_id` ASC) USING BTREE,
  INDEX `purchase_settings_foreign_order_user_id_foreign`(`foreign_order_user_id` ASC) USING BTREE,
  INDEX `purchase_settings_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `purchase_settings_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `purchase_settings_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `purchase_settings_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `purchase_settings_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_settings_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_settings_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_settings_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_settings_external_purchases_account_id_foreign` FOREIGN KEY (`external_purchases_account_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_settings_foreign_order_user_id_foreign` FOREIGN KEY (`foreign_order_user_id`) 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 purchase_settings
-- ----------------------------
INSERT INTO `purchase_settings` VALUES (1, '\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, NULL, NULL, NULL, 1, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);

-- ----------------------------
-- Table structure for qc_companies
-- ----------------------------
CREATE TABLE `qc_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 NULL DEFAULT NULL,
  `company_price` double UNSIGNED NULL DEFAULT NULL,
  `customer_price` 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 `qc_companies_account_user_id_foreign`(`account_user_id` ASC) USING BTREE,
  INDEX `qc_companies_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `qc_companies_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `qc_companies_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `qc_companies_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `qc_companies_account_user_id_foreign` FOREIGN KEY (`account_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `qc_companies_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `qc_companies_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `qc_companies_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `qc_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 qc_companies
-- ----------------------------

-- ----------------------------
-- Table structure for quality_groups
-- ----------------------------
CREATE TABLE `quality_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 NULL,
  `sub_child_counter` double NULL DEFAULT NULL,
  `quality_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 `quality_groups_quality_group_id_foreign`(`quality_group_id` ASC) USING BTREE,
  INDEX `quality_groups_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `quality_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `quality_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `quality_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `quality_groups_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_groups_quality_group_id_foreign` FOREIGN KEY (`quality_group_id`) REFERENCES `quality_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 quality_groups
-- ----------------------------
INSERT INTO `quality_groups` VALUES (1, 'فحص اولي', '1', 'First Test', 10, NULL, 1000, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:57', '2025-06-12 14:05:57', NULL);
INSERT INTO `quality_groups` VALUES (2, 'فحص نهائي', '2', 'Final Test', 10, NULL, 1000, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:57', '2025-06-12 14:05:57', NULL);

-- ----------------------------
-- Table structure for quality_step_status
-- ----------------------------
CREATE TABLE `quality_step_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 `quality_step_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `quality_step_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `quality_step_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `quality_step_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `quality_step_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_step_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_step_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_step_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 quality_step_status
-- ----------------------------
INSERT INTO `quality_step_status` VALUES (1, 'لا يوجد أي اجراء', '1', 'Pending', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:58', '2025-06-12 14:05:58', NULL);
INSERT INTO `quality_step_status` VALUES (2, 'اخذ عينة وباقي عينات', '2', 'One test tack and there is more', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:58', '2025-06-12 14:05:58', NULL);
INSERT INTO `quality_step_status` VALUES (3, 'اكتمل', '3', 'Finshed', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:58', '2025-06-12 14:05:58', NULL);

-- ----------------------------
-- Table structure for quality_test_key_values
-- ----------------------------
CREATE TABLE `quality_test_key_values`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `quality_test_key_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 `quality_test_key_values_quality_test_key_id_foreign`(`quality_test_key_id` ASC) USING BTREE,
  INDEX `quality_test_key_values_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `quality_test_key_values_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `quality_test_key_values_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `quality_test_key_values_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `quality_test_key_values_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_test_key_values_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_test_key_values_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_test_key_values_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_test_key_values_quality_test_key_id_foreign` FOREIGN KEY (`quality_test_key_id`) REFERENCES `quality_test_keys` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of quality_test_key_values
-- ----------------------------

-- ----------------------------
-- Table structure for quality_test_keys
-- ----------------------------
CREATE TABLE `quality_test_keys`  (
  `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,
  `quality_type_id` int UNSIGNED NOT NULL,
  `product_specification_type_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 `quality_test_keys_quality_type_id_foreign`(`quality_type_id` ASC) USING BTREE,
  INDEX `quality_test_keys_product_specification_type_id_foreign`(`product_specification_type_id` ASC) USING BTREE,
  INDEX `quality_test_keys_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `quality_test_keys_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `quality_test_keys_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `quality_test_keys_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `quality_test_keys_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_test_keys_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_test_keys_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_test_keys_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_test_keys_product_specification_type_id_foreign` FOREIGN KEY (`product_specification_type_id`) REFERENCES `product_specification_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_test_keys_quality_type_id_foreign` FOREIGN KEY (`quality_type_id`) REFERENCES `quality_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 quality_test_keys
-- ----------------------------

-- ----------------------------
-- Table structure for quality_test_lines
-- ----------------------------
CREATE TABLE `quality_test_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `quality_test_id` int UNSIGNED NOT NULL,
  `quality_test_key_id` int UNSIGNED NOT NULL,
  `quality_test_key_value_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 `quality_test_lines_quality_test_id_foreign`(`quality_test_id` ASC) USING BTREE,
  INDEX `quality_test_lines_quality_test_key_id_foreign`(`quality_test_key_id` ASC) USING BTREE,
  INDEX `quality_test_lines_quality_test_key_value_id_foreign`(`quality_test_key_value_id` ASC) USING BTREE,
  INDEX `quality_test_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `quality_test_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `quality_test_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `quality_test_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `quality_test_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_test_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_test_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_test_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_test_lines_quality_test_id_foreign` FOREIGN KEY (`quality_test_id`) REFERENCES `quality_tests` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_test_lines_quality_test_key_id_foreign` FOREIGN KEY (`quality_test_key_id`) REFERENCES `quality_test_keys` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_test_lines_quality_test_key_value_id_foreign` FOREIGN KEY (`quality_test_key_value_id`) REFERENCES `quality_test_key_values` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of quality_test_lines
-- ----------------------------

-- ----------------------------
-- Table structure for quality_tests
-- ----------------------------
CREATE TABLE `quality_tests`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `date` date NULL DEFAULT NULL,
  `quality_type_id` int UNSIGNED NOT NULL,
  `work_order_line_step_id` int UNSIGNED NULL DEFAULT NULL,
  `work_order_id` int UNSIGNED NULL DEFAULT NULL,
  `manufacturing_order_id` int UNSIGNED NULL DEFAULT NULL,
  `working_contract_id` int UNSIGNED NULL DEFAULT NULL,
  `product_id` int UNSIGNED NULL DEFAULT NULL,
  `quality_test_key_id` int UNSIGNED NULL DEFAULT NULL,
  `quality_test_key_value_id` int UNSIGNED NULL DEFAULT NULL,
  `value` 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 `quality_tests_quality_test_key_id_foreign`(`quality_test_key_id` ASC) USING BTREE,
  INDEX `quality_tests_quality_test_key_value_id_foreign`(`quality_test_key_value_id` ASC) USING BTREE,
  INDEX `quality_tests_quality_type_id_foreign`(`quality_type_id` ASC) USING BTREE,
  INDEX `quality_tests_work_order_line_step_id_foreign`(`work_order_line_step_id` ASC) USING BTREE,
  INDEX `quality_tests_work_order_id_foreign`(`work_order_id` ASC) USING BTREE,
  INDEX `quality_tests_manufacturing_order_id_foreign`(`manufacturing_order_id` ASC) USING BTREE,
  INDEX `quality_tests_working_contract_id_foreign`(`working_contract_id` ASC) USING BTREE,
  INDEX `quality_tests_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `quality_tests_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `quality_tests_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `quality_tests_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `quality_tests_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `quality_tests_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_tests_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_tests_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_tests_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_tests_manufacturing_order_id_foreign` FOREIGN KEY (`manufacturing_order_id`) REFERENCES `manufacturing_orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_tests_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_tests_quality_test_key_id_foreign` FOREIGN KEY (`quality_test_key_id`) REFERENCES `quality_test_keys` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_tests_quality_test_key_value_id_foreign` FOREIGN KEY (`quality_test_key_value_id`) REFERENCES `quality_test_key_values` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_tests_quality_type_id_foreign` FOREIGN KEY (`quality_type_id`) REFERENCES `quality_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_tests_work_order_id_foreign` FOREIGN KEY (`work_order_id`) REFERENCES `work_orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_tests_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 `quality_tests_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 quality_tests
-- ----------------------------

-- ----------------------------
-- Table structure for quality_types
-- ----------------------------
CREATE TABLE `quality_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,
  `quality_group_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 `quality_types_numbering_type_id_foreign`(`numbering_type_id` ASC) USING BTREE,
  INDEX `quality_types_quality_group_id_foreign`(`quality_group_id` ASC) USING BTREE,
  INDEX `quality_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `quality_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `quality_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `quality_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `quality_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_types_numbering_type_id_foreign` FOREIGN KEY (`numbering_type_id`) REFERENCES `numbering_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `quality_types_quality_group_id_foreign` FOREIGN KEY (`quality_group_id`) REFERENCES `quality_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 quality_types
-- ----------------------------
INSERT INTO `quality_types` VALUES (1, 'فحص دهان', '1', 'Painting Test', 1, 1, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:57', '2025-06-12 14:05:57', NULL);
INSERT INTO `quality_types` VALUES (2, 'فحص نجارة', '2', 'Ngara Test', 1, 2, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:57', '2025-06-12 14:05:57', NULL);

-- ----------------------------
-- Table structure for question_options
-- ----------------------------
CREATE TABLE `question_options`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `question_id` int UNSIGNED NOT NULL,
  `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 `question_options_question_id_foreign`(`question_id` ASC) USING BTREE,
  INDEX `question_options_state_id_foreign`(`state_id` ASC) USING BTREE,
  INDEX `question_options_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `question_options_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `question_options_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `question_options_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `question_options_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `question_options_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `question_options_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `question_options_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `question_options_question_id_foreign` FOREIGN KEY (`question_id`) REFERENCES `questions` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `question_options_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 question_options
-- ----------------------------

-- ----------------------------
-- Table structure for question_types
-- ----------------------------
CREATE TABLE `question_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 `question_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `question_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `question_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `question_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `question_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `question_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `question_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `question_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 question_types
-- ----------------------------
INSERT INTO `question_types` VALUES (1, 'اكثر من اختيار', '1', 'Multiable choose', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:54', '2025-06-12 14:05:54', NULL);
INSERT INTO `question_types` VALUES (2, 'كتابة', '2', 'Text', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:54', '2025-06-12 14:05:54', NULL);

-- ----------------------------
-- Table structure for questions
-- ----------------------------
CREATE TABLE `questions`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `mark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `subject_id` int UNSIGNED NOT NULL,
  `question_type_id` int UNSIGNED NOT NULL,
  `question_option_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 `questions_subject_id_foreign`(`subject_id` ASC) USING BTREE,
  INDEX `questions_question_type_id_foreign`(`question_type_id` ASC) USING BTREE,
  INDEX `questions_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `questions_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `questions_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `questions_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  INDEX `questions_question_option_id_foreign`(`question_option_id` ASC) USING BTREE,
  CONSTRAINT `questions_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `questions_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `questions_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `questions_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `questions_question_option_id_foreign` FOREIGN KEY (`question_option_id`) REFERENCES `question_options` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `questions_question_type_id_foreign` FOREIGN KEY (`question_type_id`) REFERENCES `question_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `questions_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 questions
-- ----------------------------

-- ----------------------------
-- Table structure for reminder_lines
-- ----------------------------
CREATE TABLE `reminder_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `reminder_id` int UNSIGNED NOT NULL,
  `asset_it` int UNSIGNED NULL DEFAULT NULL,
  `product_id` int UNSIGNED NULL DEFAULT NULL,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `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 `reminder_lines_reminder_id_foreign`(`reminder_id` ASC) USING BTREE,
  INDEX `reminder_lines_asset_it_foreign`(`asset_it` ASC) USING BTREE,
  INDEX `reminder_lines_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `reminder_lines_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `reminder_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `reminder_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `reminder_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `reminder_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `reminder_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reminder_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reminder_lines_asset_it_foreign` FOREIGN KEY (`asset_it`) REFERENCES `assets` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reminder_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reminder_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reminder_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reminder_lines_reminder_id_foreign` FOREIGN KEY (`reminder_id`) REFERENCES `reminders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reminder_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 reminder_lines
-- ----------------------------

-- ----------------------------
-- Table structure for reminders
-- ----------------------------
CREATE TABLE `reminders`  (
  `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,
  `number_of_days` int 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 `reminders_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `reminders_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `reminders_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `reminders_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `reminders_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reminders_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reminders_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `reminders_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 reminders
-- ----------------------------

-- ----------------------------
-- Table structure for rental_categories
-- ----------------------------
CREATE TABLE `rental_categories`  (
  `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 NULL,
  `main_child_counter` double NULL DEFAULT NULL,
  `sub_child_zeros` double NULL DEFAULT NULL,
  `sub_child_counter` double NULL DEFAULT NULL,
  `rental_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 `rental_categories_rental_category_id_foreign`(`rental_category_id` ASC) USING BTREE,
  INDEX `rental_categories_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `rental_categories_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `rental_categories_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `rental_categories_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `rental_categories_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rental_categories_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rental_categories_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rental_categories_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rental_categories_rental_category_id_foreign` FOREIGN KEY (`rental_category_id`) REFERENCES `rental_categories` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of rental_categories
-- ----------------------------
INSERT INTO `rental_categories` VALUES (4, 'محلات الشارع الرئيسي', '1', NULL, 10, NULL, 1000, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-07-08 15:04:50', '2025-07-08 15:09:32', NULL);
INSERT INTO `rental_categories` VALUES (5, 'محلات الشارع الفرعي', '2', NULL, 10, NULL, 1000, NULL, NULL, NULL, 71, NULL, NULL, NULL, NULL, '2025-07-08 15:09:48', '2025-07-08 15:09:48', NULL);
INSERT INTO `rental_categories` VALUES (6, 'مشاغل', '3', NULL, 10, NULL, 1000, NULL, NULL, NULL, 71, NULL, NULL, NULL, NULL, '2025-07-08 15:10:09', '2025-07-08 15:10:09', NULL);
INSERT INTO `rental_categories` VALUES (7, 'سكن', '4', NULL, 10, NULL, 1000, NULL, NULL, NULL, 71, NULL, NULL, NULL, NULL, '2025-07-08 15:10:19', '2025-07-08 15:10:19', NULL);
INSERT INTO `rental_categories` VALUES (8, 'الارض الفارغة', '5', NULL, 10, NULL, 1000, NULL, NULL, NULL, 71, NULL, NULL, NULL, NULL, '2025-07-18 22:20:19', '2025-07-18 22:20:19', NULL);

-- ----------------------------
-- Table structure for rental_category_products
-- ----------------------------
CREATE TABLE `rental_category_products`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `rental_category_id` int UNSIGNED NOT NULL,
  `product_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_category_products_rental_category_id_foreign`(`rental_category_id` ASC) USING BTREE,
  INDEX `rental_category_products_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `rental_category_products_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `rental_category_products_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `rental_category_products_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `rental_category_products_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `rental_category_products_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rental_category_products_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rental_category_products_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rental_category_products_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rental_category_products_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `rental_category_products_rental_category_id_foreign` FOREIGN KEY (`rental_category_id`) REFERENCES `rental_categories` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 47 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

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

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