<div wire:ignore.self class="modal fade" tabindex="-1" role="dialog" id="theModal-AF">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header bg-primary">
                <h5 class="modal-title">
                <b>{{ $componentName }}</b> | {{ $selected_AF_id > 0 ? 'EDITAR' : 'CREAR' }}
                </h5>
                <h6 class="text-center text-warning" wire:loading>ESPERE UN MOMENTO POR FAVOR</h6>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12 col-md-8">
                        <div class="form-group">
                            <label>Centro educativo</label>
                            <input type="text" wire:model.lazy="institution_name" class="form-control" placeholder="ej: Universidad del Tolima" maxlength="99">
                            @error('institution_name')
                                <span class="text-danger er">{{ $message }}</span>
                            @enderror
                        </div>
                    </div>

                    <div class="col-sm-12 col-md-4">
                        <div class="form-group">
                            <label>Modalidad</label>
                            <select class="form-control form-select" wire:model.lazy="modality" name="modality">
                                <option value="Seleccionar">Seleccionar</option>
                                @foreach (DataTypeModalityAcademic() as $key => $value)
                                    <option value="{{ $key }}">{{ $value }}</option>
                                @endforeach
                            </select>
                            @error('modality')
                                <span class="text-danger er">{{ $message }}</span>
                            @enderror
                        </div>
                    </div>

                    <div class="col-sm-12 col-md-6">
                        <div class="form-group">
                            <label>Nivel de Estudios</label>
                            <select class="form-control form-select" wire:model.lazy="educational_level" name="educational_level">
                                <option value="Seleccionar">Seleccionar</option>
                                @foreach ( $educational_levels as $educ_level )
                                    <option value="{{ $educ_level->id }}">{{ $educ_level->name }}</option>
                                @endforeach
                            </select>
                            @error('educational_level')
                                <span class="text-danger er">{{ $message }}</span>
                            @enderror
                        </div>
                    </div>

                    <div class="col-sm-12 col-md-6">
                        <div class="form-group">
                            <label>Estado</label>
                            <select class="form-control form-select" wire:model.lazy="status" name="status">
                                <option value="Seleccionar">Seleccionar</option>
                                @foreach (DataTypeStatusAcademic() as $key => $value)
                                    <option value="{{ $key }}">{{ $value }}</option>
                                @endforeach
                            </select>
                            @error('status')
                                <span class="text-danger er">{{ $message }}</span>
                            @enderror
                        </div>
                    </div>

                    <div class="col-sm-12 col-md-8">
                        @if ($educational_level > 3)
                        <div class="form-group">
                            <label>Área de estudio</label>
                            <input type="text" wire:model.lazy="study_area" class="form-control" placeholder="ej: Bellas Artes" maxlength="99">
                            @error('study_area')
                                <span class="text-danger er">{{ $message }}</span>
                            @enderror
                        </div>
                        @endif
                    </div>



                    <div class="col-sm-12 col-md-4">
                    </div>
                    <div class="col-sm-12 col-md-6">
                        <h5 class="blockquote-footer mt-4">Periodo de inicio</h5>
                        <div class="row">
                            <div class="col-sm-12 col-md-7">
                                <div class="form-group">
                                    <label>Mes</label>
                                    <select class="form-control form-select" wire:model.lazy="initial_date_month" name="initial_date_month">
                                        <option value="Seleccionar">Seleccionar</option>
                                        @foreach (DataTypeMonth() as $key => $value)
                                            <option value="{{ $key }}">{{ $value }}</option>
                                        @endforeach
                                    </select>
                                    @error('initial_date_month')
                                        <span class="text-danger er">{{ $message }}</span>
                                    @enderror
                                </div>
                            </div>

                            <div class="col-sm-12 col-md-5">
                                <div class="form-group">
                                    <label>Año</label>
                                    <select class="form-control form-select" wire:model.lazy="initial_date_year" name="initial_date_year">
                                        <option value="Seleccionar">Seleccionar</option>
                                        @for ($i = date('Y'); $i >= date('Y') - 100; $i--)
                                            <option value="{{ $i }}">{{ $i }}</option>
                                        @endfor
                                    </select>
                                    @error('initial_date_year')
                                        <span class="text-danger er">{{ $message }}</span>
                                    @enderror
                                </div>
                            </div>
                        </div><!-- row -->
                    </div><!-- col- periodo inicial -->

                    <div class="col-sm-12 col-md-6">
                        <h5 class="blockquote-footer mt-4">Periodo de finalización</h5>
                        <div class="row">
                            @if ($status != 2)
                            <div class="col-sm-12 col-md-7">
                                <div class="form-group">
                                    <label>Mes</label>
                                    <select class="form-control form-select" wire:model.lazy="final_date_month" name="final_date_month">
                                        <option value="Seleccionar">Seleccionar</option>
                                        @foreach (DataTypeMonth() as $key => $value)
                                            <option value="{{ $key }}">{{ $value }}</option>
                                        @endforeach
                                    </select>
                                    @error('final_date_month')
                                        <span class="text-danger er">{{ $message }}</span>
                                    @enderror
                                </div>
                            </div>

                            <div class="col-sm-12 col-md-5">
                                <div class="form-group">
                                    <label>Año</label>
                                    <select class="form-control form-select" wire:model.lazy="final_date_year" name="final_date_year">
                                        <option value="Seleccionar">Seleccionar</option>
                                        @for ($i = date('Y'); $i >= date('Y') - 100; $i--)
                                            <option value="{{ $i }}">{{ $i }}</option>
                                        @endfor
                                    </select>
                                    @error('final_date_year')
                                        <span class="text-danger er">{{ $message }}</span>
                                    @enderror
                                </div>
                            </div>
                            @else
                            <div class="col-sm-12 col-md-12">
                                <div class="form-group">
                                    <label> -- </label>
                                    <p>Este estudio se encuentra cursando actualmente</p>
                                </div>
                            </div>
                        @endif
                        </div><!-- row -->

                    </div><!-- col- periodo final -->
                    <div class="col-sm-12 col-md-6">
                        <div class="form-group">
                            <label>Soporte Acádemico</label>
                            <small class="text-muted">(Formatos: .jpg | .png | .pdf)</small>
                            <input type="file" wire:model="academic_formation_support" class="form-control" accept=".png, .jpg .pdf">
                            @if ($academic_formation_support_view != null)
                            <a href="{{ asset('storage/users/'.$user_sel_id.'/academic_formation_supports/'.$academic_formation_support_view) }}" target="_blank">Ver archivo</a>
                            @endif
                            @error('academic_formation_support')
                                <span class="text-danger er">{{ $message }}</span>
                            @enderror
                        </div>
                    </div>
                    <div class="col-sm-12 col-md-6">
                        @if ($educational_level == 6)
                        <div class="form-group">
                            <label>Soporte tarjeta profesional</label>
                            <small class="text-muted">(Formatos: .jpg | .png | .pdf)</small>
                            <input type="file" wire:model="professional_card_support" class="form-control" accept=".png, .jpg .pdf">
                            @if ($professional_card_support_view != null)
                                <a href="{{ asset('storage/users/'.$user_sel_id.'/proffesional_card_supports/'.$professional_card_support_view) }}" target="_blank">Ver archivo</a>
                            @endif
                            @error('professional_card_support')
                                <span class="text-danger er">{{ $message }}</span>
                            @enderror
                        </div>
                        @endif
                    </div>
                </div><!-- row -->
            </div><!-- modal-body -->
            <div class="modal-footer">
                <button type="button" class="btn btn-outline-primary" wire:click.prevent="resetUI()" data-bs-dismiss="modal">CERRAR</button>

                @if( $selected_AF_id < 1 )
                <button type="button" class="btn btn-primary close-modal" wire:click.prevent="StoreAF()">GUARDAR</button>
                @else
                <button type="button" class="btn btn-primary close-modal" wire:click.prevent="UpdateAF()">ACTUALIZAR</button>
                @endif
            </div>
        </div><!-- modal-content -->

    </div>
</div>

