403Webshell
Server IP : 127.0.0.1  /  Your IP : 192.168.99.1
Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9
System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64
User : Administrator ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /laragon4/www/bpkd.test_/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /laragon4/www/bpkd.test_/admin//ikm.php
<?php
/**
 * File: admin/ikm.php
 * Halaman Kelola IKM (Indeks Kepuasan Masyarakat) dengan Modal Form
 */

require_once 'config/database.php';
require_once 'includes/init.php';

// Cek login
requireLogin();

$page_title = 'Kelola IKM - ' . ($settings['site_title'] ?? 'Website Instansi');

// =====================================================
// PROSES TAMBAH DATA (via AJAX/Modal)
// =====================================================
$message = '';
$message_type = '';

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    
    if (isset($_POST['action'])) {
        
        // ========== TAMBAH DATA ==========
        if ($_POST['action'] == 'add') {
            $tahun = (int)$_POST['tahun'];
            $judul = sanitize($_POST['judul']);
            $deskripsi = sanitize($_POST['deskripsi']);
            $indeks = !empty($_POST['indeks']) ? (float)$_POST['indeks'] : null;
            $predikat = isset($_POST['predikat']) ? sanitize($_POST['predikat']) : '';
            $status = sanitize($_POST['status']);
            
            // Validasi indeks
            if ($indeks !== null && ($indeks < 0 || $indeks > 100)) {
                $message = "Indeks harus antara 0 - 100";
                $message_type = "danger";
            } else {
                // Upload file PDF
                $file_pdf = '';
                if (isset($_FILES['file_pdf']) && $_FILES['file_pdf']['error'] == 0) {
                    $target_dir = "../uploads/ikm/";
                    if (!file_exists($target_dir)) {
                        mkdir($target_dir, 0777, true);
                    }
                    
                    $file_extension = strtolower(pathinfo($_FILES['file_pdf']['name'], PATHINFO_EXTENSION));
                    if ($file_extension != 'pdf') {
                        $message = "File harus berformat PDF";
                        $message_type = "danger";
                    } elseif ($_FILES['file_pdf']['size'] > 5000000) {
                        $message = "Ukuran file maksimal 5MB";
                        $message_type = "danger";
                    } else {
                        $file_name = 'ikm_' . $tahun . '_' . time() . '.pdf';
                        $target_file = $target_dir . $file_name;
                        
                        if (move_uploaded_file($_FILES['file_pdf']['tmp_name'], $target_file)) {
                            $file_pdf = $file_name;
                        } else {
                            $message = "Gagal mengupload file";
                            $message_type = "danger";
                        }
                    }
                } else {
                    $message = "File PDF wajib diupload";
                    $message_type = "danger";
                }
                
                if (empty($message)) {
                    $query = "INSERT INTO ikm (tahun, judul, deskripsi, file_pdf, indeks, predikat, status) 
                              VALUES (?, ?, ?, ?, ?, ?, ?)";
                    $stmt = $conn->prepare($query);
                    $stmt->bind_param("isssdss", $tahun, $judul, $deskripsi, $file_pdf, $indeks, $predikat, $status);
                    
                    if ($stmt->execute()) {
                        $message = "Data IKM berhasil ditambahkan";
                        $message_type = "success";
                    } else {
                        $message = "Error: " . $stmt->error;
                        $message_type = "danger";
                    }
                    $stmt->close();
                }
            }
        }
        
        // ========== EDIT DATA ==========
        elseif ($_POST['action'] == 'edit') {
            $id = (int)$_POST['id'];
            $tahun = (int)$_POST['tahun'];
            $judul = sanitize($_POST['judul']);
            $deskripsi = sanitize($_POST['deskripsi']);
            $indeks = !empty($_POST['indeks']) ? (float)$_POST['indeks'] : null;
            $predikat = isset($_POST['predikat']) ? sanitize($_POST['predikat']) : '';
            $status = sanitize($_POST['status']);
            
            // Validasi indeks
            if ($indeks !== null && ($indeks < 0 || $indeks > 100)) {
                $message = "Indeks harus antara 0 - 100";
                $message_type = "danger";
            } else {
                // Ambil data lama
                $old_data = $conn->query("SELECT file_pdf FROM ikm WHERE id = $id")->fetch_assoc();
                $file_pdf = $old_data['file_pdf'];
                
                // Upload file PDF baru jika ada
                if (isset($_FILES['file_pdf']) && $_FILES['file_pdf']['error'] == 0 && !empty($_FILES['file_pdf']['name'])) {
                    $target_dir = "../uploads/ikm/";
                    $file_extension = strtolower(pathinfo($_FILES['file_pdf']['name'], PATHINFO_EXTENSION));
                    
                    if ($file_extension != 'pdf') {
                        $message = "File harus berformat PDF";
                        $message_type = "danger";
                    } elseif ($_FILES['file_pdf']['size'] > 5000000) {
                        $message = "Ukuran file maksimal 5MB";
                        $message_type = "danger";
                    } else {
                        $file_name = 'ikm_' . $tahun . '_' . time() . '.pdf';
                        $target_file = $target_dir . $file_name;
                        
                        if (move_uploaded_file($_FILES['file_pdf']['tmp_name'], $target_file)) {
                            // Hapus file lama
                            if (!empty($old_data['file_pdf']) && file_exists($target_dir . $old_data['file_pdf'])) {
                                unlink($target_dir . $old_data['file_pdf']);
                            }
                            $file_pdf = $file_name;
                        } else {
                            $message = "Gagal mengupload file";
                            $message_type = "danger";
                        }
                    }
                }
                
                if (empty($message)) {
                    $query = "UPDATE ikm SET tahun = ?, judul = ?, deskripsi = ?, file_pdf = ?, indeks = ?, predikat = ?, status = ? WHERE id = ?";
                    $stmt = $conn->prepare($query);
                    $stmt->bind_param("isssdssi", $tahun, $judul, $deskripsi, $file_pdf, $indeks, $predikat, $status, $id);
                    
                    if ($stmt->execute()) {
                        $message = "Data IKM berhasil diupdate";
                        $message_type = "success";
                    } else {
                        $message = "Error: " . $stmt->error;
                        $message_type = "danger";
                    }
                    $stmt->close();
                }
            }
        }
        
        // ========== HAPUS DATA ==========
        elseif ($_POST['action'] == 'delete') {
            $id = (int)$_POST['id'];
            
            // Ambil file PDF untuk dihapus
            $data = $conn->query("SELECT file_pdf FROM ikm WHERE id = $id")->fetch_assoc();
            if ($data && !empty($data['file_pdf']) && file_exists("../uploads/ikm/" . $data['file_pdf'])) {
                unlink("../uploads/ikm/" . $data['file_pdf']);
            }
            
            if ($conn->query("DELETE FROM ikm WHERE id = $id")) {
                $message = "Data IKM berhasil dihapus";
                $message_type = "success";
            } else {
                $message = "Error: " . $conn->error;
                $message_type = "danger";
            }
        }
    }
}

