[ Mini Kiebo ]
Server: Windows NT AKFAR_SERVER 10.0 build 26200 (Windows 10) AMD64
Path:
D:
/
xampp
/
htdocs
/
repository_afbs
/
admin
/
[
Home
]
File: theses.php
<?php session_start(); require_once '../includes/config.php'; require_once '../includes/database.php'; require_once '../includes/functions.php'; require_once '../includes/auth.php'; if (!isAdmin()) { header('Location: ../login.php'); exit(); } $db = new Database(); $conn = $db->getConnection(); // Handle filter $status = isset($_GET['status']) ? $_GET['status'] : ''; $search = isset($_GET['search']) ? $_GET['search'] : ''; $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; $limit = 20; $offset = ($page - 1) * $limit; // Build query $query = "SELECT t.*, u.full_name, u.nim FROM theses t JOIN users u ON t.author_id = u.id WHERE 1=1"; $countQuery = "SELECT COUNT(*) as total FROM theses t WHERE 1=1"; $params = []; if (!empty($status)) { $query .= " AND t.status = :status"; $countQuery .= " AND status = :status"; $params[':status'] = $status; } if (!empty($search)) { $query .= " AND (t.title LIKE :search OR t.authors LIKE :search OR u.full_name LIKE :search)"; $countQuery .= " AND (title LIKE :search OR authors LIKE :search)"; $params[':search'] = "%$search%"; } $query .= " ORDER BY t.submitted_at DESC LIMIT :limit OFFSET :offset"; // Get total records $stmt = $conn->prepare($countQuery); foreach($params as $key => $value) { $stmt->bindValue($key, $value); } $stmt->execute(); $totalRecords = $stmt->fetch(PDO::FETCH_ASSOC)['total']; $totalPages = ceil($totalRecords / $limit); // Get theses $stmt = $conn->prepare($query); foreach($params as $key => $value) { $stmt->bindValue($key, $value); } $stmt->bindValue(':limit', $limit, PDO::PARAM_INT); $stmt->bindValue(':offset', $offset, PDO::PARAM_INT); $stmt->execute(); $theses = $stmt->fetchAll(PDO::FETCH_ASSOC); $page_title = 'Manajemen Tugas Akhir'; 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">Manajemen Tugas Akhir</h1> <div class="btn-toolbar mb-2 mb-md-0"> <a href="thesis-export.php" class="btn btn-sm btn-outline-secondary me-2"> <i class="fas fa-download"></i> Export </a> <a href="thesis-add.php" class="btn btn-sm btn-primary"> <i class="fas fa-plus"></i> Tambah </a> </div> </div> <!-- Filter --> <div class="card mb-4"> <div class="card-body"> <form method="GET" class="row g-3"> <div class="col-md-4"> <select name="status" class="form-select"> <option value="">Semua Status</option> <option value="pending" <?php echo $status == 'pending' ? 'selected' : ''; ?>>Pending</option> <option value="approved" <?php echo $status == 'approved' ? 'selected' : ''; ?>>Approved</option> <option value="rejected" <?php echo $status == 'rejected' ? 'selected' : ''; ?>>Rejected</option> <option value="revision" <?php echo $status == 'revision' ? 'selected' : ''; ?>>Revision</option> </select> </div> <div class="col-md-6"> <input type="text" name="search" class="form-control" placeholder="Cari judul, penulis..." value="<?php echo htmlspecialchars($search); ?>"> </div> <div class="col-md-2"> <button type="submit" class="btn btn-primary w-100">Filter</button> </div> </form> </div> </div> <!-- Tabel Theses --> <div class="card"> <div class="card-body"> <div class="table-responsive"> <table class="table table-hover"> <thead> <tr> <th>ID</th> <th>Judul</th> <th>Penulis</th> <th>NIM</th> <th>Tahun</th> <th>Status</th> <th>Views</th> <th>Downloads</th> <th>Tanggal</th> <th>Aksi</th> </tr> </thead> <tbody> <?php foreach($theses as $thesis): ?> <tr> <td><?php echo $thesis['id']; ?></td> <td> <a href="thesis-detail.php?id=<?php echo $thesis['id']; ?>"> <?php echo htmlspecialchars(substr($thesis['title'], 0, 50)) . '...'; ?> </a> </td> <td><?php echo htmlspecialchars($thesis['authors']); ?></td> <td><?php echo $thesis['nim']; ?></td> <td><?php echo $thesis['year']; ?></td> <td> <?php $status_class = [ 'pending' => 'warning', 'approved' => 'success', 'rejected' => 'danger', 'revision' => 'info' ]; $class = $status_class[$thesis['status']] ?? 'secondary'; ?> <span class="badge bg-<?php echo $class; ?>"> <?php echo $thesis['status']; ?> </span> </td> <td><?php echo $thesis['views']; ?></td> <td><?php echo $thesis['downloads']; ?></td> <td><?php echo date('d/m/Y', strtotime($thesis['submitted_at'])); ?></td> <td> <div class="btn-group"> <a href="thesis-detail.php?id=<?php echo $thesis['id']; ?>" class="btn btn-sm btn-info"> <i class="fas fa-eye"></i> </a> <a href="thesis-edit.php?id=<?php echo $thesis['id']; ?>" class="btn btn-sm btn-warning"> <i class="fas fa-edit"></i> </a> <?php if($thesis['status'] == 'pending'): ?> <a href="thesis-approve.php?id=<?php echo $thesis['id']; ?>" class="btn btn-sm btn-success"> <i class="fas fa-check"></i> </a> <?php endif; ?> <button onclick="deleteThesis(<?php echo $thesis['id']; ?>)" class="btn btn-sm btn-danger"> <i class="fas fa-trash"></i> </button> </div> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> <!-- Pagination --> <?php if($totalPages > 1): ?> <nav aria-label="Page navigation" class="mt-4"> <ul class="pagination justify-content-center"> <?php for($i = 1; $i <= $totalPages; $i++): ?> <li class="page-item <?php echo $i == $page ? 'active' : ''; ?>"> <a class="page-link" href="?page=<?php echo $i; ?>&status=<?php echo $status; ?>&search=<?php echo urlencode($search); ?>"> <?php echo $i; ?> </a> </li> <?php endfor; ?> </ul> </nav> <?php endif; ?> </div> </div> </main> </div> </div> <script> function deleteThesis(id) { if(confirm('Apakah Anda yakin ingin menghapus tugas akhir ini?')) { window.location.href = 'thesis-delete.php?id=' + id; } } </script> <?php include '../templates/footer.php'; ?>