-- https://www.phpmyadmin.net/
--

START TRANSACTION;



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

--
-- Table structure for table `admins_roles`
--

CREATE TABLE `admins_roles` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `group_id` tinyint(4) NOT NULL,
  `module` varchar(100) NOT NULL,
  `add_access` tinyint(4) NOT NULL,
  `view_access` tinyint(4) NOT NULL,
  `edit_access` tinyint(4) NOT NULL,
  `full_access` tinyint(4) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `admins_roles`
--

INSERT INTO `admins_roles` (`id`, `group_id`, `module`, `add_access`, `view_access`, `edit_access`, `full_access`, `created_at`, `updated_at`) VALUES
(1, 3, 'vacation_requests', 1, 1, 0, 0, '2024-06-21 18:19:03', '2024-06-21 18:19:03'),
(2, 4, 'employees', 1, 1, 1, 0, '2024-06-21 18:21:18', '2024-06-21 18:21:18'),
(3, 4, 'vacation_requests', 1, 1, 0, 0, '2024-06-21 18:21:18', '2024-06-21 18:21:18'),
(4, 2, 'employees', 1, 1, 1, 0, '2024-06-21 18:30:56', '2024-06-21 18:30:56'),
(5, 2, 'vacation_requests', 1, 1, 0, 0, '2024-06-21 18:30:56', '2024-06-21 18:30:56'),
(6, 5, 'employees', 0, 1, 0, 0, '2024-06-21 22:06:56', '2024-06-21 22:06:56'),
(7, 5, 'vacation_requests', 0, 1, 1, 0, '2024-06-21 22:06:56', '2024-06-21 22:06:56');

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

--
-- Table structure for table `branches`
--

