<?php $__env->startSection('title', 'Edit Izin P1'); ?>

<?php $__env->startSection('content'); ?>
<div class="card">
    <div class="card-header"><h3 class="card-title">Edit Izin P1</h3></div>
    <div class="card-body">
        <form action="<?php echo e(route('izin_p1.update', $izin->id)); ?>" method="POST">
            <?php echo csrf_field(); ?>
            <?php echo method_field('PUT'); ?>
            
            <h5 class="mb-3 border-bottom pb-2">Identitas Utama</h5>
            <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($izin->nosrt); ?>" required></div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">Tanggal</label>
                <div class="col-sm-10"><input type="date" name="tanggal" class="form-control" value="<?php echo e($izin->tanggal); ?>" 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" class="form-control select2" required>
                        <option value="">Pilih Mahasiswa...</option>
                        <?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($izin->nim == $m->nim ? 'selected' : ''); ?>><?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">Judul Skripsi</label>
                <div class="col-sm-10"><textarea name="judul" class="form-control" required><?php echo e($izin->judul); ?></textarea></div>
            </div>

            <h5 class="mt-5 mb-3 border-bottom pb-2">Kelengkapan Data Akademik (Checklist)</h5>
            <p class="text-muted small">Centang data yang sudah dipenuhi oleh mahasiswa</p>
            
            <div class="row">
                <div class="col-md-6">
                    <label>1. SPP</label>
                    <div class="row">
                        <?php for($i = 1; $i <= 10; $i++): ?>
                        <div class="col-sm-6">
                            <div class="form-check">
                                <?php $field = 'spp_'.$i; ?>
                                <input class="form-check-input" type="checkbox" name="spp_<?php echo e($i); ?>" value="1" id="spp_<?php echo e($i); ?>" <?php echo e($izin->$field ? 'checked' : ''); ?>>
                                <label class="form-check-label" for="spp_<?php echo e($i); ?>">SMT <?php echo e(['I','II','III','IV','V','VI','VII','VIII','IX','X'][$i-1]); ?></label>
                            </div>
                        </div>
                        <?php endfor; ?>
                    </div>
                </div>
                <div class="col-md-6">
                    <label>2. KRS</label>
                    <div class="row">
                        <?php for($i = 1; $i <= 10; $i++): ?>
                        <div class="col-sm-6">
                            <div class="form-check">
                                <?php $field = 'krs_'.$i; ?>
                                <input class="form-check-input" type="checkbox" name="krs_<?php echo e($i); ?>" value="1" id="krs_<?php echo e($i); ?>" <?php echo e($izin->$field ? 'checked' : ''); ?>>
                                <label class="form-check-label" for="krs_<?php echo e($i); ?>">SMT <?php echo e(['I','II','III','IV','V','VI','VII','VIII','IX','X'][$i-1]); ?></label>
                            </div>
                        </div>
                        <?php endfor; ?>
                    </div>
                </div>
            </div>
            
            <div class="row mt-4">
                <div class="col-md-12">
                    <div class="form-check mb-2">
                        <input class="form-check-input" type="checkbox" name="spi" value="1" id="spi" <?php echo e($izin->spi ? 'checked' : ''); ?>>
                        <label class="form-check-label" for="spi"><strong>3. SPI</strong></label>
                    </div>
                    <div class="form-check mb-2">
                        <input class="form-check-input" type="checkbox" name="spf" value="1" id="spf" <?php echo e($izin->spf ? 'checked' : ''); ?>>
                        <label class="form-check-label" for="spf"><strong>4. SPF</strong></label>
                    </div>
                    <div class="form-check mb-2">
                        <input class="form-check-input" type="checkbox" name="rekap_nilai" value="1" id="rekap_nilai" <?php echo e($izin->rekap_nilai ? 'checked' : ''); ?>>
                        <label class="form-check-label" for="rekap_nilai"><strong>5. Rekap Nilai Database Minimal 142 SKS</strong></label>
                    </div>
                </div>
            </div>

            <div class="mt-4">
                <button type="submit" class="btn btn-primary">Simpan Perubahan</button>
                <a href="<?php echo e(route('izin_p1.index')); ?>" class="btn btn-secondary">Batal</a>
            </div>
        </form>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('js'); ?>
<script>
    $(document).ready(function() {
        $('select[name="nim"]').select2({
            theme: 'bootstrap4',
            placeholder: 'Ketik Nama atau NIM...'
        });
        
        $('select[name="nim"]').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) {
                            $('textarea[name="judul"]').val(data.judul_skripsi);
                        } else {
                            $('textarea[name="judul"]').val('');
                        }
                    }
                });
            } else {
                $('textarea[name="judul"]').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/izin_p1/edit.blade.php ENDPATH**/ ?>