-- https://www.phpmyadmin.net/
--
-- إصدار الخادم: 10.4.32-MariaDB

START TRANSACTION;



--
-- Database: `hrms`
--

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

--
-- بنية الجدول `accounts`
--

CREATE TABLE `accounts` (
  `id` int(11) NOT NULL,
  `code` varchar(20) NOT NULL,
  `name` varchar(150) NOT NULL,
  `type` varchar(20) NOT NULL,
  `parent_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `accounts`
--

INSERT INTO `accounts` (`id`, `code`, `name`, `type`, `parent_id`) VALUES
(1, '1000', 'نقدية / بنك', 'asset', NULL),
(2, '1100', 'ذمم سلف', 'asset', NULL),
(3, '2000', 'مستحقات مرتبات', 'liability', NULL),
(4, '5000', 'مصروف مرتبات', 'expense', NULL),
(5, '5100', 'مصروفات تسويات الموظفين', 'expense', NULL);

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

--
-- بنية الجدول `approval_sla_events`
--

CREATE TABLE `approval_sla_events` (
  `id` bigint(20) NOT NULL,
  `rule_id` int(11) NOT NULL,
  `module_key` varchar(40) NOT NULL,
  `entity_id` bigint(20) NOT NULL,
  `branch_id` int(11) DEFAULT NULL,
  `minutes_pending` int(11) NOT NULL DEFAULT 0,
  `notified_user_ids` varchar(255) DEFAULT NULL,
  `status` varchar(20) NOT NULL DEFAULT 'raised',
  `message` varchar(255) DEFAULT NULL,
  `detected_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `approval_sla_rules`
--

CREATE TABLE `approval_sla_rules` (
  `id` int(11) NOT NULL,
  `module_key` varchar(40) NOT NULL,
  `pending_status` varchar(40) DEFAULT NULL,
  `branch_id` int(11) DEFAULT NULL,
  `threshold_minutes` int(11) NOT NULL DEFAULT 240,
  `notify_every_minutes` int(11) NOT NULL DEFAULT 240,
  `escalate_to_role` varchar(30) DEFAULT NULL,
  `escalate_to_user_id` int(11) DEFAULT NULL,
  `is_active` tinyint(4) NOT NULL DEFAULT 1,
  `created_by_user_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `approval_workflows`
--

CREATE TABLE `approval_workflows` (
  `id` int(11) NOT NULL,
  `module_key` varchar(50) NOT NULL,
  `branch_id` int(11) DEFAULT NULL,
  `name` varchar(150) NOT NULL,
  `is_active` tinyint(4) NOT NULL DEFAULT 1,
  `apply_to_all_employees` tinyint(4) NOT NULL DEFAULT 1,
  `created_by_user_id` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `approval_workflows`
--

INSERT INTO `approval_workflows` (`id`, `module_key`, `branch_id`, `name`, `is_active`, `apply_to_all_employees`, `created_by_user_id`, `created_at`, `updated_at`) VALUES
(1, 'loans', 1, 'اعتماد السلف', 1, 1, 1, '2026-02-26 13:23:27', '2026-02-26 13:23:27');

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

--
-- بنية الجدول `approval_workflow_employee_scopes`
--

CREATE TABLE `approval_workflow_employee_scopes` (
  `workflow_id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `approval_workflow_steps`
--

CREATE TABLE `approval_workflow_steps` (
  `id` int(11) NOT NULL,
  `workflow_id` int(11) NOT NULL,
  `step_no` int(11) NOT NULL,
  `step_code` varchar(50) NOT NULL,
  `step_label` varchar(150) DEFAULT NULL,
  `target_status` varchar(30) DEFAULT NULL,
  `required_role` varchar(20) DEFAULT NULL,
  `approver_user_id` int(11) DEFAULT NULL,
  `approver_employee_id` int(11) DEFAULT NULL,
  `min_amount` decimal(14,2) DEFAULT NULL,
  `max_amount` decimal(14,2) DEFAULT NULL,
  `is_required` tinyint(4) NOT NULL DEFAULT 1,
  `is_active` tinyint(4) NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `app_settings`
--

CREATE TABLE `app_settings` (
  `setting_key` varchar(100) NOT NULL,
  `setting_value` text DEFAULT NULL,
  `updated_by_user_id` int(11) DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `app_settings`
--

INSERT INTO `app_settings` (`setting_key`, `setting_value`, `updated_by_user_id`, `updated_at`) VALUES
('smtp_enabled', '1', NULL, '2026-02-25 23:41:47'),
('smtp_encryption', 'tls', 1, '2026-02-25 23:34:04'),
('smtp_from_email', 'g00gletoolsai@gmail.com', 1, '2026-02-25 23:34:04'),
('smtp_from_name', 'HR', 1, '2026-02-25 23:34:04'),
('smtp_host', 'smtp.gmail.com', 1, '2026-02-25 23:34:04'),
('smtp_password', 'lafhvrxvmyfgardd', 1, '2026-02-25 23:34:04'),
('smtp_port', '587', 1, '2026-02-25 23:34:04'),
('smtp_reply_to', 'g00gletoolsai@gmail.com', 1, '2026-02-25 23:34:04'),
('smtp_username', 'g00gletoolsai@gmail.com', 1, '2026-02-25 23:34:04'),
('ui_brand_logo_url', 'uploads/branding/brand-logo-20260226-152300-b85e250f.png', 1, '2026-02-26 15:49:25'),
('ui_brand_subtitle', '', 1, '2026-02-26 15:49:25'),
('ui_dash_cards_u_1_admin', '', 1, '2026-02-26 17:30:50'),
('ui_sidebar_customizations_json', '{\"my_profile\":{\"label\":\"الملف الشخصي\",\"icon\":\"\",\"hidden\":0}}', 1, '2026-02-26 15:24:31'),
('ui_site_name', '', 1, '2026-02-26 15:49:25');

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

--
-- بنية الجدول `assets`
--

CREATE TABLE `assets` (
  `id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `asset_code` varchar(30) NOT NULL,
  `name` varchar(150) NOT NULL,
  `category` varchar(100) DEFAULT NULL,
  `cost` decimal(14,2) NOT NULL DEFAULT 0.00,
  `status` varchar(20) NOT NULL DEFAULT 'available'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `assets`
--

INSERT INTO `assets` (`id`, `branch_id`, `asset_code`, `name`, `category`, `cost`, `status`) VALUES
(1, 1, 'LAP-CAI-01', 'Laptop Dell 5400', 'IT', 18000.00, 'available'),
(2, 2, 'LAP-ALX-01', 'Laptop HP 840', 'IT', 17000.00, 'available');

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

--
-- بنية الجدول `asset_issues`
--

CREATE TABLE `asset_issues` (
  `id` int(11) NOT NULL,
  `asset_id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `issue_date` date NOT NULL,
  `expected_return_date` date DEFAULT NULL,
  `return_date` datetime DEFAULT NULL,
  `notes` varchar(255) DEFAULT NULL,
  `status` varchar(20) NOT NULL DEFAULT 'issued'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `attendance_corrections`
--

CREATE TABLE `attendance_corrections` (
  `id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `work_date` date NOT NULL,
  `requested_first_in` datetime DEFAULT NULL,
  `requested_last_out` datetime DEFAULT NULL,
  `reason` varchar(255) DEFAULT NULL,
  `status` varchar(30) NOT NULL DEFAULT 'pending_manager',
  `created_by_user_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `manager_by_user_id` int(11) DEFAULT NULL,
  `manager_at` datetime DEFAULT NULL,
  `manager_note` varchar(255) DEFAULT NULL,
  `hr_by_user_id` int(11) DEFAULT NULL,
  `hr_at` datetime DEFAULT NULL,
  `hr_note` varchar(255) DEFAULT NULL,
  `applied` tinyint(4) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `attendance_daily`
--

CREATE TABLE `attendance_daily` (
  `id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `work_date` date NOT NULL,
  `shift_id` int(11) DEFAULT NULL,
  `first_in` datetime DEFAULT NULL,
  `last_out` datetime DEFAULT NULL,
  `work_minutes` int(11) NOT NULL DEFAULT 0,
  `late_minutes` int(11) NOT NULL DEFAULT 0,
  `early_leave_minutes` int(11) NOT NULL DEFAULT 0,
  `overtime_minutes` int(11) NOT NULL DEFAULT 0,
  `status` varchar(20) NOT NULL DEFAULT 'absent',
  `leave_request_id` int(11) DEFAULT NULL,
  `notes` varchar(255) DEFAULT NULL,
  `computed_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `attendance_daily`
--

INSERT INTO `attendance_daily` (`id`, `employee_id`, `branch_id`, `work_date`, `shift_id`, `first_in`, `last_out`, `work_minutes`, `late_minutes`, `early_leave_minutes`, `overtime_minutes`, `status`, `leave_request_id`, `notes`, `computed_at`) VALUES
(1, 1, 1, '2026-02-24', 1, '2026-02-24 09:02:00', '2026-02-24 17:18:00', 436, 0, 0, 18, 'present', NULL, NULL, '2026-02-26 01:00:25'),
(2, 2, 1, '2026-02-24', 1, '2026-02-24 09:22:00', '2026-02-24 17:03:00', 401, 7, 0, 3, 'present', NULL, NULL, '2026-02-26 01:00:25'),
(3, 3, 2, '2026-02-24', 2, '2026-02-24 08:58:00', '2026-02-24 17:10:00', 432, 0, 0, 10, 'present', NULL, NULL, '2026-02-25 22:29:53'),
(4, 4, 2, '2026-02-24', 2, '2026-02-24 09:10:00', '2026-02-24 16:50:00', 400, 0, 5, 0, 'present', NULL, NULL, '2026-02-25 22:29:53'),
(5, 5, 1, '2026-02-24', 1, '2026-02-24 09:05:00', '2026-02-24 17:00:00', 415, 0, 0, 0, 'present', NULL, NULL, '2026-02-26 01:00:25'),
(6, 6, 1, '2026-02-24', 1, '2026-02-24 09:00:00', '2026-02-24 17:25:00', 445, 0, 0, 25, 'present', NULL, NULL, '2026-02-26 01:00:25'),
(7, 3, 2, '2026-01-01', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(8, 3, 2, '2026-01-02', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(9, 3, 2, '2026-01-03', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(10, 3, 2, '2026-01-04', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(11, 3, 2, '2026-01-05', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(12, 3, 2, '2026-01-06', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(13, 3, 2, '2026-01-07', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(14, 3, 2, '2026-01-08', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(15, 3, 2, '2026-01-09', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(16, 3, 2, '2026-01-10', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(17, 3, 2, '2026-01-11', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(18, 3, 2, '2026-01-12', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(19, 3, 2, '2026-01-13', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(20, 3, 2, '2026-01-14', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(21, 3, 2, '2026-01-15', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(22, 3, 2, '2026-01-16', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(23, 3, 2, '2026-01-17', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(24, 3, 2, '2026-01-18', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(25, 3, 2, '2026-01-19', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(26, 3, 2, '2026-01-20', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(27, 3, 2, '2026-01-21', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(28, 3, 2, '2026-01-22', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(29, 3, 2, '2026-01-23', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(30, 3, 2, '2026-01-24', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(31, 3, 2, '2026-01-25', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(32, 3, 2, '2026-01-26', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(33, 3, 2, '2026-01-27', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(34, 3, 2, '2026-01-28', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(35, 3, 2, '2026-01-29', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(36, 3, 2, '2026-01-30', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(37, 3, 2, '2026-01-31', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(38, 3, 2, '2026-02-01', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(39, 3, 2, '2026-02-02', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(40, 3, 2, '2026-02-03', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(41, 3, 2, '2026-02-04', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(42, 3, 2, '2026-02-05', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(43, 3, 2, '2026-02-06', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(44, 3, 2, '2026-02-07', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(45, 3, 2, '2026-02-08', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(46, 3, 2, '2026-02-09', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(47, 3, 2, '2026-02-10', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(48, 3, 2, '2026-02-11', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(49, 3, 2, '2026-02-12', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(50, 3, 2, '2026-02-13', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(51, 3, 2, '2026-02-14', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(52, 3, 2, '2026-02-15', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(53, 3, 2, '2026-02-16', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(54, 3, 2, '2026-02-17', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(55, 3, 2, '2026-02-18', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(56, 3, 2, '2026-02-19', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(57, 3, 2, '2026-02-20', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(58, 3, 2, '2026-02-21', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(59, 3, 2, '2026-02-22', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(60, 3, 2, '2026-02-23', 2, '2026-02-23 08:58:00', '2026-02-23 17:10:00', 432, 0, 0, 10, 'present', NULL, NULL, '2026-02-25 22:29:53'),
(61, 4, 2, '2026-01-01', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(62, 4, 2, '2026-01-02', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(63, 4, 2, '2026-01-03', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(64, 4, 2, '2026-01-04', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(65, 4, 2, '2026-01-05', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(66, 4, 2, '2026-01-06', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(67, 4, 2, '2026-01-07', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(68, 4, 2, '2026-01-08', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(69, 4, 2, '2026-01-09', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(70, 4, 2, '2026-01-10', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(71, 4, 2, '2026-01-11', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(72, 4, 2, '2026-01-12', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(73, 4, 2, '2026-01-13', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(74, 4, 2, '2026-01-14', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(75, 4, 2, '2026-01-15', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(76, 4, 2, '2026-01-16', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(77, 4, 2, '2026-01-17', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(78, 4, 2, '2026-01-18', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(79, 4, 2, '2026-01-19', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(80, 4, 2, '2026-01-20', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(81, 4, 2, '2026-01-21', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(82, 4, 2, '2026-01-22', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(83, 4, 2, '2026-01-23', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(84, 4, 2, '2026-01-24', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(85, 4, 2, '2026-01-25', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(86, 4, 2, '2026-01-26', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(87, 4, 2, '2026-01-27', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(88, 4, 2, '2026-01-28', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(89, 4, 2, '2026-01-29', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(90, 4, 2, '2026-01-30', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(91, 4, 2, '2026-01-31', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(92, 4, 2, '2026-02-01', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(93, 4, 2, '2026-02-02', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(94, 4, 2, '2026-02-03', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(95, 4, 2, '2026-02-04', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(96, 4, 2, '2026-02-05', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(97, 4, 2, '2026-02-06', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(98, 4, 2, '2026-02-07', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(99, 4, 2, '2026-02-08', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(100, 4, 2, '2026-02-09', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(101, 4, 2, '2026-02-10', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(102, 4, 2, '2026-02-11', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(103, 4, 2, '2026-02-12', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(104, 4, 2, '2026-02-13', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(105, 4, 2, '2026-02-14', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(106, 4, 2, '2026-02-15', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(107, 4, 2, '2026-02-16', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(108, 4, 2, '2026-02-17', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(109, 4, 2, '2026-02-18', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(110, 4, 2, '2026-02-19', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(111, 4, 2, '2026-02-20', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(112, 4, 2, '2026-02-21', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-25 22:29:53'),
(113, 4, 2, '2026-02-22', 2, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-25 22:29:53'),
(114, 4, 2, '2026-02-23', 2, '2026-02-23 09:10:00', '2026-02-23 16:50:00', 400, 0, 5, 0, 'present', NULL, NULL, '2026-02-25 22:29:53'),
(115, 1, 1, '2026-01-01', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(116, 1, 1, '2026-01-02', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(117, 1, 1, '2026-01-03', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(118, 1, 1, '2026-01-04', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(119, 1, 1, '2026-01-05', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(120, 1, 1, '2026-01-06', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(121, 1, 1, '2026-01-07', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(122, 1, 1, '2026-01-08', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(123, 1, 1, '2026-01-09', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(124, 1, 1, '2026-01-10', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(125, 1, 1, '2026-01-11', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(126, 1, 1, '2026-01-12', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(127, 1, 1, '2026-01-13', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(128, 1, 1, '2026-01-14', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(129, 1, 1, '2026-01-15', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(130, 1, 1, '2026-01-16', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(131, 1, 1, '2026-01-17', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(132, 1, 1, '2026-01-18', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(133, 1, 1, '2026-01-19', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(134, 1, 1, '2026-01-20', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(135, 1, 1, '2026-01-21', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(136, 1, 1, '2026-01-22', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(137, 1, 1, '2026-01-23', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(138, 1, 1, '2026-01-24', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(139, 1, 1, '2026-01-25', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(140, 1, 1, '2026-01-26', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(141, 1, 1, '2026-01-27', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(142, 1, 1, '2026-01-28', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(143, 1, 1, '2026-01-29', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(144, 1, 1, '2026-01-30', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(145, 1, 1, '2026-01-31', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(146, 1, 1, '2026-02-01', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(147, 1, 1, '2026-02-02', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(148, 1, 1, '2026-02-03', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(149, 1, 1, '2026-02-04', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(150, 1, 1, '2026-02-05', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(151, 1, 1, '2026-02-06', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(152, 1, 1, '2026-02-07', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(153, 1, 1, '2026-02-08', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(154, 1, 1, '2026-02-09', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(155, 1, 1, '2026-02-10', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(156, 1, 1, '2026-02-11', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(157, 1, 1, '2026-02-12', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(158, 1, 1, '2026-02-13', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(159, 1, 1, '2026-02-14', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(160, 1, 1, '2026-02-15', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(161, 1, 1, '2026-02-16', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(162, 1, 1, '2026-02-17', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(163, 1, 1, '2026-02-18', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(164, 1, 1, '2026-02-19', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(165, 1, 1, '2026-02-20', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(166, 1, 1, '2026-02-21', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(167, 1, 1, '2026-02-22', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(168, 1, 1, '2026-02-23', 1, '2026-02-23 09:02:00', '2026-02-23 17:18:00', 436, 0, 0, 18, 'present', NULL, NULL, '2026-02-26 01:00:25'),
(169, 2, 1, '2026-01-01', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(170, 2, 1, '2026-01-02', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(171, 2, 1, '2026-01-03', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(172, 2, 1, '2026-01-04', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(173, 2, 1, '2026-01-05', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(174, 2, 1, '2026-01-06', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(175, 2, 1, '2026-01-07', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(176, 2, 1, '2026-01-08', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(177, 2, 1, '2026-01-09', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(178, 2, 1, '2026-01-10', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(179, 2, 1, '2026-01-11', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(180, 2, 1, '2026-01-12', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(181, 2, 1, '2026-01-13', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(182, 2, 1, '2026-01-14', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(183, 2, 1, '2026-01-15', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(184, 2, 1, '2026-01-16', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(185, 2, 1, '2026-01-17', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(186, 2, 1, '2026-01-18', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(187, 2, 1, '2026-01-19', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(188, 2, 1, '2026-01-20', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(189, 2, 1, '2026-01-21', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(190, 2, 1, '2026-01-22', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(191, 2, 1, '2026-01-23', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(192, 2, 1, '2026-01-24', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(193, 2, 1, '2026-01-25', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(194, 2, 1, '2026-01-26', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(195, 2, 1, '2026-01-27', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(196, 2, 1, '2026-01-28', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(197, 2, 1, '2026-01-29', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(198, 2, 1, '2026-01-30', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(199, 2, 1, '2026-01-31', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(200, 2, 1, '2026-02-01', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(201, 2, 1, '2026-02-02', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(202, 2, 1, '2026-02-03', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(203, 2, 1, '2026-02-04', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(204, 2, 1, '2026-02-05', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(205, 2, 1, '2026-02-06', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(206, 2, 1, '2026-02-07', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(207, 2, 1, '2026-02-08', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(208, 2, 1, '2026-02-09', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(209, 2, 1, '2026-02-10', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(210, 2, 1, '2026-02-11', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(211, 2, 1, '2026-02-12', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(212, 2, 1, '2026-02-13', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(213, 2, 1, '2026-02-14', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(214, 2, 1, '2026-02-15', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(215, 2, 1, '2026-02-16', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(216, 2, 1, '2026-02-17', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(217, 2, 1, '2026-02-18', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(218, 2, 1, '2026-02-19', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(219, 2, 1, '2026-02-20', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(220, 2, 1, '2026-02-21', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(221, 2, 1, '2026-02-22', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(222, 2, 1, '2026-02-23', 1, '2026-02-23 09:22:00', '2026-02-23 17:03:00', 401, 7, 0, 3, 'present', NULL, NULL, '2026-02-26 01:00:25'),
(223, 5, 1, '2026-01-01', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(224, 5, 1, '2026-01-02', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(225, 5, 1, '2026-01-03', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(226, 5, 1, '2026-01-04', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(227, 5, 1, '2026-01-05', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(228, 5, 1, '2026-01-06', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(229, 5, 1, '2026-01-07', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(230, 5, 1, '2026-01-08', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(231, 5, 1, '2026-01-09', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(232, 5, 1, '2026-01-10', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(233, 5, 1, '2026-01-11', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(234, 5, 1, '2026-01-12', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(235, 5, 1, '2026-01-13', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(236, 5, 1, '2026-01-14', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(237, 5, 1, '2026-01-15', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(238, 5, 1, '2026-01-16', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(239, 5, 1, '2026-01-17', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(240, 5, 1, '2026-01-18', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(241, 5, 1, '2026-01-19', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(242, 5, 1, '2026-01-20', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(243, 5, 1, '2026-01-21', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(244, 5, 1, '2026-01-22', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(245, 5, 1, '2026-01-23', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(246, 5, 1, '2026-01-24', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(247, 5, 1, '2026-01-25', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(248, 5, 1, '2026-01-26', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(249, 5, 1, '2026-01-27', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(250, 5, 1, '2026-01-28', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(251, 5, 1, '2026-01-29', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(252, 5, 1, '2026-01-30', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(253, 5, 1, '2026-01-31', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(254, 5, 1, '2026-02-01', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(255, 5, 1, '2026-02-02', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(256, 5, 1, '2026-02-03', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(257, 5, 1, '2026-02-04', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(258, 5, 1, '2026-02-05', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(259, 5, 1, '2026-02-06', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(260, 5, 1, '2026-02-07', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(261, 5, 1, '2026-02-08', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(262, 5, 1, '2026-02-09', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(263, 5, 1, '2026-02-10', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(264, 5, 1, '2026-02-11', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(265, 5, 1, '2026-02-12', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(266, 5, 1, '2026-02-13', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(267, 5, 1, '2026-02-14', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(268, 5, 1, '2026-02-15', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(269, 5, 1, '2026-02-16', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(270, 5, 1, '2026-02-17', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(271, 5, 1, '2026-02-18', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(272, 5, 1, '2026-02-19', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(273, 5, 1, '2026-02-20', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(274, 5, 1, '2026-02-21', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(275, 5, 1, '2026-02-22', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(276, 5, 1, '2026-02-23', 1, '2026-02-23 09:05:00', '2026-02-23 17:00:00', 415, 0, 0, 0, 'present', NULL, NULL, '2026-02-26 01:00:25'),
(277, 6, 1, '2026-01-01', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(278, 6, 1, '2026-01-02', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(279, 6, 1, '2026-01-03', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(280, 6, 1, '2026-01-04', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(281, 6, 1, '2026-01-05', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(282, 6, 1, '2026-01-06', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(283, 6, 1, '2026-01-07', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(284, 6, 1, '2026-01-08', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(285, 6, 1, '2026-01-09', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(286, 6, 1, '2026-01-10', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(287, 6, 1, '2026-01-11', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(288, 6, 1, '2026-01-12', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(289, 6, 1, '2026-01-13', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(290, 6, 1, '2026-01-14', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(291, 6, 1, '2026-01-15', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(292, 6, 1, '2026-01-16', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(293, 6, 1, '2026-01-17', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(294, 6, 1, '2026-01-18', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(295, 6, 1, '2026-01-19', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(296, 6, 1, '2026-01-20', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(297, 6, 1, '2026-01-21', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(298, 6, 1, '2026-01-22', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(299, 6, 1, '2026-01-23', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(300, 6, 1, '2026-01-24', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(301, 6, 1, '2026-01-25', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(302, 6, 1, '2026-01-26', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(303, 6, 1, '2026-01-27', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(304, 6, 1, '2026-01-28', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(305, 6, 1, '2026-01-29', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(306, 6, 1, '2026-01-30', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(307, 6, 1, '2026-01-31', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(308, 6, 1, '2026-02-01', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(309, 6, 1, '2026-02-02', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(310, 6, 1, '2026-02-03', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(311, 6, 1, '2026-02-04', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(312, 6, 1, '2026-02-05', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(313, 6, 1, '2026-02-06', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(314, 6, 1, '2026-02-07', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(315, 6, 1, '2026-02-08', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(316, 6, 1, '2026-02-09', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(317, 6, 1, '2026-02-10', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(318, 6, 1, '2026-02-11', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(319, 6, 1, '2026-02-12', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(320, 6, 1, '2026-02-13', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(321, 6, 1, '2026-02-14', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(322, 6, 1, '2026-02-15', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(323, 6, 1, '2026-02-16', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(324, 6, 1, '2026-02-17', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(325, 6, 1, '2026-02-18', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(326, 6, 1, '2026-02-19', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(327, 6, 1, '2026-02-20', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(328, 6, 1, '2026-02-21', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 01:00:25'),
(329, 6, 1, '2026-02-22', 1, NULL, NULL, 0, 0, 0, 0, 'absent', NULL, NULL, '2026-02-26 01:00:25'),
(330, 6, 1, '2026-02-23', 1, '2026-02-23 09:00:00', '2026-02-23 17:25:00', 445, 0, 0, 25, 'present', NULL, NULL, '2026-02-26 01:00:25'),
(331, 3, 2, '2026-02-25', 2, '2026-02-25 08:58:00', '2026-02-25 17:10:00', 432, 0, 0, 10, 'present', NULL, NULL, '2026-02-25 23:33:47'),
(332, 3, 2, '2026-02-26', 2, '2026-02-26 08:58:00', '2026-02-26 17:10:00', 432, 0, 0, 10, 'present', NULL, NULL, '2026-02-26 12:30:51'),
(333, 3, 2, '2026-02-27', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-24 13:41:39'),
(334, 3, 2, '2026-02-28', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-24 13:41:39'),
(335, 4, 2, '2026-02-25', 2, '2026-02-25 09:10:00', '2026-02-25 16:50:00', 400, 0, 5, 0, 'present', NULL, NULL, '2026-02-25 23:33:47'),
(336, 4, 2, '2026-02-26', 2, '2026-02-26 09:10:00', '2026-02-26 16:50:00', 400, 0, 5, 0, 'present', NULL, NULL, '2026-02-26 12:30:51'),
(337, 4, 2, '2026-02-27', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-24 13:41:39'),
(338, 4, 2, '2026-02-28', 2, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-24 13:41:39'),
(1266, 1, 1, '2026-02-25', 1, '2026-02-25 09:02:00', '2026-02-25 17:18:00', 436, 0, 0, 18, 'present', NULL, NULL, '2026-02-26 01:00:25'),
(1267, 2, 1, '2026-02-25', 1, '2026-02-25 09:22:00', '2026-02-25 17:03:00', 401, 7, 0, 3, 'present', NULL, NULL, '2026-02-26 01:00:25'),
(1270, 5, 1, '2026-02-25', 1, '2026-02-25 09:05:00', '2026-02-25 17:00:00', 415, 0, 0, 0, 'present', NULL, NULL, '2026-02-26 01:00:25'),
(1271, 6, 1, '2026-02-25', 1, '2026-02-25 09:00:00', '2026-02-25 17:25:00', 445, 0, 0, 25, 'present', NULL, NULL, '2026-02-26 01:00:25'),
(2328, 1, 1, '2026-02-26', 1, '2026-02-26 09:02:00', '2026-02-26 17:18:00', 436, 0, 0, 18, 'present', NULL, NULL, '2026-02-26 12:30:51'),
(2329, 2, 1, '2026-02-26', 1, '2026-02-26 09:22:00', '2026-02-26 17:03:00', 401, 7, 0, 3, 'present', NULL, NULL, '2026-02-26 12:30:51'),
(2332, 5, 1, '2026-02-26', 1, '2026-02-26 09:05:00', '2026-02-26 17:00:00', 415, 0, 0, 0, 'present', NULL, NULL, '2026-02-26 12:30:51'),
(2333, 6, 1, '2026-02-26', 1, '2026-02-26 09:00:00', '2026-02-26 17:25:00', 445, 0, 0, 25, 'present', NULL, NULL, '2026-02-26 12:30:51'),
(2621, 1, 1, '2026-02-27', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 00:33:01'),
(2622, 1, 1, '2026-02-28', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 00:33:01'),
(2624, 2, 1, '2026-02-27', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 00:33:01'),
(2625, 2, 1, '2026-02-28', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 00:33:01'),
(2627, 5, 1, '2026-02-27', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 00:33:01'),
(2628, 5, 1, '2026-02-28', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 00:33:01'),
(2630, 6, 1, '2026-02-27', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 00:33:01'),
(2631, 6, 1, '2026-02-28', 1, NULL, NULL, 0, 0, 0, 0, 'off', NULL, NULL, '2026-02-26 00:33:01');

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

--
-- بنية الجدول `attendance_deduction_policies`
--

CREATE TABLE `attendance_deduction_policies` (
  `id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `grade_id` int(11) DEFAULT NULL,
  `department_id` int(11) DEFAULT NULL,
  `shift_id` int(11) DEFAULT NULL,
  `late_multiplier` decimal(6,2) DEFAULT NULL,
  `early_multiplier` decimal(6,2) DEFAULT NULL,
  `absence_multiplier` decimal(6,2) DEFAULT NULL,
  `unpaid_multiplier` decimal(6,2) DEFAULT NULL,
  `late_rounding_minutes` int(11) DEFAULT NULL,
  `priority` int(11) NOT NULL DEFAULT 0,
  `is_active` tinyint(4) NOT NULL DEFAULT 1,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `attendance_deduction_policies`
--

INSERT INTO `attendance_deduction_policies` (`id`, `branch_id`, `grade_id`, `department_id`, `shift_id`, `late_multiplier`, `early_multiplier`, `absence_multiplier`, `unpaid_multiplier`, `late_rounding_minutes`, `priority`, `is_active`, `created_at`) VALUES
(1, 1, 3, NULL, NULL, 1.50, 1.00, 1.00, 1.00, 10, 10, 1, '2026-02-24 13:19:46'),
(2, 2, 6, NULL, NULL, 1.50, 1.00, 1.00, 1.00, 10, 10, 1, '2026-02-24 13:19:46');

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

--
-- بنية الجدول `attendance_device_field_maps`
--

CREATE TABLE `attendance_device_field_maps` (
  `id` int(11) NOT NULL,
  `device_id` int(11) NOT NULL,
  `source_field` varchar(100) NOT NULL,
  `target_field` varchar(100) NOT NULL,
  `transform_rule` varchar(100) DEFAULT NULL,
  `is_required` tinyint(4) NOT NULL DEFAULT 0,
  `sort_order` int(11) NOT NULL DEFAULT 0,
  `is_active` tinyint(4) NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `attendance_device_sync_runs`
--

CREATE TABLE `attendance_device_sync_runs` (
  `id` bigint(20) NOT NULL,
  `device_id` int(11) NOT NULL,
  `started_at` datetime NOT NULL,
  `finished_at` datetime DEFAULT NULL,
  `status` varchar(20) NOT NULL DEFAULT 'running',
  `rows_fetched` int(11) NOT NULL DEFAULT 0,
  `rows_inserted` int(11) NOT NULL DEFAULT 0,
  `rows_skipped` int(11) NOT NULL DEFAULT 0,
  `error_count` int(11) NOT NULL DEFAULT 0,
  `cursor_after` varchar(255) DEFAULT NULL,
  `error_message` text DEFAULT NULL,
  `created_by_user_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `attendance_import_jobs`
--

CREATE TABLE `attendance_import_jobs` (
  `id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `file_name` varchar(255) DEFAULT NULL,
  `imported_by_user_id` int(11) DEFAULT NULL,
  `imported_at` datetime NOT NULL,
  `rows_total` int(11) NOT NULL DEFAULT 0,
  `rows_inserted` int(11) NOT NULL DEFAULT 0,
  `rows_skipped` int(11) NOT NULL DEFAULT 0,
  `error_count` int(11) NOT NULL DEFAULT 0,
  `error_sample` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `attendance_payroll_rules`
--

CREATE TABLE `attendance_payroll_rules` (
  `branch_id` int(11) NOT NULL,
  `basis` varchar(20) NOT NULL DEFAULT 'gross',
  `work_days_per_month` int(11) NOT NULL DEFAULT 26,
  `work_hours_per_day` decimal(4,2) NOT NULL DEFAULT 8.00,
  `overtime_multiplier` decimal(6,2) NOT NULL DEFAULT 1.50,
  `weekend_work_as_overtime` tinyint(4) NOT NULL DEFAULT 1,
  `holiday_work_as_overtime` tinyint(4) NOT NULL DEFAULT 1,
  `late_deduction_multiplier` decimal(6,2) NOT NULL DEFAULT 1.00,
  `early_leave_deduction_multiplier` decimal(6,2) NOT NULL DEFAULT 1.00,
  `absence_deduction_multiplier` decimal(6,2) NOT NULL DEFAULT 1.00,
  `unpaid_leave_deduction_multiplier` decimal(6,2) NOT NULL DEFAULT 1.00,
  `late_rounding_minutes` int(11) NOT NULL DEFAULT 0,
  `overtime_rounding_minutes` int(11) NOT NULL DEFAULT 0,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `attendance_payroll_rules`
--

INSERT INTO `attendance_payroll_rules` (`branch_id`, `basis`, `work_days_per_month`, `work_hours_per_day`, `overtime_multiplier`, `weekend_work_as_overtime`, `holiday_work_as_overtime`, `late_deduction_multiplier`, `early_leave_deduction_multiplier`, `absence_deduction_multiplier`, `unpaid_leave_deduction_multiplier`, `late_rounding_minutes`, `overtime_rounding_minutes`, `created_at`, `updated_at`) VALUES
(1, 'gross', 26, 8.00, 1.50, 1, 1, 1.00, 1.00, 1.00, 1.00, 5, 15, '2026-02-24 13:19:46', '2026-02-24 13:19:46'),
(2, 'gross', 26, 8.00, 1.50, 1, 1, 1.00, 1.00, 1.00, 1.00, 5, 15, '2026-02-24 13:19:46', '2026-02-24 13:19:46');

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

--
-- بنية الجدول `attendance_punches`
--

CREATE TABLE `attendance_punches` (
  `id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `punch_type` varchar(3) NOT NULL,
  `punched_at` datetime NOT NULL,
  `source` varchar(20) NOT NULL DEFAULT 'manual',
  `note` varchar(255) DEFAULT NULL,
  `ip_address` varchar(50) DEFAULT NULL,
  `user_agent` varchar(255) DEFAULT NULL,
  `device_name` varchar(100) DEFAULT NULL,
  `created_by_user_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `attendance_punches`
--

INSERT INTO `attendance_punches` (`id`, `employee_id`, `branch_id`, `punch_type`, `punched_at`, `source`, `note`, `ip_address`, `user_agent`, `device_name`, `created_by_user_id`, `created_at`) VALUES
(1, 1, 1, 'IN', '2026-02-23 09:02:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(2, 1, 1, 'OUT', '2026-02-23 17:18:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(3, 2, 1, 'IN', '2026-02-23 09:22:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(4, 2, 1, 'OUT', '2026-02-23 17:03:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(5, 3, 2, 'IN', '2026-02-23 08:58:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(6, 3, 2, 'OUT', '2026-02-23 17:10:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(7, 4, 2, 'IN', '2026-02-23 09:10:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(8, 4, 2, 'OUT', '2026-02-23 16:50:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(9, 5, 1, 'IN', '2026-02-23 09:05:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(10, 5, 1, 'OUT', '2026-02-23 17:00:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(11, 6, 1, 'IN', '2026-02-23 09:00:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(12, 6, 1, 'OUT', '2026-02-23 17:25:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(13, 1, 1, 'IN', '2026-02-24 09:02:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(14, 1, 1, 'OUT', '2026-02-24 17:18:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(15, 2, 1, 'IN', '2026-02-24 09:22:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(16, 2, 1, 'OUT', '2026-02-24 17:03:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(17, 3, 2, 'IN', '2026-02-24 08:58:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(18, 3, 2, 'OUT', '2026-02-24 17:10:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(19, 4, 2, 'IN', '2026-02-24 09:10:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(20, 4, 2, 'OUT', '2026-02-24 16:50:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(21, 5, 1, 'IN', '2026-02-24 09:05:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(22, 5, 1, 'OUT', '2026-02-24 17:00:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(23, 6, 1, 'IN', '2026-02-24 09:00:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(24, 6, 1, 'OUT', '2026-02-24 17:25:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-24 13:19:46'),
(25, 2, 1, 'IN', '2026-02-24 13:43:17', 'manual', NULL, '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', NULL, 5, '2026-02-24 13:43:17'),
(182, 1, 1, 'IN', '2026-02-25 09:02:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-25 20:45:16'),
(183, 1, 1, 'OUT', '2026-02-25 17:18:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-25 20:45:16'),
(184, 2, 1, 'IN', '2026-02-25 09:22:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-25 20:45:16'),
(185, 2, 1, 'OUT', '2026-02-25 17:03:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-25 20:45:16'),
(186, 3, 2, 'IN', '2026-02-25 08:58:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-25 20:45:16'),
(187, 3, 2, 'OUT', '2026-02-25 17:10:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-25 20:45:16'),
(188, 4, 2, 'IN', '2026-02-25 09:10:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-25 20:45:16'),
(189, 4, 2, 'OUT', '2026-02-25 16:50:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-25 20:45:16'),
(190, 5, 1, 'IN', '2026-02-25 09:05:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-25 20:45:16'),
(191, 5, 1, 'OUT', '2026-02-25 17:00:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-25 20:45:16'),
(192, 6, 1, 'IN', '2026-02-25 09:00:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-25 20:45:16'),
(193, 6, 1, 'OUT', '2026-02-25 17:25:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-25 20:45:16'),
(278, 1, 1, 'IN', '2026-02-26 09:02:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-26 00:10:52'),
(279, 1, 1, 'OUT', '2026-02-26 17:18:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-26 00:10:52'),
(280, 2, 1, 'IN', '2026-02-26 09:22:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-26 00:10:52'),
(281, 2, 1, 'OUT', '2026-02-26 17:03:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-26 00:10:52'),
(282, 3, 2, 'IN', '2026-02-26 08:58:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-26 00:10:52'),
(283, 3, 2, 'OUT', '2026-02-26 17:10:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-26 00:10:52'),
(284, 4, 2, 'IN', '2026-02-26 09:10:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-26 00:10:52'),
(285, 4, 2, 'OUT', '2026-02-26 16:50:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-26 00:10:52'),
(286, 5, 1, 'IN', '2026-02-26 09:05:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-26 00:10:52'),
(287, 5, 1, 'OUT', '2026-02-26 17:00:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-26 00:10:52'),
(288, 6, 1, 'IN', '2026-02-26 09:00:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-26 00:10:52'),
(289, 6, 1, 'OUT', '2026-02-26 17:25:00', 'import', 'بيانات تجريبية', NULL, NULL, 'DEMO', NULL, '2026-02-26 00:10:52'),
(362, 2, 1, 'IN', '2026-02-26 01:04:02', 'manual', NULL, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', NULL, 5, '2026-02-26 01:04:02'),
(363, 2, 1, 'IN', '2026-02-26 01:04:15', 'manual', NULL, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', NULL, 5, '2026-02-26 01:04:15');

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

--
-- بنية الجدول `audit_logs`
--

CREATE TABLE `audit_logs` (
  `id` bigint(20) NOT NULL,
  `module` varchar(50) NOT NULL,
  `entity_type` varchar(50) NOT NULL,
  `entity_id` int(11) DEFAULT NULL,
  `branch_id` int(11) DEFAULT NULL,
  `action` varchar(50) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` varchar(255) DEFAULT NULL,
  `route` varchar(100) DEFAULT NULL,
  `payload_json` mediumtext DEFAULT NULL,
  `created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `audit_logs`
--

INSERT INTO `audit_logs` (`id`, `module`, `entity_type`, `entity_id`, `branch_id`, `action`, `user_id`, `ip_address`, `user_agent`, `route`, `payload_json`, `created_at`) VALUES
(1, 'notifications', 'notification', NULL, NULL, 'sent_batch', 1, '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'notifications', '{\"recipients\":7,\"category\":\"general\",\"severity\":\"info\",\"title\":\"ي\",\"source_module\":\"notifications\",\"source_entity_type\":\"manual\",\"source_entity_id\":null}', '2026-02-24 14:13:11'),
(2, 'chat', 'chat_conversation', 1, 2, 'created', 1, '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'chat', '{\"participants\":2,\"kind\":\"direct\",\"subject\":\"ي\"}', '2026-02-24 14:19:35'),
(3, 'notifications', 'notification', NULL, 2, 'sent_batch', 1, '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'chat', '{\"recipients\":1,\"category\":\"chat\",\"severity\":\"info\",\"title\":\"رسالة جديدة: ي\",\"source_module\":\"chat\",\"source_entity_type\":\"conversation\",\"source_entity_id\":1}', '2026-02-24 14:19:35'),
(4, 'chat', 'chat_message', 1, 2, 'created', 1, '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'chat', '{\"conversation_id\":1,\"has_attachments\":false,\"attachments_count\":0}', '2026-02-24 14:19:35'),
(5, 'notifications', 'notification', NULL, 2, 'sent_batch', 1, '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'chat', '{\"recipients\":1,\"category\":\"chat\",\"severity\":\"info\",\"title\":\"رسالة جديدة: ي\",\"source_module\":\"chat\",\"source_entity_type\":\"conversation\",\"source_entity_id\":1}', '2026-02-24 14:19:43'),
(6, 'chat', 'chat_message', 2, 2, 'created', 1, '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'chat', '{\"conversation_id\":1,\"has_attachments\":true,\"attachments_count\":1}', '2026-02-24 14:19:43'),
(7, 'notifications', 'notification', NULL, 2, 'sent_batch', 1, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'chat', '{\"recipients\":1,\"category\":\"chat\",\"severity\":\"info\",\"title\":\"رسالة جديدة: ي\",\"source_module\":\"chat\",\"source_entity_type\":\"conversation\",\"source_entity_id\":1}', '2026-02-25 22:07:16'),
(8, 'chat', 'chat_message', 3, 2, 'created', 1, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'chat', '{\"conversation_id\":1,\"has_attachments\":true,\"attachments_count\":1}', '2026-02-25 22:07:16'),
(9, 'visit_request', 'reception_visit', 1, 1, 'visit_request_created', 1, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'visit_request', '{\"visitor_name\":\"ali\",\"purpose\":\"مقابلة\",\"branch_id\":1,\"source_type\":\"pre_registered\"}', '2026-02-25 22:26:35'),
(10, 'notifications', 'notification', NULL, 1, 'sent_batch', 1, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'visit_request', '{\"recipients\":2,\"category\":\"reception\",\"severity\":\"warning\",\"title\":\"طلب زيارة جديد (بلاغ مسبق)\",\"source_module\":\"reception\",\"source_entity_type\":\"visit\",\"source_entity_id\":1}', '2026-02-25 22:26:35'),
(11, 'reception', 'reception_visit', 1, 1, 'checked_in', 8, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'reception', '{\"prev\":\"expected\"}', '2026-02-25 22:28:30'),
(12, 'notifications', 'notification', NULL, 1, 'sent_batch', 8, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'reception', '{\"recipients\":1,\"category\":\"reception\",\"severity\":\"info\",\"title\":\"الزائر وصل إلى الاستقبال\",\"source_module\":\"reception\",\"source_entity_type\":\"visit\",\"source_entity_id\":1}', '2026-02-25 22:28:30'),
(13, 'reception', 'reception_visit', 1, 1, 'checked_out', 8, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'reception', '{\"prev\":\"checked_in\"}', '2026-02-25 22:29:15'),
(14, 'notifications', 'notification', NULL, 1, 'sent_batch', 8, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'reception', '{\"recipients\":1,\"category\":\"reception\",\"severity\":\"info\",\"title\":\"تم خروج الزائر من الشركة\",\"source_module\":\"reception\",\"source_entity_type\":\"visit\",\"source_entity_id\":1}', '2026-02-25 22:29:15'),
(15, 'chat', 'chat_conversation', 2, NULL, 'created', 8, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'chat', '{\"participants\":2,\"kind\":\"direct\",\"subject\":\"محادثة داخلية\"}', '2026-02-25 22:30:09'),
(16, 'notifications', 'notification', NULL, NULL, 'sent_batch', 8, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'chat', '{\"recipients\":1,\"category\":\"chat\",\"severity\":\"info\",\"title\":\"رسالة جديدة: محادثة داخلية\",\"source_module\":\"chat\",\"source_entity_type\":\"conversation\",\"source_entity_id\":2}', '2026-02-25 22:30:14'),
(17, 'chat', 'chat_message', 4, NULL, 'created', 8, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'chat', '{\"conversation_id\":2,\"has_attachments\":false,\"attachments_count\":0}', '2026-02-25 22:30:14'),
(18, 'jobs', 'job_queue', 1, NULL, 'enqueue', 1, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'ops_center', '{\"job_type\":\"attendance_sync_plan\",\"queue\":\"default\"}', '2026-02-26 01:16:12'),
(19, 'jobs', 'job_queue', 1, NULL, 'done', 1, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'ops_center', '{\"worker\":\"ops-web-1\",\"job_type\":\"attendance_sync_plan\"}', '2026-02-26 01:16:29'),
(20, 'jobs', 'job_queue', 2, NULL, 'enqueue', 1, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'ops_center', '{\"job_type\":\"attendance_sync_plan\",\"queue\":\"default\"}', '2026-02-26 11:28:04'),
(21, 'email', 'email', NULL, NULL, 'sent_batch', 1, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'notifications', '{\"recipients\":6,\"subject\":\"alimahmoudali1712@gmail.com\",\"title\":\"d\"}', '2026-02-26 12:11:36'),
(22, 'jobs', 'job_queue', 2, NULL, 'done', 1, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'ops_center', '{\"worker\":\"ops-web-1\",\"job_type\":\"attendance_sync_plan\"}', '2026-02-26 12:19:12'),
(23, 'jobs', 'job_queue', 3, NULL, 'enqueue', 1, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'ops_center', '{\"job_type\":\"approval_sla_scan\",\"queue\":\"default\"}', '2026-02-26 12:39:11'),
(24, 'email', 'email', NULL, 1, 'sent_batch', 1, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'loans', '{\"recipients\":1,\"subject\":\"تحديث طلب السلفة LOAN-1\",\"title\":\"تحديث حالة طلب السلفة\"}', '2026-02-26 12:39:23'),
(25, 'email', 'email', NULL, 1, 'sent_batch', 1, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'loans', '{\"recipients\":1,\"subject\":\"تحديث طلب السلفة LOAN-1\",\"title\":\"تحديث حالة طلب السلفة\"}', '2026-02-26 12:39:24'),
(26, 'jobs', 'job_queue', 4, NULL, 'enqueue', 1, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'ops_center', '{\"job_type\":\"approval_sla_scan\",\"queue\":\"default\"}', '2026-02-26 15:25:26'),
(27, 'email', 'email', NULL, 1, 'sent_batch', 1, '10.23.0.94', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', 'mail_center', '{\"recipients\":4,\"subject\":\"d\",\"title\":\"d\"}', '2026-02-26 16:02:59');

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

--
-- بنية الجدول `backup_runs`
--

CREATE TABLE `backup_runs` (
  `id` bigint(20) NOT NULL,
  `run_type` varchar(30) NOT NULL DEFAULT 'manual',
  `status` varchar(20) NOT NULL DEFAULT 'pending',
  `target_path` varchar(255) DEFAULT NULL,
  `started_at` datetime NOT NULL,
  `finished_at` datetime DEFAULT NULL,
  `size_bytes` bigint(20) NOT NULL DEFAULT 0,
  `created_by_user_id` int(11) DEFAULT NULL,
  `error_message` text DEFAULT NULL,
  `notes` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `backup_runs`
--

INSERT INTO `backup_runs` (`id`, `run_type`, `status`, `target_path`, `started_at`, `finished_at`, `size_bytes`, `created_by_user_id`, `error_message`, `notes`) VALUES
(1, 'manual_stub', 'completed', 'storage/backups', '2026-02-26 01:16:16', '2026-02-26 01:16:16', 0, 1, NULL, 'Recorded from Ops Center'),
(2, 'manual_stub', 'completed', 'storage/backups', '2026-02-26 11:28:16', '2026-02-26 11:28:16', 0, 1, NULL, 'Recorded from Ops Center');

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

--
-- بنية الجدول `branches`
--

CREATE TABLE `branches` (
  `id` int(11) NOT NULL,
  `code` varchar(10) NOT NULL,
  `name` varchar(100) NOT NULL,
  `address` varchar(255) DEFAULT NULL,
  `is_active` tinyint(4) NOT NULL DEFAULT 1,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `branches`
--

INSERT INTO `branches` (`id`, `code`, `name`, `address`, `is_active`, `created_at`) VALUES
(1, 'CAI', 'القاهرة', 'المقر الرئيسي - القاهرة', 1, '2026-02-24 13:19:46'),
(2, 'ALX', 'الإسكندرية', 'فرع الإسكندرية', 1, '2026-02-24 13:19:46');

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

--
-- بنية الجدول `branch_calendar`
--

CREATE TABLE `branch_calendar` (
  `branch_id` int(11) NOT NULL,
  `weekend_days` varchar(20) NOT NULL DEFAULT '5,6',
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `branch_calendar`
--

INSERT INTO `branch_calendar` (`branch_id`, `weekend_days`, `created_at`) VALUES
(1, '5,6', '2026-02-24 13:19:46'),
(2, '5,6', '2026-02-24 13:19:46');

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

--
-- بنية الجدول `branch_holidays`
--

CREATE TABLE `branch_holidays` (
  `id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `holiday_date` date NOT NULL,
  `name` varchar(150) NOT NULL,
  `is_paid` tinyint(4) NOT NULL DEFAULT 1,
  `is_active` tinyint(4) NOT NULL DEFAULT 1,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `cases`
--

CREATE TABLE `cases` (
  `id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `subject` varchar(150) NOT NULL,
  `description` text NOT NULL,
  `priority` varchar(20) NOT NULL DEFAULT 'normal',
  `status` varchar(20) NOT NULL DEFAULT 'open',
  `assigned_to_user_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `cases`
--

INSERT INTO `cases` (`id`, `branch_id`, `employee_id`, `subject`, `description`, `priority`, `status`, `assigned_to_user_id`, `created_at`, `updated_at`) VALUES
(1, 1, 2, 'ي', 'ي', 'low', 'closed', 1, '2026-02-24 13:43:41', '2026-02-24 13:44:09');

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

--
-- بنية الجدول `chat_conversations`
--

CREATE TABLE `chat_conversations` (
  `id` bigint(20) NOT NULL,
  `branch_id` int(11) DEFAULT NULL,
  `subject` varchar(180) NOT NULL,
  `created_by_user_id` int(11) NOT NULL,
  `kind` varchar(20) NOT NULL DEFAULT 'direct',
  `status` varchar(20) NOT NULL DEFAULT 'open',
  `last_message_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `chat_conversations`
--

INSERT INTO `chat_conversations` (`id`, `branch_id`, `subject`, `created_by_user_id`, `kind`, `status`, `last_message_at`, `created_at`, `updated_at`) VALUES
(1, 2, 'ي', 1, 'direct', 'open', '2026-02-25 22:07:16', '2026-02-24 14:19:35', '2026-02-25 22:07:16'),
(2, NULL, 'محادثة داخلية', 8, 'direct', 'open', '2026-02-25 22:30:14', '2026-02-25 22:30:09', '2026-02-25 22:30:14');

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

--
-- بنية الجدول `chat_messages`
--

CREATE TABLE `chat_messages` (
  `id` bigint(20) NOT NULL,
  `conversation_id` bigint(20) NOT NULL,
  `sender_user_id` int(11) NOT NULL,
  `body` text DEFAULT NULL,
  `has_attachments` tinyint(4) NOT NULL DEFAULT 0,
  `created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `chat_messages`
--

INSERT INTO `chat_messages` (`id`, `conversation_id`, `sender_user_id`, `body`, `has_attachments`, `created_at`) VALUES
(1, 1, 1, 'هاي', 0, '2026-02-24 14:19:35'),
(2, 1, 1, NULL, 1, '2026-02-24 14:19:43'),
(3, 1, 1, NULL, 1, '2026-02-25 22:07:16'),
(4, 2, 8, 'f', 0, '2026-02-25 22:30:14');

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

--
-- بنية الجدول `chat_message_attachments`
--

CREATE TABLE `chat_message_attachments` (
  `id` bigint(20) NOT NULL,
  `message_id` bigint(20) NOT NULL,
  `original_name` varchar(255) NOT NULL,
  `stored_name` varchar(255) NOT NULL,
  `relative_path` varchar(255) NOT NULL,
  `mime_type` varchar(120) DEFAULT NULL,
  `file_ext` varchar(20) DEFAULT NULL,
  `file_size` bigint(20) NOT NULL DEFAULT 0,
  `created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `chat_message_attachments`
--

INSERT INTO `chat_message_attachments` (`id`, `message_id`, `original_name`, `stored_name`, `relative_path`, `mime_type`, `file_ext`, `file_size`, `created_at`) VALUES
(1, 2, 'payroll_items_ALX_202602.csv', 'c81827f87b9d38118b1c2e8cb2f78658.csv', 'chat_uploads/2026/02/c81827f87b9d38118b1c2e8cb2f78658.csv', 'text/csv', 'csv', 768, '2026-02-24 14:19:43'),
(2, 3, 'top_hour_report_all_2026-02-24_to_2026-02-24.xls', '35ee60760693f333e19a2549a10abfb0.xls', 'chat_uploads/2026/02/35ee60760693f333e19a2549a10abfb0.xls', 'application/vnd.ms-excel', 'xls', 1146866, '2026-02-25 22:07:16');

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

--
-- بنية الجدول `chat_participants`
--

CREATE TABLE `chat_participants` (
  `conversation_id` bigint(20) NOT NULL,
  `user_id` int(11) NOT NULL,
  `role_hint` varchar(20) DEFAULT NULL,
  `can_post` tinyint(4) NOT NULL DEFAULT 1,
  `last_read_message_id` bigint(20) DEFAULT NULL,
  `joined_at` datetime NOT NULL,
  `muted` tinyint(4) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `chat_participants`
--

INSERT INTO `chat_participants` (`conversation_id`, `user_id`, `role_hint`, `can_post`, `last_read_message_id`, `joined_at`, `muted`) VALUES
(1, 1, NULL, 1, 3, '2026-02-24 14:19:35', 0),
(1, 5, NULL, 1, 3, '2026-02-24 14:19:35', 0),
(2, 1, NULL, 1, 4, '2026-02-25 22:30:09', 0),
(2, 8, NULL, 1, 4, '2026-02-25 22:30:09', 0);

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

--
-- بنية الجدول `cost_centers`
--

CREATE TABLE `cost_centers` (
  `id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `code` varchar(20) NOT NULL,
  `name` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `cost_centers`
--

INSERT INTO `cost_centers` (`id`, `branch_id`, `code`, `name`) VALUES
(1, 1, 'CAI-OPS', 'عمليات القاهرة'),
(2, 1, 'CAI-ADM', 'إدارة القاهرة'),
(3, 2, 'ALX-OPS', 'عمليات الإسكندرية'),
(4, 2, 'ALX-ADM', 'إدارة الإسكندرية');

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

--
-- بنية الجدول `departments`
--

CREATE TABLE `departments` (
  `id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `departments`
--

INSERT INTO `departments` (`id`, `branch_id`, `name`) VALUES
(3, 1, 'الحسابات'),
(1, 1, 'العمليات'),
(2, 1, 'الموارد البشرية'),
(6, 2, 'الحسابات'),
(4, 2, 'العمليات'),
(5, 2, 'الموارد البشرية');

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

--
-- بنية الجدول `doc_sequences`
--

CREATE TABLE `doc_sequences` (
  `id` int(11) NOT NULL,
  `domain` varchar(50) NOT NULL,
  `branch_id` int(11) NOT NULL DEFAULT 0,
  `period_yyyymm` varchar(6) NOT NULL DEFAULT '',
  `prefix` varchar(50) NOT NULL DEFAULT '',
  `padding` int(11) NOT NULL DEFAULT 6,
  `next_number` int(11) NOT NULL DEFAULT 1,
  `is_active` tinyint(4) NOT NULL DEFAULT 1,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `doc_sequences`
--

INSERT INTO `doc_sequences` (`id`, `domain`, `branch_id`, `period_yyyymm`, `prefix`, `padding`, `next_number`, `is_active`, `updated_at`) VALUES
(1, 'leave_request', 0, '', 'LR-', 6, 1, 1, '2026-02-24 14:06:32'),
(2, 'loan', 0, '', 'LN-', 6, 1, 1, '2026-02-24 14:06:32'),
(3, 'settlement', 0, '', 'SET-', 6, 1, 1, '2026-02-24 14:06:32'),
(4, 'case', 0, '', 'CS-', 6, 1, 1, '2026-02-24 14:06:32'),
(5, 'journal', 0, '', 'JV-', 6, 1, 1, '2026-02-24 14:06:32'),
(6, 'payroll_run', 0, '', 'PR-', 6, 1, 1, '2026-02-24 14:06:32'),
(7, 'asset', 0, '', 'AST-', 6, 1, 1, '2026-02-24 14:06:32');

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

--
-- بنية الجدول `employees`
--

CREATE TABLE `employees` (
  `id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `department_id` int(11) DEFAULT NULL,
  `grade_id` int(11) DEFAULT NULL,
  `manager_id` int(11) DEFAULT NULL,
  `employee_no` varchar(30) NOT NULL,
  `first_name` varchar(100) NOT NULL,
  `last_name` varchar(100) NOT NULL,
  `email` varchar(150) DEFAULT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `hire_date` date DEFAULT NULL,
  `status` varchar(20) NOT NULL DEFAULT 'active',
  `base_salary` decimal(12,2) NOT NULL DEFAULT 0.00,
  `allowance` decimal(12,2) NOT NULL DEFAULT 0.00,
  `bank_account` varchar(100) DEFAULT NULL,
  `national_id` varchar(50) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `employees`
--

INSERT INTO `employees` (`id`, `branch_id`, `department_id`, `grade_id`, `manager_id`, `employee_no`, `first_name`, `last_name`, `email`, `phone`, `hire_date`, `status`, `base_salary`, `allowance`, `bank_account`, `national_id`, `created_at`) VALUES
(1, 1, 1, 1, NULL, 'CAI-0001', 'أحمد', 'مدير', 'ahmed.manager@example.com', '01000000001', '2023-01-01', 'active', 15000.00, 2000.00, '', '', '2026-02-24 13:19:46'),
(2, 1, 1, 3, 1, 'CAI-0002', 'منى', 'موظف', 'mona.employee@example.com', '01000000002', '2023-02-01', 'active', 8000.00, 1000.00, '', '', '2026-02-24 13:19:46'),
(3, 2, 4, 4, NULL, 'ALX-0001', 'عمر', 'مدير', 'omar.manager@example.com', '01000000003', '2023-01-15', 'active', 14000.00, 1500.00, '', '', '2026-02-24 13:19:46'),
(4, 2, 4, 6, 3, 'ALX-0002', 'سارة', 'موظف', 'sara.employee@example.com', '01000000004', '2023-03-01', 'active', 7500.00, 900.00, '', '', '2026-02-24 13:19:46'),
(5, 1, 2, 2, NULL, 'CAI-0003', 'حنان', 'موارد بشرية', 'hanan.hr@example.com', '01000000005', '2022-10-01', 'active', 12000.00, 1500.00, '', '', '2026-02-24 13:19:46'),
(6, 1, 3, 2, NULL, 'CAI-0004', 'فادي', 'حسابات', 'fady.finance@example.com', '01000000006', '2022-11-01', 'active', 13000.00, 1500.00, '', '', '2026-02-24 13:19:46');

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

--
-- بنية الجدول `employee_shift_assignments`
--

CREATE TABLE `employee_shift_assignments` (
  `id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `shift_id` int(11) NOT NULL,
  `valid_from` date NOT NULL,
  `valid_to` date DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `employee_shift_assignments`
--

INSERT INTO `employee_shift_assignments` (`id`, `employee_id`, `shift_id`, `valid_from`, `valid_to`, `created_at`) VALUES
(1, 1, 1, '2023-01-01', NULL, '2026-02-24 13:19:46'),
(2, 2, 1, '2023-02-01', NULL, '2026-02-24 13:19:46'),
(3, 5, 1, '2022-10-01', NULL, '2026-02-24 13:19:46'),
(4, 6, 1, '2022-11-01', NULL, '2026-02-24 13:19:46'),
(5, 3, 2, '2023-01-15', NULL, '2026-02-24 13:19:46'),
(6, 4, 2, '2023-03-01', NULL, '2026-02-24 13:19:46');

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

--
-- بنية الجدول `employee_shift_roster`
--

CREATE TABLE `employee_shift_roster` (
  `id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `shift_id` int(11) NOT NULL,
  `work_date` date NOT NULL,
  `created_by_user_id` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `fiscal_periods`
--

CREATE TABLE `fiscal_periods` (
  `id` int(11) NOT NULL,
  `fiscal_year_id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `period_yyyymm` varchar(6) NOT NULL,
  `period_no` int(11) NOT NULL,
  `starts_on` date NOT NULL,
  `ends_on` date NOT NULL,
  `status` varchar(20) NOT NULL DEFAULT 'open',
  `closed_at` datetime DEFAULT NULL,
  `closed_by_user_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `fiscal_periods`
--

INSERT INTO `fiscal_periods` (`id`, `fiscal_year_id`, `branch_id`, `period_yyyymm`, `period_no`, `starts_on`, `ends_on`, `status`, `closed_at`, `closed_by_user_id`) VALUES
(1, 1, 1, '202601', 1, '2026-01-01', '2026-01-31', 'open', NULL, NULL),
(2, 1, 1, '202602', 2, '2026-02-01', '2026-02-28', 'open', NULL, NULL),
(3, 1, 1, '202603', 3, '2026-03-01', '2026-03-31', 'open', NULL, NULL),
(4, 1, 1, '202604', 4, '2026-04-01', '2026-04-30', 'open', NULL, NULL),
(5, 1, 1, '202605', 5, '2026-05-01', '2026-05-31', 'open', NULL, NULL),
(6, 1, 1, '202606', 6, '2026-06-01', '2026-06-30', 'open', NULL, NULL),
(7, 1, 1, '202607', 7, '2026-07-01', '2026-07-31', 'open', NULL, NULL),
(8, 1, 1, '202608', 8, '2026-08-01', '2026-08-31', 'open', NULL, NULL),
(9, 1, 1, '202609', 9, '2026-09-01', '2026-09-30', 'open', NULL, NULL),
(10, 1, 1, '202610', 10, '2026-10-01', '2026-10-31', 'open', NULL, NULL),
(11, 1, 1, '202611', 11, '2026-11-01', '2026-11-30', 'open', NULL, NULL),
(12, 1, 1, '202612', 12, '2026-12-01', '2026-12-31', 'open', NULL, NULL),
(13, 2, 2, '202601', 1, '2026-01-01', '2026-01-31', 'open', NULL, NULL),
(14, 2, 2, '202602', 2, '2026-02-01', '2026-02-28', 'open', NULL, NULL),
(15, 2, 2, '202603', 3, '2026-03-01', '2026-03-31', 'open', NULL, NULL),
(16, 2, 2, '202604', 4, '2026-04-01', '2026-04-30', 'open', NULL, NULL),
(17, 2, 2, '202605', 5, '2026-05-01', '2026-05-31', 'open', NULL, NULL),
(18, 2, 2, '202606', 6, '2026-06-01', '2026-06-30', 'open', NULL, NULL),
(19, 2, 2, '202607', 7, '2026-07-01', '2026-07-31', 'open', NULL, NULL),
(20, 2, 2, '202608', 8, '2026-08-01', '2026-08-31', 'open', NULL, NULL),
(21, 2, 2, '202609', 9, '2026-09-01', '2026-09-30', 'open', NULL, NULL),
(22, 2, 2, '202610', 10, '2026-10-01', '2026-10-31', 'open', NULL, NULL),
(23, 2, 2, '202611', 11, '2026-11-01', '2026-11-30', 'open', NULL, NULL),
(24, 2, 2, '202612', 12, '2026-12-01', '2026-12-31', 'open', NULL, NULL);

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

--
-- بنية الجدول `fiscal_years`
--

CREATE TABLE `fiscal_years` (
  `id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `year_label` varchar(20) NOT NULL,
  `starts_on` date NOT NULL,
  `ends_on` date NOT NULL,
  `status` varchar(20) NOT NULL DEFAULT 'open',
  `is_current` tinyint(4) NOT NULL DEFAULT 0,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `fiscal_years`
--

INSERT INTO `fiscal_years` (`id`, `branch_id`, `year_label`, `starts_on`, `ends_on`, `status`, `is_current`, `created_at`) VALUES
(1, 1, '2026', '2026-01-01', '2026-12-31', 'open', 1, '2026-02-24 14:06:32'),
(2, 2, '2026', '2026-01-01', '2026-12-31', 'open', 1, '2026-02-24 14:06:32');

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

--
-- بنية الجدول `grades`
--

CREATE TABLE `grades` (
  `id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `code` varchar(20) NOT NULL,
  `name` varchar(100) NOT NULL,
  `is_active` tinyint(4) NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `grades`
--

INSERT INTO `grades` (`id`, `branch_id`, `code`, `name`, `is_active`) VALUES
(1, 1, 'A', 'درجة A (قيادي/مدير)', 1),
(2, 1, 'B', 'درجة B (إشرافي)', 1),
(3, 1, 'C', 'درجة C (تشغيلي)', 1),
(4, 2, 'A', 'درجة A (قيادي/مدير)', 1),
(5, 2, 'B', 'درجة B (إشرافي)', 1),
(6, 2, 'C', 'درجة C (تشغيلي)', 1);

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

--
-- بنية الجدول `job_queue`
--

CREATE TABLE `job_queue` (
  `id` bigint(20) NOT NULL,
  `queue_name` varchar(40) NOT NULL DEFAULT 'default',
  `job_type` varchar(80) NOT NULL,
  `payload_json` mediumtext DEFAULT NULL,
  `status` varchar(20) NOT NULL DEFAULT 'queued',
  `priority` smallint(6) NOT NULL DEFAULT 100,
  `run_after` datetime NOT NULL,
  `attempts` int(11) NOT NULL DEFAULT 0,
  `max_attempts` int(11) NOT NULL DEFAULT 3,
  `locked_by` varchar(80) DEFAULT NULL,
  `locked_at` datetime DEFAULT NULL,
  `created_by_user_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `finished_at` datetime DEFAULT NULL,
  `last_error` text DEFAULT NULL,
  `result_json` mediumtext DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `job_queue`
--

INSERT INTO `job_queue` (`id`, `queue_name`, `job_type`, `payload_json`, `status`, `priority`, `run_after`, `attempts`, `max_attempts`, `locked_by`, `locked_at`, `created_by_user_id`, `created_at`, `updated_at`, `finished_at`, `last_error`, `result_json`) VALUES
(1, 'default', 'attendance_sync_plan', '{\"source\":\"ops_center\"}', 'done', 100, '2026-02-26 01:16:28', 1, 3, NULL, NULL, 1, '2026-02-26 01:16:12', '2026-02-26 01:16:29', '2026-02-26 01:16:29', NULL, '{\"ok\":true,\"devices\":0,\"planned\":0}'),
(2, 'default', 'attendance_sync_plan', '{\"source\":\"ops_center\"}', 'done', 100, '2026-02-26 11:28:04', 1, 3, NULL, NULL, 1, '2026-02-26 11:28:04', '2026-02-26 12:19:12', '2026-02-26 12:19:12', NULL, '{\"ok\":true,\"devices\":0,\"planned\":0}'),
(3, 'default', 'approval_sla_scan', '{\"source\":\"ops_center\"}', 'queued', 100, '2026-02-26 12:39:11', 0, 3, NULL, NULL, 1, '2026-02-26 12:39:11', '2026-02-26 12:39:11', NULL, NULL, NULL),
(4, 'default', 'approval_sla_scan', '{\"source\":\"ops_center\"}', 'queued', 100, '2026-02-26 15:25:26', 0, 3, NULL, NULL, 1, '2026-02-26 15:25:26', '2026-02-26 15:25:26', NULL, NULL, NULL);

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

--
-- بنية الجدول `job_worker_heartbeats`
--

CREATE TABLE `job_worker_heartbeats` (
  `worker_key` varchar(80) NOT NULL,
  `last_seen_at` datetime NOT NULL,
  `last_result` varchar(20) DEFAULT NULL,
  `last_message` varchar(255) DEFAULT NULL,
  `updated_jobs` int(11) NOT NULL DEFAULT 0,
  `host_name` varchar(120) DEFAULT NULL,
  `pid` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `job_worker_heartbeats`
--

INSERT INTO `job_worker_heartbeats` (`worker_key`, `last_seen_at`, `last_result`, `last_message`, `updated_jobs`, `host_name`, `pid`) VALUES
('ops-web-1', '2026-02-26 12:19:12', 'ok', 'p=1,d=1,f=0,r=0', 1, 'DESKTOP-E3ADH4N', 7940);

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

--
-- بنية الجدول `journals`
--

CREATE TABLE `journals` (
  `id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `journal_date` date NOT NULL,
  `ref` varchar(50) DEFAULT NULL,
  `memo` varchar(255) DEFAULT NULL,
  `source_module` varchar(50) DEFAULT NULL,
  `source_id` int(11) DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `posted` tinyint(4) NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `journal_lines`
--

CREATE TABLE `journal_lines` (
  `id` int(11) NOT NULL,
  `journal_id` int(11) NOT NULL,
  `account_id` int(11) NOT NULL,
  `debit` decimal(14,2) NOT NULL DEFAULT 0.00,
  `credit` decimal(14,2) NOT NULL DEFAULT 0.00,
  `memo` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `leave_balances`
--

CREATE TABLE `leave_balances` (
  `employee_id` int(11) NOT NULL,
  `leave_type_id` int(11) NOT NULL,
  `year` int(11) NOT NULL,
  `opening_days` decimal(6,2) NOT NULL DEFAULT 0.00,
  `carryover_days` decimal(6,2) NOT NULL DEFAULT 0.00,
  `used_days` decimal(6,2) NOT NULL DEFAULT 0.00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `leave_balances`
--

INSERT INTO `leave_balances` (`employee_id`, `leave_type_id`, `year`, `opening_days`, `carryover_days`, `used_days`) VALUES
(1, 1, 2026, 21.00, 0.00, 0.00),
(1, 2, 2026, 10.00, 0.00, 0.00),
(2, 1, 2026, 21.00, 0.00, 0.00),
(2, 2, 2026, 10.00, 0.00, 0.00),
(3, 1, 2026, 21.00, 0.00, 0.00),
(3, 2, 2026, 10.00, 0.00, 0.00),
(4, 1, 2026, 21.00, 0.00, 0.00),
(4, 2, 2026, 10.00, 0.00, 0.00),
(5, 1, 2026, 21.00, 0.00, 0.00),
(5, 2, 2026, 10.00, 0.00, 0.00),
(6, 1, 2026, 21.00, 0.00, 0.00),
(6, 2, 2026, 10.00, 0.00, 0.00);

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

--
-- بنية الجدول `leave_requests`
--

CREATE TABLE `leave_requests` (
  `id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `leave_type_id` int(11) NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `days` decimal(6,2) NOT NULL DEFAULT 0.00,
  `reason` varchar(255) DEFAULT NULL,
  `status` varchar(20) NOT NULL DEFAULT 'pending',
  `requested_at` datetime NOT NULL,
  `approved_by_user_id` int(11) DEFAULT NULL,
  `approved_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `leave_types`
--

CREATE TABLE `leave_types` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `is_paid` tinyint(4) NOT NULL DEFAULT 1,
  `annual_limit_days` decimal(6,2) NOT NULL DEFAULT 0.00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `leave_types`
--

INSERT INTO `leave_types` (`id`, `name`, `is_paid`, `annual_limit_days`) VALUES
(1, 'إجازة سنوية', 1, 21.00),
(2, 'إجازة مرضية', 1, 10.00),
(3, 'إجازة بدون أجر', 0, 0.00);

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

--
-- بنية الجدول `loans`
--

CREATE TABLE `loans` (
  `id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `amount` decimal(14,2) NOT NULL,
  `months` int(11) NOT NULL,
  `monthly_deduction` decimal(14,2) NOT NULL,
  `reason` varchar(255) DEFAULT NULL,
  `status` varchar(30) NOT NULL DEFAULT 'pending_manager',
  `requested_at` datetime NOT NULL,
  `manager_approved_by` int(11) DEFAULT NULL,
  `manager_approved_at` datetime DEFAULT NULL,
  `hr_approved_by` int(11) DEFAULT NULL,
  `hr_approved_at` datetime DEFAULT NULL,
  `disbursed_by` int(11) DEFAULT NULL,
  `disbursed_at` datetime DEFAULT NULL,
  `gl_journal_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `loans`
--

INSERT INTO `loans` (`id`, `employee_id`, `branch_id`, `amount`, `months`, `monthly_deduction`, `reason`, `status`, `requested_at`, `manager_approved_by`, `manager_approved_at`, `hr_approved_by`, `hr_approved_at`, `disbursed_by`, `disbursed_at`, `gl_journal_id`) VALUES
(1, 2, 1, 1000.00, 2, 500.00, 'ظرف', 'pending_manager', '2026-02-26 01:04:41', NULL, NULL, NULL, NULL, NULL, NULL, NULL);

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

--
-- بنية الجدول `loan_installments`
--

CREATE TABLE `loan_installments` (
  `id` int(11) NOT NULL,
  `loan_id` int(11) NOT NULL,
  `period_yyyymm` varchar(6) NOT NULL,
  `amount` decimal(14,2) NOT NULL,
  `status` varchar(20) NOT NULL DEFAULT 'due',
  `deducted_in_run_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `notifications`
--

CREATE TABLE `notifications` (
  `id` bigint(20) NOT NULL,
  `recipient_user_id` int(11) NOT NULL,
  `sender_user_id` int(11) DEFAULT NULL,
  `branch_id` int(11) DEFAULT NULL,
  `category` varchar(30) NOT NULL DEFAULT 'general',
  `severity` varchar(20) NOT NULL DEFAULT 'info',
  `title` varchar(180) NOT NULL,
  `body` text DEFAULT NULL,
  `route_url` varchar(255) DEFAULT NULL,
  `source_module` varchar(50) DEFAULT NULL,
  `source_entity_type` varchar(50) DEFAULT NULL,
  `source_entity_id` int(11) DEFAULT NULL,
  `is_read` tinyint(4) NOT NULL DEFAULT 0,
  `read_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `notifications`
--

INSERT INTO `notifications` (`id`, `recipient_user_id`, `sender_user_id`, `branch_id`, `category`, `severity`, `title`, `body`, `route_url`, `source_module`, `source_entity_type`, `source_entity_id`, `is_read`, `read_at`, `created_at`) VALUES
(1, 1, 1, NULL, 'general', 'info', 'ي', 'ي', NULL, 'notifications', 'manual', NULL, 1, '2026-02-24 14:13:41', '2026-02-24 14:13:11'),
(2, 2, 1, NULL, 'general', 'info', 'ي', 'ي', NULL, 'notifications', 'manual', NULL, 0, NULL, '2026-02-24 14:13:11'),
(3, 3, 1, NULL, 'general', 'info', 'ي', 'ي', NULL, 'notifications', 'manual', NULL, 0, NULL, '2026-02-24 14:13:11'),
(4, 4, 1, NULL, 'general', 'info', 'ي', 'ي', NULL, 'notifications', 'manual', NULL, 0, NULL, '2026-02-24 14:13:11'),
(5, 5, 1, NULL, 'general', 'info', 'ي', 'ي', NULL, 'notifications', 'manual', NULL, 1, '2026-02-24 14:13:21', '2026-02-24 14:13:11'),
(6, 6, 1, NULL, 'general', 'info', 'ي', 'ي', NULL, 'notifications', 'manual', NULL, 0, NULL, '2026-02-24 14:13:11'),
(7, 7, 1, NULL, 'general', 'info', 'ي', 'ي', NULL, 'notifications', 'manual', NULL, 0, NULL, '2026-02-24 14:13:11'),
(8, 5, 1, 2, 'chat', 'info', 'رسالة جديدة: ي', 'هاي', 'index.php?route=chat&conversation_id=1', 'chat', 'conversation', 1, 1, '2026-02-26 00:22:23', '2026-02-24 14:19:35'),
(9, 5, 1, 2, 'chat', 'info', 'رسالة جديدة: ي', 'تم إرسال مرفق جديد.', 'index.php?route=chat&conversation_id=1', 'chat', 'conversation', 1, 1, '2026-02-24 14:20:04', '2026-02-24 14:19:43'),
(10, 5, 1, 2, 'chat', 'info', 'رسالة جديدة: ي', 'تم إرسال مرفق جديد.', 'index.php?route=chat&conversation_id=1', 'chat', 'conversation', 1, 1, '2026-02-26 00:22:23', '2026-02-25 22:07:16'),
(11, 1, 1, 1, 'reception', 'warning', 'طلب زيارة جديد (بلاغ مسبق)', 'المضيف: admin\nالزائر: ali\nالغرض: مقابلة\nالفرع: CAI - القاهرة\nموعد متوقع: 2026-02-25 22:26', 'index.php?route=reception', 'reception', 'visit', 1, 1, '2026-02-25 22:33:05', '2026-02-25 22:26:35'),
(12, 2, 1, 1, 'reception', 'warning', 'طلب زيارة جديد (بلاغ مسبق)', 'المضيف: admin\nالزائر: ali\nالغرض: مقابلة\nالفرع: CAI - القاهرة\nموعد متوقع: 2026-02-25 22:26', 'index.php?route=reception', 'reception', 'visit', 1, 0, NULL, '2026-02-25 22:26:35'),
(13, 1, 8, 1, 'reception', 'info', 'الزائر وصل إلى الاستقبال', 'الزائر: ali\nالغرض: مقابلة', 'index.php?route=reception', 'reception', 'visit', 1, 1, '2026-02-25 22:33:05', '2026-02-25 22:28:30'),
(14, 1, 8, 1, 'reception', 'info', 'تم خروج الزائر من الشركة', 'الزائر: ali\nوقت الخروج: 2026-02-25 22:29', 'index.php?route=reception', 'reception', 'visit', 1, 1, '2026-02-25 22:30:46', '2026-02-25 22:29:15'),
(15, 1, 8, NULL, 'chat', 'info', 'رسالة جديدة: محادثة داخلية', 'f', 'index.php?route=chat&conversation_id=2', 'chat', 'conversation', 2, 1, '2026-02-25 22:30:34', '2026-02-25 22:30:14');

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

--
-- بنية الجدول `payroll_items`
--

CREATE TABLE `payroll_items` (
  `id` int(11) NOT NULL,
  `payroll_run_id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `item_type` varchar(20) NOT NULL,
  `code` varchar(20) NOT NULL,
  `description` varchar(150) NOT NULL,
  `amount` decimal(14,2) NOT NULL DEFAULT 0.00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `payroll_items`
--

INSERT INTO `payroll_items` (`id`, `payroll_run_id`, `employee_id`, `item_type`, `code`, `description`, `amount`) VALUES
(1, 1, 3, 'earning', 'BASIC', 'الراتب الأساسي', 14000.00),
(2, 1, 3, 'earning', 'ALLOW', 'بدلات', 1500.00),
(3, 1, 3, 'deduction', 'ABS', 'خصم غياب', 10730.77),
(4, 1, 4, 'earning', 'BASIC', 'الراتب الأساسي', 7500.00),
(5, 1, 4, 'earning', 'ALLOW', 'بدلات', 900.00),
(6, 1, 4, 'deduction', 'EARLY', 'خصم انصراف مبكر', 6.73),
(7, 1, 4, 'deduction', 'ABS', 'خصم غياب', 5815.38),
(8, 2, 1, 'earning', 'BASIC', 'الراتب الأساسي', 15000.00),
(9, 2, 1, 'earning', 'ALLOW', 'بدلات', 2000.00),
(10, 2, 1, 'earning', 'OT', 'ساعات إضافية', 122.60),
(11, 2, 1, 'deduction', 'ABS', 'خصم غياب', 10461.54),
(12, 2, 2, 'earning', 'BASIC', 'الراتب الأساسي', 8000.00),
(13, 2, 2, 'earning', 'ALLOW', 'بدلات', 1000.00),
(14, 2, 2, 'deduction', 'LATE', 'خصم تأخير', 43.27),
(15, 2, 2, 'deduction', 'ABS', 'خصم غياب', 5538.46),
(16, 2, 5, 'earning', 'BASIC', 'الراتب الأساسي', 12000.00),
(17, 2, 5, 'earning', 'ALLOW', 'بدلات', 1500.00),
(18, 2, 5, 'deduction', 'ABS', 'خصم غياب', 8307.69),
(19, 2, 6, 'earning', 'BASIC', 'الراتب الأساسي', 13000.00),
(20, 2, 6, 'earning', 'ALLOW', 'بدلات', 1500.00),
(21, 2, 6, 'earning', 'OT', 'ساعات إضافية', 104.57),
(22, 2, 6, 'deduction', 'ABS', 'خصم غياب', 8923.08);

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

--
-- بنية الجدول `payroll_runs`
--

CREATE TABLE `payroll_runs` (
  `id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `period_yyyymm` varchar(6) NOT NULL,
  `status` varchar(20) NOT NULL DEFAULT 'draft',
  `created_at` datetime NOT NULL,
  `created_by` int(11) DEFAULT NULL,
  `posted_journal_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `payroll_runs`
--

INSERT INTO `payroll_runs` (`id`, `branch_id`, `period_yyyymm`, `status`, `created_at`, `created_by`, `posted_journal_id`) VALUES
(1, 2, '202602', 'generated', '2026-02-24 13:21:52', 1, NULL),
(2, 1, '202602', 'generated', '2026-02-24 14:12:35', 1, NULL);

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

--
-- بنية الجدول `payslips`
--

CREATE TABLE `payslips` (
  `id` int(11) NOT NULL,
  `payroll_run_id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `gross` decimal(14,2) NOT NULL DEFAULT 0.00,
  `deductions` decimal(14,2) NOT NULL DEFAULT 0.00,
  `net` decimal(14,2) NOT NULL DEFAULT 0.00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `payslips`
--

INSERT INTO `payslips` (`id`, `payroll_run_id`, `employee_id`, `gross`, `deductions`, `net`) VALUES
(1, 1, 3, 15500.00, 10730.77, 4769.23),
(2, 1, 4, 8400.00, 5822.11, 2577.89),
(3, 2, 1, 17122.60, 10461.54, 6661.06),
(4, 2, 2, 9000.00, 5581.73, 3418.27),
(5, 2, 5, 13500.00, 8307.69, 5192.31),
(6, 2, 6, 14604.57, 8923.08, 5681.49);

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

--
-- بنية الجدول `reception_visits`
--

CREATE TABLE `reception_visits` (
  `id` bigint(20) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `source_type` varchar(20) NOT NULL DEFAULT 'walk_in',
  `status` varchar(20) NOT NULL DEFAULT 'expected',
  `approval_status` varchar(20) NOT NULL DEFAULT 'not_required',
  `visitor_name` varchar(180) NOT NULL,
  `visitor_phone` varchar(50) DEFAULT NULL,
  `visitor_email` varchar(190) DEFAULT NULL,
  `visitor_company` varchar(180) DEFAULT NULL,
  `visitor_job_title` varchar(120) DEFAULT NULL,
  `id_type` varchar(30) DEFAULT NULL,
  `id_number` varchar(80) DEFAULT NULL,
  `nationality` varchar(80) DEFAULT NULL,
  `vehicle_plate` varchar(40) DEFAULT NULL,
  `persons_count` int(11) NOT NULL DEFAULT 1,
  `purpose` varchar(255) NOT NULL,
  `notes` text DEFAULT NULL,
  `host_user_id` int(11) DEFAULT NULL,
  `host_employee_id` int(11) DEFAULT NULL,
  `host_name_manual` varchar(180) DEFAULT NULL,
  `host_department` varchar(150) DEFAULT NULL,
  `expected_at` datetime DEFAULT NULL,
  `checked_in_at` datetime DEFAULT NULL,
  `checked_out_at` datetime DEFAULT NULL,
  `approved_by_user_id` int(11) DEFAULT NULL,
  `approved_at` datetime DEFAULT NULL,
  `approval_note` varchar(255) DEFAULT NULL,
  `badge_no` varchar(50) DEFAULT NULL,
  `pre_registered_by_user_id` int(11) DEFAULT NULL,
  `created_by_user_id` int(11) DEFAULT NULL,
  `updated_by_user_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `reception_visits`
--

INSERT INTO `reception_visits` (`id`, `branch_id`, `source_type`, `status`, `approval_status`, `visitor_name`, `visitor_phone`, `visitor_email`, `visitor_company`, `visitor_job_title`, `id_type`, `id_number`, `nationality`, `vehicle_plate`, `persons_count`, `purpose`, `notes`, `host_user_id`, `host_employee_id`, `host_name_manual`, `host_department`, `expected_at`, `checked_in_at`, `checked_out_at`, `approved_by_user_id`, `approved_at`, `approval_note`, `badge_no`, `pre_registered_by_user_id`, `created_by_user_id`, `updated_by_user_id`, `created_at`, `updated_at`) VALUES
(1, 1, 'pre_registered', 'checked_out', 'approved', 'ali', '01127999178', 'alimahmoudali1712@gmail.com', 'النصر', 'مدير عام', 'national_id', '2025854659562', 'مصري', '56', 1, 'مقابلة', 'مقابلة عمل استاذ حسام', 1, NULL, 'admin', NULL, '2026-02-25 22:26:00', '2026-02-25 22:28:30', '2026-02-25 22:29:15', NULL, NULL, NULL, NULL, 1, 1, 8, '2026-02-25 22:26:35', '2026-02-25 22:29:15');

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

--
-- بنية الجدول `scheduled_reports`
--

CREATE TABLE `scheduled_reports` (
  `id` bigint(20) NOT NULL,
  `name` varchar(150) NOT NULL,
  `report_key` varchar(60) NOT NULL,
  `branch_id` int(11) DEFAULT NULL,
  `frequency` varchar(20) NOT NULL DEFAULT 'daily',
  `run_time_hhmm` varchar(5) NOT NULL DEFAULT '09:00',
  `day_of_week` tinyint(4) DEFAULT NULL,
  `day_of_month` tinyint(4) DEFAULT NULL,
  `recipient_emails` text DEFAULT NULL,
  `recipient_roles` varchar(255) DEFAULT NULL,
  `recipient_user_ids` varchar(255) DEFAULT NULL,
  `email_subject` varchar(190) DEFAULT NULL,
  `filters_json` mediumtext DEFAULT NULL,
  `is_active` tinyint(4) NOT NULL DEFAULT 1,
  `next_run_at` datetime DEFAULT NULL,
  `last_run_at` datetime DEFAULT NULL,
  `last_status` varchar(20) DEFAULT NULL,
  `last_error` varchar(255) DEFAULT NULL,
  `created_by_user_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `scheduled_report_runs`
--

CREATE TABLE `scheduled_report_runs` (
  `id` bigint(20) NOT NULL,
  `report_id` bigint(20) NOT NULL,
  `job_id` bigint(20) DEFAULT NULL,
  `started_at` datetime NOT NULL,
  `finished_at` datetime DEFAULT NULL,
  `status` varchar(20) NOT NULL DEFAULT 'running',
  `recipient_count` int(11) NOT NULL DEFAULT 0,
  `rows_count` int(11) NOT NULL DEFAULT 0,
  `error_message` text DEFAULT NULL,
  `summary_json` mediumtext DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `settlements`
--

CREATE TABLE `settlements` (
  `id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `title` varchar(150) NOT NULL,
  `notes` varchar(255) DEFAULT NULL,
  `amount_total` decimal(14,2) NOT NULL DEFAULT 0.00,
  `status` varchar(20) NOT NULL DEFAULT 'pending',
  `requested_at` datetime NOT NULL,
  `approved_by` int(11) DEFAULT NULL,
  `approved_at` datetime DEFAULT NULL,
  `posted_journal_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `settlement_items`
--

CREATE TABLE `settlement_items` (
  `id` int(11) NOT NULL,
  `settlement_id` int(11) NOT NULL,
  `item_date` date NOT NULL,
  `description` varchar(255) NOT NULL,
  `amount` decimal(14,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `shifts`
--

CREATE TABLE `shifts` (
  `id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `start_time` time NOT NULL,
  `end_time` time NOT NULL,
  `break_minutes` int(11) NOT NULL DEFAULT 0,
  `grace_in_minutes` int(11) NOT NULL DEFAULT 0,
  `grace_out_minutes` int(11) NOT NULL DEFAULT 0,
  `is_default` tinyint(4) NOT NULL DEFAULT 0,
  `is_active` tinyint(4) NOT NULL DEFAULT 1,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `shifts`
--

INSERT INTO `shifts` (`id`, `branch_id`, `name`, `start_time`, `end_time`, `break_minutes`, `grace_in_minutes`, `grace_out_minutes`, `is_default`, `is_active`, `created_at`) VALUES
(1, 1, 'دوام صباحي (09:00-17:00)', '09:00:00', '17:00:00', 60, 15, 5, 1, 1, '2026-02-24 13:19:46'),
(2, 2, 'دوام صباحي (09:00-17:00)', '09:00:00', '17:00:00', 60, 15, 5, 1, 1, '2026-02-24 13:19:46');

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

--
-- بنية الجدول `system_health_checks`
--

CREATE TABLE `system_health_checks` (
  `id` bigint(20) NOT NULL,
  `check_key` varchar(60) NOT NULL,
  `status` varchar(20) NOT NULL,
  `message` varchar(255) DEFAULT NULL,
  `details_json` mediumtext DEFAULT NULL,
  `source` varchar(40) DEFAULT NULL,
  `checked_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `user_branch_access`
--

CREATE TABLE `user_branch_access` (
  `user_id` int(11) NOT NULL,
  `branch_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `user_branch_access`
--

INSERT INTO `user_branch_access` (`user_id`, `branch_id`) VALUES
(2, 1),
(2, 2),
(3, 1),
(3, 2),
(4, 1),
(5, 1),
(6, 2),
(7, 2),
(8, 1),
(8, 2);

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

--
-- بنية الجدول `user_route_permissions`
--

CREATE TABLE `user_route_permissions` (
  `user_id` int(11) NOT NULL,
  `route_key` varchar(50) NOT NULL,
  `can_view` tinyint(4) DEFAULT NULL,
  `show_in_sidebar` tinyint(4) DEFAULT NULL,
  `can_create` tinyint(4) DEFAULT NULL,
  `can_edit` tinyint(4) DEFAULT NULL,
  `can_delete` tinyint(4) DEFAULT NULL,
  `can_approve` tinyint(4) DEFAULT NULL,
  `is_disabled` tinyint(4) NOT NULL DEFAULT 0,
  `updated_by_user_id` int(11) DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `user_route_permissions`
--

INSERT INTO `user_route_permissions` (`user_id`, `route_key`, `can_view`, `show_in_sidebar`, `can_create`, `can_edit`, `can_delete`, `can_approve`, `is_disabled`, `updated_by_user_id`, `updated_at`) VALUES
(5, 'assets', 0, NULL, NULL, NULL, NULL, NULL, 0, 1, '2026-02-24 15:30:31');

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

--
-- بنية الجدول `workflow_actions`
--

CREATE TABLE `workflow_actions` (
  `id` int(11) NOT NULL,
  `workflow_instance_id` int(11) NOT NULL,
  `step_no` int(11) NOT NULL DEFAULT 1,
  `action` varchar(30) NOT NULL,
  `from_status` varchar(30) DEFAULT NULL,
  `to_status` varchar(30) DEFAULT NULL,
  `acted_by_user_id` int(11) DEFAULT NULL,
  `acted_at` datetime NOT NULL,
  `note` varchar(255) DEFAULT NULL,
  `context_json` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- بنية الجدول `workflow_instances`
--

CREATE TABLE `workflow_instances` (
  `id` int(11) NOT NULL,
  `module` varchar(50) NOT NULL,
  `entity_type` varchar(50) NOT NULL,
  `entity_id` int(11) NOT NULL,
  `branch_id` int(11) DEFAULT NULL,
  `workflow_key` varchar(50) NOT NULL DEFAULT 'default',
  `status` varchar(30) NOT NULL DEFAULT 'pending',
  `current_step_no` int(11) NOT NULL DEFAULT 1,
  `requested_by_user_id` int(11) DEFAULT NULL,
  `requested_at` datetime NOT NULL,
  `acted_by_user_id` int(11) DEFAULT NULL,
  `acted_at` datetime DEFAULT NULL,
  `note` varchar(255) DEFAULT NULL,
  `context_json` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `accounts`
--
ALTER TABLE `accounts`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`),
  ADD KEY `fk_acc_parent` (`parent_id`);

--
-- Indexes for table `approval_sla_events`
--
ALTER TABLE `approval_sla_events`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_ase_rule_entity` (`rule_id`,`module_key`,`entity_id`,`detected_at`),
  ADD KEY `idx_ase_detected` (`detected_at`),
  ADD KEY `idx_ase_status` (`status`,`detected_at`);

--
-- Indexes for table `approval_sla_rules`
--
ALTER TABLE `approval_sla_rules`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_asr_active` (`is_active`,`module_key`),
  ADD KEY `idx_asr_branch` (`branch_id`,`module_key`);

--
-- Indexes for table `approval_workflows`
--
ALTER TABLE `approval_workflows`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_awf_module` (`module_key`,`is_active`),
  ADD KEY `idx_awf_branch` (`branch_id`,`is_active`),
  ADD KEY `fk_awf_creator` (`created_by_user_id`);

--
-- Indexes for table `approval_workflow_employee_scopes`
--
ALTER TABLE `approval_workflow_employee_scopes`
  ADD PRIMARY KEY (`workflow_id`,`employee_id`),
  ADD KEY `idx_awfes_employee` (`employee_id`);

--
-- Indexes for table `approval_workflow_steps`
--
ALTER TABLE `approval_workflow_steps`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_awfs_step` (`workflow_id`,`step_no`),
  ADD KEY `idx_awfs_lookup` (`workflow_id`,`step_code`,`is_active`),
  ADD KEY `fk_awfs_user` (`approver_user_id`),
  ADD KEY `fk_awfs_emp` (`approver_employee_id`);

--
-- Indexes for table `app_settings`
--
ALTER TABLE `app_settings`
  ADD PRIMARY KEY (`setting_key`),
  ADD KEY `idx_app_settings_updated` (`updated_at`);

--
-- Indexes for table `assets`
--
ALTER TABLE `assets`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_asset` (`branch_id`,`asset_code`);

--
-- Indexes for table `asset_issues`
--
ALTER TABLE `asset_issues`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_ai_asset` (`asset_id`),
  ADD KEY `fk_ai_emp` (`employee_id`);

--
-- Indexes for table `attendance_corrections`
--
ALTER TABLE `attendance_corrections`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_corr_emp_date` (`employee_id`,`work_date`),
  ADD KEY `idx_corr_status` (`status`),
  ADD KEY `fk_corr_branch` (`branch_id`),
  ADD KEY `fk_corr_created` (`created_by_user_id`),
  ADD KEY `fk_corr_mgr` (`manager_by_user_id`),
  ADD KEY `fk_corr_hr` (`hr_by_user_id`);

--
-- Indexes for table `attendance_daily`
--
ALTER TABLE `attendance_daily`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_ad` (`employee_id`,`work_date`),
  ADD KEY `idx_ad_branch_date` (`branch_id`,`work_date`),
  ADD KEY `fk_ad_shift` (`shift_id`),
  ADD KEY `fk_ad_leave` (`leave_request_id`);

--
-- Indexes for table `attendance_deduction_policies`
--
ALTER TABLE `attendance_deduction_policies`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_adp_branch` (`branch_id`),
  ADD KEY `idx_adp_match` (`branch_id`,`grade_id`,`department_id`,`shift_id`,`is_active`),
  ADD KEY `fk_adp_grade` (`grade_id`),
  ADD KEY `fk_adp_dept` (`department_id`),
  ADD KEY `fk_adp_shift` (`shift_id`);

--
-- Indexes for table `attendance_device_field_maps`
--
ALTER TABLE `attendance_device_field_maps`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_adfm` (`device_id`,`source_field`),
  ADD KEY `idx_adfm_device` (`device_id`,`is_active`);

--
-- Indexes for table `attendance_device_sync_runs`
--
ALTER TABLE `attendance_device_sync_runs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_adsr_device` (`device_id`,`id`),
  ADD KEY `idx_adsr_status` (`status`,`started_at`),
  ADD KEY `fk_adsr_user` (`created_by_user_id`);

--
-- Indexes for table `attendance_import_jobs`
--
ALTER TABLE `attendance_import_jobs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_aij_branch` (`branch_id`),
  ADD KEY `fk_aij_user` (`imported_by_user_id`);

--
-- Indexes for table `attendance_payroll_rules`
--
ALTER TABLE `attendance_payroll_rules`
  ADD PRIMARY KEY (`branch_id`);

--
-- Indexes for table `attendance_punches`
--
ALTER TABLE `attendance_punches`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_punch` (`employee_id`,`punch_type`,`punched_at`),
  ADD KEY `idx_ap_emp_dt` (`employee_id`,`punched_at`),
  ADD KEY `idx_ap_branch_dt` (`branch_id`,`punched_at`),
  ADD KEY `fk_ap_user` (`created_by_user_id`);

--
-- Indexes for table `audit_logs`
--
ALTER TABLE `audit_logs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_audit_entity` (`entity_type`,`entity_id`,`created_at`),
  ADD KEY `idx_audit_module` (`module`,`created_at`),
  ADD KEY `idx_audit_user` (`user_id`,`created_at`),
  ADD KEY `idx_audit_branch` (`branch_id`,`created_at`);

--
-- Indexes for table `backup_runs`
--
ALTER TABLE `backup_runs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_br_status` (`status`,`started_at`),
  ADD KEY `idx_br_started` (`started_at`);

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

--
-- Indexes for table `branch_calendar`
--
ALTER TABLE `branch_calendar`
  ADD PRIMARY KEY (`branch_id`);

--
-- Indexes for table `branch_holidays`
--
ALTER TABLE `branch_holidays`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_bh` (`branch_id`,`holiday_date`),
  ADD KEY `idx_bh_date` (`holiday_date`);

--
-- Indexes for table `cases`
--
ALTER TABLE `cases`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_c_branch` (`branch_id`),
  ADD KEY `fk_c_emp` (`employee_id`),
  ADD KEY `fk_c_assignee` (`assigned_to_user_id`);

--
-- Indexes for table `chat_conversations`
--
ALTER TABLE `chat_conversations`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_chat_conv_branch` (`branch_id`,`updated_at`),
  ADD KEY `idx_chat_conv_status` (`status`,`updated_at`),
  ADD KEY `fk_chat_conv_creator` (`created_by_user_id`);

--
-- Indexes for table `chat_messages`
--
ALTER TABLE `chat_messages`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_chat_msg_conv` (`conversation_id`,`id`),
  ADD KEY `idx_chat_msg_sender` (`sender_user_id`,`created_at`);

--
-- Indexes for table `chat_message_attachments`
--
ALTER TABLE `chat_message_attachments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_chat_att_msg` (`message_id`,`id`);

--
-- Indexes for table `chat_participants`
--
ALTER TABLE `chat_participants`
  ADD PRIMARY KEY (`conversation_id`,`user_id`),
  ADD KEY `idx_chat_part_user` (`user_id`,`conversation_id`);

--
-- Indexes for table `cost_centers`
--
ALTER TABLE `cost_centers`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_cc` (`branch_id`,`code`);

--
-- Indexes for table `departments`
--
ALTER TABLE `departments`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_dept` (`branch_id`,`name`);

--
-- Indexes for table `doc_sequences`
--
ALTER TABLE `doc_sequences`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_doc_seq` (`domain`,`branch_id`,`period_yyyymm`),
  ADD KEY `idx_doc_seq_active` (`is_active`,`domain`);

--
-- Indexes for table `employees`
--
ALTER TABLE `employees`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `employee_no` (`employee_no`),
  ADD KEY `fk_emp_branch` (`branch_id`),
  ADD KEY `fk_emp_dept` (`department_id`),
  ADD KEY `fk_emp_grade` (`grade_id`),
  ADD KEY `fk_emp_manager` (`manager_id`);

--
-- Indexes for table `employee_shift_assignments`
--
ALTER TABLE `employee_shift_assignments`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_esa` (`employee_id`,`shift_id`,`valid_from`),
  ADD KEY `idx_esa_emp` (`employee_id`,`valid_from`,`valid_to`),
  ADD KEY `fk_esa_shift` (`shift_id`);

--
-- Indexes for table `employee_shift_roster`
--
ALTER TABLE `employee_shift_roster`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_roster` (`employee_id`,`work_date`),
  ADD KEY `idx_roster_date` (`work_date`),
  ADD KEY `fk_esr_shift` (`shift_id`);

--
-- Indexes for table `fiscal_periods`
--
ALTER TABLE `fiscal_periods`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_fp_branch_period` (`branch_id`,`period_yyyymm`),
  ADD UNIQUE KEY `uniq_fp_year_no` (`fiscal_year_id`,`period_no`),
  ADD KEY `idx_fp_branch_status` (`branch_id`,`status`);

--
-- Indexes for table `fiscal_years`
--
ALTER TABLE `fiscal_years`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_fy_branch_label` (`branch_id`,`year_label`),
  ADD KEY `idx_fy_branch_status` (`branch_id`,`status`);

--
-- Indexes for table `grades`
--
ALTER TABLE `grades`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_grade` (`branch_id`,`code`);

--
-- Indexes for table `job_queue`
--
ALTER TABLE `job_queue`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_jq_status_run` (`status`,`run_after`,`priority`,`id`),
  ADD KEY `idx_jq_queue` (`queue_name`,`status`,`run_after`),
  ADD KEY `idx_jq_lock` (`locked_at`);

--
-- Indexes for table `job_worker_heartbeats`
--
ALTER TABLE `job_worker_heartbeats`
  ADD PRIMARY KEY (`worker_key`);

--
-- Indexes for table `journals`
--
ALTER TABLE `journals`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_j_branch` (`branch_id`),
  ADD KEY `fk_j_user` (`created_by`);

--
-- Indexes for table `journal_lines`
--
ALTER TABLE `journal_lines`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_jl_j` (`journal_id`),
  ADD KEY `fk_jl_a` (`account_id`);

--
-- Indexes for table `leave_balances`
--
ALTER TABLE `leave_balances`
  ADD PRIMARY KEY (`employee_id`,`leave_type_id`,`year`),
  ADD KEY `fk_lb_lt` (`leave_type_id`);

--
-- Indexes for table `leave_requests`
--
ALTER TABLE `leave_requests`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_lr_emp` (`employee_id`),
  ADD KEY `fk_lr_branch` (`branch_id`),
  ADD KEY `fk_lr_lt` (`leave_type_id`),
  ADD KEY `fk_lr_appr` (`approved_by_user_id`);

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

--
-- Indexes for table `loans`
--
ALTER TABLE `loans`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_l_emp` (`employee_id`),
  ADD KEY `fk_l_branch` (`branch_id`),
  ADD KEY `fk_l_mgr` (`manager_approved_by`),
  ADD KEY `fk_l_hr` (`hr_approved_by`),
  ADD KEY `fk_l_fin` (`disbursed_by`),
  ADD KEY `fk_l_journal` (`gl_journal_id`);

--
-- Indexes for table `loan_installments`
--
ALTER TABLE `loan_installments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_li_loan` (`loan_id`),
  ADD KEY `fk_li_run` (`deducted_in_run_id`);

--
-- Indexes for table `notifications`
--
ALTER TABLE `notifications`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_notif_recipient_read` (`recipient_user_id`,`is_read`,`created_at`),
  ADD KEY `idx_notif_branch` (`branch_id`,`created_at`),
  ADD KEY `idx_notif_source` (`source_module`,`source_entity_type`,`source_entity_id`),
  ADD KEY `fk_notif_sender` (`sender_user_id`);

--
-- Indexes for table `payroll_items`
--
ALTER TABLE `payroll_items`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_pi_run` (`payroll_run_id`),
  ADD KEY `fk_pi_emp` (`employee_id`);

--
-- Indexes for table `payroll_runs`
--
ALTER TABLE `payroll_runs`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_payrun` (`branch_id`,`period_yyyymm`),
  ADD KEY `fk_pr_user` (`created_by`),
  ADD KEY `fk_pr_journal` (`posted_journal_id`);

--
-- Indexes for table `payslips`
--
ALTER TABLE `payslips`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_payslip` (`payroll_run_id`,`employee_id`),
  ADD KEY `fk_ps_emp` (`employee_id`);

--
-- Indexes for table `reception_visits`
--
ALTER TABLE `reception_visits`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_rv_branch_date` (`branch_id`,`created_at`),
  ADD KEY `idx_rv_status_date` (`status`,`checked_in_at`,`expected_at`),
  ADD KEY `idx_rv_host_user` (`host_user_id`,`status`),
  ADD KEY `idx_rv_host_emp` (`host_employee_id`,`status`),
  ADD KEY `fk_rv_pre_user` (`pre_registered_by_user_id`),
  ADD KEY `fk_rv_created_user` (`created_by_user_id`),
  ADD KEY `fk_rv_updated_user` (`updated_by_user_id`);

--
-- Indexes for table `scheduled_reports`
--
ALTER TABLE `scheduled_reports`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_sr_due` (`is_active`,`next_run_at`),
  ADD KEY `idx_sr_key` (`report_key`,`is_active`);

--
-- Indexes for table `scheduled_report_runs`
--
ALTER TABLE `scheduled_report_runs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_srr_report` (`report_id`,`started_at`),
  ADD KEY `idx_srr_status` (`status`,`started_at`);

--
-- Indexes for table `settlements`
--
ALTER TABLE `settlements`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_s_emp` (`employee_id`),
  ADD KEY `fk_s_branch` (`branch_id`),
  ADD KEY `fk_s_appr` (`approved_by`),
  ADD KEY `fk_s_journal` (`posted_journal_id`);

--
-- Indexes for table `settlement_items`
--
ALTER TABLE `settlement_items`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_si_set` (`settlement_id`);

--
-- Indexes for table `shifts`
--
ALTER TABLE `shifts`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_shift` (`branch_id`,`name`);

--
-- Indexes for table `system_health_checks`
--
ALTER TABLE `system_health_checks`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_shc_key` (`check_key`,`checked_at`),
  ADD KEY `idx_shc_status` (`status`,`checked_at`);

--
-- Indexes for table `user_branch_access`
--
ALTER TABLE `user_branch_access`
  ADD PRIMARY KEY (`user_id`,`branch_id`),
  ADD KEY `fk_uba_branch` (`branch_id`);

--
-- Indexes for table `user_route_permissions`
--
ALTER TABLE `user_route_permissions`
  ADD PRIMARY KEY (`user_id`,`route_key`),
  ADD KEY `idx_urp_route` (`route_key`),
  ADD KEY `fk_urp_upd` (`updated_by_user_id`);

--
-- Indexes for table `workflow_actions`
--
ALTER TABLE `workflow_actions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_wfa_instance` (`workflow_instance_id`,`id`),
  ADD KEY `idx_wfa_actor` (`acted_by_user_id`,`acted_at`);

--
-- Indexes for table `workflow_instances`
--
ALTER TABLE `workflow_instances`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_wf_entity` (`module`,`entity_type`,`entity_id`,`workflow_key`),
  ADD KEY `idx_wf_status` (`module`,`status`),
  ADD KEY `idx_wf_branch` (`branch_id`,`status`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `accounts`
--
ALTER TABLE `accounts`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

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

--
-- AUTO_INCREMENT for table `approval_sla_rules`
--
ALTER TABLE `approval_sla_rules`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `approval_workflows`
--
ALTER TABLE `approval_workflows`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `approval_workflow_steps`
--
ALTER TABLE `approval_workflow_steps`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `assets`
--
ALTER TABLE `assets`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `asset_issues`
--
ALTER TABLE `asset_issues`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `attendance_corrections`
--
ALTER TABLE `attendance_corrections`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `attendance_daily`
--
ALTER TABLE `attendance_daily`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3006;

--
-- AUTO_INCREMENT for table `attendance_deduction_policies`
--
ALTER TABLE `attendance_deduction_policies`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `attendance_device_field_maps`
--
ALTER TABLE `attendance_device_field_maps`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

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

--
-- AUTO_INCREMENT for table `attendance_import_jobs`
--
ALTER TABLE `attendance_import_jobs`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `attendance_punches`
--
ALTER TABLE `attendance_punches`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=436;

--
-- AUTO_INCREMENT for table `audit_logs`
--
ALTER TABLE `audit_logs`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=28;

--
-- AUTO_INCREMENT for table `backup_runs`
--
ALTER TABLE `backup_runs`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `branches`
--
ALTER TABLE `branches`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `branch_holidays`
--
ALTER TABLE `branch_holidays`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `cases`
--
ALTER TABLE `cases`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `chat_conversations`
--
ALTER TABLE `chat_conversations`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `chat_messages`
--
ALTER TABLE `chat_messages`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `chat_message_attachments`
--
ALTER TABLE `chat_message_attachments`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `cost_centers`
--
ALTER TABLE `cost_centers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `departments`
--
ALTER TABLE `departments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `doc_sequences`
--
ALTER TABLE `doc_sequences`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=120;

--
-- AUTO_INCREMENT for table `employees`
--
ALTER TABLE `employees`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `employee_shift_assignments`
--
ALTER TABLE `employee_shift_assignments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=109;

--
-- AUTO_INCREMENT for table `employee_shift_roster`
--
ALTER TABLE `employee_shift_roster`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `fiscal_periods`
--
ALTER TABLE `fiscal_periods`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=409;

--
-- AUTO_INCREMENT for table `fiscal_years`
--
ALTER TABLE `fiscal_years`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=35;

--
-- AUTO_INCREMENT for table `grades`
--
ALTER TABLE `grades`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `job_queue`
--
ALTER TABLE `job_queue`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `journals`
--
ALTER TABLE `journals`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `journal_lines`
--
ALTER TABLE `journal_lines`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `leave_requests`
--
ALTER TABLE `leave_requests`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `leave_types`
--
ALTER TABLE `leave_types`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `loans`
--
ALTER TABLE `loans`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `loan_installments`
--
ALTER TABLE `loan_installments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `notifications`
--
ALTER TABLE `notifications`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;

--
-- AUTO_INCREMENT for table `payroll_items`
--
ALTER TABLE `payroll_items`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;

--
-- AUTO_INCREMENT for table `payroll_runs`
--
ALTER TABLE `payroll_runs`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `payslips`
--
ALTER TABLE `payslips`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `reception_visits`
--
ALTER TABLE `reception_visits`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

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

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

--
-- AUTO_INCREMENT for table `settlements`
--
ALTER TABLE `settlements`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `settlement_items`
--
ALTER TABLE `settlement_items`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `shifts`
--
ALTER TABLE `shifts`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

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

--
-- AUTO_INCREMENT for table `workflow_actions`
--
ALTER TABLE `workflow_actions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `workflow_instances`
--
ALTER TABLE `workflow_instances`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- قيود الجداول المُلقاة.
--

--
-- قيود الجداول `accounts`
--
ALTER TABLE `accounts`
  ADD CONSTRAINT `fk_acc_parent` FOREIGN KEY (`parent_id`) REFERENCES `accounts` (`id`);

--
-- قيود الجداول `approval_workflows`
--
ALTER TABLE `approval_workflows`
  ADD CONSTRAINT `fk_awf_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_awf_creator` FOREIGN KEY (`created_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- قيود الجداول `approval_workflow_employee_scopes`
--
ALTER TABLE `approval_workflow_employee_scopes`
  ADD CONSTRAINT `fk_awfes_employee` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_awfes_workflow` FOREIGN KEY (`workflow_id`) REFERENCES `approval_workflows` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `approval_workflow_steps`
--
ALTER TABLE `approval_workflow_steps`
  ADD CONSTRAINT `fk_awfs_emp` FOREIGN KEY (`approver_employee_id`) REFERENCES `employees` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_awfs_user` FOREIGN KEY (`approver_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_awfs_workflow` FOREIGN KEY (`workflow_id`) REFERENCES `approval_workflows` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `assets`
--
ALTER TABLE `assets`
  ADD CONSTRAINT `fk_a_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`);

--
-- قيود الجداول `asset_issues`
--
ALTER TABLE `asset_issues`
  ADD CONSTRAINT `fk_ai_asset` FOREIGN KEY (`asset_id`) REFERENCES `assets` (`id`),
  ADD CONSTRAINT `fk_ai_emp` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`);

--
-- قيود الجداول `attendance_corrections`
--
ALTER TABLE `attendance_corrections`
  ADD CONSTRAINT `fk_corr_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_corr_created` FOREIGN KEY (`created_by_user_id`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `fk_corr_emp` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_corr_hr` FOREIGN KEY (`hr_by_user_id`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `fk_corr_mgr` FOREIGN KEY (`manager_by_user_id`) REFERENCES `users` (`id`);

--
-- قيود الجداول `attendance_daily`
--
ALTER TABLE `attendance_daily`
  ADD CONSTRAINT `fk_ad_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_ad_emp` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_ad_leave` FOREIGN KEY (`leave_request_id`) REFERENCES `leave_requests` (`id`),
  ADD CONSTRAINT `fk_ad_shift` FOREIGN KEY (`shift_id`) REFERENCES `shifts` (`id`);

--
-- قيود الجداول `attendance_deduction_policies`
--
ALTER TABLE `attendance_deduction_policies`
  ADD CONSTRAINT `fk_adp_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_adp_dept` FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_adp_grade` FOREIGN KEY (`grade_id`) REFERENCES `grades` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_adp_shift` FOREIGN KEY (`shift_id`) REFERENCES `shifts` (`id`) ON DELETE SET NULL;

--
-- قيود الجداول `attendance_device_field_maps`
--
ALTER TABLE `attendance_device_field_maps`
  ADD CONSTRAINT `fk_adfm_device` FOREIGN KEY (`device_id`) REFERENCES `attendance_devices` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `attendance_device_sync_runs`
--
ALTER TABLE `attendance_device_sync_runs`
  ADD CONSTRAINT `fk_adsr_device` FOREIGN KEY (`device_id`) REFERENCES `attendance_devices` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_adsr_user` FOREIGN KEY (`created_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- قيود الجداول `attendance_import_jobs`
--
ALTER TABLE `attendance_import_jobs`
  ADD CONSTRAINT `fk_aij_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_aij_user` FOREIGN KEY (`imported_by_user_id`) REFERENCES `users` (`id`);

--
-- قيود الجداول `attendance_payroll_rules`
--
ALTER TABLE `attendance_payroll_rules`
  ADD CONSTRAINT `fk_apr_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `attendance_punches`
--
ALTER TABLE `attendance_punches`
  ADD CONSTRAINT `fk_ap_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_ap_emp` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_ap_user` FOREIGN KEY (`created_by_user_id`) REFERENCES `users` (`id`);

--
-- قيود الجداول `branch_calendar`
--
ALTER TABLE `branch_calendar`
  ADD CONSTRAINT `fk_bc_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `branch_holidays`
--
ALTER TABLE `branch_holidays`
  ADD CONSTRAINT `fk_bh_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `cases`
--
ALTER TABLE `cases`
  ADD CONSTRAINT `fk_c_assignee` FOREIGN KEY (`assigned_to_user_id`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `fk_c_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`),
  ADD CONSTRAINT `fk_c_emp` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`);

--
-- قيود الجداول `chat_conversations`
--
ALTER TABLE `chat_conversations`
  ADD CONSTRAINT `fk_chat_conv_creator` FOREIGN KEY (`created_by_user_id`) REFERENCES `users` (`id`);

--
-- قيود الجداول `chat_messages`
--
ALTER TABLE `chat_messages`
  ADD CONSTRAINT `fk_chat_msg_conv` FOREIGN KEY (`conversation_id`) REFERENCES `chat_conversations` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_chat_msg_sender` FOREIGN KEY (`sender_user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `chat_message_attachments`
--
ALTER TABLE `chat_message_attachments`
  ADD CONSTRAINT `fk_chat_att_msg` FOREIGN KEY (`message_id`) REFERENCES `chat_messages` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `chat_participants`
--
ALTER TABLE `chat_participants`
  ADD CONSTRAINT `fk_chat_part_conv` FOREIGN KEY (`conversation_id`) REFERENCES `chat_conversations` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_chat_part_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `cost_centers`
--
ALTER TABLE `cost_centers`
  ADD CONSTRAINT `fk_cc_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`);

--
-- قيود الجداول `departments`
--
ALTER TABLE `departments`
  ADD CONSTRAINT `fk_dept_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`);

--
-- قيود الجداول `employees`
--
ALTER TABLE `employees`
  ADD CONSTRAINT `fk_emp_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`),
  ADD CONSTRAINT `fk_emp_dept` FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`),
  ADD CONSTRAINT `fk_emp_grade` FOREIGN KEY (`grade_id`) REFERENCES `grades` (`id`),
  ADD CONSTRAINT `fk_emp_manager` FOREIGN KEY (`manager_id`) REFERENCES `employees` (`id`);

--
-- قيود الجداول `employee_shift_assignments`
--
ALTER TABLE `employee_shift_assignments`
  ADD CONSTRAINT `fk_esa_emp` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_esa_shift` FOREIGN KEY (`shift_id`) REFERENCES `shifts` (`id`);

--
-- قيود الجداول `employee_shift_roster`
--
ALTER TABLE `employee_shift_roster`
  ADD CONSTRAINT `fk_esr_emp` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_esr_shift` FOREIGN KEY (`shift_id`) REFERENCES `shifts` (`id`);

--
-- قيود الجداول `grades`
--
ALTER TABLE `grades`
  ADD CONSTRAINT `fk_grade_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`);

--
-- قيود الجداول `journals`
--
ALTER TABLE `journals`
  ADD CONSTRAINT `fk_j_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`),
  ADD CONSTRAINT `fk_j_user` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`);

--
-- قيود الجداول `journal_lines`
--
ALTER TABLE `journal_lines`
  ADD CONSTRAINT `fk_jl_a` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`),
  ADD CONSTRAINT `fk_jl_j` FOREIGN KEY (`journal_id`) REFERENCES `journals` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `leave_balances`
--
ALTER TABLE `leave_balances`
  ADD CONSTRAINT `fk_lb_emp` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_lb_lt` FOREIGN KEY (`leave_type_id`) REFERENCES `leave_types` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `leave_requests`
--
ALTER TABLE `leave_requests`
  ADD CONSTRAINT `fk_lr_appr` FOREIGN KEY (`approved_by_user_id`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `fk_lr_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`),
  ADD CONSTRAINT `fk_lr_emp` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`),
  ADD CONSTRAINT `fk_lr_lt` FOREIGN KEY (`leave_type_id`) REFERENCES `leave_types` (`id`);

--
-- قيود الجداول `loans`
--
ALTER TABLE `loans`
  ADD CONSTRAINT `fk_l_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`),
  ADD CONSTRAINT `fk_l_emp` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`),
  ADD CONSTRAINT `fk_l_fin` FOREIGN KEY (`disbursed_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `fk_l_hr` FOREIGN KEY (`hr_approved_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `fk_l_journal` FOREIGN KEY (`gl_journal_id`) REFERENCES `journals` (`id`),
  ADD CONSTRAINT `fk_l_mgr` FOREIGN KEY (`manager_approved_by`) REFERENCES `users` (`id`);

--
-- قيود الجداول `loan_installments`
--
ALTER TABLE `loan_installments`
  ADD CONSTRAINT `fk_li_loan` FOREIGN KEY (`loan_id`) REFERENCES `loans` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_li_run` FOREIGN KEY (`deducted_in_run_id`) REFERENCES `payroll_runs` (`id`);

--
-- قيود الجداول `notifications`
--
ALTER TABLE `notifications`
  ADD CONSTRAINT `fk_notif_recipient` FOREIGN KEY (`recipient_user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_notif_sender` FOREIGN KEY (`sender_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- قيود الجداول `payroll_items`
--
ALTER TABLE `payroll_items`
  ADD CONSTRAINT `fk_pi_emp` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`),
  ADD CONSTRAINT `fk_pi_run` FOREIGN KEY (`payroll_run_id`) REFERENCES `payroll_runs` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `payroll_runs`
--
ALTER TABLE `payroll_runs`
  ADD CONSTRAINT `fk_pr_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`),
  ADD CONSTRAINT `fk_pr_journal` FOREIGN KEY (`posted_journal_id`) REFERENCES `journals` (`id`),
  ADD CONSTRAINT `fk_pr_user` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`);

--
-- قيود الجداول `payslips`
--
ALTER TABLE `payslips`
  ADD CONSTRAINT `fk_ps_emp` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`),
  ADD CONSTRAINT `fk_ps_run` FOREIGN KEY (`payroll_run_id`) REFERENCES `payroll_runs` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `reception_visits`
--
ALTER TABLE `reception_visits`
  ADD CONSTRAINT `fk_rv_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_rv_created_user` FOREIGN KEY (`created_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_rv_host_emp` FOREIGN KEY (`host_employee_id`) REFERENCES `employees` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_rv_host_user` FOREIGN KEY (`host_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_rv_pre_user` FOREIGN KEY (`pre_registered_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_rv_updated_user` FOREIGN KEY (`updated_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- قيود الجداول `settlements`
--
ALTER TABLE `settlements`
  ADD CONSTRAINT `fk_s_appr` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `fk_s_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`),
  ADD CONSTRAINT `fk_s_emp` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`),
  ADD CONSTRAINT `fk_s_journal` FOREIGN KEY (`posted_journal_id`) REFERENCES `journals` (`id`);

--
-- قيود الجداول `settlement_items`
--
ALTER TABLE `settlement_items`
  ADD CONSTRAINT `fk_si_set` FOREIGN KEY (`settlement_id`) REFERENCES `settlements` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `shifts`
--
ALTER TABLE `shifts`
  ADD CONSTRAINT `fk_shift_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `user_branch_access`
--
ALTER TABLE `user_branch_access`
  ADD CONSTRAINT `fk_uba_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_uba_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `user_route_permissions`
--
ALTER TABLE `user_route_permissions`
  ADD CONSTRAINT `fk_urp_upd` FOREIGN KEY (`updated_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_urp_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
COMMIT;

