diff --git a/assets/css/style.css b/assets/css/style.css new file mode 100644 index 0000000..0b72e1f --- /dev/null +++ b/assets/css/style.css @@ -0,0 +1,23 @@ +body { + font-family: 'Poppins', sans-serif; + background-color: #f8f9fa; +} + +.navbar-brand { + font-weight: 600; +} + +.card { + border: none; + border-radius: 0.5rem; +} + +.btn-primary { + background-color: #3498db; + border-color: #3498db; +} + +.btn-primary:hover { + background-color: #2980b9; + border-color: #2980b9; +} diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..be427b7 --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1 @@ +// Custom javascript can be added here. diff --git a/config/db.php b/config/db.php new file mode 100644 index 0000000..e46e348 --- /dev/null +++ b/config/db.php @@ -0,0 +1,20 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + return $pdo; + } catch (PDOException $e) { + die("Koneksi database gagal: " . $e->getMessage()); + } +} +?> \ No newline at end of file diff --git a/config/wablas.php b/config/wablas.php new file mode 100644 index 0000000..6ab259c --- /dev/null +++ b/config/wablas.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/db/database.sql b/db/database.sql new file mode 100644 index 0000000..cca6bd7 --- /dev/null +++ b/db/database.sql @@ -0,0 +1,50 @@ +CREATE TABLE IF NOT EXISTS `users` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `username` varchar(50) NOT NULL, + `password` varchar(255) NOT NULL, + `role` enum('admin','guru','siswa') NOT NULL, + `nama_lengkap` varchar(100) DEFAULT NULL, + `nomor_induk` varchar(20) DEFAULT NULL, + `nomor_wa_orang_tua` varchar(20) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `username` (`username`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS `izin` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `tanggal_izin` datetime NOT NULL, + `alasan` text NOT NULL, + `status` enum('menunggu','disetujui','ditolak','selesai') NOT NULL DEFAULT 'menunggu', + `guru_id` int(11) DEFAULT NULL, + `admin_id` int(11) DEFAULT NULL, + `waktu_kembali` datetime DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`), + CONSTRAINT `izin_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS `log_aktivitas` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) DEFAULT NULL, + `aktivitas` varchar(255) NOT NULL, + `timestamp` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- Data Dummy +INSERT INTO `users` (`id`, `username`, `password`, `role`, `nama_lengkap`, `nomor_induk`) VALUES +(1, 'admin1', '$2y$10$g.g.j.Z.d.2...//..//..//..//..//..//..//..//..//..//', 'admin', 'Admin Satu', NULL), +(2, 'admin2', '$2y$10$g.g.j.Z.d.2...//..//..//..//..//..//..//..//..//..//', 'admin', 'Admin Dua', NULL), +(3, '1001', '$2y$10$g.g.j.Z.d.2...//..//..//..//..//..//..//..//..//..//', 'siswa', 'Siswa Satu', '1001'), +(4, '1002', '$2y$10$g.g.j.Z.d.2...//..//..//..//..//..//..//..//..//..//', 'siswa', 'Siswa Dua', '1002'), +(5, '1003', '$2y$10$g.g.j.Z.d.2...//..//..//..//..//..//..//..//..//..//', 'siswa', 'Siswa Tiga', '1003'), +(6, 'guru1', '$2y$10$g.g.j.Z.d.2...//..//..//..//..//..//..//..//..//..//', 'guru', 'Guru Satu', NULL); + +INSERT INTO `izin` (`id`, `user_id`, `tanggal_izin`, `alasan`, `status`, `guru_id`, `admin_id`, `waktu_kembali`) VALUES +(1, 3, '2025-10-23 10:00:00', 'Sakit gigi', 'disetujui', 6, 1, NULL), +(2, 4, '2025-10-23 11:00:00', 'Keperluan keluarga', 'menunggu', NULL, NULL, NULL), +(3, 5, '2025-10-23 09:30:00', 'Ada urusan mendadak', 'ditolak', NULL, 2, NULL), +(4, 3, '2025-10-22 14:00:00', 'Pulang lebih awal', 'selesai', 6, 1, '2025-10-22 15:00:00'), +(5, 4, '2025-10-24 08:00:00', 'Mengikuti lomba', 'menunggu', NULL, NULL, NULL); diff --git a/includes/functions.php b/includes/functions.php new file mode 100644 index 0000000..ac63cf9 --- /dev/null +++ b/includes/functions.php @@ -0,0 +1,25 @@ +prepare("INSERT INTO log_aktivitas (user_id, aktivitas) VALUES (?, ?)"); + $stmt->execute([$user_id, $activity]); + } catch (PDOException $e) { + // Optionally log error to a file + } +} + +function check_auth($roles = []) { + if (!isset($_SESSION['user'])) { + header('Location: /login.php'); + exit(); + } + if (!empty($roles) && !in_array($_SESSION['user']['role'], $roles)) { + http_response_code(403); + echo "Forbidden"; + exit(); + } +} +?> \ No newline at end of file diff --git a/index.php b/index.php index 7205f3d..98ccca6 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,27 @@ - - - - - - New Style - - - - - - - - - - - - - - - - - - - - - -
-
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

-
-
- - - +if (!isset($_SESSION['user'])) { + header('Location: /login.php'); + exit(); +} + +$role = $_SESSION['user']['role']; + +switch ($role) { + case 'admin': + header('Location: /pages/admin/dashboard.php'); + break; + case 'guru': + header('Location: /pages/guru/dashboard.php'); + break; + case 'siswa': + header('Location: /pages/siswa/dashboard.php'); + break; + default: + header('Location: /login.php'); + break; +} + +require_once __DIR__ . '/templates/footer.php'; +?> \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..13665ce --- /dev/null +++ b/login.php @@ -0,0 +1,69 @@ +prepare("SELECT * FROM users WHERE username = ?"); + $stmt->execute([$username]); + $user = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($user && password_verify($password, $user['password'])) { + $_SESSION['user'] = [ + 'id' => $user['id'], + 'username' => $user['username'], + 'role' => $user['role'], + 'nama_lengkap' => $user['nama_lengkap'] + ]; + log_activity($user['id'], "User logged in"); + header('Location: /index.php'); + exit(); + } else { + $error = 'Username atau password salah.'; + log_activity(null, "Failed login attempt for username: $username"); + } + } +} +?> + +
+
+
+

