@extends('layouts.landing')

@section('title',"Edit")

@section('content')

<div class="container-fluid">
    <div class="card shadow mb-4">
        <div class="card-header py-3">
                <div class="d-sm-flex align-items-center justify-content-between">
                        <h6 class="m-0 font-weight-bold text-primary">Editar alumno</h6>
                        <a href="{{route('alumno.index')}}" class="d-sm-inline-block btn btn-sm btn-primary shadow-sm"><i class="fas fa-download fa-sm text-white-50"></i> Regresar</a>
            </div>
        </div>

        <div class="card-body">
            @if (session('info'))
                <div class="alert alert-success">
                    <strong>{{session('info')}}</strong>
                </div>
            @endif
            <form action="{{ route('alumno.update', $alumno->id) }}" method="POST">
                @csrf
                @method('PUT')


            <input class="btn btn-primary" type="submit" value="Actualizar">
            </form>
        </div>

    </div>

    <div class="row">

        <div class="col-lg-8">
            <div class="card shadow mb-4">
                        <div class="card-header py-3">
                                <div class="d-sm-flex align-items-center justify-content-between">
                                        <h6 class="m-0 font-weight-bold text-primary">Expediente del alumno</h6>
                            </div>
                        </div>

                        <div class="card-body">

                            <div>

                                @php
                                    $nivel = $alumno->nivelRel ?? null;

                                    $tipos = $nivel
                                        ? $nivel->documentosRequeridos
                                        : collect();

                                    $documentos = collect($alumno?->documentos)->keyBy('tipo');
                                @endphp

                                @foreach($tipos as $tipo)

                                @php
                                    $doc = $documentos[$tipo->slug] ?? null;
                                @endphp

                                    <div class="mb-3">

                                        @if($doc)

                                            @if($doc->status == 1)
                                                <div class="alert alert-success d-sm-flex align-items-center justify-content-between">
                                                    <strong>{{ strtoupper($tipo->name) }} : Validado</strong>

                                                    <button
                                                    onclick="verDocumento('{{ url('documento/ver/'.$doc->id) }}', {{ $doc->id }})"
                                                    class="btn btn-sm btn-primary mt-2">
                                                    <i class="fa-duotone fa-solid fa-eye"></i> Ver documento
                                                    </button>
                                                </div>

                                            @elseif($doc->status == 2)
                                                <div class="alert alert-danger d-sm-flex align-items-center justify-content-between">
                                                    <strong>{{ strtoupper($tipo->name) }} : Rechazado</strong>

                                                    <button
                                                    onclick="verDocumento('{{ url('documento/ver/'.$doc->id) }}', {{ $doc->id }})"
                                                    class="btn btn-sm btn-primary mt-2">
                                                    <i class="fa-duotone fa-solid fa-eye"></i> Ver documento
                                                    </button>
                                                </div>

                                            @else

                                                <div class="alert alert-warning d-sm-flex align-items-center justify-content-between">

                                                    <strong>{{ strtoupper($tipo->name) }} : Pendiente de revisión</strong>

                                                    <button
                                                    onclick="verDocumento('{{ url('documento/ver/'.$doc->id) }}', {{ $doc->id }})"
                                                    class="btn btn-sm btn-primary mt-2">
                                                    <i class="fa-duotone fa-solid fa-eye"></i> Ver documento
                                                    </button>

                                                </div>

                                            @endif



                                        @else
                                            <div class="alert alert-danger">
                                                <strong>{{ strtoupper($tipo->name) }} : Faltante</strong>
                                            </div>
                                        @endif

                                    </div>
                                @endforeach

                            </div>

                        </div>

                    </div>
        </div>

        <div class="col-lg-4">
            <div class="card shadow mb-4 ">
                    <div class="card-header py-3">
                            <div class="d-sm-flex align-items-center justify-content-between">
                                    <h6 class="m-0 font-weight-bold text-primary">Asignación de beca</h6>
                        </div>
                    </div>

                    <div class="card-body">
                    </div>

                    </div>
        </div>




    </div>


</div>

<div class="modal fade" id="visorModal" tabindex="-1">
    <div class="modal-dialog modal-xl">
        <div class="modal-content">
            <div class="modal-header">
            <h5 class="modal-title">Vista previa</h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
            </button>
        </div>

        <div class="modal-body">
            <iframe id="visorFrame" width="100%" height="600px" style="border:none;"></iframe>
        </div>

        </div>
    </div>

</div>

@endsection
