<?php $__env->startSection('title', (isset($record) ? 'Editar' : 'Nueva') . ' Ficha Académica'); ?>
<?php $__env->startSection('content'); ?>
<div class="row justify-content-center">
    <div class="col-md-10">
        <div class="card p-4">
            <div class="mb-4 d-flex justify-content-between align-items-center">
                <div>
                    <h3 class="mb-1 fw-bold"><?php echo e(isset($record) ? 'Editar' : 'Nueva'); ?> Ficha Académica</h3>
                    <p class="text-muted small">Organice la información por secciones para un mejor control</p>
                </div>
                <a href="<?php echo e(route('admin.records.index')); ?>" class="btn btn-light btn-sm rounded-pill px-3">Volver</a>
            </div>

            <form action="<?php echo e(isset($record) ? route('admin.records.update', $record->id) : route('admin.records.store')); ?>" method="POST">
                <?php echo csrf_field(); ?>
                <?php if(isset($record)): ?> <?php echo method_field('PUT'); ?> <?php endif; ?>

                <div class="row g-4">
                    
                    <div class="col-md-12"><h6 class="fw-bold text-dark mb-0"><i class="bi bi-person-badge me-2"></i>DATOS PERSONALES</h6><hr class="mt-2"></div>
                    <div class="col-md-6">
                        <label class="form-label small fw-bold">Nombres *</label>
                        <input type="text" name="first_names" value="<?php echo e(old('first_names', $record->first_names ?? '')); ?>" class="form-control" required>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label small fw-bold">Apellidos *</label>
                        <input type="text" name="last_names" value="<?php echo e(old('last_names', $record->last_names ?? '')); ?>" class="form-control" required>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label small fw-bold">Cédula de Identidad *</label>
                        <input type="text" name="dni" value="<?php echo e(old('dni', $record->dni ?? '')); ?>" class="form-control" required>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label small fw-bold">Fecha de Nacimiento *</label>
                        <input type="date" name="birth_date" value="<?php echo e(old('birth_date', isset($record) ? $record->birth_date->format('Y-m-d') : '')); ?>" class="form-control" required>
                    </div>

                    
                    <?php $__currentLoopData = $customFields->where('section', 'personal'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $field): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="col-md-6">
                            <label class="form-label small fw-bold text-primary"><?php echo e($field->label); ?></label>
                            <input type="text" name="custom[<?php echo e($field->label); ?>]" value="<?php echo e(old('custom.'.$field->label, $record->custom_values[$field->label] ?? '')); ?>" class="form-control border-primary-subtle">
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                    
                    <div class="col-md-12 mt-5"><h6 class="fw-bold text-dark mb-0"><i class="bi bi-book me-2"></i>EXPEDIENTE ACADÉMICO</h6><hr class="mt-2"></div>
                    <div class="col-md-4">
                        <label class="form-label small fw-bold">Cohorte *</label>
                        <input type="text" name="cohort" value="<?php echo e(old('cohort', $record->cohort ?? '')); ?>" class="form-control" placeholder="Ej: 2024-I" required>
                    </div>
                    <div class="col-md-8">
                        <label class="form-label small fw-bold">Especialidad / Título *</label>
                        <input type="text" name="specialty" value="<?php echo e(old('specialty', $record->specialty ?? '')); ?>" class="form-control" required>
                    </div>
                    <div class="col-md-4">
                        <label class="form-label small fw-bold">Libro *</label>
                        <input type="text" name="book" value="<?php echo e(old('book', $record->book ?? '')); ?>" class="form-control" required>
                    </div>
                    <div class="col-md-4">
                        <label class="form-label small fw-bold">Folio *</label>
                        <input type="text" name="folio" value="<?php echo e(old('folio', $record->folio ?? '')); ?>" class="form-control" required>
                    </div>
                    <div class="col-md-4">
                        <label class="form-label small fw-bold">Fecha de Registro *</label>
                        <input type="date" name="registration_date" value="<?php echo e(old('registration_date', isset($record) ? $record->registration_date->format('Y-m-d') : '')); ?>" class="form-control" required>
                    </div>
                    <div class="col-md-12">
                        <label class="form-label small fw-bold">Ubicación de Archivo Físico *</label>
                        <input type="text" name="location" value="<?php echo e(old('location', $record->location ?? '')); ?>" class="form-control" required>
                    </div>

                    
                    <?php $__currentLoopData = $customFields->where('section', 'academic'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $field): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="col-md-6">
                            <label class="form-label small fw-bold text-primary"><?php echo e($field->label); ?></label>
                            <input type="text" name="custom[<?php echo e($field->label); ?>]" value="<?php echo e(old('custom.'.$field->label, $record->custom_values[$field->label] ?? '')); ?>" class="form-control border-primary-subtle">
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                    
                    <?php if($customFields->where('section', 'additional')->count() > 0): ?>
                        <div class="col-md-12 mt-5"><h6 class="fw-bold text-dark mb-0"><i class="bi bi-info-circle me-2"></i>INFORMACIÓN ADICIONAL</h6><hr class="mt-2"></div>
                        <?php $__currentLoopData = $customFields->where('section', 'additional'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $field): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="col-md-6">
                                <label class="form-label small fw-bold text-primary"><?php echo e($field->label); ?></label>
                                <input type="text" name="custom[<?php echo e($field->label); ?>]" value="<?php echo e(old('custom.'.$field->label, $record->custom_values[$field->label] ?? '')); ?>" class="form-control border-primary-subtle">
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endif; ?>
                </div>

                <div class="mt-5 d-flex gap-2">
                    <button type="submit" class="btn btn-primary px-5 py-2 fw-bold">
                        <i class="bi bi-save me-2"></i>GUARDAR FICHA
                    </button>
                    <a href="<?php echo e(route('admin.records.index')); ?>" class="btn btn-outline-secondary px-4 py-2">Cancelar</a>
                </div>
            </form>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/fichaacademicaup/public_html/ficha_academica/resources/views/admin/create.blade.php ENDPATH**/ ?>