
<?php $__env->startSection('content'); ?>
<div class="container">
    <?php if(Session::has('Mensaje')): ?>
        <div class="alert alert-success" role="alert">
            <?php echo e(Session::get('Mensaje')); ?>

        </div>
    <?php endif; ?>

    <p>
        <h4 style="float: right"><b>Proveedores</b></h4>
    </p><br><br>
    <a href="<?php echo e(url('Proveedores/create')); ?>" class="btn btn-success">
        <span class="fas fa-plus"></span> Agregar Proveedor</a>

    <div class="input-group col-md-6 mb-3" style="float:right; padding:0;">
        <input type="text" class="form-control" placeholder="Buscar..." id="search" name="search">
        <span type="submit" class="input-group-text border-0" id="search-addon">
        <i class="fas fa-search"></i>
        </span>
    </div>
    
    <div class="table-responsive">
        <table class="table table-light table-hover">
            <thead class="thead-dark">
                <tr style="text-align: center">
                    <th>#</th>
                    <th>Razón Social</th>
                    <th>RUT</th>
                    <th>Código</th>
                    <th>Tipo</th>
                    <th>Estado</th>
                    <th>Foto</th>
                    <th>Calle</th>
                    <th>Enumeración</th>
                    <th>Comuna</th>
                    <th>Tel. Empresa</th>
                    <th>Email Empresa</th>
                    <th>Contacto</th>
                    <th>Tel. Contacto</th>
                    <th>Email Contacto</th>
                    <th>Fecha</th>
                    <th>Acción</th>
                </tr>
            </thead>
            <tbody class="generaldata">
                <?php $__currentLoopData = $datos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dato): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr style="text-align: center">
                        <td><?php echo e($loop->iteration); ?></td>
                        <td><?php echo e($dato->razon_social); ?></td>
                        <td><?php echo e($dato->rut); ?></td>
                        <td><?php echo e($dato->codigo); ?></td>
                        <td><?php echo e($dato->tipo); ?></td>
                        <td><?php echo e($dato->estado); ?></td>
                        <td>
                            <img class="rounded img-fliud" src="<?php echo e(asset('storage').'/'.$dato->foto); ?>" alt="" width="100">
                        </td>
                        <td><?php echo e($dato->calle); ?></td>
                        <td><?php echo e($dato->enumeracion); ?></td>
                        <td><?php echo e($dato->comuna); ?></td>
                        <td><?php echo e($dato->telefono_emp); ?></td>
                        <td><?php echo e($dato->email_emp); ?></td>
                        <td><?php echo e($dato->contacto); ?></td>
                        <td><?php echo e($dato->telefono_cont); ?></td>
                        <td><?php echo e($dato->email_cont); ?></td>
                        <td><?php echo e(Carbon\Carbon::parse($dato->fecha)->format('d-m-Y')); ?></td>
                        <td>
                            <div class="align-items-center btn-group">
                                <a href="<?php echo e(url('/Proveedores/'.$dato->id_proveedor.'/edit')); ?>" class="btn btn-warning">
                                    <span class="far fa-edit"></span> Editar</a>
                                
                                <?php if(Auth::user()->user_tipe == 'Admin'): ?>
                                    <form action="<?php echo e(url('/Proveedores/'.$dato->id_proveedor)); ?>" method="post" style="">
                                        <?php echo e(csrf_field()); ?>

                                        <?php echo e(method_field('DELETE')); ?>


                                        <button class="btn btn-danger" type="submit" onclick="return confirm('¿Estas Seguro que Deseas Eliminar Este Registro?');" style="margin-left: 3px; border-radius:5px">
                                            <span class="fad fa-trash"></span> Eliminar</button>
                                    </form>
                                <?php endif; ?>
                            </div>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>
            <tbody id="content" class="ajaxdata"></tbody>
        </table>
        <div class="paginate_gnraldata"><?php echo e($datos->links()); ?></div>

        <script>
            $(function(){
                $(document).on('keyup', '#search', function(){
                    $value = $(this).val();
                    if($value)
                    {
                        $('.generaldata').hide();
                        $('.paginate_gnraldata').hide();
                        $('.ajaxdata').show();
                    }
                    else
                    {
                        $('.generaldata').show();
                        $('.ajaxdata').hide();
                        $('.paginate_gnraldata').show();
                    }
                    $.ajax({
                        type:"GET",
                        url:"<?php echo e(url('SearchProv')); ?>",
                        data:{'search':$value},
                        success:function(data){
                            $('#content').html(data);
                        }
                    });
                });
            });
        </script>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\Proyectos Laravel\SistemaDigTelRed\resources\views/Proveedores/index.blade.php ENDPATH**/ ?>