<!-- Create User Modal -->
<div class="modal fade" id="createUserModal" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <form method="POST" action="<?php echo e(route('admin.users.store')); ?>">
                <?php echo csrf_field(); ?>
                <div class="modal-header">
                    <h5 class="modal-title"><i class="fas fa-plus me-2"></i>Tambah User Baru</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <div class="mb-3">
                        <label class="form-label">Username <span class="text-danger">*</span></label>
                        <input type="text" name="username" class="form-control" required>
                        <div class="form-text">Username tidak boleh mengandung spasi</div>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">Password <span class="text-danger">*</span></label>
                        <div class="input-group">
                            <input type="password" name="password" id="createPassword" class="form-control" required>
                            <button type="button" class="btn btn-outline-secondary" onclick="togglePassword('createPassword', this)">
                                <i class="fas fa-eye"></i>
                            </button>
                        </div>
                        <div class="form-text">Minimal 6 karakter</div>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">Role <span class="text-danger">*</span></label>
                        <select name="role_id" class="form-select" id="createRoleSelect" required>
                            <option value="">Pilih Role</option>
                            <?php $__currentLoopData = $roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $role): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($role->id_role); ?>"><?php echo e(ucfirst($role->nama_role)); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    
                    <!-- Siswa Dropdown -->
                    <div class="mb-3" id="createSiswaSelect" style="display: none;">
                        <label class="form-label">Siswa <span class="text-danger">*</span></label>
                        <select name="id_siswa" class="form-select">
                            <option value="">Pilih Siswa</option>
                            <?php $__currentLoopData = $siswa; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($s->id); ?>">
                                    <?php echo e($s->nama_siswa); ?> - <?php echo e($s->sekolah->nama_sekolah ?? 'N/A'); ?> 
                                    (<?php echo e($s->mulai_magang->format('d/m/Y')); ?> - <?php echo e($s->selesai_magang->format('d/m/Y')); ?>)
                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                        <?php if($siswa->count() == 0): ?>
                            <div class="form-text text-warning">
                                <i class="fas fa-exclamation-triangle me-1"></i>
                                Tidak ada siswa yang belum memiliki akun. Silakan tambah siswa di menu Data Siswa Magang terlebih dahulu.
                            </div>
                        <?php endif; ?>
                    </div>
                    
                    <!-- Pembimbing Magang Dropdown -->
                    <div class="mb-3" id="createPembimbingMagangSelect" style="display: none;">
                        <label class="form-label">Pembimbing Magang <span class="text-danger">*</span></label>
                        <select name="id_pembimbing_magang" class="form-select">
                            <option value="">Pilih Pembimbing Magang</option>
                            <?php $__currentLoopData = $pembimbingMagang; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $pm): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($pm->id); ?>">
                                    <?php echo e($pm->nama_pembimbing); ?> - <?php echo e($pm->dudi->nama_dudi ?? 'N/A'); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                        <?php if($pembimbingMagang->count() == 0): ?>
                            <div class="form-text text-warning">
                                <i class="fas fa-exclamation-triangle me-1"></i>
                                Tidak ada pembimbing magang yang belum memiliki akun. Silakan tambah pembimbing magang di menu Data DUDI terlebih dahulu.
                            </div>
                        <?php endif; ?>
                    </div>
                    
                    <!-- Pembimbing Sekolah Dropdown -->
                    <div class="mb-3" id="createPembimbingSekolahSelect" style="display: none;">
                        <label class="form-label">Pembimbing Sekolah <span class="text-danger">*</span></label>
                        <select name="id_pembimbing_sekolah" class="form-select">
                            <option value="">Pilih Pembimbing Sekolah</option>
                            <?php $__currentLoopData = $pembimbingSekolah; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ps): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($ps->id); ?>">
                                    <?php echo e($ps->nama_pembimbing); ?> (<?php echo e($ps->no_telp ?? 'N/A'); ?>)
                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                        <?php if($pembimbingSekolah->count() == 0): ?>
                            <div class="form-text text-warning">
                                <i class="fas fa-exclamation-triangle me-1"></i>
                                Tidak ada pembimbing sekolah yang belum memiliki akun. Silakan tambah pembimbing sekolah terlebih dahulu.
                            </div>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
            </form>
        </div>
    </div>
</div><?php /**PATH C:\laragon\www\presensi-magang\resources\views/admin/users/tambah.blade.php ENDPATH**/ ?>