<table class="table table-striped table-hover table-light">
    <thead>
        <tr class="uppercase bg-blue-madison">
            <th class="col-md-1 font-white orderby" onclick="orderby('nome','<?php echo e($order->act); ?>','<?php echo e($order->url); ?>');"><span class="<?php echo e($order->seta); ?>" /> Nome</th>
                <th class="col-md-1 font-white orderby" onclick="orderby('email','<?php echo e($order->act); ?>','<?php echo e($order->url); ?>');"><span class="<?php echo e($order->seta); ?>" /> Email</th>
                    <th class="col-md-2 font-white orderby" onclick="orderby('salesman_nome','<?php echo e($order->act); ?>','<?php echo e($order->url); ?>');"><span class="<?php echo e($order->seta); ?>" />
                        Solicitante
                    </th>
                    <th class="col-md-2 font-white orderby" onclick="orderby('status','<?php echo e($order->act); ?>','<?php echo e($order->url); ?>');"><span class="<?php echo e($order->seta); ?>" /> Status</th>
                        <th class="col-md-2 font-white orderby" onclick="orderby('u.created_at','<?php echo e($order->act); ?>','<?php echo e($order->url); ?>');"><span class="<?php echo e($order->seta); ?>" /> Dt/Cad.</th>
                            <th class="col-md-2 font-white orderby" onclick="orderby('plano','<?php echo e($order->act); ?>','<?php echo e($order->url); ?>');"><span class="<?php echo e($order->seta); ?>" /> Plano</th>
                                <th class="col-md-2 font-white orderby">Ações</th>
                            </tr>
                        </thead>
                        <tbody> 
                            <?php foreach($clientes as $cliente): ?>
                            <tr>
                                <td><?php echo $cliente->nome; ?></td>
                                <td><?php echo $cliente->email; ?></td>
                                <td><?php if(!empty($cliente->salesman_nome)): ?>
                                    <?php echo $cliente->salesman_nome; ?>

                                    <?php else: ?>
                                    Venda Online
                                    <?php endif; ?>
                                </td>
                                <td><?php echo $cliente->situacao; ?></td>
                                <td><?php echo $cliente->data_cadastro; ?></td>
                                <td><?php echo $cliente->Plano; ?></td>
                                <td>
                                    <?php if(!isset($cliente->venda_id)): ?>
                                    <a class='btn btn-xs yellow-soft popovers' data-container="body" data-trigger="hover" data-placement="top" data-content="Visualizar contratos do cliente" href="<?php echo e(route('admin.vendas.faturas.customers.contrato', ['id' => $cliente->id])); ?>" >
                                        <i class="fa fa-file"></i>
                                    </a>
                                    <?php else: ?>
                                    <a class='btn btn-xs yellow-soft popovers' data-container="body" data-trigger="hover" data-placement="top" data-content="Visualizar contratos do cliente" href="<?php echo e(route('admin.vendas.faturas.customers.contrato', ['id' => $cliente->id])); ?>?codVenda=<?php echo e($cliente->venda_id); ?>" >
                                        <i class="fa fa-file"></i>
                                    </a>
                                        <?php if(routeAcess('admin.vendas.faturas.customers.aprova.desconto.total') || routeAcess('admin.vendas.faturas.customers.aprova.desconto')): ?>
                                            <a class='btn btn-xs red popovers' data-container="body" data-trigger="hover" data-placement="top" data-content="Visualizar contratos do cliente" onclick="recusarDesconto('<?php echo e(route('admin.vendas.faturas.customers.excluir.desconto',['vendaId'=>$cliente->venda_id])); ?>')">
                                                <i class="fa fa-times"></i>
                                            </a>
                                        <?php endif; ?>
                                    <?php endif; ?>

                                </td>
                            </tr>
                            <?php endforeach; ?> 
                            <?php if(count($clientes)==0): ?>
                            <tr>
                                <td class="text-center" colspan="7">
                                    Não existem clientes para serem exibidos.
                                </td>
                            </tr>
                            <?php endif; ?>                                      
                        </tbody>
                        <tfoot>
                            <tr>
                                <td colspan="8" align="center">
                                    <?php echo $paginacao; ?>

                                </td>
                            </tr>
                        </tfoot>
                    </table> 
                    <script type="text/javascript">
                        function recusarDesconto(url){
                            swal({
                                title: "",
                                text: "Deseja excluir este desconto?",
                                type: "success",
                                html:true,
                                showCancelButton: true,
                                cancelButtonClass: "btn red fa fa-thumbs-o-up",
                                cancelButtonText: "Cancelar",
                                confirmButtonClass: "btn green-jungle fa fa-thumbs-o-up",
                                confirmButtonText: "Excluir",
                                closeOnConfirm: true,
                                closeOnCancel: true
                            },
                            function(isConfirm) {
                                if (isConfirm) {
                                    ajaxExcluide(url);
                                }
                            });
                        }
                        function ajaxExcluide(url){
                            $.ajax({
                                type: "GET", 
                                url: url, 
                                success: function(data) { 
                                    var data = JSON.parse(data);
                                    if(data!=0){
                                        swal({
                                            title: "",
                                            text: "Excluído com sucesso!",
                                            type: "success",
                                            html:true,
                                            confirmButtonClass: "btn btn-lg btn-primary",
                                            confirmButtonText: "OK",
                                            closeOnConfirm: true,
                                        },
                                        function(isConfirm) {
                                            location.reload();
                                        });
                                    }else{
                                        swal({
                                            title: "",
                                            text: "Não foi possível excluir, entre em contato com o administrador do sistema!",
                                            type: "warning",
                                            html:true,
                                            confirmButtonClass: "btn btn-lg btn-primary",
                                            confirmButtonText: "OK",
                                            closeOnConfirm: true,
                                        });
                                    }
                                } 
                            });
                        }
                    </script>