<?php $__env->startSection('title', 'Registrasi Siswa (Rollover Tahun Ajaran)'); ?>

<?php $__env->startPush('styles'); ?>
<style>
    .info-card {
        border-left: 4px solid;
        border-radius: 4px;
        transition: transform 0.15s ease;
    }
    .info-card:hover { transform: translateY(-2px); }
    .info-card.border-primary  { border-left-color: #007bff; }
    .info-card.border-success  { border-left-color: #28a745; }
    .info-card.border-warning  { border-left-color: #ffc107; }
    .info-card.border-info     { border-left-color: #17a2b8; }

    .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
    .stat-label { font-size: 0.78rem; color: #6c757d; text-transform: uppercase; letter-spacing: .5px; }

    .table-rollover th { font-size: 0.82rem; text-transform: uppercase; letter-spacing: .3px; }
    .table-rollover td { vertical-align: middle !important; }
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
<div class="row">
    <div class="col-12">

        
        <?php if(session('success')): ?>
            <div class="alert alert-success alert-dismissible fade show">
                <button type="button" class="close" data-dismiss="alert">&times;</button>
                <i class="fas fa-check-circle mr-1"></i> <?php echo e(session('success')); ?>

            </div>
        <?php endif; ?>
        <?php if(session('error')): ?>
            <div class="alert alert-danger alert-dismissible fade show">
                <button type="button" class="close" data-dismiss="alert">&times;</button>
                <i class="fas fa-exclamation-circle mr-1"></i> <?php echo e(session('error')); ?>

            </div>
        <?php endif; ?>
        <?php if(session('info')): ?>
            <div class="alert alert-info alert-dismissible fade show">
                <button type="button" class="close" data-dismiss="alert">&times;</button>
                <i class="fas fa-info-circle mr-1"></i> <?php echo e(session('info')); ?>

            </div>
        <?php endif; ?>

        
        <div class="row mb-3">
            <div class="col-md-3 col-sm-6 mb-2">
                <div class="card info-card border-primary shadow-sm mb-0">
                    <div class="card-body py-3">
                        <div class="stat-label">Tahun Ajaran Sumber</div>
                        <div class="stat-value text-primary"><?php echo e($sourceYear ? $sourceYear->tahun : '-'); ?></div>
                        <small class="text-muted">Data siswa diambil dari sini</small>
                    </div>
                </div>
            </div>
            <div class="col-md-3 col-sm-6 mb-2">
                <div class="card info-card border-success shadow-sm mb-0">
                    <div class="card-body py-3">
                        <div class="stat-label">Tahun Ajaran Tujuan (Aktif)</div>
                        <div class="stat-value text-success"><?php echo e($targetYear ? $targetYear->tahun : '-'); ?></div>
                        <small class="text-muted">Siswa didaftarkan ke sini</small>
                    </div>
                </div>
            </div>
            <div class="col-md-3 col-sm-6 mb-2">
                <div class="card info-card border-warning shadow-sm mb-0">
                    <div class="card-body py-3">
                        <div class="stat-label">Total Siswa Sumber</div>
                        <div class="stat-value text-warning"><?php echo e($totalSiswaSumber); ?></div>
                        <small class="text-muted">Siswa aktif di <?php echo e($sourceYear->tahun ?? '-'); ?></small>
                    </div>
                </div>
            </div>
            <div class="col-md-3 col-sm-6 mb-2">
                <div class="card info-card border-info shadow-sm mb-0">
                    <div class="card-body py-3">
                        <div class="stat-label">Sudah Terdaftar di Tujuan</div>
                        <div class="stat-value text-info"><?php echo e($totalSudahTerdaftar); ?></div>
                        <small class="text-muted">Siswa sudah terdaftar di <?php echo e($targetYear->tahun ?? '-'); ?></small>
                    </div>
                </div>
            </div>
        </div>

        
        <div class="card card-outline card-primary shadow-sm">
            <div class="card-header d-flex align-items-center justify-content-between flex-wrap">
                <h3 class="card-title mb-0">
                    <i class="fas fa-exchange-alt mr-1"></i> Data Siswa untuk Rollover ke <?php echo e($targetYear->tahun ?? '-'); ?>

                </h3>
                <div class="card-tools d-flex flex-wrap mt-1">
                    
                    <a href="<?php echo e(route('kenaikan-kelas.export', request()->query())); ?>" class="btn btn-success btn-sm mr-2 mb-1">
                        <i class="fas fa-file-excel mr-1"></i> Export Template Pembagian Kelas
                    </a>
                    
                    <button type="button" class="btn btn-info btn-sm mr-2 mb-1" data-toggle="modal" data-target="#modal-import">
                        <i class="fas fa-file-upload mr-1"></i> Import Pembagian Kelas
                    </button>
                </div>
            </div>

            <div class="card-body p-0">
                
                <form action="<?php echo e(route('kenaikan-kelas.index')); ?>" method="GET" class="px-3 pt-3 pb-2">
                    <div class="row align-items-end">
                        <div class="col-md-2 col-sm-6">
                            <div class="form-group mb-2">
                                <label class="text-sm">Jenjang</label>
                                <select name="jenjang" class="form-control form-control-sm">
                                    <option value="">-- Semua --</option>
                                    <?php $__currentLoopData = ['TK','SD','SMP','SMA']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $j): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($j); ?>" <?php echo e(request('jenjang') == $j ? 'selected' : ''); ?>><?php echo e($j); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                        </div>
                        <div class="col-md-2 col-sm-6">
                            <div class="form-group mb-2">
                                <label class="text-sm">Tingkat</label>
                                <select name="tingkat" class="form-control form-control-sm">
                                    <option value="">-- Semua --</option>
                                    <?php $__currentLoopData = $tingkatList; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($t); ?>" <?php echo e(request('tingkat') == $t ? 'selected' : ''); ?>><?php echo e($t); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                        </div>
                        <div class="col-md-2 col-sm-6">
                            <div class="form-group mb-2">
                                <label class="text-sm">Status Rollover</label>
                                <select name="status_rollover" class="form-control form-control-sm">
                                    <option value="">-- Semua --</option>
                                    <option value="belum" <?php echo e(request('status_rollover') == 'belum' ? 'selected' : ''); ?>>Belum Terdaftar</option>
                                    <option value="sudah" <?php echo e(request('status_rollover') == 'sudah' ? 'selected' : ''); ?>>Sudah Terdaftar</option>
                                </select>
                            </div>
                        </div>
                        <div class="col-md-3 col-sm-6">
                            <div class="form-group mb-2">
                                <label class="text-sm">Cari NIS / Nama</label>
                                <input type="text" name="q" class="form-control form-control-sm" placeholder="Ketik NIS atau nama..." value="<?php echo e(request('q')); ?>">
                            </div>
                        </div>
                        <div class="col-md-3 col-sm-12 d-flex align-items-end mb-2">
                            <button type="submit" class="btn btn-primary btn-sm mr-2"><i class="fas fa-search"></i> Filter</button>
                            <a href="<?php echo e(route('kenaikan-kelas.index')); ?>" class="btn btn-default btn-sm">Reset</a>
                        </div>
                    </div>
                </form>

                
                <div class="table-responsive">
                    <table class="table table-bordered table-hover table-sm table-rollover mb-0">
                        <thead class="bg-light">
                            <tr>
                                <th width="40" class="text-center">No</th>
                                <th width="100">NIS</th>
                                <th>Nama Siswa</th>
                                <th width="150">Kelas Asal (<?php echo e($sourceYear->tahun ?? '-'); ?>)</th>
                                <th width="50" class="text-center"></th>
                                <th width="150">Kelas Tujuan (<?php echo e($targetYear->tahun ?? '-'); ?>)</th>
                                <th width="120" class="text-center">Status</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $students; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <?php
                                    $siswa = $item['siswa'];
                                    $kelasAsal = $item['kelas_asal'];
                                    $kelasTujuan = $item['kelas_tujuan'];
                                    $sudahTerdaftar = $item['sudah_terdaftar'];
                                    $isLulus = $item['is_lulus'] ?? false;
                                ?>
                                <tr class="<?php echo e($sudahTerdaftar ? 'table-light' : ''); ?>">
                                    <td class="text-center"><?php echo e($students->firstItem() + $index); ?></td>
                                    <td class="font-weight-bold"><?php echo e($siswa->nis); ?></td>
                                    <td><?php echo e($siswa->nama_lengkap); ?></td>
                                    <td>
                                        <?php if($kelasAsal): ?>
                                            <span class="badge badge-secondary"><?php echo e($kelasAsal->nama_kelas); ?></span>
                                        <?php else: ?>
                                            <span class="text-muted">-</span>
                                        <?php endif; ?>
                                    </td>
                                    <td class="text-center text-muted">
                                        <i class="fas fa-long-arrow-alt-right"></i>
                                    </td>
                                    <td>
                                        <?php if($isLulus): ?>
                                            <span class="badge badge-primary">Lulus (Non Aktif)</span>
                                        <?php elseif($sudahTerdaftar && $kelasTujuan): ?>
                                            <span class="badge badge-success"><?php echo e($kelasTujuan->nama_kelas); ?></span>
                                        <?php else: ?>
                                            <span class="text-muted">-</span>
                                        <?php endif; ?>
                                    </td>
                                    <td class="text-center">
                                        <?php if($isLulus): ?>
                                            <span class="badge badge-primary"><i class="fas fa-user-graduate mr-1"></i>Lulus</span>
                                        <?php elseif($sudahTerdaftar): ?>
                                            <span class="badge badge-success"><i class="fas fa-check mr-1"></i>Sudah Terdaftar</span>
                                        <?php else: ?>
                                            <span class="badge badge-warning">Belum Terdaftar</span>
                                        <?php endif; ?>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="7" class="text-center text-muted py-4">
                                        <i class="fas fa-inbox fa-2x mb-2 d-block"></i>
                                        Tidak ada data siswa ditemukan untuk tahun ajaran sumber.
                                    </td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>

            <div class="card-footer clearfix d-flex justify-content-between align-items-center flex-wrap">
                <div class="text-muted text-sm my-1">
                    Menampilkan <?php echo e($students->firstItem() ?? 0); ?> - <?php echo e($students->lastItem() ?? 0); ?> dari <?php echo e($students->total()); ?> siswa
                </div>
                <div class="my-1">
                    <?php echo e($students->links('pagination::bootstrap-4')); ?>

                </div>
            </div>
        </div>

    </div>
</div>


<div class="modal fade" id="modal-import" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <form action="<?php echo e(route('kenaikan-kelas.import')); ?>" method="POST" enctype="multipart/form-data">
                <?php echo csrf_field(); ?>
                <div class="modal-header">
                    <h5 class="modal-title"><i class="fas fa-file-upload mr-1"></i> Import Pembagian Kelas</h5>
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>
                <div class="modal-body">
                    <div class="alert alert-info text-sm">
                        <i class="fas fa-info-circle mr-1"></i>
                        Gunakan fitur <b>Export Template Pembagian Kelas</b> untuk mengunduh data siswa yang belum didaftarkan, lalu isi kolom <b>Kelas Tujuan</b> dengan nama kelas baru secara persis (misal: "SD 1 A") atau isi dengan kata <b>Lulus</b> untuk siswa tingkat akhir, kemudian upload kembali di sini.
                    </div>
                    <div class="form-group">
                        <label>File Excel <span class="text-danger">*</span></label>
                        <div class="custom-file">
                            <input type="file" class="custom-file-input" name="file_excel" id="importFile" accept=".xlsx,.csv" required>
                            <label class="custom-file-label" for="importFile">Pilih file...</label>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Batal</button>
                    <button type="submit" class="btn btn-info"><i class="fas fa-upload mr-1"></i> Upload & Proses</button>
                </div>
            </form>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
    // Custom file input label
    document.querySelector('.custom-file-input')?.addEventListener('change', function() {
        this.nextElementSibling.textContent = this.files[0]?.name || 'Pilih file...';
    });
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Herd\spp_app\resources\views/kenaikan-kelas/index.blade.php ENDPATH**/ ?>