@extends('layouts.admin')
@section ('title')
SisVentas | Cliente
@endsection
@section('contenido')
<div class="row">
    <div class="col-12">
        <div class="page-title-box">
            <div class="page-title-right">
                <ol class="breadcrumb m-0">
                    <li class="breadcrumb-item"><a href="javascript: void(0);">Inicio</a></li>
                    <li class="breadcrumb-item"><a href="javascript: void(0);">Ventas</a></li>
                    <li class="breadcrumb-item active">Clientes</li>
                </ol>
            </div>
            <h4 class="page-title">Administración de Clientes</h4>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <div class="row mb-2">
                    <div class="col-sm-4">
                        @can('cliente-create')
                        <a href="{{ route('cliente.create') }}" class="btn btn-success mb-2"><i class="mdi mdi-plus-circle me-2"></i> Nuevo Proveedor</a>
                        @endcan
                    </div>
                    <div class="col-sm-8">
                        <div class="text-sm-end">
                            <a href="{{url('reporteclientes')}}" target="__blank" class="btn btn-danger mb-2"><i class="mdi mdi-printer"></i> Reporte</a>
                        </div>
                    </div><!-- end col-->
                    @include('ventas.cliente.search')
                </div>                
                <div class="table-responsive">
                    <table class="table table-centered w-100 dt-responsive nowrap table-bordered table-condensed table-hover"> 
                        <thead class="table-light">
                            <tr>
                                <th>Id</th>
                            <th>Tipo Doc.</th>
                            <th>Número Doc.</th>
                            <th>Nombre</th>
                            <th>Dirección</th>
                            <th>Teléfono</th>
                            <th>Email</th>
                                <th style="width: 250px;">Acciones</th>
                            </tr>
                        </thead>
                        
                        <tbody>
                            @foreach ($personas as $key => $cli)
                            <tr>
                                <td>{{ $cli->idpersona}}</td>
                                <td>{{ $cli->tipo_documento}}</td>
                                <td>{{ $cli->num_documento}}</td>
                                <td>{{ $cli->nombre}}</td>
                                <td>{{ $cli->direccion}}</td>
                                <td>{{ $cli->telefono}}</td>
                                <td>{{ $cli->email}}</td>
                                <td align="center">
                                    @can('cliente-edit')
                                    <a href="{{ route('cliente.edit',$cli->idpersona) }}"><button class="btn btn-info"><i class="mdi mdi-square-edit-outline"></i> Editar</button></a>
                                    @endcan
                                    @can('cliente-delete')
                                    <button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#modal-delete-{{$cli->idpersona}}"><i class="mdi mdi-delete"></i> Eliminar</button>
                                    @endcan
                                </td>
                            </tr>
                            @include('ventas.cliente.modal')
                            @endforeach
                        </tbody>
                        
                    </table>
                    {{$personas->render()}}
                </div>
            </div> <!-- end card-body-->
        </div> <!-- end card-->
    </div> <!-- end col -->
</div>
@push ('scripts')
<script>
$('#liVentas').addClass("sub active");
$('#aVentas').addClass("active");
$('#liClientes').addClass("active");
</script>
@endpush
@endsection