<?php $__env->startSection('title', 'Data DU/DI - MAGANGIN'); ?>
<?php $__env->startSection('page-title', 'Data DU/DI'); ?>

<?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-building me-2"></i>Kelola Data DU/DI</h5>
            </div>
            <div class="col-12 col-md-6 text-md-end">
                <button type="button" class="btn btn-primary w-100 w-md-auto" data-bs-toggle="modal" data-bs-target="#addDudiModal">
                    <i class="fas fa-plus me-2"></i>Tambah DU/DI
                </button>
            </div>
        </div>
        
        <div class="row mt-3">
            <div class="col-12 col-md-8">
                <form method="GET" action="<?php echo e(route('dudi')); ?>" class="d-flex flex-column flex-sm-row">
                    <input type="text" name="search" class="form-control me-sm-2 mb-2 mb-sm-0" 
                           placeholder="Cari nama DU/DI..." 
                           value="<?php echo e(request('search')); ?>">
                    <div class="d-flex">
                        <button type="submit" class="btn btn-outline-primary flex-fill"><i class="fas fa-search"></i></button>
                        <?php if(request('search')): ?>
                            <a href="<?php echo e(route('dudi')); ?>" class="btn btn-outline-secondary ms-2"><i class="fas fa-times"></i></a>
                        <?php endif; ?>
                    </div>
                </form>
            </div>
        </div>
    </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 DU/DI</th>
                        <th width="15%" class="text-center">Jumlah Siswa</th>
                        <th width="15%" class="text-center">Tanggal Dibuat</th>
                        <th width="8%" class="text-center">Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $dudi; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td><?php echo e($dudi->firstItem() + $index); ?></td>
                        <td><strong><?php echo e($item->nama_dudi); ?></strong></td>
                        <td class="text-center">
                            <span class="badge bg-primary"><?php echo e($item->siswa_list_count ?? 0); ?> siswa</span>
                        </td>
                        <td class="text-center"><?php echo e($item->created_at->format('d/m/Y')); ?></td>
                        <td>
                            <div class="btn-group text-center" role="group">
                                <button class="btn btn-sm btn-warning" onclick="editDudi(<?php echo e($item->id); ?>, '<?php echo e($item->nama_dudi); ?>')">
                                    <i class="fas fa-edit"></i>
                                </button>
                                <button class="btn btn-sm btn-danger" onclick="confirmDelete(<?php echo e($item->id); ?>, '<?php echo e($item->nama_dudi); ?>', <?php echo e($item->siswa_list_count ?? 0); ?>)">
                                    <i class="fas fa-trash"></i>
                                </button>
                            </div>
                        </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="5" class="text-center text-muted py-4">
                            <i class="fas fa-building fa-3x mb-3"></i>
                            <p><?php echo e(request('search') ? 'Tidak ditemukan data DU/DI' : 'Belum ada data DU/DI yang terdaftar'); ?></p>
                        </td>
                    </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>

        
        <div class="d-block d-md-none">
            <?php $__empty_1 = true; $__currentLoopData = $dudi; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $item): $__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">
                        <h6 class="fw-bold mb-1"><?php echo e($item->nama_dudi); ?></h6>
                        <small class="text-muted">#<?php echo e($dudi->firstItem() + $index); ?></small>
                    </div>
                    <div class="row">
                        <div class="col-6">
                            <small class="text-muted">Jumlah Siswa:</small><br>
                            <span class="badge bg-primary"><?php echo e($item->siswa_list_count ?? 0); ?> siswa</span>
                        </div>
                        <div class="col-6">
                            <small class="text-muted">Tanggal Dibuat:</small><br>
                            <small><?php echo e($item->created_at->format('d/m/Y')); ?></small>
                        </div>
                    </div>
                    <div class="d-flex gap-2 mt-3">
                        <button class="btn btn-sm btn-warning flex-fill" onclick="editDudi(<?php echo e($item->id); ?>, '<?php echo e($item->nama_dudi); ?>')">
                            <i class="fas fa-edit me-1"></i>Edit
                        </button>
                        <button class="btn btn-sm btn-danger flex-fill" onclick="confirmDelete(<?php echo e($item->id); ?>, '<?php echo e($item->nama_dudi); ?>', <?php echo e($item->siswa_list_count ?? 0); ?>)">
                            <i class="fas fa-trash me-1"></i>Hapus
                        </button>
                    </div>
                </div>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <div class="text-center text-muted py-5">
                <i class="fas fa-building fa-3x mb-3"></i>
                <p><?php echo e(request('search') ? 'Tidak ditemukan data DU/DI' : 'Belum ada data DU/DI yang terdaftar'); ?></p>
            </div>
            <?php endif; ?>
        </div>
        
        <?php if($dudi->hasPages()): ?>
            <?php echo e($dudi->appends(request()->query())->links('pagination::bootstrap-4')); ?>

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


<?php echo $__env->make('admin.dudi.tambah', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<?php echo $__env->make('admin.dudi.edit', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?> 
<?php echo $__env->make('admin.dudi.hapus', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<?php echo $__env->make('admin.dudi.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/dudi/index.blade.php ENDPATH**/ ?>