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

<?php $__env->startSection('content'); ?>
<div class="row justify-content-center">
    <div class="col-md-10">
        <div class="card shadow-sm">
            <div class="card-header bg-white border-bottom-0 pt-4 px-4">
                <h3 class="card-title font-weight-bold text-dark" style="font-size: 1.25rem;">
                    <i class="fas fa-edit text-primary mr-2"></i> Edit Persetujuan Penelitian (P1)
                </h3>
            </div>
            <div class="card-body px-4 pb-4">
                <form action="<?php echo e(route('p1.persetujuan.update', $p1->nosrt)); ?>" method="POST">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('PUT'); ?>
                    
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group mb-4">
                                <label class="font-weight-600 text-muted small text-uppercase mb-2">No. Surat</label>
                                <div class="input-group">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text bg-light border-right-0" style="border-radius: 10px 0 0 10px;"><i class="fas fa-hashtag text-muted"></i></span>
                                    </div>
                                    <input type="text" name="nosrt" class="form-control bg-light border-left-0" value="<?php echo e($p1->nosrt); ?>" required style="border-radius: 0 10px 10px 0;">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group mb-4">
                                <label class="font-weight-600 text-muted small text-uppercase mb-2">Mahasiswa</label>
                                <select name="nim" class="form-control" required style="border-radius: 10px; height: calc(2.25rem + 2px);">
                                    <?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($p1->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>

                    <div class="form-group mb-4">
                        <label class="font-weight-600 text-muted small text-uppercase mb-2">Lokasi Penelitian</label>
                        <div class="input-group">
                            <div class="input-group-prepend">
                                <span class="input-group-text bg-white border-right-0" style="border-radius: 10px 0 0 10px;"><i class="fas fa-map-marker-alt text-primary"></i></span>
                            </div>
                            <input type="text" name="lokasi_penelitian" class="form-control border-left-0" value="<?php echo e($p1->lokasi_penelitian); ?>" required style="border-radius: 0 10px 10px 0;">
                        </div>
                    </div>

                    <div class="form-group mb-4">
                        <label class="font-weight-600 text-muted small text-uppercase mb-2">Judul Skripsi</label>
                        <textarea name="judul" class="form-control" required style="border-radius: 10px; min-height: 120px; padding: 1rem;"><?php echo e($p1->judul); ?></textarea>
                    </div>

                    <div class="d-flex align-items-center mt-4 pt-3 border-top">
                        <button type="submit" class="btn btn-primary px-4 mr-2">
                            <i class="fas fa-save mr-2"></i> Simpan Perubahan
                        </button>
                        <a href="<?php echo e(route('p1.persetujuan.index')); ?>" class="btn btn-light text-muted px-4 border">
                            Batal
                        </a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<style>
    .font-weight-600 { font-weight: 600; }
    .form-control:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.1);
    }
    input::placeholder { color: #cbd5e1; }
</style>
<?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 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/p1/persetujuan/edit.blade.php ENDPATH**/ ?>