Login SIKMS

+ + + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..e2ffa2b --- /dev/null +++ b/logout.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/pages/admin/dashboard.php b/pages/admin/dashboard.php new file mode 100644 index 0000000..15e829d --- /dev/null +++ b/pages/admin/dashboard.php @@ -0,0 +1,23 @@ + + +
+
+
+

Dashboard Admin

+
+
+
Selamat Datang, !
+

Anda login sebagai Admin. Anda dapat mengelola izin siswa dan melihat aktivitas sistem.

+ +
+
+
+ + \ No newline at end of file diff --git a/pages/admin/izin.php b/pages/admin/izin.php new file mode 100644 index 0000000..5b316a1 --- /dev/null +++ b/pages/admin/izin.php @@ -0,0 +1,22 @@ + + +
+
+
+

Manajemen Izin

+
+
+

Halaman ini akan menampilkan daftar semua izin yang diajukan oleh siswa.

+ +
+
+
+ + \ No newline at end of file diff --git a/pages/admin/log.php b/pages/admin/log.php new file mode 100644 index 0000000..e3c9d21 --- /dev/null +++ b/pages/admin/log.php @@ -0,0 +1,22 @@ + + +
+
+
+

Log Aktivitas

+
+
+

Halaman ini akan menampilkan log aktivitas pengguna dalam sistem.

+ +
+
+
+ + \ No newline at end of file diff --git a/pages/guru/dashboard.php b/pages/guru/dashboard.php new file mode 100644 index 0000000..f6c0d51 --- /dev/null +++ b/pages/guru/dashboard.php @@ -0,0 +1,22 @@ + + +
+
+
+

Dashboard Guru

+
+
+
Selamat Datang, !
+

Anda login sebagai Guru. Anda dapat mereview pengajuan izin dari siswa.

+
+
+
+ + \ No newline at end of file diff --git a/pages/guru/izin.php b/pages/guru/izin.php new file mode 100644 index 0000000..0265896 --- /dev/null +++ b/pages/guru/izin.php @@ -0,0 +1,22 @@ + + +
+
+
+

Review Izin Siswa

+
+
+

Halaman ini akan menampilkan daftar izin yang perlu direview oleh guru.

+ +
+
+
+ + \ No newline at end of file diff --git a/pages/siswa/ajukan_izin.php b/pages/siswa/ajukan_izin.php new file mode 100644 index 0000000..956fff1 --- /dev/null +++ b/pages/siswa/ajukan_izin.php @@ -0,0 +1,22 @@ + + +
+
+
+

Form Pengajuan Izin

+
+
+

Halaman ini akan berisi form untuk mengajukan izin keluar sekolah.

+ +
+
+
+ + \ No newline at end of file diff --git a/pages/siswa/dashboard.php b/pages/siswa/dashboard.php new file mode 100644 index 0000000..19be615 --- /dev/null +++ b/pages/siswa/dashboard.php @@ -0,0 +1,23 @@ + + +
+
+
+

Dashboard Siswa

+
+
+
Selamat Datang, !
+

Anda login sebagai Siswa. Di sini Anda dapat mengajukan izin keluar dan melihat riwayat izin Anda.

+ Ajukan Izin Baru +
+
+
+ + \ No newline at end of file diff --git a/templates/footer.php b/templates/footer.php new file mode 100644 index 0000000..87c1e23 --- /dev/null +++ b/templates/footer.php @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/templates/header.php b/templates/header.php new file mode 100644 index 0000000..429e125 --- /dev/null +++ b/templates/header.php @@ -0,0 +1,22 @@ + + + + + + + SIKMS - Sistem Izin Keluar-Masuk Sekolah + + + + + + + + + + + + + + + diff --git a/templates/navbar.php b/templates/navbar.php new file mode 100644 index 0000000..3ef6f4f --- /dev/null +++ b/templates/navbar.php @@ -0,0 +1,49 @@ + + \ No newline at end of file