<?php 
include '../koneksi.php';
cek_akses(['Kepala', 'Super Admin']);

// Ambil parameter dari URL (dikirim dari supervisi_menu.php)
$guru_id = isset($_GET['guru_id']) ? (int)$_GET['guru_id'] : 0;
$guru_nama = isset($_GET['guru_nama']) ? urldecode($_GET['guru_nama']) : '';

// Jika ada guru_id tapi nama kosong, ambil dari database
if($guru_id > 0 && empty($guru_nama)) {
    $query_guru = mysqli_query($conn, "SELECT full_name FROM users WHERE id = $guru_id AND role = 'Guru'");
    if($query_guru && mysqli_num_rows($query_guru) > 0) {
        $guru = mysqli_fetch_assoc($query_guru);
        $guru_nama = $guru['full_name'];
    }
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Formulir Wawancara Pasca Supervisi</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/admin-lte@3.2/dist/css/adminlte.min.css">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="../assets/css/theme-istiqlal-green.css">
    <style>
        .form-container { max-width: 1000px; margin: 0 auto; }
        .section-card { margin-bottom: 20px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
        .section-header { background: #0b5e4e; color: white; padding: 10px 15px; font-weight: 600; }
        .section-body { background: white; padding: 15px; }
        .question-card { background: #f8fafc; border-left: 4px solid #0b5e4e; margin-bottom: 15px; border-radius: 8px; overflow: hidden; }
        .question-number { background: #e0f2fe; padding: 8px 12px; font-weight: bold; color: #0b5e4e; }
        .question-text { padding: 12px; font-weight: 500; }
        .answer-area { padding: 0 12px 12px 12px; }
        @media print { .no-print { display: none !important; } }
    </style>
</head>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">
    <?php include '../sidebar.php'; ?>
    
    <div class="content-wrapper">
        <div class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1 class="m-0" style="font-size: 18px;"><i class="fas fa-comments text-info"></i> FORMULIR WAWANCARA</h1>
                        <small>PASCA SUPERVISI AKADEMIK (F-038-KM)</small>
                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="../dashboard.php">Home</a></li>
                            <li class="breadcrumb-item"><a href="supervisi_menu.php">Supervisi</a></li>
                            <li class="breadcrumb-item active">Wawancara Pasca Supervisi</li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>

        <div class="content">
            <div class="container-fluid form-container">
                <form method="POST" action="cetak_dokumen.php" target="_blank">
                    <input type="hidden" name="form_type" value="wawancara">
                    
                    <!-- Data Guru -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-user"></i> Data Guru</div>
                        <div class="section-body">
                            <div class="row">
                                <div class="col-md-3 mb-2">
                                    <label class="small fw-bold">Nama Guru</label>
                                    <input type="text" name="nama_guru" class="form-control form-control-sm" value="<?= htmlspecialchars($guru_nama) ?>" required>
                                    <?php if($guru_nama): ?>
                                    <small class="text-success d-block">✓ Data otomatis dari jadwal supervisi</small>
                                    <?php endif; ?>
                                </div>
                                <div class="col-md-3 mb-2">
                                    <label class="small fw-bold">Mata Pelajaran</label>
                                    <input type="text" name="mata_pelajaran" class="form-control form-control-sm" required>
                                </div>
                                <div class="col-md-3 mb-2">
                                    <label class="small fw-bold">Kelas</label>
                                    <input type="text" name="kelas" class="form-control form-control-sm" required>
                                </div>
                                <div class="col-md-3 mb-2">
                                    <label class="small fw-bold">Hari/Tanggal</label>
                                    <input type="text" name="hari_tanggal" class="form-control form-control-sm" placeholder="Senin, 25 Mei 2024" required>
                                </div>
                                <div class="col-md-3 mb-2">
                                    <label class="small fw-bold">Waktu</label>
                                    <input type="text" name="waktu" class="form-control form-control-sm" placeholder="09:00 - 10:00 WIB" required>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Pertanyaan Wawancara -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-question-circle"></i> Daftar Pertanyaan Wawancara</div>
                        <div class="section-body">
                            <!-- Pertanyaan 1 -->
                            <div class="question-card">
                                <div class="question-number">Pertanyaan 1</div>
                                <div class="question-text">Bagaimana kesan Saudara setelah menyajikan pelajaran ini? Apakah sudah sesuai dengan yang Saudara rencanakan?</div>
                                <div class="answer-area">
                                    <label class="small fw-bold">Catatan Supervisor</label>
                                    <textarea name="jawaban1" class="form-control form-control-sm" rows="2" placeholder="Tulis catatan hasil wawancara..."></textarea>
                                </div>
                            </div>

                            <!-- Pertanyaan 2 -->
                            <div class="question-card">
                                <div class="question-number">Pertanyaan 2</div>
                                <div class="question-text">Coba Saudara ceritakan hal-hal yang Saudara rasa telah memuaskan dan hal-hal yang kurang memuaskan dalam pembelajaran tadi!</div>
                                <div class="answer-area">
                                    <label class="small fw-bold">Catatan Supervisor</label>
                                    <textarea name="jawaban2" class="form-control form-control-sm" rows="2" placeholder="Tulis catatan hasil wawancara..."></textarea>
                                </div>
                            </div>

                            <!-- Pertanyaan 3 -->
                            <div class="question-card">
                                <div class="question-number">Pertanyaan 3</div>
                                <div class="question-text">Bagaimana perkiraan Saudara mengenai ketercapaian kompetensi siswa?</div>
                                <div class="answer-area">
                                    <label class="small fw-bold">Catatan Supervisor</label>
                                    <textarea name="jawaban3" class="form-control form-control-sm" rows="2" placeholder="Tulis catatan hasil wawancara..."></textarea>
                                </div>
                            </div>

                            <!-- Pertanyaan 4 -->
                            <div class="question-card">
                                <div class="question-number">Pertanyaan 4</div>
                                <div class="question-text">Apa yang menjadi kesulitan siswa?</div>
                                <div class="answer-area">
                                    <label class="small fw-bold">Catatan Supervisor</label>
                                    <textarea name="jawaban4" class="form-control form-control-sm" rows="2" placeholder="Tulis catatan hasil wawancara..."></textarea>
                                </div>
                            </div>

                            <!-- Pertanyaan 5 -->
                            <div class="question-card">
                                <div class="question-number">Pertanyaan 5</div>
                                <div class="question-text">Apa yang menjadi kesulitan Saudara?</div>
                                <div class="answer-area">
                                    <label class="small fw-bold">Catatan Supervisor</label>
                                    <textarea name="jawaban5" class="form-control form-control-sm" rows="2" placeholder="Tulis catatan hasil wawancara..."></textarea>
                                </div>
                            </div>

                            <!-- Pertanyaan 6 -->
                            <div class="question-card">
                                <div class="question-number">Pertanyaan 6</div>
                                <div class="question-text">Bagaimanakah alternatif untuk mengatasi kesulitan itu?</div>
                                <div class="answer-area">
                                    <label class="small fw-bold">Catatan Supervisor</label>
                                    <textarea name="jawaban6" class="form-control form-control-sm" rows="2" placeholder="Tulis catatan hasil wawancara..."></textarea>
                                </div>
                            </div>

                            <!-- Pertanyaan 7 -->
                            <div class="question-card">
                                <div class="question-number">Pertanyaan 7</div>
                                <div class="question-text">Marilah bersama-sama kita identifikasi hal-hal yang telah mantap dan hal-hal yang perlu peningkatan berdasarkan kegiatan yang baru saja Saudara lakukan dan pengamatan saya!</div>
                                <div class="answer-area">
                                    <label class="small fw-bold">Catatan Supervisor</label>
                                    <textarea name="jawaban7" class="form-control form-control-sm" rows="2" placeholder="Tulis catatan hasil wawancara..."></textarea>
                                </div>
                            </div>

                            <!-- Pertanyaan 8 -->
                            <div class="question-card">
                                <div class="question-number">Pertanyaan 8</div>
                                <div class="question-text">Apa yang saudara sarankan untuk dilaksanakan pada pertemuan berikutnya?</div>
                                <div class="answer-area">
                                    <label class="small fw-bold">Catatan Supervisor</label>
                                    <textarea name="jawaban8" class="form-control form-control-sm" rows="2" placeholder="Tulis catatan hasil wawancara..."></textarea>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Catatan Tambahan -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-pen"></i> Catatan Tambahan</div>
                        <div class="section-body">
                            <textarea name="catatan_tambahan" class="form-control form-control-sm" rows="3" placeholder="Tulis catatan tambahan hasil wawancara..."></textarea>
                        </div>
                    </div>

                    <!-- Tanda Tangan -->
                    <div class="section-card">
                        <div class="section-header"><i class="fas fa-signature"></i> Tanda Tangan</div>
                        <div class="section-body">
                            <div class="row">
                                <div class="col-md-4">
                                    <label class="small fw-bold">Mengetahui, Kepala Madrasah</label>
                                    <input type="text" name="kepala_madrasah" class="form-control form-control-sm" placeholder="Nama Kepala Madrasah">
                                </div>
                                <div class="col-md-4">
                                    <label class="small fw-bold">Jakarta, tanggal</label>
                                    <input type="text" name="tanggal_ttd" class="form-control form-control-sm" placeholder="25 Mei 2024" required>
                                </div>
                                <div class="col-md-4">
                                    <label class="small fw-bold">Guru Mata Pelajaran</label>
                                    <input type="text" name="guru_mapel" class="form-control form-control-sm" placeholder="Nama Guru">
                                </div>
                                <div class="col-md-4 mt-2">
                                    <label class="small fw-bold">Penilai / Supervisor</label>
                                    <input type="text" name="supervisor" class="form-control form-control-sm" value="<?= $_SESSION['full_name'] ?>" readonly>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="text-center mb-4 no-print">
                        <button type="submit" class="btn btn-info btn-sm"><i class="fas fa-file-pdf"></i> Simpan & Cetak PDF</button>
                        <button type="button" class="btn btn-secondary btn-sm" onclick="window.print()"><i class="fas fa-print"></i> Print</button>
                        <a href="supervisi_menu.php?guru_id=<?= $guru_id ?>&guru_nama=<?= urlencode($guru_nama) ?>" class="btn btn-outline-secondary btn-sm">
                            <i class="fas fa-arrow-left"></i> Kembali
                        </a>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <footer class="main-footer no-print"><strong>&copy; <?= date('Y') ?> SIM ISTIQLAL</strong></footer>
</div>

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>