@extends('layouts.landing')

@section('head')
    @include('layouts._partials.tablaStyle')
@endsection
@section('title',"Inicio")

@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">Mis pagos</h6>
            </div>
        </div>

        <div class="card-body">
            <div class="container-fluid">

                    <table id="tcont" class="table table-striped table-bordered nowrap table-hover" style="width:100%;">
                        <thead>
                            <tr>
                                <th>Fecha de pago</th>
                                <th>Concepto</th>
                                <th>Monto</th>
                                <th>Opciones</th>
                            </tr>
                        </thead>
                        <tbody>
                                @forelse ($pagos as $pago)
                                    <tr style="width:100%">
                                        <td>{{$pago->fecha_pago}}</td>
                                        <td>
                                            @foreach ($nombres as $tconcepto)
                                                @if ($pago->concepto == $tconcepto->id)
                                                    {{$tconcepto->name}}
                                                @endif
                                            @endforeach
                                        </td>
                                        <td>{{$pago->monto}}</td>
                                        <td class="row mx-auto">

                                            <form action="{{ route('pagar', $pago->id) }}" method="POST">
                                                    @csrf
                                                    <button class="btn btn-success">
                                                        Pagar
                                                    </button>
                                                </form>
                                        </td>
                                    </tr>
                                @empty
                                    <p>Sin pagos.</p>
                                @endforelse

                        </tbody>
                    </table>



            </div>
        </div>
    </div>
</div>

@endsection


@section('scripts')
    @include('layouts._partials.tablaSinOrden')

    @if (session('swal'))
        <script>
            Swal.fire({
                icon: "{{ session('swal.icon') }}",
                title: "{{ session('swal.title') }}",
                text: "{{ session('swal.text') }}",
            });
        </script>
    @endif
@endsection
