[ Mini Kiebo ]
Server: Windows NT AKFAR_SERVER 10.0 build 26200 (Windows 10) AMD64
Path:
D:
/
xampp
/
htdocs
/
repository_afbs
/
admin
/
[
Home
]
File: index.php
<?php session_start(); require_once '../includes/config.php'; require_once '../includes/database.php'; require_once '../includes/functions.php'; require_once '../includes/auth.php'; // Cek akses admin if (!isAdmin()) { header('Location: ../login.php'); exit(); } $db = new Database(); $conn = $db->getConnection(); // Ambil statistik $stats = [ 'total_theses' => getCount($conn, 'theses'), 'pending_theses' => getCount($conn, 'theses', 'status = "pending"'), 'approved_theses' => getCount($conn, 'theses', 'status = "approved"'), 'total_users' => getCount($conn, 'users'), 'total_downloads' => getSum($conn, 'theses', 'downloads'), 'total_views' => getSum($conn, 'theses', 'views') ]; // Ambil aktivitas terbaru $activities = getRecentActivities($conn, 10); $page_title = 'Dashboard Admin'; include '../templates/header.php'; include '../templates/admin-navbar.php'; ?> <div class="container-fluid"> <div class="row"> <?php include '../templates/admin-sidebar.php'; ?> <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4"> <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom"> <h1 class="h2">Dashboard</h1> <div class="btn-toolbar mb-2 mb-md-0"> <span class="text-muted"><?php echo date('d F Y'); ?></span> </div> </div> <!-- Statistik Cards --> <div class="row"> <div class="col-md-4 mb-3"> <div class="card text-white bg-primary"> <div class="card-body"> <h5 class="card-title">Total Tugas Akhir</h5> <h2 class="display-4"><?php echo $stats['total_theses']; ?></h2> <p class="card-text"> <span class="badge bg-warning">Pending: <?php echo $stats['pending_theses']; ?></span> <span class="badge bg-success">Approved: <?php echo $stats['approved_theses']; ?></span> </p> </div> </div> </div> <div class="col-md-4 mb-3"> <div class="card text-white bg-success"> <div class="card-body"> <h5 class="card-title">Total Pengguna</h5> <h2 class="display-4"><?php echo $stats['total_users']; ?></h2> <p class="card-text">Mahasiswa, dosen, dan admin</p> </div> </div> </div> <div class="col-md-4 mb-3"> <div class="card text-white bg-info"> <div class="card-body"> <h5 class="card-title">Interaksi</h5> <h2 class="display-4"><?php echo $stats['total_downloads']; ?></h2> <p class="card-text">Download: <?php echo $stats['total_downloads']; ?> | Views: <?php echo $stats['total_views']; ?></p> </div> </div> </div> </div> <!-- Grafik Statistik --> <div class="row mt-4"> <div class="col-md-8"> <div class="card"> <div class="card-header"> <h5>Statistik Upload per Bulan</h5> </div> <div class="card-body"> <canvas id="thesesChart" height="300"></canvas> </div> </div> </div> <div class="col-md-4"> <div class="card"> <div class="card-header"> <h5>Status Tugas Akhir</h5> </div> <div class="card-body"> <canvas id="statusChart" height="200"></canvas> </div> </div> </div> </div> <!-- Aktivitas Terbaru --> <div class="row mt-4"> <div class="col-md-12"> <div class="card"> <div class="card-header"> <h5>Aktivitas Terbaru</h5> </div> <div class="card-body"> <div class="table-responsive"> <table class="table table-hover"> <thead> <tr> <th>Waktu</th> <th>User</th> <th>Aksi</th> <th>Detail</th> </tr> </thead> <tbody> <?php foreach($activities as $activity): ?> <tr> <td><?php echo waktuLalu($activity['created_at']); ?></td> <td><?php echo $activity['full_name']; ?></td> <td> <?php $badge = ''; switch($activity['action_type']) { case 'upload': $badge = 'bg-primary'; break; case 'download': $badge = 'bg-success'; break; case 'approve': $badge = 'bg-warning'; break; case 'reject': $badge = 'bg-danger'; break; default: $badge = 'bg-secondary'; } ?> <span class="badge <?php echo $badge; ?>"><?php echo $activity['action_type']; ?></span> </td> <td><?php echo $activity['description']; ?></td> </tr> <?php endforeach; ?> </tbody> </table> </div> </div> </div> </div> </div> </main> </div> </div> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <script> // Chart untuk statistik per bulan var ctx = document.getElementById('thesesChart').getContext('2d'); var thesesChart = new Chart(ctx, { type: 'line', data: { labels: ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Agu', 'Sep', 'Okt', 'Nov', 'Des'], datasets: [{ label: 'Jumlah Upload', data: [12, 19, 15, 17, 24, 30, 28, 35, 42, 48, 52, 45], borderColor: 'rgb(75, 192, 192)', backgroundColor: 'rgba(75, 192, 192, 0.2)', tension: 0.1 }] } }); // Chart untuk status var ctx2 = document.getElementById('statusChart').getContext('2d'); var statusChart = new Chart(ctx2, { type: 'doughnut', data: { labels: ['Approved', 'Pending', 'Rejected'], datasets: [{ data: [<?php echo $stats['approved_theses']; ?>, <?php echo $stats['pending_theses']; ?>, 5], backgroundColor: ['#28a745', '#ffc107', '#dc3545'] }] } }); </script> <?php include '../templates/footer.php'; ?> <?php // Fungsi bantuan function getCount($conn, $table, $condition = '1=1') { $query = "SELECT COUNT(*) as total FROM $table WHERE $condition"; $stmt = $conn->prepare($query); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result['total']; } function getSum($conn, $table, $field) { $query = "SELECT SUM($field) as total FROM $table"; $stmt = $conn->prepare($query); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result['total'] ?? 0; } function getRecentActivities($conn, $limit = 10) { $query = "SELECT a.*, u.full_name FROM activities_log a LEFT JOIN users u ON a.user_id = u.id ORDER BY a.created_at DESC LIMIT :limit"; $stmt = $conn->prepare($query); $stmt->bindParam(':limit', $limit, PDO::PARAM_INT); $stmt->execute(); return $stmt->fetchAll(PDO::FETCH_ASSOC); } ?>