// Pagination
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$limit = 10;
$offset = ($page - 1) * $limit;

// Filter
$tahun_filter = isset($_GET['tahun']) ? (int)$_GET['tahun'] : 0;
$status_filter = isset($_GET['status']) ? sanitize($_GET['status']) : '';
$search = isset($_GET['search']) ? sanitize($_GET['search']) : '';

// Build query
$where = [];
$params = [];
$types = "";

if ($tahun_filter > 0) {
    $where[] = "tahun = ?";
    $params[] = $tahun_filter;
    $types .= "i";
}
if (!empty($status_filter)) {
    $where[] = "status = ?";
    $params[] = $status_filter;
    $types .= "s";
}
if (!empty($search)) {
    $where[] = "(judul LIKE ? OR deskripsi LIKE ?)";
    $params[] = "%$search%";
    $params[] = "%$search%";
    $types .= "ss";
}

$where_clause = !empty($where) ? "WHERE " . implode(" AND ", $where) : "";

// Get total records
$total_sql = "SELECT COUNT(*) as total FROM ikm $where_clause";
if (!empty($params)) {
    $stmt = $conn->prepare($total_sql);
    $stmt->bind_param($types, ...$params);
    $stmt->execute();
    $total_result = $stmt->get_result();
    $total_records = $total_result->fetch_assoc()['total'];
    $stmt->close();
} else {
    $total_result = $conn->query($total_sql);
    $total_records = $total_result->fetch_assoc()['total'];
}
$total_pages = ceil($total_records / $limit);

