<?php $__env->startSection('content'); ?>

<style>
    /* --- HANYA CSS SPESIFIK HALAMAN INI (Penilaian) --- */
    /* Warna elemen standar sudah diatur secara terpusat di app.blade.php */

    .modern-card {
        border-radius: 20px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    [data-theme="dark"] .modern-card {
        background-color: var(--bg-card, #1e293b);
        border: 1px solid var(--border-color, #334155);
    }

    /* Custom Table Header untuk Penilaian */
    .table-header-soft {
        background-color: var(--hover-bg);
        color: var(--text-muted);
        font-size: 0.85rem;
        text-transform: uppercase;
        font-weight: 700;
        letter-spacing: 0.5px;
    }
    [data-theme="dark"] .table-header-soft { color: var(--text-main); border-color: var(--border-color) !important; }

    /* Styling Accordion Modern */
    .accordion-penilaian .accordion-item {
        border: 1px solid var(--border-color, #dee2e6);
        border-radius: 16px !important;
        margin-bottom: 20px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.05);
        overflow: hidden;
        background-color: transparent;
    }
    .accordion-penilaian .accordion-button {
        font-size: 1.05rem;
        padding: 1.25rem 1.5rem;
    }
    .accordion-penilaian .accordion-button:not(.collapsed) {
        background-color: rgba(59, 130, 246, 0.05);
        color: var(--primary-color, #3b82f6);
        box-shadow: none;
        border-bottom: 1px solid var(--border-color, #334155);
    }
    .accordion-penilaian .accordion-body { padding: 0; }
    
    [data-theme="dark"] .accordion-penilaian .accordion-item { background-color: var(--bg-card); border-color: var(--border-color); }
    [data-theme="dark"] .accordion-penilaian .accordion-button { background-color: var(--bg-card); color: var(--text-main); }
    [data-theme="dark"] .accordion-penilaian .accordion-button:not(.collapsed) { background-color: var(--hover-bg); color: #6ea8fe; border-bottom: 1px solid var(--border-color); }
    [data-theme="dark"] .accordion-penilaian .accordion-button::after { filter: invert(1); }
    [data-theme="dark"] .accordion-penilaian .accordion-body { background-color: var(--bg-card); }
    
    /* Helper Kustom Tambahan */
    .bg-inner-card { background-color: var(--hover-bg); }
    .btn-pill { border-radius: 50rem !important; }
</style>

<div class="container py-4">
    
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h2 class="fw-bold"><i class="bi bi-award me-2 text-primary"></i>Manajemen Penilaian</h2>
            <p class="text-muted mb-0">Kelola nilai siswa, dikelompokkan per kelas dan mapel.</p>
        </div>
        <div class="d-flex gap-2">
            <button type="button" class="btn btn-outline-secondary btn-pill px-4 shadow-sm" id="btnCetak" onclick="submitCetak()" disabled>
                <i class="bi bi-printer me-1"></i> Cetak Terpilih
            </button>
            <button type="button" class="btn btn-primary btn-pill px-4 fw-bold shadow-sm" onclick="openModalCreate()">
                <i class="bi bi-plus-circle me-1"></i> Buat Penilaian
            </button>
        </div>
    </div>

    
    <div class="card modern-card shadow-sm mb-4">
        <div class="card-body py-3 px-4 d-flex align-items-center">
            <div class="form-check m-0">
                <input class="form-check-input mt-1" style="cursor:pointer; width:1.3rem; height:1.3rem;" type="checkbox" id="checkAllGlobal">
                <label class="form-check-label fw-bold ms-3 text-primary" for="checkAllGlobal" style="cursor: pointer; padding-top: 0.1rem;">
                    Pilih Semua Data Penilaian
                </label>
            </div>
        </div>
    </div>

    
    <div class="accordion accordion-penilaian" id="accordionPenilaian">
        <?php $__empty_1 = true; $__currentLoopData = $penilaians; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $namaKelas => $mapelGroup): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <div class="accordion-item shadow-sm">
                <h2 class="accordion-header" id="heading-<?php echo e($loop->index); ?>">
                    <button class="accordion-button fw-bold collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse-<?php echo e($loop->index); ?>" aria-expanded="false" aria-controls="collapse-<?php echo e($loop->index); ?>">
                        <div class="d-flex align-items-center w-100">
                            <div class="bg-primary bg-opacity-10 text-primary rounded-circle d-flex align-items-center justify-content-center me-3" style="width: 40px; height: 40px;">
                                <i class="bi bi-door-open-fill"></i> 
                            </div>
                            <span class="fs-5">Kelas <?php echo e($namaKelas); ?></span>
                        </div>
                    </button>
                </h2>
                <div id="collapse-<?php echo e($loop->index); ?>" class="accordion-collapse collapse" aria-labelledby="heading-<?php echo e($loop->index); ?>">
                    <div class="accordion-body">
                        <?php $__currentLoopData = $mapelGroup; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $namaMapel => $jenisGroup): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="p-4 border-bottom last-no-border bg-inner-card">
                                
                                <h6 class="fw-bold mb-4 text-uppercase d-flex align-items-center" style="letter-spacing: 0.5px;">
                                    <i class="bi bi-journal-bookmark-fill me-2 text-warning fs-5"></i> <?php echo e($namaMapel); ?>

                                </h6>

                                <?php $__currentLoopData = $jenisGroup; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $jenisPenilaian => $dataItems): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    
                                    <div class="mb-4 ps-4 border-start border-4 border-info">
                                        <div class="d-flex align-items-center mb-3 justify-content-between">
                                            <div>
                                                <span class="badge bg-info bg-opacity-10 text-info border border-info-subtle rounded-pill px-3 py-2">
                                                    <?php echo e($jenisPenilaian); ?>

                                                </span>
                                                <small class="text-muted ms-2 fw-medium">(<?php echo e($dataItems->count()); ?> Data)</small>
                                            </div>
                                        </div>

                                        
                                        <div class="table-responsive rounded-4 border overflow-hidden">
                                            <table class="table table-hover align-middle mb-0">
                                                <thead class="table-header-soft">
                                                    <tr>
                                                        <th width="5%" class="text-center py-3">
                                                            <input type="checkbox" class="form-check-input checkAll-group mt-1" style="cursor:pointer; width:1.1rem; height:1.1rem;" title="Pilih Semua di Grup Ini">
                                                        </th>
                                                        <th width="15%" class="py-3 px-3">Hari, Tanggal</th>
                                                        <th width="8%" class="py-3">Skala</th>
                                                        <th class="py-3">Topik / Judul</th>
                                                        <th width="15%" class="text-end pe-4 py-3">Aksi</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <?php $__currentLoopData = $dataItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <tr>
                                                        <td class="text-center">
                                                            <input type="checkbox" class="form-check-input check-item" style="cursor:pointer; width:1.1rem; height:1.1rem;" value="<?php echo e($p->id); ?>">
                                                        </td>
                                                        <td class="fw-medium small px-3">
                                                            <?php echo e(\Carbon\Carbon::parse($p->tanggal)->locale('id')->translatedFormat('l, d F Y')); ?>

                                                        </td>
                                                        <td>
                                                            <span class="badge bg-secondary bg-opacity-10 text-muted border border-secondary-subtle rounded-pill">
                                                                <?php echo e(ucfirst($p->skala_penilaian ?? 'angka')); ?>

                                                            </span>
                                                        </td>
                                                        <td class="fw-bold"><?php echo e($p->topik ?? '-'); ?>

                                                            <span class="badge bg-success bg-opacity-10 text-success border border-success-subtle rounded-pill px-3 ms-2">
                                                                <i class="bi bi-person-check-fill me-1"></i> Dinilai : 
                                                                <?php echo e($p->details_count); ?> orang
                                                            </span>                                                        
                                                        </td>
                                                        <td class="text-end pe-4">
                                                            <div class="d-flex justify-content-end gap-2">
                                                                <button class="btn btn-sm btn-outline-warning rounded-circle" style="width:35px; height:35px;" onclick="editPenilaian(<?php echo e($p->id); ?>)" title="Edit">
                                                                    <i class="bi bi-pencil-square"></i>
                                                                </button>
                                                                <form action="<?php echo e(route('penilaian.destroy', $p->id)); ?>" method="POST" onsubmit="return confirm('Hapus penilaian ini?')" style="display:inline;">
                                                                    <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                                                    <button type="submit" class="btn btn-sm btn-outline-danger rounded-circle" style="width:35px; height:35px;" title="Hapus">
                                                                        <i class="bi bi-trash"></i>
                                                                    </button>
                                                                </form>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                </div>
            </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            
            <div class="card modern-card border-0 py-5 text-center">
                <div class="card-body">
                    <div class="text-muted opacity-50 mb-3">
                        <i class="bi bi-clipboard-data" style="font-size: 4rem;"></i>
                    </div>
                    <h5 class="fw-bold">Belum ada data penilaian.</h5>
                    <p class="text-muted mb-4">Silakan klik tombol di bawah untuk mulai merekap nilai.</p>
                    <button type="button" class="btn btn-primary btn-pill px-4 fw-bold shadow-sm" onclick="openModalCreate()">
                        <i class="bi bi-plus-circle me-1"></i> Buat Penilaian
                    </button>
                </div>
            </div>
        <?php endif; ?>
    </div>
</div>


<div class="modal fade" id="modalForm" tabindex="-1" aria-hidden="true">
    <div class="modal-dialog modal-lg modal-dialog-scrollable modal-dialog-centered">
        
        
        <div class="modal-content shadow-lg border-0 rounded-4">
            
            <form action="<?php echo e(route('penilaian.store')); ?>" method="POST" id="formPenilaian">
                <?php echo csrf_field(); ?>
                <div id="methodPut"></div>

                <div class="modal-header bg-primary border-0 rounded-top-4 py-3 text-white">
                    <h5 class="modal-title fw-bold" id="modalTitle"><i class="bi bi-pencil-square me-2"></i> Buat Penilaian Baru</h5>
                    <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                
                
                <div class="modal-body p-4">
                    <div class="row g-3">
                        
                        <div class="col-md-6 mb-2">
                            <label class="form-label small text-muted text-uppercase fw-bold">Mata Pelajaran</label>
                            <select name="subject_id" id="inputMapel" class="form-select rounded-pill py-2" required onchange="loadClasses()">
                                <option value="">-- Pilih Mapel --</option>
                                <?php $__currentLoopData = $subjects; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($s->id); ?>"><?php echo e($s->name); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>

                        <div class="col-md-6 mb-2">
                            <label class="form-label small text-muted text-uppercase fw-bold">Kelas</label>
                            <select name="kelas_id" id="inputKelas" class="form-select rounded-pill py-2" required>
                                <option value="">-- Pilih Mapel Dulu --</option>
                            </select>
                        </div>

                        <div class="col-md-6 mb-2">
                            <label class="form-label small text-muted text-uppercase fw-bold">Tanggal</label>
                            <input type="date" name="tanggal" id="inputTanggal" class="form-control rounded-pill py-2" value="<?php echo e(date('Y-m-d')); ?>" required>
                        </div>
                        <div class="col-md-6 mb-2">
                            <label class="form-label small text-muted text-uppercase fw-bold">Jenis Penilaian</label>
                            <select name="jenis_penilaian" id="inputJenis" class="form-select rounded-pill py-2" required>
                                <option value="Harian">Penilaian Harian</option>
                                <option value="Sumatif">Sumatif</option>
                                <option value="Formatif">Formatif</option>
                                <option value="Projek">Projek</option>
                                <option value="Praktik">Praktik</option>
                            </select>
                        </div>
                        <div class="col-md-6 mb-2">
                            <label class="form-label small text-muted text-uppercase fw-bold">Skala Penilaian</label>
                            <select name="skala_penilaian" id="inputSkala" class="form-select rounded-pill py-2 border-primary" required>
                                <option value="angka">Angka (0 - 100)</option>
                                <option value="huruf">Huruf (A - E)</option>
                            </select>
                            <small class="text-danger d-none mt-1" id="msgSkalaLocked"><i class="bi bi-lock-fill"></i> Terkunci saat Edit</small>
                        </div>
                        <div class="col-md-12 mb-2">
                            <label class="form-label small text-muted text-uppercase fw-bold">Topik / Judul</label>
                            <input type="text" name="topik" id="inputTopik" class="form-control rounded-pill py-2" placeholder="Contoh: PH 1 Listrik Dinamis" required>
                        </div>
                    </div>

                    <div class="my-4 border-top"></div>
                    
                    <div class="d-grid gap-2 mb-4" id="divTombolLoad">
                        <button type="button" id="btnLoadSiswa" class="btn btn-outline-primary btn-pill py-2 fw-bold shadow-sm">
                            <i class="bi bi-people-fill me-2"></i> Load Data Siswa & Input Nilai
                        </button>
                    </div>

                    <div id="areaInputNilai" style="display: none;" class="mb-2">
                        <h6 class="fw-bold mb-3 text-primary"><i class="bi bi-pencil-square me-2"></i>Input Nilai Siswa</h6>
                        
                        
                        <div class="table-responsive border border-secondary rounded-4 bg-inner-card" style="max-height: 40vh; overflow-y: auto;">
                            <table class="table table-hover align-middle mb-0">
                                
                                
                                <thead class="table-secondary sticky-top shadow-sm" style="z-index: 2;">
                                    <tr>
                                        <th class="ps-4 py-3 border-0">Nama Siswa</th>
                                        <th width="35%" class="py-3 pe-4 border-0">Nilai</th>
                                    </tr>
                                </thead>
                                
                                <tbody id="tabelSiswaBody"></tbody>
                            </table>
                            
                            
                            <div style="height: 20px; width: 100%; background-color: transparent;"></div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer border-0 py-3 bg-inner-card rounded-bottom-4">
                    <button type="button" class="btn btn-outline-secondary btn-pill px-4" data-bs-dismiss="modal">Batal</button>
                    <button type="submit" class="btn btn-primary btn-pill px-5 fw-bold shadow-sm" id="btnSimpan"><i class="bi bi-save me-1"></i> Simpan Data</button>
                </div>
                
            </form>
        </div>
    </div>
</div>
                            
<form id="formCetak" action="<?php echo e(route('penilaian.print')); ?>" method="GET" target="_blank" style="display:none;">
    <input type="hidden" name="ids" id="idsCetak">
</form>
                            
<?php $__env->stopSection(); ?>  

<?php $__env->startSection('scripts'); ?>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
    function submitCetak() {
        var selectedIds = [];
        
        $('.check-item:checked').each(function() {
            selectedIds.push($(this).val());
        });

        if (selectedIds.length === 0) {
            alert("Pilih minimal satu data penilaian untuk dicetak!");
            return;
        }

        $('#idsCetak').val(selectedIds.join(','));
        $('#formCetak').submit();
    }


    document.addEventListener("DOMContentLoaded", function() {
        var $ = jQuery;
        
        const modalElement = document.getElementById('modalForm');
        const modalInstance = new bootstrap.Modal(modalElement);

        window.openModalCreate = function() {
            $('#formPenilaian')[0].reset();
            $('#formPenilaian').attr('action', "<?php echo e(route('penilaian.store')); ?>");
            $('#methodPut').html(''); 
            
            $('#modalTitle').html('<i class="bi bi-pencil-square me-2"></i> Buat Penilaian Baru');
            $('#inputKelas').html('<option value="">-- Pilih Mapel Dulu --</option>').prop('disabled', false);
            $('#inputSkala').prop('disabled', false);
            $('#msgSkalaLocked').addClass('d-none');
            
            $('#divTombolLoad').show();
            $('#btnLoadSiswa')
                .prop('disabled', false)
                .removeClass('btn-outline-secondary').addClass('btn-outline-primary')
                .html('<i class="bi bi-people-fill me-2"></i> Load Data Siswa & Input Nilai');
            
            $('#areaInputNilai').hide();
            $('#tabelSiswaBody').empty();

            modalInstance.show();
        }

        window.editPenilaian = function(id) {
            $('#modalTitle').html('<i class="bi bi-arrow-repeat me-2"></i> Sedang memuat data...');
            $('#areaInputNilai').hide();
            
            $('#divTombolLoad').show(); 
            $('#btnLoadSiswa')
                .prop('disabled', true)
                .removeClass('btn-outline-primary').addClass('btn-outline-secondary')
                .html('<i class="bi bi-lock-fill me-2"></i> Terkunci saat Edit');

            modalInstance.show();

            var url = "<?php echo e(route('penilaian.get_data', ':id')); ?>";
            url = url.replace(':id', id);

            $.ajax({
                url: url, 
                type: 'GET',
                success: function(data) {
                    var p = data.penilaian;
                    
                    $('#inputMapel').val(p.subject_id);
                    $('#inputTanggal').val(p.tanggal);
                    $('#inputJenis').val(p.jenis_penilaian);
                    $('#inputTopik').val(p.topik);

                    var skalaDb = p.skala_penilaian ? p.skala_penilaian : 'angka';
                    $('#inputSkala').val(skalaDb);
                    
                    if(p.skala_penilaian) {
                        $('#inputSkala').prop('disabled', true);
                        $('#msgSkalaLocked').removeClass('d-none');
                    } else {
                        $('#inputSkala').prop('disabled', false);
                        $('#msgSkalaLocked').addClass('d-none');
                    }

                    loadClassesForEdit(p.subject_id, p.kelas_id);

                    var updateUrl = "<?php echo e(route('penilaian.update', ':id')); ?>";
                    updateUrl = updateUrl.replace(':id', id);
                    
                    $('#formPenilaian').attr('action', updateUrl);
                    $('#methodPut').html('<input type="hidden" name="_method" value="PUT">');
                    $('#modalTitle').html('<i class="bi bi-pencil-square me-2"></i> Edit Penilaian');

                    $('#areaInputNilai').show();
                    renderRows(data.students, skalaDb);
                },
                error: function(xhr) {
                    console.error("Error:", xhr);
                    alert("Gagal mengambil data. Pastikan Anda sudah mengakses menu /bersih-bersih untuk reset cache.");
                    modalInstance.hide();
                }
            });
        }

        function loadClassesForEdit(subjectId, targetKelasId) {
            var kelasSelect = $('#inputKelas');
            kelasSelect.html('<option value="">Memuat...</option>');

            $.get("<?php echo e(route('ajax.penilaian.classes')); ?>", { subject_id: subjectId })
            .done(function(data) {
                kelasSelect.empty();
                if(data.length === 0) {
                    kelasSelect.html('<option value="">Tidak ada kelas</option>');
                } else {
                    kelasSelect.append('<option value="">-- Pilih Kelas --</option>');
                    $.each(data, function(index, k) {
                        kelasSelect.append(`<option value="${k.id}">${k.nama_kelas}</option>`);
                    });
                    
                    kelasSelect.val(targetKelasId);
                    kelasSelect.prop('disabled', true); 
                }
            });
        }

        window.loadClasses = function() {
            var subjectId = $('#inputMapel').val();
            var kelasSelect = $('#inputKelas');

            if(!subjectId) {
                kelasSelect.html('<option value="">-- Pilih Mapel Dulu --</option>');
                return;
            }

            $.get("<?php echo e(route('ajax.penilaian.classes')); ?>", { subject_id: subjectId })
            .done(function(data) {
                kelasSelect.empty();
                if(data.length === 0) {
                    kelasSelect.html('<option value="">Tidak ada kelas</option>');
                } else {
                    kelasSelect.append('<option value="">-- Pilih Kelas --</option>');
                    $.each(data, function(index, k) {
                        kelasSelect.append(`<option value="${k.id}">${k.nama_kelas}</option>`);
                    });
                }
            });
        }

        $('#btnLoadSiswa').click(function() {
            var btn = $(this);
            var originalText = btn.html();
            var kelasId = $('#inputKelas').val();
            var skala = $('#inputSkala').val();

            if(!kelasId) { alert('Pilih Kelas Terlebih Dahulu!'); return; }

            btn.prop('disabled', true).html('<span class="spinner-border spinner-border-sm me-2"></span> Memuat...');
            $('#areaInputNilai').show();
            $('#tabelSiswaBody').html('<tr><td colspan="2" class="text-center py-4 text-muted border-0">Sedang mengambil data siswa...</td></tr>');

			var url = "<?php echo e(route('api.get_siswa', ':id')); ?>".replace(':id', kelasId);
            
            $.ajax({
                url: url,
                type: 'GET',
                success: function(response) {
                    renderRows(response, skala);
                    btn.prop('disabled', false).html(originalText);
                },
                error: function() {
                    $('#tabelSiswaBody').html('<tr><td colspan="2" class="text-center text-danger border-0 py-4">Gagal memuat data.</td></tr>');
                    btn.prop('disabled', false).html(originalText);
                }
            });
        });

        function renderRows(students, skala) {
            var html = '';
            var optionsHuruf = ['A', 'A-', 'B+', 'B', 'B-', 'C+', 'C', 'C-', 'D+', 'D', 'E'];

            if(!students || students.length === 0) {
                $('#tabelSiswaBody').html('<tr><td colspan="2" class="text-center text-danger py-4 border-0">Tidak ada data siswa.</td></tr>');
                return;
            }

            $.each(students, function(i, s) {
                var nilaiLama = s.existing_nilai; 
                if (nilaiLama === null || nilaiLama === undefined) nilaiLama = '';

                var input = '';

                if(skala === 'angka') {
                    input = `<input type="number" name="nilai[${s.id}]" class="form-control form-control-sm rounded-pill px-3" placeholder="0-100" value="${nilaiLama}" min="0" max="100">`;
                } else {
                    var opts = `<option value="">-- Pilih --</option>`;
                    optionsHuruf.forEach(function(h) {
                        var selected = (nilaiLama == h) ? 'selected' : '';
                        opts += `<option value="${h}" ${selected}>${h}</option>`;
                    });
                    input = `<select name="nilai[${s.id}]" class="form-select form-select-sm rounded-pill px-3">${opts}</select>`;
                }

                html += `
                    <tr>
                        <td class="ps-3 fw-bold">
                            ${s.name}
                            <input type="hidden" name="siswa_id[]" value="${s.id}">
                        </td>
                        <td>${input}</td>
                    </tr>`;
            });
            $('#tabelSiswaBody').html(html);
        }

        $('#inputKelas, #inputSkala').change(function() {
             if($('#divTombolLoad').is(':visible')) {
                 $('#areaInputNilai').hide();
                 $('#tabelSiswaBody').empty();
             }
        });

        $('#checkAllGlobal').click(function() {
            $('.check-item, .checkAll-group').prop('checked', this.checked);
            toggleBtnCetak();
        });

        $(document).on('click', '.checkAll-group', function() {
            let table = $(this).closest('table');
            table.find('.check-item').prop('checked', this.checked);
            toggleBtnCetak();
        });

        $(document).on('change', '.check-item', function() {
            toggleBtnCetak();
            
            if(!this.checked) {
                $('#checkAllGlobal').prop('checked', false);
                $(this).closest('table').find('.checkAll-group').prop('checked', false);
            }
        });

        function toggleBtnCetak() {
            var count = $('.check-item:checked').length;
            $('#btnCetak').prop('disabled', count === 0).html(`<i class="bi bi-printer me-1"></i> Cetak (${count})`);
        }
    });
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/vol15_7/infinityfree.com/if0_40829333/sislajar-skansa.gt.tc/htdocs/resources/views/pages/pembelajaran/penilaian/index.blade.php ENDPATH**/ ?>