@extends('plantilla.header')

@section('titulo')
   Lista de Solicitudes de Lentes
@stop

@section('js')

<script type="text/javascript">
	function aviso() {
		$("#id_mensaje").append('<h3 class="h6 mb-4">Este Registro no acredita la aprobación de su solicitud, será evaluado por el Equipo Especialista del Programa Independencia + Salud Visual. <br><br>Verifique su solicitud en la pestaña: ESTATUS</h3>');
        $("#modal-mensaje").modal({
            show: false,
            keyboard: false,
            backdrop: 'static'
        });

        $("#modal-mensaje").modal("show");
	}
</script>
@stop

@section('contenido')
<div class="col-12 col-xl-12">
    <div class="card card-body bg-white border-light shadow-sm mb-4">

        <div class="row">
            <div class="col-sm-9 mb-3">
                <h3 class="h5 mb-4">Solicitud de Lentes (Estatus)</h3>
            </div>
            <div class="col-sm-3" style="text-align: right;">
                <div class="form-group">
                    <a type="submit" href="{{route('l_lentes')}}" class="btn btn-dark"><i class="fa-solid fa-add"></i> Solicitud de Lentes</a>
                </div>
            </div>
        </div>


        <div class="row">
            <div class="col-md-12 mb-3 table-responsive">
                <table class="table table-striped table-sm">
                    <thead>
                      <tr>
                        <th scope="col">#</th>
                        <th scope="col">Cédula</th>
                        <th scope="col">Nombre</th>
                        <th scope="col">Cédula Menor</th>
                        <th scope="col">Nombre Menor</th>
                        <th scope="col">Fecha R</th>
                        <th scope="col">VenApp/Reporte</th>
                        <th scope="col">Estatus</th>
                        <th scope="col"></th>
                      </tr>
                    </thead>
                    <tbody>
                    	@php $aviso = "NO"; @endphp

                        @if (!@empty($datos))
                            @foreach ($datos as $i => $d)
                                <tr class="@if($d->estatus2 == 1)table-info @elseif($d->estatus2 == 2) table-success @else table-danger @endif">
                                    <th scope="row">{{$i+1}}</th>
                                    <td>{{$d->cedula}}</td>
                                    <td>{{$d->nombre}}</td>
                                    @if ($d->menor == 'SI')
                                        <td>{{$d->cedula_menor}}</td>
                                        <td>{{$d->nombre_menor}}</td>   
                                    @else
                                        <td></td>
                                        <td></td>
                                    @endif

                                    <td>{{$d->fecha_registro}}</td>
                                    @if ($d->app == '0')
                                    <td></td>
                                    @else
                                        @if ($d->app == 'NO')
                                            <td>{{$d->app}}</td>
                                        @else
                                            <td>{{$d->app}}/{{$d->reporte}}</td>
                                        @endif
                                    @endif
                                    <td>{{$d->estatus}}</td>
                                    <td></td>
                                </tr>

                                @if($d->estatus2 == 1)
                                	@if($aviso == 'NO')
                                		@php 
                                			$aviso = "SI"; 
                                		@endphp
                                	@endif
                                @endif
                            @endforeach

                            @if($aviso == 'SI')
                        		<script type="text/javascript">
                        			window.addEventListener("load", function(event) {
									     aviso();
									 });
                        		</script>
                        	@endif
                        @else
                            <tr>
                                <td colspan="9" style="text-align: center"><label>Sin Solicitud</label></td>
                            </tr>
                        @endif
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
@stop