// Get data
$sql = "SELECT * FROM ikm $where_clause ORDER BY tahun DESC, created_at DESC LIMIT ? OFFSET ?";
$params[] = $limit;
$params[] = $offset;
$types .= "ii";

$stmt = $conn->prepare($sql);
$stmt->bind_param($types, ...$params);
$stmt->execute();
$ikm_list = $stmt->get_result();

// Ambil daftar tahun untuk filter
$tahun_list = $conn->query("SELECT DISTINCT tahun FROM ikm ORDER BY tahun DESC");

include 'includes/header.php';
?>

<style>
/* Admin IKM Styles */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid #eef2f6; }
.admin-table th { background: #f8fafc; font-weight: 600; color: #1e293b; }
.admin-table tr:hover { background: #f8fafc; }
.status-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 0.7rem; font-weight: 600; }
.status-publish { background: #dcfce7; color: #15803d; }
.status-draft { background: #fef3c7; color: #b45309; }
.btn-action { padding: 5px 10px; border-radius: 8px; text-decoration: none; margin: 0 3px; display: inline-flex; align-items: center; gap: 5px; font-size: 0.8rem; cursor: pointer; border: none; }
.btn-edit { background: #fef3c7; color: #b45309; }
.btn-delete { background: #fee2e2; color: #dc2626; }
.btn-view { background: #dbeafe; color: #1d4ed8; }
.filter-section { background: #f8fafc; padding: 20px; border-radius: 12px; margin-bottom: 24px; }
.filter-form { display: flex; flex-wrap: wrap; gap: 15px; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 5px; }
.filter-group label { font-size: 0.75rem; font-weight: 600; color: #475569; }
.filter-group select, .filter-group input { padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 8px; min-width: 150px; }
.btn-filter { padding: 8px 20px; background: #3b82f6; color: white; border: none; border-radius: 8px; cursor: pointer; }
.btn-reset { padding: 8px 20px; background: #e2e8f0; color: #475569; border: none; border-radius: 8px; text-decoration: none; }

/* Modal Styles */
.modal-xl { max-width: 800px; }
.modal-header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
.modal-header .btn-close { filter: invert(1); }
.form-group { margin-bottom: 20px; }
.form-group label { font-weight: 600; margin-bottom: 8px; display: block; }
.form-control { width: 100%; padding: 10px 15px; border: 1px solid #e2e8f0; border-radius: 10px; }
textarea.form-control { resize: vertical; min-height: 80px; }
.current-file { background: #f1f5f9; padding: 10px; border-radius: 8px; margin-top: 5px; font-size: 0.8rem; }
</style>

<div class="container-fluid">
    <div class="d-sm-flex align-items-center justify-content-between mb-4">
        <h1 class="h3 mb-0 text-gray-800">
            <i class="fas fa-chart-line me-2"></i> Kelola IKM
        </h1>
        <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#modalAdd">
            <i class="fas fa-plus me-2"></i> Tambah IKM
        </button>
    </div>

    <!-- Alert Message -->
    <?php if (!empty($message)): ?>
        <div class="alert alert-<?php echo $message_type; ?> alert-dismissible fade show" role="alert">
            <i class="fas fa-<?php echo $message_type == 'success' ? 'check-circle' : 'exclamation-triangle'; ?> me-2"></i>
            <?php echo $message; ?>
            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        </div>
    <?php endif; ?>

    <!-- Filter Section -->
    <div class="filter-section">
        <form method="GET" class="filter-form">
            <div class="filter-group">
                <label>Tahun</label>
                <select name="tahun">
                    <option value="">Semua Tahun</option>
                    <?php while($t = $tahun_list->fetch_assoc()): ?>
                        <option value="<?php echo $t['tahun']; ?>" <?php echo $tahun_filter == $t['tahun'] ? 'selected' : ''; ?>>
                            <?php echo $t['tahun']; ?>
                        </option>
                    <?php endwhile; ?>
                </select>
            </div>
            <div class="filter-group">
                <label>Status</label>
                <select name="status">
                    <option value="">Semua Status</option>
                    <option value="publish" <?php echo $status_filter == 'publish' ? 'selected' : ''; ?>>Publish</option>
                    <option value="draft" <?php echo $status_filter == 'draft' ? 'selected' : ''; ?>>Draft</option>
                </select>
            </div>
            <div class="filter-group">
                <label>Cari</label>
                <input type="text" name="search" placeholder="Judul..." value="<?php echo htmlspecialchars($search); ?>">
            </div>
            <div class="filter-group">
                <button type="submit" class="btn-filter"><i class="fas fa-search me-1"></i> Filter</button>
            </div>
            <div class="filter-group">
                <a href="ikm.php" class="btn-reset"><i class="fas fa-undo me-1"></i> Reset</a>
            </div>
        </form>
    </div>

    <!-- Table Data -->
    <div class="card shadow">
        <div class="card-body">
            <div class="table-responsive">
                <table class="admin-table">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>Tahun</th>
                            <th>Judul</th>
                            <th>Indeks</th>
                            <th>Predikat</th>
                            <th>File PDF</th>
                            <th>Status</th>
                            <th>Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php if ($ikm_list && $ikm_list->num_rows > 0): ?>
                            <?php while($row = $ikm_list->fetch_assoc()): ?>
                                <tr>
                                    <td><?php echo $row['id']; ?></td>
                                    <td><?php echo $row['tahun']; ?></td>
                                    <td><?php echo htmlspecialchars($row['judul']); ?></td>
                                    <td><?php echo $row['indeks'] ? number_format($row['indeks'], 2) : '-'; ?></td>
                                    <td><?php echo htmlspecialchars($row['predikat'] ?? '-'); ?></td>
                                    <td>
                                        <?php if($row['file_pdf']): ?>
                                            <a href="../uploads/ikm/<?php echo $row['file_pdf']; ?>" target="_blank" class="btn-view" style="padding: 3px 8px; border-radius: 5px; text-decoration: none;">
                                                <i class="fas fa-file-pdf"></i> Lihat
                                            </a>
                                        <?php else: ?>
                                            <span class="text-muted">-</span>
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <span class="status-badge status-<?php echo $row['status']; ?>">
                                            <?php echo $row['status'] == 'publish' ? 'Publish' : 'Draft'; ?>
                                        </span>
                                    </td>
                                    <td>
                                        <button class="btn-action btn-edit" onclick="editIKM(<?php echo $row['id']; ?>)">
                                            <i class="fas fa-edit"></i>
                                        </button>
                                        <button class="btn-action btn-delete" onclick="deleteIKM(<?php echo $row['id']; ?>)">
                                            <i class="fas fa-trash"></i>
                                        </button>
                                    </td>
                                </tr>
                            <?php endwhile; ?>
                        <?php else: ?>
                            <tr>
                                <td colspan="8" class="text-center py-5">Belum ada data IKM</td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>

            <!-- Pagination -->
            <?php if ($total_pages > 1): ?>
            <nav class="mt-4">
                <ul class="pagination justify-content-center">
                    <li class="page-item <?php echo $page <= 1 ? 'disabled' : ''; ?>">
                        <a class="page-link" href="?page=<?php echo $page-1; ?>&tahun=<?php echo $tahun_filter; ?>&status=<?php echo $status_filter; ?>&search=<?php echo urlencode($search); ?>">« Prev</a>
                    </li>
                    <?php for($i = 1; $i <= $total_pages; $i++): ?>
                        <li class="page-item <?php echo $i == $page ? 'active' : ''; ?>">
                            <a class="page-link" href="?page=<?php echo $i; ?>&tahun=<?php echo $tahun_filter; ?>&status=<?php echo $status_filter; ?>&search=<?php echo urlencode($search); ?>"><?php echo $i; ?></a>
                        </li>
                    <?php endfor; ?>
                    <li class="page-item <?php echo $page >= $total_pages ? 'disabled' : ''; ?>">
                        <a class="page-link" href="?page=<?php echo $page+1; ?>&tahun=<?php echo $tahun_filter; ?>&status=<?php echo $status_filter; ?>&search=<?php echo urlencode($search); ?>">Next »</a>
                    </li>
                </ul>
            </nav>
            <?php endif; ?>
        </div>
    </div>
</div>

<!-- ===================================================== -->
<!-- MODAL TAMBAH IKM -->
<!-- ===================================================== -->
<div class="modal fade" id="modalAdd" tabindex="-1">
    <div class="modal-dialog modal-xl">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">
                    <i class="fas fa-plus me-2"></i> Tambah IKM
                </h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <form method="POST" enctype="multipart/form-data" id="formAdd">
                <div class="modal-body">
                    <input type="hidden" name="action" value="add">
                    
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label>Tahun <span class="text-danger">*</span></label>
                                <select name="tahun" class="form-control" required>
                                    <option value="">Pilih Tahun</option>
                                    <?php for($y = date('Y'); $y >= 2020; $y--): ?>
                                        <option value="<?php echo $y; ?>"><?php echo $y; ?></option>
                                    <?php endfor; ?>
                                </select>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label>Status</label>
                                <select name="status" class="form-control">
                                    <option value="draft">Draft</option>
                                    <option value="publish">Publish</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label>Judul <span class="text-danger">*</span></label>
                        <input type="text" name="judul" class="form-control" required>
                    </div>
                    
                    <div class="form-group">
                        <label>Deskripsi</label>
                        <textarea name="deskripsi" class="form-control" placeholder="Deskripsi singkat..."></textarea>
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label>File PDF <span class="text-danger">*</span></label>
                                <input type="file" name="file_pdf" class="form-control" accept=".pdf" required>
                                <small class="text-muted">Maksimal 5MB, format PDF</small>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label>Indeks (0-100)</label>
                                <input type="number" name="indeks" class="form-control" step="0.01" min="0" max="100" placeholder="Contoh: 85.50">
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label>Predikat</label>
                                <select name="predikat" class="form-control">
                                    <option value="">Pilih Predikat</option>
                                    <option value="Sangat Baik">Sangat Baik (81-100)</option>
                                    <option value="Baik">Baik (61-80)</option>
                                    <option value="Cukup Baik">Cukup Baik (41-60)</option>
                                    <option value="Kurang Baik">Kurang Baik (21-40)</option>
                                    <option value="Tidak Baik">Tidak Baik (0-20)</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
            </form>
        </div>
    </div>
</div>

<!-- ===================================================== -->
<!-- MODAL EDIT IKM -->
<!-- ===================================================== -->
<div class="modal fade" id="modalEdit" tabindex="-1">
    <div class="modal-dialog modal-xl">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">
                    <i class="fas fa-edit me-2"></i> Edit IKM
                </h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <form method="POST" enctype="multipart/form-data" id="formEdit">
                <div class="modal-body">
                    <input type="hidden" name="action" value="edit">
                    <input type="hidden" name="id" id="edit_id">
                    
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label>Tahun <span class="text-danger">*</span></label>
                                <select name="tahun" id="edit_tahun" class="form-control" required>
                                    <option value="">Pilih Tahun</option>
                                    <?php for($y = date('Y'); $y >= 2020; $y--): ?>
                                        <option value="<?php echo $y; ?>"><?php echo $y; ?></option>
                                    <?php endfor; ?>
                                </select>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label>Status</label>
                                <select name="status" id="edit_status" class="form-control">
                                    <option value="draft">Draft</option>
                                    <option value="publish">Publish</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label>Judul <span class="text-danger">*</span></label>
                        <input type="text" name="judul" id="edit_judul" class="form-control" required>
                    </div>
                    
                    <div class="form-group">
                        <label>Deskripsi</label>
                        <textarea name="deskripsi" id="edit_deskripsi" class="form-control"></textarea>
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label>File PDF</label>
                                <input type="file" name="file_pdf" class="form-control" accept=".pdf">
                                <div class="current-file" id="edit_file_current"></div>
                                <small class="text-muted">Kosongkan jika tidak ingin mengubah file</small>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label>Indeks (0-100)</label>
                                <input type="number" name="indeks" id="edit_indeks" class="form-control" step="0.01" min="0" max="100" placeholder="Contoh: 85.50">
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label>Predikat</label>
                                <select name="predikat" id="edit_predikat" class="form-control">
                                    <option value="">Pilih Predikat</option>
                                    <option value="Sangat Baik">Sangat Baik (81-100)</option>
                                    <option value="Baik">Baik (61-80)</option>
                                    <option value="Cukup Baik">Cukup Baik (41-60)</option>
                                    <option value="Kurang Baik">Kurang Baik (21-40)</option>
                                    <option value="Tidak Baik">Tidak Baik (0-20)</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
                    <button type="submit" class="btn btn-primary">Update</button>
                </div>
            </form>
        </div>
    </div>
</div>

<!-- ===================================================== -->
<!-- MODAL HAPUS IKM -->
<!-- ===================================================== -->
<div class="modal fade" id="modalDelete" tabindex="-1">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header bg-danger text-white">
                <h5 class="modal-title">
                    <i class="fas fa-trash me-2"></i> Hapus IKM
                </h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <form method="POST" id="formDelete">
                <div class="modal-body">
                    <input type="hidden" name="action" value="delete">
                    <input type="hidden" name="id" id="delete_id">
                    <p>Apakah Anda yakin ingin menghapus data IKM ini?</p>
                    <p class="text-danger"><small>Tindakan ini tidak dapat dibatalkan!</small></p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
                    <button type="submit" class="btn btn-danger">Hapus</button>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
// Edit IKM - Load data via AJAX
function editIKM(id) {
    // Fetch data via AJAX
    fetch('ikm_get.php?id=' + id)
        .then(response => response.json())
        .then(data => {
            if (data.success) {
                document.getElementById('edit_id').value = data.id;
                document.getElementById('edit_tahun').value = data.tahun;
                document.getElementById('edit_judul').value = data.judul;
                document.getElementById('edit_deskripsi').value = data.deskripsi;
                document.getElementById('edit_indeks').value = data.indeks;
                document.getElementById('edit_predikat').value = data.predikat;
                document.getElementById('edit_status').value = data.status;
                document.getElementById('edit_file_current').innerHTML = '<i class="fas fa-file-pdf"></i> File saat ini: ' + data.file_pdf;
                
                // Show modal
                new bootstrap.Modal(document.getElementById('modalEdit')).show();
            } else {
                alert('Gagal mengambil data');
            }
        })
        .catch(error => {
            console.error('Error:', error);
            alert('Terjadi kesalahan');
        });
}

// Delete IKM
function deleteIKM(id) {
    document.getElementById('delete_id').value = id;
    new bootstrap.Modal(document.getElementById('modalDelete')).show();
}
</script>

<?php require_once 'includes/footer.php'; ?>

Youez - 2016 - github.com/yon3zu
LinuXploit