[ Mini Kiebo ]
Server: Windows NT AKFAR_SERVER 10.0 build 26200 (Windows 10) AMD64
Path:
D:
/
xampp
/
htdocs
/
repository_afbs
/
admin
/
[
Home
]
File: thesis-approve.php
<?php session_start(); require_once '../includes/config.php'; require_once '../includes/database.php'; require_once '../includes/functions.php'; require_once '../includes/auth.php'; require_once '../includes/email.php'; if (!isAdmin()) { header('Location: ../login.php'); exit(); } $db = new Database(); $conn = $db->getConnection(); $id = isset($_GET['id']) ? $_GET['id'] : 0; $action = isset($_GET['action']) ? $_GET['action'] : ''; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $id = $_POST['id']; $status = $_POST['status']; $notes = $_POST['notes'] ?? ''; try { $conn->beginTransaction(); // Update status thesis $query = "UPDATE theses SET status = :status, notes = :notes, reviewed_at = NOW(), approved_by = :admin_id, approved_at = CASE WHEN :status = 'approved' THEN NOW() ELSE NULL END WHERE id = :id"; $stmt = $conn->prepare($query); $stmt->bindParam(':status', $status); $stmt->bindParam(':notes', $notes); $stmt->bindParam(':admin_id', $_SESSION['user_id']); $stmt->bindParam(':id', $id); $stmt->execute(); // Log aktivitas $log_query = "INSERT INTO activities_log (user_id, action_type, thesis_id, description) VALUES (:user_id, :action, :thesis_id, :description)"; $log_stmt = $conn->prepare($log_query); $log_stmt->bindParam(':user_id', $_SESSION['user_id']); $log_stmt->bindParam(':action', $status == 'approved' ? 'approve' : 'reject'); $log_stmt->bindParam(':thesis_id', $id); $desc = $status == 'approved' ? 'Menyetujui tugas akhir' : 'Menolak tugas akhir dengan catatan: ' . $notes; $log_stmt->bindParam(':description', $desc); $log_stmt->execute(); // Kirim email notifikasi $thesis = getThesisData($conn, $id); $user = getUserData($conn, $thesis['author_id']); $subject = $status == 'approved' ? 'Tugas Akhir Disetujui' : 'Tugas Akhir Ditolak'; $message = "Yth. " . $user['full_name'] . ",\n\n"; $message .= "Tugas akhir Anda dengan judul:\n"; $message .= "\"" . $thesis['title'] . "\"\n\n"; if($status == 'approved') { $message .= "Telah DISETUJUI dan sudah dapat diakses di repository.\n"; } else { $message .= "Telah DITOLAK dengan alasan:\n" . $notes . "\n\n"; $message .= "Silakan perbaiki dan upload ulang tugas akhir Anda.\n"; } $message .= "\n\nTerima kasih.\nAdmin Repository AFBS"; sendEmail($user['email'], $subject, $message); $conn->commit(); $_SESSION['success'] = "Tugas akhir berhasil di-" . ($status == 'approved' ? 'setujui' : 'tolak'); header('Location: theses.php'); exit(); } catch(Exception $e) { $conn->rollBack(); $error = "Gagal memproses: " . $e->getMessage(); } } // Ambil data thesis $thesis = getThesisData($conn, $id); if (!$thesis) { header('Location: theses.php'); exit(); } $page_title = 'Approve 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">Review Tugas Akhir</h1> </div> <div class="row"> <div class="col-md-8"> <div class="card mb-4"> <div class="card-header"> <h5>Detail Tugas Akhir</h5> </div> <div class="card-body"> <h4><?php echo htmlspecialchars($thesis['title']); ?></h4> <div class="row mt-4"> <div class="col-md-6"> <p><strong>Penulis:</strong> <?php echo htmlspecialchars($thesis['authors']); ?></p> <p><strong>NIM:</strong> <?php echo $thesis['nim']; ?></p> <p><strong>Tahun:</strong> <?php echo $thesis['year']; ?></p> </div> <div class="col-md-6"> <p><strong>Pembimbing 1:</strong> <?php echo htmlspecialchars($thesis['supervisor1']); ?></p> <p><strong>Pembimbing 2:</strong> <?php echo htmlspecialchars($thesis['supervisor2'] ?? '-'); ?></p> <p><strong>Penguji 1:</strong> <?php echo htmlspecialchars($thesis['examiner1']); ?></p> </div> </div> <div class="mt-3"> <h6>Abstrak:</h6> <p class="text-justify"><?php echo nl2br(htmlspecialchars($thesis['abstract'])); ?></p> </div> <div class="mt-3"> <h6>Kata Kunci:</h6> <p><?php echo htmlspecialchars($thesis['keywords']); ?></p> </div> <div class="mt-3"> <a href="../download.php?id=<?php echo $thesis['id']; ?>" class="btn btn-primary" target="_blank"> <i class="fas fa-file-pdf"></i> Lihat PDF </a> </div> </div> </div> </div> <div class="col-md-4"> <div class="card"> <div class="card-header"> <h5>Review</h5> </div> <div class="card-body"> <?php if(isset($error)): ?> <div class="alert alert-danger"><?php echo $error; ?></div> <?php endif; ?> <form method="POST"> <input type="hidden" name="id" value="<?php echo $thesis['id']; ?>"> <div class="mb-3"> <label class="form-label">Status</label> <div class="form-check"> <input class="form-check-input" type="radio" name="status" id="approve" value="approved" checked> <label class="form-check-label" for="approve"> <span class="badge bg-success">Setujui</span> </label> </div> <div class="form-check"> <input class="form-check-input" type="radio" name="status" id="reject" value="rejected"> <label class="form-check-label" for="reject"> <span class="badge bg-danger">Tolak</span> </label> </div> <div class="form-check"> <input class="form-check-input" type="radio" name="status" id="revision" value="revision"> <label class="form-check-label" for="revision"> <span class="badge bg-info">Revisi</span> </label> </div> </div> <div class="mb-3"> <label for="notes" class="form-label">Catatan Review</label> <textarea class="form-control" id="notes" name="notes" rows="5" placeholder="Masukkan catatan review, alasan penolakan, atau saran revisi..."></textarea> </div> <button type="submit" class="btn btn-primary w-100"> <i class="fas fa-check-circle"></i> Submit Review </button> </form> </div> </div> <div class="card mt-3"> <div class="card-header"> <h5>Informasi Upload</h5> </div> <div class="card-body"> <p><strong>Diupload:</strong><br><?php echo date('d F Y H:i', strtotime($thesis['submitted_at'])); ?></p> <p><strong>Oleh:</strong><br><?php echo htmlspecialchars($thesis['full_name']); ?></p> <p><strong>Email:</strong><br><?php echo $thesis['email']; ?></p> </div> </div> </div> </div> </main> </div> </div> <?php include '../templates/footer.php'; ?> <?php function getThesisData($conn, $id) { $query = "SELECT t.*, u.full_name, u.nim, u.email FROM theses t JOIN users u ON t.author_id = u.id WHERE t.id = :id"; $stmt = $conn->prepare($query); $stmt->bindParam(':id', $id); $stmt->execute(); return $stmt->fetch(PDO::FETCH_ASSOC); } function getUserData($conn, $user_id) { $query = "SELECT * FROM users WHERE id = :id"; $stmt = $conn->prepare($query); $stmt->bindParam(':id', $user_id); $stmt->execute(); return $stmt->fetch(PDO::FETCH_ASSOC); } ?>