<?php $__env->startSection('title', 'Buat SK P2'); ?>

<?php $__env->startSection('content'); ?>
<div class="card">
    <div class="card-header"><h3 class="card-title">Form SK Pembimbing (P2)</h3></div>
    <div class="card-body">
        <form action="<?php echo e(route('p2.sk_pembimbing.store')); ?>" method="POST">
            <?php echo csrf_field(); ?>
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">No. Surat</label>
                <div class="col-sm-10"><input type="text" name="nosrt" class="form-control" value="<?php echo e($nosrt); ?>" required></div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">Mahasiswa</label>
                <div class="col-sm-10">
                    <select name="nim_mahasiswa" class="form-control" required>
                        <?php $__currentLoopData = $mahasiswa; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $m): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($m->nim); ?>"><?php echo e($m->nim); ?> - <?php echo e($m->nama); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">Program Studi</label>
                <div class="col-sm-10"><input type="text" name="program_studi" class="form-control" value="Ilmu Hukum" required></div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">Judul Skripsi</label>
                <div class="col-sm-10"><textarea name="judul_skripsi" class="form-control" required></textarea></div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">Dosen Pembimbing 1</label>
                <div class="col-sm-10">
                    <select name="nip_dosen_pembimbing1" class="form-control" required>
                        <?php $__currentLoopData = $dosen; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $d): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($d->nip); ?>"><?php echo e($d->nip); ?> - <?php echo e($d->nama); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">Dosen Pembimbing 2</label>
                <div class="col-sm-10">
                    <select name="nip_dosen_pembimbing2" class="form-control" required>
                        <?php $__currentLoopData = $dosen; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $d): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($d->nip); ?>"><?php echo e($d->nip); ?> - <?php echo e($d->nama); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
            </div>
            <button type="submit" class="btn btn-primary">Simpan & Cetak</button>
            <a href="<?php echo e(route('p2.sk_pembimbing.index')); ?>" class="btn btn-secondary">Batal</a>
        </form>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('js'); ?>
<script>
    $(document).ready(function() {
        var nimSelect = $('select[name="nim_mahasiswa"], select[name="nim"]');
        nimSelect.select2({ theme: 'bootstrap4', placeholder: 'Pilih atau Cari Mahasiswa' });
        
        var dosenSelect = $('select[name^="nip_dosen"], select[name^="nip_penguji"]');
        if (dosenSelect.length > 0) {
            dosenSelect.select2({ theme: 'bootstrap4', placeholder: 'Pilih atau Cari Dosen' });
        }

        var judulTextarea = $('textarea[name="judul_skripsi"], textarea[name="judul"]');
        
        nimSelect.on('change', function() {
            var nim = $(this).val();
            if (nim) {
                $.ajax({
                    url: '/mahasiswa/detail/' + nim,
                    type: 'GET',
                    dataType: 'json',
                    success: function(data) {
                        if (data && data.judul_skripsi) {
                            judulTextarea.val(data.judul_skripsi);
                        } else {
                            judulTextarea.val('');
                        }
                    }
                });
            } else {
                judulTextarea.val('');
            }
        });
    });
</script>
<?php $__env->stopPush(); ?>


<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /opt/lampp/htdocs/skripsifh/resources/views/p2/sk_pembimbing/create.blade.php ENDPATH**/ ?>