Update UI Login dan Perbaikan Routing

This commit is contained in:
2026-06-11 14:17:09 +07:00
parent 02563d05d5
commit 4cbbd3c718
3 changed files with 151 additions and 149 deletions
+27 -8
View File
@@ -4,16 +4,26 @@
// ============================================================
session_start();
// Cek apakah sudah login
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
$currentUser = $_SESSION['username'];
$currentRole = $_SESSION['role'];
$modul = $_GET['modul'] ?? 'utuh';
// TAHAP 1: Modul publik diizinkan tanpa login
$public_modules = ['spbu', 'tematik', 'digitasi'];
$is_public_access = in_array($modul, $public_modules);
if ($is_public_access) {
// Jika akses publik, berikan role petugas agar pengunjung dapat mengedit data
$currentUser = $_SESSION['username'] ?? 'Pengunjung Kelas';
$currentRole = $_SESSION['role'] ?? 'petugas';
} else {
// Modul privat wajib login
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
$currentUser = $_SESSION['username'];
$currentRole = $_SESSION['role'];
}
include 'koneksi.php';
// Eksekusi ALTER TABLE secara diam-diam jika kolom belum ada
@@ -170,10 +180,17 @@ $spbuTidak = $totalSPBU - $spbu24;
============================================================ -->
<aside class="sidebar" id="sidebar">
<div class="sidebar-top-sticky" id="sidebarSticky">
<?php if (!isset($_SESSION['user_id'])): ?>
<a href="login.php" class="btn-back-dashboard" style="display:flex;align-items:center;gap:8px;padding:12px 16px;color:#e11d48;background:rgba(225,29,72,0.03);text-decoration:none;border-bottom:1px solid rgba(225,29,72,0.1);transition:all 0.3s;font-size:0.85rem;font-weight:700;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"></path></svg>
Masuk Aplikasi Kemiskinan
</a>
<?php else: ?>
<a href="dashboard.php" class="btn-back-dashboard" style="display:flex;align-items:center;gap:8px;padding:12px 16px;color:var(--sidebar-text);text-decoration:none;border-bottom:1px solid var(--sidebar-border);transition:all 0.3s;font-size:0.85rem;font-weight:600;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M19 12H5M12 19l-7-7 7-7"/></svg>
Kembali ke Dashboard
</a>
<?php endif; ?>
<!-- Header Sidebar -->
<div class="sidebar-header">
@@ -218,6 +235,7 @@ $modulTitle = $modulNames[$modul] ?? 'Analisis Spasial';
<span class="user-role"><?= ucfirst($currentRole) ?></span>
</div>
</div>
<?php if (isset($_SESSION['user_id'])): ?>
<a href="logout.php" class="btn-logout" title="Logout">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/>
@@ -225,6 +243,7 @@ $modulTitle = $modulNames[$modul] ?? 'Analisis Spasial';
<line x1="21" y1="12" x2="9" y2="12"/>
</svg>
</a>
<?php endif; ?>
</div>