<?php $__env->startSection('title', 'Data Siswa Magang - MagangTime'); ?>
<?php $__env->startSection('page-title', 'Data Siswa Magang'); ?>

<?php $__env->startSection('content'); ?>
<div class="card">
    <div class="card-header bg-white">
        <div class="row align-items-center">
            <div class="col-12 col-md-6 mb-2 mb-md-0">
                <h5 class="mb-0"><i class="fas fa-user-graduate me-2"></i>Data Siswa Magang</h5>
            </div>
            <div class="col-12 col-md-6 text-md-end">
                <button class="btn btn-primary w-100 w-md-auto" data-bs-toggle="modal" data-bs-target="#addSiswaModal">
                    <i class="fas fa-plus me-2"></i>Tambah Siswa
                </button>
            </div>
        </div>

        <!-- Form Filter dan Pencarian -->
        <form method="GET" action="<?php echo e(route('admin.siswa')); ?>" class="mt-3">
            <div class="row g-2">
                <div class="col-12 col-md-3">
                    <label class="form-label">Cari Siswa</label>
                    <input type="text" name="search" class="form-control" 
                           placeholder="Cari nama siswa atau sekolah..." 
                           value="<?php echo e(request('search')); ?>">
                </div>
                <div class="col-6 col-md-2">
                    <label class="form-label">Jenis Kelamin</label>
                    <select name="jk" class="form-select">
                        <option value="">Semua JK</option>
                        <option value="L" <?php echo e(request('jk') == 'L' ? 'selected' : ''); ?>>Laki-laki</option>
                        <option value="P" <?php echo e(request('jk') == 'P' ? 'selected' : ''); ?>>Perempuan</option>
                    </select>
                </div>
                <div class="col-6 col-md-3">
                    <label class="form-label">Sekolah</label>
                    <select name="sekolah" class="form-select">
                        <option value="">Semua Sekolah</option>
                        <?php $__currentLoopData = $sekolah; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sch): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($sch->id); ?>" <?php echo e(request('sekolah') == $sch->id ? 'selected' : ''); ?>>
                                <?php echo e($sch->nama_sekolah); ?>

                            </option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
                <div class="col-6 col-md-2">
                    <label class="form-label">Status Akun</label>
                    <select name="status_akun" class="form-select">
                        <option value="">Semua Status</option>
                        <option value="ada" <?php echo e(request('status_akun') == 'ada' ? 'selected' : ''); ?>>Sudah Ada Akun</option>
                        <option value="belum" <?php echo e(request('status_akun') == 'belum' ? 'selected' : ''); ?>>Belum Ada Akun</option>
                    </select>
                </div>
                <div class="col-6 col-md-2">
                    <label class="form-label d-none d-md-block">&nbsp;</label>
                    <div class="d-flex mt-md-0 mt-2">
                        <button type="submit" class="btn btn-primary flex-fill me-1">
                            <i class="fas fa-search"></i><span class="d-none d-sm-inline ms-1">Cari</span>
                        </button>
                        <?php if(request()->hasAny(['search', 'jk', 'sekolah', 'status_akun'])): ?>
                            <a href="<?php echo e(route('admin.siswa')); ?>" class="btn btn-outline-secondary">
                                <i class="fas fa-times"></i>
                            </a>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </form>
    </div>
    
    <div class="card-body">
        <?php if($errors->any()): ?>
            <div class="alert alert-danger">
                <ul class="mb-0">
                    <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <li><?php echo e($error); ?></li>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </ul>
            </div>
        <?php endif; ?>

        
        <div class="table-responsive d-none d-md-block">
            <table class="table table-striped table-hover">
                <thead class="table-dark">
                    <tr>
                        <th width="5%" class="text-center">No</th>
                        <th>Nama Siswa</th>
                        <th width="15%" class="text-center">Jenis Kelamin</th>
                        <th width="15%" class="text-center">Sekolah</th>
                        <th width="15%" class="text-center">Periode Magang</th>
                        <th width="12%" class="text-center">Status Akun</th>
                        <th width="10%" class="text-center">Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $siswa; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td class="text-center"><?php echo e($siswa->firstItem() + $i); ?></td>
                        <td>
                            <div class="fw-bold"><?php echo e($s->nama_siswa); ?></div>
                            <small class="text-muted"><?php echo e($s->no_telp_siswa); ?></small>
                        </td>
                        <td class="text-center">
                            <span class="badge bg-<?php echo e($s->jk == 'L' ? 'primary' : 'danger'); ?>"><?php echo e($s->jk == 'L' ? 'Laki-laki' : 'Perempuan'); ?></span>
                        </td>
                        <td class="text-center"><?php echo e($s->sekolah->nama_sekolah); ?></td>
                        <td class="text-center">
                            <small><?php echo e($s->mulai_magang->format('d/m/Y')); ?> s/d<br><?php echo e($s->selesai_magang->format('d/m/Y')); ?></small>
                        </td>
                        <td class="text-center">
                            <?php if($s->user): ?>
                                <span class="badge bg-success"><?php echo e($s->user->username); ?></span>
                            <?php else: ?>
                                <span class="badge bg-secondary">Belum ada akun</span>
                            <?php endif; ?>
                        </td>
                        <td>
                            <div class="btn-group text-center" role="group">
                                <a href="<?php echo e(route('admin.detail.siswa', $s->id)); ?>" class="btn btn-sm btn-info" title="Detail">
                                    <i class="fas fa-eye"></i>
                                </a>
                                <button class="btn btn-sm btn-warning" onclick="editSiswa(<?php echo e($s->id); ?>)" title="Edit">
                                    <i class="fas fa-edit"></i>
                                </button>
                                <a href="<?php echo e(route('admin.export.pdf', $s->id)); ?>" class="btn btn-sm btn-success" title="Export PDF">
                                    <i class="fas fa-file-pdf"></i>
                                </a>
                                <button class="btn btn-sm btn-danger" onclick="confirmDelete(<?php echo e($s->id); ?>, '<?php echo e($s->nama_siswa); ?>')" title="Hapus">
                                    <i class="fas fa-trash"></i>
                                </button>
                            </div>
                        </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="7" class="text-center text-muted py-4">
                            <?php if(request()->hasAny(['search', 'jk', 'sekolah', 'status_akun'])): ?>
                                <i class="fas fa-search fa-3x mb-3"></i>
                                <p>Tidak ditemukan data siswa dengan kriteria yang dipilih</p>
                                <a href="<?php echo e(route('admin.siswa')); ?>" class="btn btn-primary">Reset Filter</a>
                            <?php else: ?>
                                <i class="fas fa-user-graduate fa-3x mb-3"></i>
                                <p>Belum ada data siswa magang</p>
                            <?php endif; ?>
                        </td>
                    </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>

        
        <div class="d-block d-md-none">
            <?php $__empty_1 = true; $__currentLoopData = $siswa; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <div class="card mb-3 border-start border-primary border-4">
                <div class="card-body py-3">
                    <div class="d-flex justify-content-between align-items-start mb-2">
                        <div>
                            <h6 class="fw-bold mb-0"><?php echo e($s->nama_siswa); ?></h6>
                            <small class="text-muted"><?php echo e($s->no_telp_siswa); ?></small>
                        </div>
                        <small class="text-muted">#<?php echo e($siswa->firstItem() + $i); ?></small>
                    </div>
                    
                    <div class="mb-3">
                        <div class="mb-2">
                            <small class="text-muted">Jenis Kelamin:</small><br>
                            <span class="badge bg-<?php echo e($s->jk == 'L' ? 'primary' : 'danger'); ?>">
                                <?php echo e($s->jk == 'L' ? 'Laki-laki' : 'Perempuan'); ?>

                            </span>
                        </div>
                        <div class="mb-2">
                            <small class="text-muted">Sekolah:</small><br>
                            <small class="fw-bold"><?php echo e($s->sekolah->nama_sekolah); ?></small>
                        </div>
                        <div class="mb-2">
                            <small class="text-muted">Periode Magang:</small><br>
                            <small><?php echo e($s->mulai_magang->format('d/m/Y')); ?> s/d <?php echo e($s->selesai_magang->format('d/m/Y')); ?></small>
                        </div>
                        <div class="mb-2">
                            <small class="text-muted">Status Akun:</small><br>
                            <?php if($s->user): ?>
                                <span class="badge bg-success"><?php echo e($s->user->username); ?></span>
                            <?php else: ?>
                                <span class="badge bg-secondary">Belum ada akun</span>
                            <?php endif; ?>
                        </div>
                    </div>
                    
                    <div class="row g-1">
                        <div class="col-3">
                            <a href="<?php echo e(route('admin.detail.siswa', $s->id)); ?>" class="btn btn-sm btn-info w-100" title="Detail">
                                <i class="fas fa-eye"></i>
                            </a>
                        </div>
                        <div class="col-3">
                            <button class="btn btn-sm btn-warning w-100" onclick="editSiswa(<?php echo e($s->id); ?>)" title="Edit">
                                <i class="fas fa-edit"></i>
                            </button>
                        </div>
                        <div class="col-3">
                            <a href="<?php echo e(route('admin.export.pdf', $s->id)); ?>" class="btn btn-sm btn-success w-100" title="Export PDF">
                                <i class="fas fa-file-pdf"></i>
                            </a>
                        </div>
                        <div class="col-3">
                            <button class="btn btn-sm btn-danger w-100" onclick="confirmDelete(<?php echo e($s->id); ?>, '<?php echo e($s->nama_siswa); ?>')" title="Hapus">
                                <i class="fas fa-trash"></i>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <div class="text-center text-muted py-5">
                <?php if(request()->hasAny(['search', 'jk', 'sekolah', 'status_akun'])): ?>
                    <i class="fas fa-search fa-3x mb-3"></i>
                    <p>Tidak ditemukan data siswa dengan kriteria yang dipilih</p>
                    <a href="<?php echo e(route('admin.siswa')); ?>" class="btn btn-primary">Reset Filter</a>
                <?php else: ?>
                    <i class="fas fa-user-graduate fa-3x mb-3"></i>
                    <p>Belum ada data siswa magang</p>
                <?php endif; ?>
            </div>
            <?php endif; ?>
        </div>
        
        <!-- Pagination -->
        <?php if($siswa->hasPages()): ?>
            <?php echo e($siswa->appends(request()->query())->links('pagination::bootstrap-4')); ?>

        <?php endif; ?>
    </div>
</div>

<!-- Include Modals -->
<?php echo $__env->make('admin.siswa.tambah', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<?php echo $__env->make('admin.siswa.edit', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<?php echo $__env->make('admin.siswa.hapus', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

<!-- Include JavaScript -->
<?php echo $__env->make('admin.siswa.script', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\presensi-magang\resources\views/admin/siswa/index.blade.php ENDPATH**/ ?>