@extends('plantilla.header')

@section('titulo')
Consultar
@stop

@section('js')

@stop

@section('contenido')

<div class="col-12 col-xl-12">
    <div class="card card-body bg-white border-light shadow-sm mb-4">
        <h3 class="h5 mb-4">Datos Personales</h3>
        <div class="row">
            <div class="col-md-4 mb-3">
                <div class="form-group">
                    <label for="city"><strong>Cédula:</strong> @php echo !empty($personas[0][0]->cedula) ? $personas[0][0]->cedula : 'Error' @endphp</label>
                </div>
            </div>
            <div class="col-md-6 mb-3">
                <div class="form-group">
                    <label for="city"><strong>Nombre y Apellido:</strong> @php echo !empty($personas[0][0]->nombre) ? $personas[0][0]->nombre : 'Error' @endphp</label>
                </div>
            </div>
        </div>
    </div>
@foreach ($personas as $key => $value)
    <div class="card card-body bg-white border-light shadow-sm mb-4">
        <div class="row">
            <div class="col-sm-3 mb-3">
                <div class="form-group">
                    <h3 class="h5 mb-4">Pagos</h3>
                </div>
            </div>
            <div class="col-sm-3 mb-3">
                <div class="form-group">
                    <label for="city"><strong>Zona:</strong> @php echo !empty($value[0]->zona) ? $value[0]->zona : 'Error' @endphp</label>
                </div>
            </div>
            <div class="col-sm-6 mb-3">
                <div class="form-group">
                    <label for="city"><strong>Comunidad:</strong> @php echo !empty($value[0]->comunidad) ? $value[0]->comunidad : 'Error' @endphp</label>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-md-12 mb-3">
                <div class="form-group">
                    <table class="table table-hover">
                        <thead>
                          <tr>
                            <th scope="col">#</th>
                            <th scope="col">Fecha</th>
                            <th scope="col">Trimestre</th>
                            <th scope="col">Recibo N°</th>
                            <th scope="col">Monto</th>
                          </tr>
                        </thead>
                        <tbody>
                            @php
                                $verr = 0;
                            @endphp
                            @if (!empty($value[1]))
                                @foreach ($value[1] as $n => $p)
                                @php
                                    $verr = 1;
                                @endphp
                                    <tr>
                                        <th scope="row">{{$n+1}}</th>
                                        <td>{{$p->fecha}}</td>
                                        <td>{{$p->trimestre}}</td>
                                        <td><?php echo str_pad($p->idpagos, 7, "0", STR_PAD_LEFT);?></td>
                                        <td><?php echo number_format($p->tarifa, 2, ',','.'); ?></td>
                                    </tr>
                                @endforeach
                            @else
                                <tr style="text-align: center;">
                                    <th colspan="5" scope="row">Aún sin pagar</th>
                                </tr>
                            @endif
                        </tbody>
                      </table>
                </div>
            </div>
            <div class="col-sm-12" style="text-align: right;">
                <div class="form-group">
                    @if ($verr == 1)
                        <a href="{{route('comprobante', $value[0]->jefe_id)}}" target="_back" class="btn btn-default"><i style="color: orange;" class="fa-solid fa-file-pdf"></i> Generar</a>
                    @endif
                    
                </div>
            </div>
        </div>

    </div>

@endforeach
    <div class="card card-body bg-white border-light shadow-sm mb-4">
        <div class="row">
            <div class="col-sm-6 mb-3">
                <div class="form-group">
                    @if ($at == "C")
                    <a href="{{route('index')}}" class="btn btn-default"><i class="fa fa-reply"></i> Atrás</a>
                    @else
                    <a href="{{route('consultar_cedula')}}" class="btn btn-default"><i  class="fa fa-reply"></i> Atrás</a>
                    @endif
                </div>
            </div>
            
        </div>

    </div>
</div>

@stop