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

START TRANSACTION;



--
-- Database: `absensi`
--

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

--
-- Table structure for table `attendance`
--

CREATE TABLE `attendance` (
  `id` int(11) NOT NULL,
  `student_id` int(11) NOT NULL,
  `date` date NOT NULL,
  `check_in_time` time DEFAULT NULL,
  `check_out_time` time DEFAULT NULL,
  `status` enum('present','absent','late','excused') DEFAULT 'absent',
  `notes` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `attendance`
--

INSERT INTO `attendance` (`id`, `student_id`, `date`, `check_in_time`, `check_out_time`, `status`, `notes`, `created_at`, `updated_at`) VALUES
(1, 53, '2025-10-22', '18:50:42', '18:51:05', 'present', NULL, '2025-10-22 16:50:42', '2025-10-22 16:51:05'),
(2, 38, '2025-10-29', '06:39:38', '06:39:44', 'present', NULL, '2025-10-29 05:39:38', '2025-10-29 05:39:44');

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

--
-- Table structure for table `attendances`
--

CREATE TABLE `attendances` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `schedule_id` int(11) DEFAULT NULL,
  `attendance_date` date NOT NULL,
  `check_in_time` time DEFAULT NULL,
  `check_out_time` time DEFAULT NULL,
  `status` enum('Hadir','Terlambat','Izin','Sakit','Alpha') DEFAULT 'Alpha',
  `notes` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `classes`
--

CREATE TABLE `classes` (
  `id` int(11) NOT NULL,
  `nama_kelas` varchar(50) NOT NULL,
  `tingkat` varchar(20) DEFAULT NULL,
  `homeroom_teacher_id` int(11) DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `classes`
--

INSERT INTO `classes` (`id`, `nama_kelas`, `tingkat`, `homeroom_teacher_id`, `is_active`, `created_at`, `updated_at`) VALUES
(17, 'X BD', NULL, NULL, 1, '2025-10-17 04:46:57', '2025-10-29 01:20:45'),
(18, 'X BR', NULL, NULL, 1, '2025-10-17 04:48:20', '2025-10-17 04:48:20'),
(19, 'X KULINER', NULL, NULL, 1, '2025-10-17 04:48:45', '2025-10-17 04:48:45'),
(20, 'X AK', NULL, NULL, 1, '2025-10-17 04:49:09', '2025-10-28 04:58:09'),
(21, 'X MP', NULL, NULL, 1, '2025-10-17 04:49:45', '2025-10-17 04:49:45'),
(22, 'X ML', NULL, NULL, 1, '2025-10-17 04:49:56', '2025-10-17 04:49:56'),
(23, 'XI AK 1', NULL, NULL, 1, '2025-10-17 04:50:18', '2025-10-17 04:50:45'),
(24, 'XI AK 2', NULL, NULL, 1, '2025-10-17 04:51:14', '2025-10-17 04:51:14'),
(25, 'XI BD', NULL, NULL, 1, '2025-10-17 04:51:53', '2025-10-17 04:51:53'),
(26, 'XI BR', NULL, NULL, 1, '2025-10-17 04:52:03', '2025-10-17 04:52:03'),
(27, 'XI MP', NULL, NULL, 1, '2025-10-17 04:52:13', '2025-10-17 04:52:13'),
(28, 'XI ML', NULL, NULL, 1, '2025-10-17 04:52:42', '2025-10-17 04:52:42'),
(37, 'XII BDP 1', NULL, NULL, 1, '2025-10-17 05:03:59', '2025-10-17 05:03:59'),
(38, 'XII BDP 2', NULL, NULL, 1, '2025-10-17 05:04:04', '2025-10-17 05:04:04'),
(39, 'XII MP 1', NULL, NULL, 1, '2025-10-17 05:04:16', '2025-10-17 05:04:28'),
(41, 'XII AKKL 1', NULL, NULL, 1, '2025-10-17 05:04:34', '2025-10-17 05:04:34'),
(42, 'XII AKKL 2', NULL, NULL, 1, '2025-10-17 05:04:39', '2025-10-17 05:04:39');

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

--
-- Table structure for table `permissions`
--

CREATE TABLE `permissions` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `permission_type` enum('Sakit','Izin','Cuti') NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `reason` text NOT NULL,
  `attachment` varchar(255) DEFAULT NULL,
  `status` enum('Pending','Approved','Rejected') DEFAULT 'Pending',
  `approved_by` int(11) DEFAULT NULL,
  `approved_at` timestamp NULL DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `piket_schedules`
--

CREATE TABLE `piket_schedules` (
  `id` int(11) NOT NULL,
  `day` enum('Senin','Selasa','Rabu','Kamis','Jumat','Sabtu','Minggu') NOT NULL,
  `teacher_id` int(11) NOT NULL,
  `shift` enum('Pagi','Siang','Sore') DEFAULT 'Pagi',
  `start_time` time NOT NULL,
  `end_time` time NOT NULL,
  `location` varchar(100) DEFAULT 'Meja Piket',
  `notes` text DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `piket_schedules`
--

INSERT INTO `piket_schedules` (`id`, `day`, `teacher_id`, `shift`, `start_time`, `end_time`, `location`, `notes`, `is_active`, `created_at`, `updated_at`) VALUES
(1, 'Kamis', 13, 'Pagi', '12:12:00', '14:14:00', 'Meja Piket', '', 0, '2025-10-22 15:01:57', '2025-10-22 15:05:41'),
(2, 'Selasa', 13, 'Pagi', '12:12:00', '14:14:00', 'Meja Piket', '', 0, '2025-10-22 15:11:26', '2025-10-22 15:11:39'),
(3, 'Selasa', 13, 'Siang', '10:00:00', '21:00:00', 'Meja Piket', '', 1, '2025-10-28 05:09:43', '2025-10-28 05:09:43');

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

--
-- Table structure for table `roles`
--

CREATE TABLE `roles` (
  `id` int(11) NOT NULL,
  `nama_role` varchar(50) NOT NULL,
  `deskripsi` text DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `roles`
--

INSERT INTO `roles` (`id`, `nama_role`, `deskripsi`, `is_active`, `created_at`, `updated_at`) VALUES
(1, 'Developer', 'Super Admin - Akses penuh ke semua fitur', 1, '2025-10-17 00:58:33', '2025-10-17 00:58:33'),
(2, 'Pengurus Sekolah', 'Admin sekolah - Manajemen data sekolah', 1, '2025-10-17 00:58:33', '2025-10-17 00:58:33'),
(3, 'Guru', 'Guru mata pelajaran', 1, '2025-10-17 00:58:33', '2025-10-17 00:58:33'),
(4, 'Wali Kelas', 'Guru yang merangkap sebagai wali kelas', 1, '2025-10-17 00:58:33', '2025-10-17 00:58:33'),
(5, 'Siswa', 'Siswa sekolah', 1, '2025-10-17 00:58:33', '2025-10-17 00:58:33');

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

--
-- Table structure for table `schedules`
--

CREATE TABLE `schedules` (
  `id` int(11) NOT NULL,
  `hari` enum('Senin','Selasa','Rabu','Kamis','Jumat','Sabtu') NOT NULL,
  `jam_mulai` time NOT NULL,
  `jam_selesai` time NOT NULL,
  `class_id` int(11) NOT NULL,
  `subject_id` int(11) NOT NULL,
  `teacher_id` int(11) NOT NULL,
  `room` varchar(50) DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `schedules`
--

INSERT INTO `schedules` (`id`, `hari`, `jam_mulai`, `jam_selesai`, `class_id`, `subject_id`, `teacher_id`, `room`, `is_active`, `created_at`, `updated_at`) VALUES
(6, 'Senin', '12:12:00', '13:13:00', 25, 10, 13, '115', 0, '2025-10-21 14:27:08', '2025-10-21 14:34:37'),
(7, 'Senin', '12:12:00', '13:13:00', 18, 2, 13, '114', 0, '2025-10-21 14:34:08', '2025-10-21 14:34:30'),
(8, 'Rabu', '12:12:00', '13:13:00', 17, 10, 13, '115', 1, '2025-10-21 14:38:12', '2025-10-29 05:44:06');

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

--
-- Table structure for table `site_settings`
--

CREATE TABLE `site_settings` (
  `id` int(11) NOT NULL,
  `setting_key` varchar(100) NOT NULL,
  `setting_value` text DEFAULT NULL,
  `description` text DEFAULT NULL,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `site_settings`
--

INSERT INTO `site_settings` (`id`, `setting_key`, `setting_value`, `description`, `updated_at`) VALUES
(1, 'site_name', 'Sistem Absensi Sekolah', 'Nama situs', '2025-10-17 00:58:34'),
(2, 'site_logo', 'assets/images/logo-sekolah.png', 'Logo sekolah', '2025-10-17 00:58:34'),
(3, 'maintenance_mode', '0', 'Mode maintenance (0=off, 1=on)', '2025-10-17 00:58:34'),
(4, 'debug_mode', '0', 'Mode debug (0=off, 1=on)', '2025-10-17 00:58:34'),
(5, 'cache_enabled', '1', 'Enable cache (0=off, 1=on)', '2025-10-17 00:58:34'),
(7, 'site_description', 'Sistem presensi dan manajemen sekolah berbasis digital', NULL, '2025-10-29 00:20:43'),
(8, 'site_keywords', 'presensi digital, sekolah, face recognition', NULL, '2025-10-29 00:20:43'),
(9, 'site_author', 'SMK Negeri 1 Yogyakarta', NULL, '2025-10-29 00:20:43'),
(10, 'logo_url', 'assets/images/logo-sekolah.png', NULL, '2025-10-29 00:20:43'),
(11, 'primary_color', '#4F46E5', NULL, '2025-10-29 00:20:43'),
(12, 'theme_color', '#4F46E5', NULL, '2025-10-29 00:20:43'),
(13, 'contact_email', 'info@smkn1yogya.sch.id', NULL, '2025-10-29 00:20:43'),
(14, 'contact_phone', '(0274) 123456', NULL, '2025-10-29 00:20:43'),
(15, 'address', 'Jl. Magelang Km. 4, Sleman, Yogyakarta', NULL, '2025-10-29 00:20:43');

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

--
-- Table structure for table `student_permits`
--

CREATE TABLE `student_permits` (
  `id` int(11) NOT NULL,
  `student_id` int(11) NOT NULL,
  `permit_type` enum('sick','family','other') NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `reason` text NOT NULL,
  `address` text NOT NULL,
  `attachment` varchar(255) DEFAULT NULL,
  `status` enum('Pending','Approved','Rejected') DEFAULT 'Pending',
  `approved_by` int(11) DEFAULT NULL,
  `approved_at` timestamp NULL DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `student_permits`
--

INSERT INTO `student_permits` (`id`, `student_id`, `permit_type`, `start_date`, `end_date`, `reason`, `address`, `attachment`, `status`, `approved_by`, `approved_at`, `notes`, `created_at`, `updated_at`) VALUES
(1, 34, 'sick', '2025-10-28', '2025-10-29', 'Test izin sakit untuk debugging', 'Jl. Test No. 123, Jakarta', NULL, 'Pending', NULL, NULL, NULL, '2025-10-28 05:33:11', '2025-10-28 05:33:11'),
(2, 34, 'sick', '2025-10-28', '2025-10-29', 'sakit wokkkk kaki gw', 'jalan indah kemayu', NULL, 'Pending', NULL, NULL, NULL, '2025-10-28 05:34:38', '2025-10-28 05:34:38'),
(4, 34, 'family', '2025-10-28', '2025-10-29', 'makan malam bg', 'jalan indah kemayu', NULL, 'Pending', NULL, NULL, NULL, '2025-10-28 05:34:54', '2025-10-28 05:34:54'),
(5, 34, 'family', '2025-10-28', '2025-10-29', 'makan malam bg', 'jalan indah kemayu', NULL, 'Pending', NULL, NULL, NULL, '2025-10-28 05:38:35', '2025-10-28 05:38:35');

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

--
-- Table structure for table `subjects`
--

CREATE TABLE `subjects` (
  `id` int(11) NOT NULL,
  `kode_mapel` varchar(10) NOT NULL,
  `nama_mapel` varchar(100) NOT NULL,
  `deskripsi` text DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `subjects`
--

INSERT INTO `subjects` (`id`, `kode_mapel`, `nama_mapel`, `deskripsi`, `is_active`, `created_at`, `updated_at`) VALUES
(1, 'MTK', 'Matematika', 'Mata pelajaran matematika', 1, '2025-10-17 00:58:33', '2025-10-17 00:58:33'),
(2, 'BIN', 'Bahasa Indonesia', 'Mata pelajaran bahasa Indonesia', 1, '2025-10-17 00:58:33', '2025-10-17 00:58:33'),
(3, 'BING', 'Bahasa Inggris', 'Mata pelajaran bahasa Inggris', 1, '2025-10-17 00:58:33', '2025-10-17 00:58:33'),
(4, 'IPA', 'Ilmu Pengetahuan Alam', 'Mata pelajaran IPA', 1, '2025-10-17 00:58:33', '2025-10-17 00:58:33'),
(5, 'IPS', 'Ilmu Pengetahuan Sosial', 'Mata pelajaran IPS', 1, '2025-10-17 00:58:33', '2025-10-17 00:58:33'),
(6, 'PKN', 'Pendidikan Kewarganegaraan', 'Mata pelajaran PKN', 1, '2025-10-17 00:58:33', '2025-10-17 00:58:33'),
(7, 'PJOK', 'Pendidikan Jasmani', 'Mata pelajaran PJOK', 1, '2025-10-17 00:58:33', '2025-10-17 00:58:33'),
(10, 'AGM', 'Agama', 'Mata pelajaran Agama', 1, '2025-10-17 00:58:33', '2025-10-17 00:58:33');

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

--
-- Table structure for table `system_logs`
--

CREATE TABLE `system_logs` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `action` varchar(100) NOT NULL,
  `details` text DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `system_logs`
--

INSERT INTO `system_logs` (`id`, `user_id`, `action`, `details`, `ip_address`, `user_agent`, `created_at`) VALUES
(1, 1, 'login', 'Developer login successful', '127.0.0.1', NULL, '2025-10-17 00:58:34'),
(2, 1, 'dashboard_access', 'Accessed dashboard', '127.0.0.1', NULL, '2025-10-17 00:58:34'),
(3, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-17 01:07:14'),
(4, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 01:13:04'),
(5, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-17 01:13:43'),
(6, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-17 01:17:27'),
(7, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-17 01:19:57'),
(8, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-17 01:23:16'),
(9, 1, 'login', 'User login successful', '192.168.1.7', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36', '2025-10-17 02:57:24'),
(10, 1, 'login', 'User login successful', '192.168.1.23', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Mobile Safari/537.36', '2025-10-17 02:58:35'),
(11, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-17 03:25:47'),
(12, 1, 'delete_user', 'Menghapus user: Sari Indah banget sih', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 03:34:44'),
(13, 1, 'delete_user', 'Menghapus user: Felix Ferdinand', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 03:36:23'),
(14, 1, 'delete_user', 'Menghapus user: Andi Pratama aa', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 03:37:57'),
(15, 1, 'delete_user', 'Menghapus user: Ahmad Rizki, S.Pd', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 03:43:00'),
(16, 1, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 04:03:12'),
(17, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 04:03:20'),
(18, 1, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 04:03:34'),
(19, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 04:03:39'),
(20, 1, 'login', 'User login successful', '192.168.1.7', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36', '2025-10-17 04:04:48'),
(21, 1, 'login', 'User login successful', '192.168.1.7', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36', '2025-10-17 04:07:20'),
(22, 1, 'login', 'User login successful', '192.168.1.7', 'Mozilla/5.0 (Linux; Android 14; en; TECNO LH7n Build/SP1A.210812.016) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.7339.207 HiBrowser/v2.24.5.2 UWS/ Mobile Safari/537.36', '2025-10-17 04:08:07'),
(23, 1, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 04:30:54'),
(24, NULL, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 04:30:57'),
(25, NULL, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 04:31:02'),
(26, NULL, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 04:31:06'),
(27, NULL, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 04:31:14'),
(28, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 04:31:18'),
(29, 1, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 04:36:33'),
(30, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 04:36:59'),
(31, 1, 'delete_user', 'Menghapus user: Budi Santoso, S.Pd', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 04:45:24'),
(32, 1, 'delete_user', 'Menghapus user: Siti Nurhaliza, S.Pd', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 04:45:32'),
(33, 1, 'delete_subject', 'Menghapus mata pelajaran: Teknologi Informasi', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 05:27:37'),
(34, 1, 'delete_subject', 'Menghapus mata pelajaran: Seni Budaya', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 05:30:16'),
(35, 1, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-17 05:44:04'),
(36, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT; Windows NT 10.0; en-US) WindowsPowerShell/5.1.26100.6899', '2025-10-19 07:19:18'),
(37, 1, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-19 07:23:10'),
(38, 1, 'logout', 'User logout successful', '192.168.1.2', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Mobile Safari/537.36', '2025-10-19 08:27:47'),
(39, 1, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36', '2025-10-19 09:15:12'),
(40, 1, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', '2025-10-21 14:54:40'),
(41, 1, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', '2025-10-22 16:15:23'),
(42, 53, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', '2025-10-22 16:26:35'),
(43, 1, 'logout', 'User logout successful', '10.167.89.38', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Mobile Safari/537.36', '2025-10-22 16:51:39'),
(44, 13, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-28 05:18:09'),
(45, 13, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-28 05:21:41'),
(46, 13, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-29 00:16:19'),
(47, 38, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-29 00:30:13'),
(48, 1, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-29 00:35:37'),
(49, 1, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-29 00:48:28'),
(50, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', '2025-10-29 01:02:12'),
(51, 1, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', '2025-10-29 01:09:24'),
(52, 13, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', '2025-10-29 01:09:31'),
(53, 13, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', '2025-10-29 01:10:34'),
(54, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', '2025-10-29 01:10:40'),
(55, 38, 'login', 'User login successful', '192.168.1.41', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Mobile Safari/537.36', '2025-10-29 04:10:21'),
(56, 38, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-29 05:33:29'),
(57, 38, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Mobile Safari/537.36', '2025-10-29 05:34:53'),
(58, 38, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Mobile Safari/537.36', '2025-10-29 05:40:02'),
(59, 38, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Mobile Safari/537.36', '2025-10-29 05:54:26'),
(60, 38, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Mobile Safari/537.36', '2025-10-29 05:54:46'),
(61, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-29 06:03:17'),
(62, 58, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Mobile Safari/537.36', '2025-10-29 06:09:26'),
(63, 58, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Mobile Safari/537.36', '2025-10-29 06:12:50'),
(64, 1, 'logout', 'User logout successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', '2025-10-29 07:43:45'),
(65, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', '2025-10-29 07:43:56'),
(66, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-30 03:14:25'),
(67, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-30 03:16:23'),
(68, 1, 'login', 'User login successful', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0', '2025-10-30 05:41:46');

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

--
-- Table structure for table `teacher_subjects`
--

CREATE TABLE `teacher_subjects` (
  `id` int(11) NOT NULL,
  `teacher_id` int(11) NOT NULL,
  `subject_id` int(11) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `attendance`
--
ALTER TABLE `attendance`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_student_date` (`student_id`,`date`),
  ADD KEY `idx_student_date` (`student_id`,`date`),
  ADD KEY `idx_date` (`date`),
  ADD KEY `idx_status` (`status`);

--
-- Indexes for table `attendances`
--
ALTER TABLE `attendances`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_user_date` (`user_id`,`attendance_date`),
  ADD KEY `schedule_id` (`schedule_id`),
  ADD KEY `idx_attendances_user_date` (`user_id`,`attendance_date`);

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

--
-- Indexes for table `permissions`
--
ALTER TABLE `permissions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `approved_by` (`approved_by`);

--
-- Indexes for table `piket_schedules`
--
ALTER TABLE `piket_schedules`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_day` (`day`),
  ADD KEY `idx_teacher` (`teacher_id`),
  ADD KEY `idx_active` (`is_active`);

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

--
-- Indexes for table `schedules`
--
ALTER TABLE `schedules`
  ADD PRIMARY KEY (`id`),
  ADD KEY `subject_id` (`subject_id`),
  ADD KEY `teacher_id` (`teacher_id`),
  ADD KEY `idx_schedules_class_day` (`class_id`,`hari`);

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

--
-- Indexes for table `student_permits`
--
ALTER TABLE `student_permits`
  ADD PRIMARY KEY (`id`),
  ADD KEY `approved_by` (`approved_by`),
  ADD KEY `idx_student` (`student_id`),
  ADD KEY `idx_status` (`status`),
  ADD KEY `idx_created` (`created_at`);

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

--
-- Indexes for table `system_logs`
--
ALTER TABLE `system_logs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indexes for table `teacher_subjects`
--
ALTER TABLE `teacher_subjects`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_teacher_subject` (`teacher_id`,`subject_id`),
  ADD KEY `subject_id` (`subject_id`);

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

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

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

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

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

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

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

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `attendance`
--
ALTER TABLE `attendance`
  ADD CONSTRAINT `attendance_ibfk_1` FOREIGN KEY (`student_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `attendances`
--
ALTER TABLE `attendances`
  ADD CONSTRAINT `attendances_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `attendances_ibfk_2` FOREIGN KEY (`schedule_id`) REFERENCES `schedules` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `permissions`
--
ALTER TABLE `permissions`
  ADD CONSTRAINT `permissions_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `permissions_ibfk_2` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `piket_schedules`
--
ALTER TABLE `piket_schedules`
  ADD CONSTRAINT `piket_schedules_ibfk_1` FOREIGN KEY (`teacher_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `schedules`
--
ALTER TABLE `schedules`
  ADD CONSTRAINT `schedules_ibfk_1` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `schedules_ibfk_2` FOREIGN KEY (`subject_id`) REFERENCES `subjects` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `schedules_ibfk_3` FOREIGN KEY (`teacher_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `student_permits`
--
ALTER TABLE `student_permits`
  ADD CONSTRAINT `student_permits_ibfk_1` FOREIGN KEY (`student_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `student_permits_ibfk_2` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `system_logs`
--
ALTER TABLE `system_logs`
  ADD CONSTRAINT `system_logs_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `teacher_subjects`
--
ALTER TABLE `teacher_subjects`
  ADD CONSTRAINT `teacher_subjects_ibfk_1` FOREIGN KEY (`teacher_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `teacher_subjects_ibfk_2` FOREIGN KEY (`subject_id`) REFERENCES `subjects` (`id`) ON DELETE CASCADE;
COMMIT;