CREATE TABLE `branches` (
  `branch_code` int(11) NOT NULL,
  `branch_name` varchar(200) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `branches`
--

INSERT INTO `branches` (`branch_code`, `branch_name`) VALUES
(20002007, 'Abha Branch'),
(20002003, 'Dammam Branch'),
(20002412, 'Jeddah Branch'),
(20002593, 'Jubail Branch'),
(21000304, 'Khobar Branch'),
(21000472, 'Makkah Branch'),
(20002513, 'Medina Branch'),
(20002836, 'Riyadh Main Branch'),
(20002516, 'Tabuk Branch'),
(20002049, 'Yanbu Branch');

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

--
-- Table structure for table `cities`
--

CREATE TABLE `cities` (
  `city_code` tinyint(4) NOT NULL,
  `city` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `cities`
--

INSERT INTO `cities` (`city_code`, `city`) VALUES
(6, 'Cairo'),
(5, 'Delhi'),
(3, 'Islamabad'),
(7, 'Khartoum'),
(2, 'Madras'),
(1, 'Riyadh'),
(4, 'Sana');

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

--
-- Table structure for table `contract_types`
--

CREATE TABLE `contract_types` (
  `contract_type_code` tinyint(4) NOT NULL,
  `contract_type` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `contract_types`
--

INSERT INTO `contract_types` (`contract_type_code`, `contract_type`) VALUES
(1, 'Fixed-Term Contract'),
(2, 'Indefinite-Term Contract'),
(3, 'Part-Time Contract'),
(5, 'Probationary Contract'),
(6, 'Project-Based Contract'),
(4, 'Seasonal Contract');

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

--
-- Table structure for table `cost_centers`
--

CREATE TABLE `cost_centers` (
  `cost_center_code` int(11) NOT NULL,
  `cost_center` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `cost_centers`
--

INSERT INTO `cost_centers` (`cost_center_code`, `cost_center`) VALUES
(44120101, 'Customer Support'),
(22120101, 'Human Resources'),
(55010101, 'IT Services'),
(67120102, 'Research and Development'),
(53010100, 'Sales and Marketing');

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

--
-- Table structure for table `countries`
--

CREATE TABLE `countries` (
  `country_code` tinyint(4) NOT NULL,
  `country` varchar(100) NOT NULL,
  `country_flag_class` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `countries`
--

INSERT INTO `countries` (`country_code`, `country`, `country_flag_class`) VALUES
(1, 'Saudi Arabia', 'rounded-circle flag large SA'),
(2, 'Egypt', 'rounded-circle flag large EG'),
(3, 'Jordan', 'rounded-circle flag large JO'),
(4, 'Yaman', 'rounded-circle flag large YE'),
(5, 'India', 'rounded-circle flag large IN'),
(6, 'Pakistan', 'rounded-circle flag large PK'),
(7, 'Sudan', 'rounded-circle flag large SD');

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

--
-- Table structure for table `departments`
--

CREATE TABLE `departments` (
  `department_code` tinyint(4) NOT NULL,
  `department_name` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `departments`
--

INSERT INTO `departments` (`department_code`, `department_name`) VALUES
(6, 'Admin'),
(2, 'Finance'),
(1, 'Human Resources'),
(3, 'IT'),
(4, 'Marketing'),
(5, 'Sales');

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

--
-- Table structure for table `documents`
--

CREATE TABLE `documents` (
  `document_code` bigint(20) NOT NULL,
  `emp_id` bigint(20) DEFAULT NULL,
  `document_name` varchar(100) NOT NULL,
  `document_type_code` tinyint(4) DEFAULT NULL,
  `issue_date` date DEFAULT NULL,
  `expiration_date` date DEFAULT NULL,
  `attachment` varchar(500) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `documents`
--

INSERT INTO `documents` (`document_code`, `emp_id`, `document_name`, `document_type_code`, `issue_date`, `expiration_date`, `attachment`) VALUES
(1, 9001, 'Passport', 1, '2024-03-18', '2023-12-31', NULL),
(2, 9002, 'Iqama', 2, '2023-06-01', '2023-12-31', NULL),
(3, 9003, 'ID Card', 3, '2022-09-01', '2023-08-31', NULL),
(4, 9004, 'Diploma', 4, '2023-01-01', '2023-12-31', NULL),
(5, 9005, 'Resume', 5, '2022-06-15', '2023-06-14', NULL),
(6, 9006, 'Cover Letter', 6, '2022-03-01', '2023-02-28', NULL),
(7, 9007, 'Passport', 1, '2021-05-22', '2022-09-14', NULL),
(8, 9008, 'Iqama', 2, '2022-01-10', '2023-01-09', NULL),
(9, 9009, 'ID Card', 3, '2021-12-01', '2022-11-30', NULL),
(10, 9010, 'Diploma', 4, '2022-05-15', '2023-05-14', NULL);

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

--
-- Table structure for table `document_types`
--

CREATE TABLE `document_types` (
  `document_type_code` tinyint(4) NOT NULL,
  `document_type` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `document_types`
--

INSERT INTO `document_types` (`document_type_code`, `document_type`) VALUES
(6, 'Cover Letter'),
(4, 'Diploma'),
(3, 'ID Card'),
(2, 'Iqama'),
(1, 'Passport'),
(5, 'Resume');

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

--
-- Table structure for table `employees_allowances`
--

CREATE TABLE `employees_allowances` (
  `id` bigint(20) NOT NULL,
  `company_code` varchar(20) NOT NULL,
  `emp_id` bigint(20) NOT NULL,
  `allowance_code` tinyint(4) NOT NULL,
  `allowance_value` int(11) NOT NULL,
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) DEFAULT NULL,
  `updated_by` bigint(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `employees_children`
--

CREATE TABLE `employees_children` (
  `id` bigint(20) NOT NULL,
  `company_code` varchar(20) NOT NULL,
  `emp_id` bigint(20) NOT NULL,
  `spouse_id` bigint(20) NOT NULL,
  `child_id` bigint(20) NOT NULL,
  `child_name_arabic` varchar(100) NOT NULL,
  `child_name_english` varchar(100) NOT NULL,
  `date_of_birth` date NOT NULL,
  `national_id_of_child` bigint(20) NOT NULL,
  `medical_insurance` tinyint(4) NOT NULL COMMENT '0=No Medical Insurance\r\n1=Medical Insurance',
  `medical_insurance_start_date` date NOT NULL,
  `medical_insurance_end_date` date NOT NULL,
  `gender` tinyint(4) NOT NULL COMMENT '1=Male\r\n2=Female',
  `insurance_code` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) DEFAULT NULL,
  `updated_by` bigint(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Triggers `employees_children`
--
DELIMITER $$
CREATE TRIGGER `before_insert_employees_children_child_id` BEFORE INSERT ON `employees_children` FOR EACH ROW BEGIN
  DECLARE max_child_id INT;

  -- Get the maximum child_id for the given emp_id
  SELECT IFNULL(MAX(child_id), 0) + 1 INTO max_child_id
  FROM employees_children
  WHERE emp_id = NEW.emp_id;

  -- Set the new child_id
  SET NEW.child_id = max_child_id;
END
$$
DELIMITER ;

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

--
-- Table structure for table `employees_spouses`
--

CREATE TABLE `employees_spouses` (
  `id` bigint(20) NOT NULL,
  `company_code` varchar(20) NOT NULL,
  `emp_id` bigint(20) NOT NULL,
  `spouse_id` int(11) NOT NULL,
  `spouse_name_arabic` varchar(100) NOT NULL,
  `spouse_name_english` varchar(100) NOT NULL,
  `date_of_birth` date NOT NULL,
  `medical_insurance` tinyint(4) NOT NULL COMMENT '0=No Medical Insurance\r\n1=Medical Insurance',
  `medical_insurance_start_date` date NOT NULL,
  `insurance_code` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) DEFAULT NULL,
  `updated_by` bigint(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Triggers `employees_spouses`
--
DELIMITER $$
CREATE TRIGGER `before_insert_employees_children_spouse_id` BEFORE INSERT ON `employees_spouses` FOR EACH ROW BEGIN
  DECLARE max_spouse_id INT;

  -- Get the maximum spouse_id for the given emp_id
  SELECT IFNULL(MAX(spouse_id), 0) + 1 INTO max_spouse_id
  FROM employees_children
  WHERE emp_id = NEW.emp_id;

  -- Set the new spouse_id
  SET NEW.spouse_id = max_spouse_id;
END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `before_insert_employees_spouses` BEFORE INSERT ON `employees_spouses` FOR EACH ROW BEGIN
  DECLARE max_spouse_id INT;

  -- Get the maximum spouse_id for the given emp_id
  SELECT IFNULL(MAX(spouse_id), 0) + 1 INTO max_spouse_id
  FROM employees_spouses
  WHERE emp_id = NEW.emp_id;

  -- Set the new spouse_id
  SET NEW.spouse_id = max_spouse_id;
END
$$
DELIMITER ;

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

--
-- Table structure for table `emp_categories`
--

CREATE TABLE `emp_categories` (
  `category_code` tinyint(4) NOT NULL,
  `category` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `emp_categories`
--

INSERT INTO `emp_categories` (`category_code`, `category`) VALUES
(3, 'Administrative'),
(5, 'Intern'),
(1, 'Management'),
(4, 'Support'),
(2, 'Technical');

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

--
-- Table structure for table `emp_documents`
--

CREATE TABLE `emp_documents` (
  `document_code` bigint(20) NOT NULL,
  `document_name` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `emp_documents`
--

INSERT INTO `emp_documents` (`document_code`, `document_name`) VALUES
(1, 'Passport'),
(2, 'Iqama'),
(3, 'ID Card'),
(4, 'Diploma'),
(5, 'Resume'),
(6, 'Cover Letter'),
(7, 'Passport'),
(8, 'Iqama'),
(9, 'ID Card'),
(10, 'Diploma');

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

--
-- Table structure for table `emp_sites`
--

CREATE TABLE `emp_sites` (
  `site_code` smallint(6) NOT NULL,
  `site_name` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `emp_sites`
--

INSERT INTO `emp_sites` (`site_code`, `site_name`) VALUES
(2, 'Branch Office 1'),
(3, 'Branch Office 2'),
(5, 'Customer Site'),
(1, 'Headquarters'),
(4, 'Remote Site');

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

--
-- Table structure for table `emp_subcategories`
--

CREATE TABLE `emp_subcategories` (
  `subcategory_code` tinyint(4) NOT NULL,
  `subcategory` varchar(100) NOT NULL,
  `category_code` tinyint(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `emp_subcategories`
--

INSERT INTO `emp_subcategories` (`subcategory_code`, `subcategory`, `category_code`) VALUES
(1, 'Senior Management', 1),
(2, 'Junior Management', 2),
(3, 'Technical Lead', 3),
(4, 'Support Staff', 4),
(5, 'Internship Trainee', 5);

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

--
-- Table structure for table `failed_jobs`
--

CREATE TABLE `failed_jobs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `uuid` varchar(255) NOT NULL,
  `connection` text NOT NULL,
  `queue` text NOT NULL,
  `payload` longtext NOT NULL,
  `exception` longtext NOT NULL,
  `failed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `groups`
--

CREATE TABLE `groups` (
  `group_id` tinyint(4) NOT NULL,
  `group` varchar(100) NOT NULL,
  `status` tinyint(4) NOT NULL COMMENT '1 - Active\r\n2 - Inactive',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) DEFAULT NULL,
  `updated_by` bigint(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `groups`
--

INSERT INTO `groups` (`group_id`, `group`, `status`, `created_at`, `updated_at`, `created_by`, `updated_by`) VALUES
(1, 'admin', 1, '2024-05-15 21:04:10', '2024-06-18 17:30:12', 9001, 9001),
(2, 'subadmin', 1, '2024-05-15 21:04:10', '2024-06-12 06:29:06', 9001, 9001),
(3, 'user', 1, '2024-05-15 21:04:10', '2024-06-12 18:18:46', 9001, 9001),
(4, 'hrms', 1, '2024-05-15 21:04:10', '2024-06-19 19:27:01', 9001, 9001),
(5, 'Manager', 1, '2024-06-21 19:43:45', '2024-06-21 19:43:45', 9001, 9001);

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

--
-- Table structure for table `jobs`
--

CREATE TABLE `jobs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `queue` varchar(255) NOT NULL,
  `payload` longtext NOT NULL,
  `attempts` tinyint(3) UNSIGNED NOT NULL,
  `reserved_at` int(10) UNSIGNED DEFAULT NULL,
  `available_at` int(10) UNSIGNED NOT NULL,
  `created_at` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `job_batches`
--

CREATE TABLE `job_batches` (
  `id` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `total_jobs` int(11) NOT NULL,
  `pending_jobs` int(11) NOT NULL,
  `failed_jobs` int(11) NOT NULL,
  `failed_job_ids` longtext NOT NULL,
  `options` mediumtext DEFAULT NULL,
  `cancelled_at` int(11) DEFAULT NULL,
  `created_at` int(11) NOT NULL,
  `finished_at` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `job_titles`
--

CREATE TABLE `job_titles` (
  `job_code` tinyint(4) NOT NULL,
  `job_title` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `job_titles`
--

INSERT INTO `job_titles` (`job_code`, `job_title`) VALUES
(5, 'Accountant'),
(8, 'CTO'),
(4, 'HR Manager'),
(3, 'IT Consultant'),
(2, 'IT Director'),
(6, 'Marketing Manager'),
(7, 'Marketing Officer'),
(1, 'Software Developer');

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

--
-- Table structure for table `migrations`
--

CREATE TABLE `migrations` (
  `id` int(10) UNSIGNED NOT NULL,
  `migration` varchar(255) NOT NULL,
  `batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `migrations`
--

INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(1, '0001_01_01_000000_create_users_table', 1),
(2, '0001_01_01_000001_create_cache_table', 1),
(3, '0001_01_01_000002_create_jobs_table', 1),
(4, '2024_05_06_095318_create_admins_table', 1),
(5, '2024_05_07_222123_create_admins_roles_table', 1),
(6, '2024_05_15_155154_create_vacation_requests_table', 1);

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

--
-- Table structure for table `religions`
--

CREATE TABLE `religions` (
  `religion_code` tinyint(4) NOT NULL,
  `religion` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `religions`
--

INSERT INTO `religions` (`religion_code`, `religion`) VALUES
(4, 'Buddhism'),
(2, 'Christianity'),
(3, 'Hinduism'),
(1, 'Islam'),
(5, 'Judaism'),
(6, 'Sikhism');

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

--
-- Table structure for table `sections`
--

CREATE TABLE `sections` (
  `section_code` tinyint(4) NOT NULL,
  `section_name` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `sections`
--

INSERT INTO `sections` (`section_code`, `section_name`) VALUES
(1, 'Section A'),
(2, 'Section B'),
(3, 'Section C'),
(4, 'Section D'),
(5, 'Section E');

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

--
-- Table structure for table `sessions`
--

CREATE TABLE `sessions` (
  `id` varchar(255) NOT NULL,
  `user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL,
  `payload` longtext NOT NULL,
  `last_activity` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `vacation_requests`
--

CREATE TABLE `vacation_requests` (
  `request_id` bigint(20) UNSIGNED NOT NULL,
  `emp_id` bigint(20) NOT NULL,
  `status` tinyint(4) NOT NULL COMMENT '1 - Pending HRD Eligibility Review\r\n2 - Pending Manager Approval\r\n3 - Rejected\r\n4 - Approved',
  `type` varchar(255) NOT NULL COMMENT '1 - Annual\r\n2 - Birth\r\n3 - Death\r\n4 - Emergency\r\n5 - Examination\r\n6 - Marriage\r\n7 - Other\r\n8 - Pregnancy\r\n9 - Sick',
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `eligibility` varchar(255) DEFAULT NULL,
  `travel_from` varchar(255) NOT NULL COMMENT 'Traveling From (City)',
  `travel_to` varchar(255) NOT NULL COMMENT 'Traveling To (City)',
  `repl_emp_id` bigint(20) DEFAULT NULL,
  `requested_by` bigint(20) NOT NULL,
  `request_date` date NOT NULL,
  `requester_remarks` varchar(255) DEFAULT NULL,
  `hrd` bigint(20) DEFAULT NULL,
  `hrd_approval_date` date DEFAULT NULL,
  `hrd_remarks` varchar(255) DEFAULT NULL,
  `manager_approval` bigint(20) DEFAULT NULL,
  `manager_approval_date` date DEFAULT NULL,
  `manager_remarks` varchar(255) DEFAULT NULL,
  `return_date` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) DEFAULT NULL,
  `updated_by` bigint(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `vacation_requests`
--

INSERT INTO `vacation_requests` (`request_id`, `emp_id`, `status`, `type`, `start_date`, `end_date`, `eligibility`, `travel_from`, `travel_to`, `repl_emp_id`, `requested_by`, `request_date`, `requester_remarks`, `hrd`, `hrd_approval_date`, `hrd_remarks`, `manager_approval`, `manager_approval_date`, `manager_remarks`, `return_date`, `created_at`, `updated_at`, `created_by`, `updated_by`) VALUES
(1, 9004, 4, '6', '2024-06-01', '2024-06-30', '40', 'Riyadh', 'Sialkot', 9005, 9004, '2024-05-15', 'Looking forward to the break', 9006, '2024-05-16', '40 days eligible', 9007, '2024-05-17', '30 days Approved', NULL, '2024-06-22 10:46:59', '2024-06-22 10:46:59', 9001, 9001),
(2, 9008, 3, '2', '2024-07-15', '2024-08-20', '50', 'Riyadh', 'Madras', 9009, 9008, '2024-05-16', 'Need to handle urgent family matter', 9010, '2024-05-17', '50 days eligible', 9001, '2024-06-22', 'Approved 37 days', NULL, '2024-06-22 11:05:21', '2024-06-22 11:05:21', 9001, 9001),
(3, 9007, 2, '1', '2024-06-01', '2024-06-30', NULL, 'Riyadh', 'Lahore', NULL, 9001, '2024-05-20', 'Want to go for Annual Vacation', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2024-05-20 12:11:36', '2024-06-22 11:08:07', 9001, 9001),
(4, 9007, 4, '1', '2024-07-01', '2024-07-31', '', 'Riyadh', 'Lahore', NULL, 9001, '2024-05-20', 'Want to go for Annual Vacation', 9006, '2024-05-20', '', 9001, '2024-06-22', NULL, NULL, '2024-05-20 12:23:54', '2024-06-22 11:09:38', 9001, 9001),
(6, 9009, 4, '4', '2024-08-01', '2024-08-08', NULL, 'Riyadh', 'Lahore', NULL, 9007, '2024-05-22', 'Emergency Leave', NULL, NULL, NULL, 9001, '2024-06-22', NULL, NULL, '2024-05-22 12:09:50', '2024-06-22 11:09:38', 9007, 9007),
(7, 9009, 2, '4', '2024-07-01', '2024-07-31', NULL, 'Riyadh', 'Lahore', NULL, 9001, '2024-06-22', 'abc', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2024-06-21 22:51:10', '2024-06-22 11:08:31', 9001, 9001);

--
-- Indexes for table `admins_roles`
--
ALTER TABLE `admins_roles`
  ADD PRIMARY KEY (`id`),
  ADD KEY `group_id` (`group_id`);

--
-- Indexes for table `branches`
--
ALTER TABLE `branches`
  ADD PRIMARY KEY (`branch_code`),
  ADD UNIQUE KEY `branch_name` (`branch_name`);

--
-- Indexes for table `cities`
--
ALTER TABLE `cities`
  ADD PRIMARY KEY (`city_code`),
  ADD UNIQUE KEY `city` (`city`);

--
-- Indexes for table `contract_types`
--
ALTER TABLE `contract_types`
  ADD PRIMARY KEY (`contract_type_code`),
  ADD UNIQUE KEY `contract_type` (`contract_type`);

--
-- Indexes for table `cost_centers`
--
ALTER TABLE `cost_centers`
  ADD PRIMARY KEY (`cost_center_code`),
  ADD UNIQUE KEY `cost_center` (`cost_center`);

--
-- Indexes for table `countries`
--
ALTER TABLE `countries`
  ADD PRIMARY KEY (`country_code`),
  ADD UNIQUE KEY `country` (`country`);

--
-- Indexes for table `departments`
--
ALTER TABLE `departments`
  ADD PRIMARY KEY (`department_code`),
  ADD UNIQUE KEY `department_name` (`department_name`);

--
-- Indexes for table `documents`
--
ALTER TABLE `documents`
  ADD PRIMARY KEY (`document_code`),
  ADD KEY `emp_id` (`emp_id`),
  ADD KEY `document_type_code` (`document_type_code`);

--
-- Indexes for table `document_types`
--
ALTER TABLE `document_types`
  ADD PRIMARY KEY (`document_type_code`),
  ADD UNIQUE KEY `document_type` (`document_type`);

--
-- Indexes for table `employees_allowances`
--
ALTER TABLE `employees_allowances`
  ADD PRIMARY KEY (`id`),
  ADD KEY `emp_id` (`emp_id`);

--
-- Indexes for table `employees_children`
--
ALTER TABLE `employees_children`
  ADD PRIMARY KEY (`id`),
  ADD KEY `emp_id` (`emp_id`);

--
-- Indexes for table `employees_spouses`
--
ALTER TABLE `employees_spouses`
  ADD PRIMARY KEY (`id`),
  ADD KEY `emp_id` (`emp_id`);

--
-- Indexes for table `emp_categories`
--
ALTER TABLE `emp_categories`
  ADD PRIMARY KEY (`category_code`),
  ADD KEY `category` (`category`);

--
-- Indexes for table `emp_documents`
--
ALTER TABLE `emp_documents`
  ADD PRIMARY KEY (`document_code`);

--
-- Indexes for table `emp_sites`
--
ALTER TABLE `emp_sites`
  ADD PRIMARY KEY (`site_code`),
  ADD UNIQUE KEY `site_name` (`site_name`);

--
-- Indexes for table `emp_subcategories`
--
ALTER TABLE `emp_subcategories`
  ADD PRIMARY KEY (`subcategory_code`),
  ADD UNIQUE KEY `subcategory` (`subcategory`),
  ADD KEY `category_code` (`category_code`);

--
-- Indexes for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`);

--
-- Indexes for table `groups`
--
ALTER TABLE `groups`
  ADD PRIMARY KEY (`group_id`);

--
-- Indexes for table `jobs`
--
ALTER TABLE `jobs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `jobs_queue_index` (`queue`);

--
-- Indexes for table `job_batches`
--
ALTER TABLE `job_batches`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `job_titles`
--
ALTER TABLE `job_titles`
  ADD PRIMARY KEY (`job_code`),
  ADD UNIQUE KEY `job_title` (`job_title`);

--
-- Indexes for table `migrations`
--
ALTER TABLE `migrations`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `religions`
--
ALTER TABLE `religions`
  ADD PRIMARY KEY (`religion_code`),
  ADD UNIQUE KEY `religion` (`religion`);

--
-- Indexes for table `sections`
--
ALTER TABLE `sections`
  ADD PRIMARY KEY (`section_code`),
  ADD UNIQUE KEY `section_name` (`section_name`);

--
-- Indexes for table `sessions`
--
ALTER TABLE `sessions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sessions_user_id_index` (`user_id`),
  ADD KEY `sessions_last_activity_index` (`last_activity`);

--
-- Indexes for table `vacation_requests`
--
ALTER TABLE `vacation_requests`
  ADD PRIMARY KEY (`request_id`),
  ADD KEY `emp_id` (`emp_id`);

--
-- AUTO_INCREMENT for table `admins_roles`
--
ALTER TABLE `admins_roles`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=186;

--
-- AUTO_INCREMENT for table `cities`
--
ALTER TABLE `cities`
  MODIFY `city_code` tinyint(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `contract_types`
--
ALTER TABLE `contract_types`
  MODIFY `contract_type_code` tinyint(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `departments`
--
ALTER TABLE `departments`
  MODIFY `department_code` tinyint(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `documents`
--
ALTER TABLE `documents`
  MODIFY `document_code` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

--
-- AUTO_INCREMENT for table `document_types`
--
ALTER TABLE `document_types`
  MODIFY `document_type_code` tinyint(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `employees_allowances`
--
ALTER TABLE `employees_allowances`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `employees_children`
--
ALTER TABLE `employees_children`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `employees_spouses`
--
ALTER TABLE `employees_spouses`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `emp_categories`
--
ALTER TABLE `emp_categories`
  MODIFY `category_code` tinyint(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `emp_documents`
--
ALTER TABLE `emp_documents`
  MODIFY `document_code` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

--
-- AUTO_INCREMENT for table `emp_sites`
--
ALTER TABLE `emp_sites`
  MODIFY `site_code` smallint(6) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `emp_subcategories`
--
ALTER TABLE `emp_subcategories`
  MODIFY `subcategory_code` tinyint(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `groups`
--
ALTER TABLE `groups`
  MODIFY `group_id` tinyint(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `jobs`
--
ALTER TABLE `jobs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `job_titles`
--
ALTER TABLE `job_titles`
  MODIFY `job_code` tinyint(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `religions`
--
ALTER TABLE `religions`
  MODIFY `religion_code` tinyint(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `sections`
--
ALTER TABLE `sections`
  MODIFY `section_code` tinyint(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `vacation_requests`
--
ALTER TABLE `vacation_requests`
  MODIFY `request_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- Constraints for table `admins_roles`
--
ALTER TABLE `admins_roles`
  ADD CONSTRAINT `admins_roles_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `groups` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `documents`
--
ALTER TABLE `documents`
  ADD CONSTRAINT `documents_ibfk_2` FOREIGN KEY (`document_type_code`) REFERENCES `document_types` (`document_type_code`) ON UPDATE CASCADE;

--
-- Constraints for table `emp_subcategories`
--
ALTER TABLE `emp_subcategories`
  ADD CONSTRAINT `emp_subcategories_ibfk_1` FOREIGN KEY (`category_code`) REFERENCES `emp_categories` (`category_code`) ON UPDATE CASCADE;
COMMIT;

