<div class="animated fadeIn">
    <div class="row">
        <!-- /.col-->
        <div class="col-md-12">
            <!-- /.row-->
            <!--<div class="row">
                <div class="col-md-12">
                    <div class="card-group mb-5">
                        <div class="card">
                            <div class="card-body">
                                <div class="h1 text-muted text-right mb-4">
                                    <i class="icon-globe"></i>
                                </div>
                                <div class="text-value"><?php e($contLand); ?></div>
                                <small class="text-muted text-uppercase font-weight-bold">Landingpage</small>
                                <div class="progress progress-xs my-2">
                                    <div class="progress-bar bg-primary" role="progressbar" style="width: 25%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
                                </div>
                                <small class="text-muted">Ativaram <strong class=""><?php e($contLandAtivo); ?></strong></small>
                            </div>
                        </div>
                        <div class="card">
                            <div class="card-body">
                                <div class="h1 text-muted text-right mb-4">
                                    <i class="icon-social-facebook"></i>
                                </div>
                                <div class="text-value"><?php e($contFace); ?></div>
                                <small class="text-muted text-uppercase font-weight-bold">Facebook</small>
                                <div class="progress progress-xs my-2">
                                    <div class="progress-bar bg-primary" role="progressbar" style="width: 25%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
                                </div>
                                <small class="text-muted">Ativaram <strong class=""><?php e($contFaceAtivo); ?></strong></small>
                            </div>
                        </div>
                        
                        <div class="card text-white bg-info">
                            <div class="card-body">
                                <div class="h1 text-muted text-right mb-4">
                                    <i class="icon-globe"></i>
                                    <i class="icon-social-facebook"></i>
                                </div>
                                <div class="text-value"><?php e($contLand+$contFace); ?></div>
                                <small class="text-muted text-uppercase font-weight-bold">Total</small>
                                <div class="progress progress-xs my-2">
                                    <div class="progress-bar bg-primary" role="progressbar" style="width: 25%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
                                </div>
                                <small class="text-muted">Ativaram <strong class=""><?php e($contLandAtivo+$contFaceAtivo); ?></strong></small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>-->
            
            <!-- /.row-->
            <div class="row">
                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-header"><a href="#" data-toggle="collapse" data-target="#collapsePrecadastros" aria-expanded="false" class="collapsed"><i class="icon-user-follow"></i> Leads Elleven</a>
                            <div class="card-header-actions">
                                <a class="card-header-action btn-minimize" href="#" data-toggle="collapse" data-target="#collapsePrecadastros" aria-expanded="false" class="collapsed">
                                    <i class="icon-arrow-up"></i>
                                </a>
                            </div>
                        </div>
                        <div class="collapse show" id="collapsePrecadastros" data-parent="#accordion">
                            <div class="card-body">
                                <div class="table-container table-responsive">
                                    <table class="display table table-striped table-bordered" style="width:100%">
                                        <thead>
                                            <tr>
                                                <th>Nome</th>
                                                <th>E-mail</th>
                                                <th style="min-width: 85px;">Telefone</th>
                                                <th>Origem</th>
                                                <th>Data captura/envio</th>
                                                <th class="sorting_asc_custom">Última atualização</th>
                                                <th>Unidade</th>
                                                <th style="min-width: 130px;">Último atendimento</th>
                                                <th style="min-width: 130px;">Proximo atendimento</th>
                                                <th style="min-width: 185px;">Ação</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            
                                            <?php foreach($capturas as $id=>$captura) { ?>
                                            
                                            <tr id="divImovel_<?php e($id) ?>" class="trData" data-atendimento='<?php e(json_encode($captura->atendimento)) ?>'>
                                                <td><?php e($captura->nome); ?></td>
                                                <td><?php e($captura->email); ?></td>
                                                <td><?php e($captura->telefone); ?></td>
                                                <td><?php e($captura->mensagem == ''?'Landingpage':$captura->mensagem); ?></td>
                                                <?php 
                                                    $nenv = '<span class="d-none">000000000</span>'.'<span class="badge badge-danger">Não enviado</span>'; 
                                                    $denv = '<span class="d-none">'.$captura->datetime_captura.'</span>'.(date("d/m/Y H:i:s", strtotime($captura->datetime_captura)));
                                                    $denv_atulizacao = '<span class="d-none">'.$captura->ultima_atualizacao.'</span>'.(date("d/m/Y H:i:s", strtotime($captura->ultima_atualizacao)));
                                                ?>
                                                <td><?php e($captura->datetime_captura == 0 ? $nenv:$denv); ?></td>
                                                <td><?php e($captura->ultima_atualizacao == 0 ? $nenv:$denv_atulizacao); ?></td>
                                                <td><?php e($captura->tipo_imovel); ?></td>
                                                
                                                <td><p class="resumo-text m-0"><?php e(end($captura->atendimento)->observacao??''); ?></p></td>
                                                <?php 
                                                    $proximo_contato = end($captura->atendimento)->proximo_contato??'';
                                                    if($proximo_contato == 0 || $proximo_contato == '0000-00-00 00:00:00'){
                                                         $proximo_contato = '';
                                                         $alert = '<span class="d-none">z'.$proximo_contato.'</span>';
                                                    }else{
                                                        $alert = '<span class="d-none">a'.$proximo_contato.'</span>'.
                                                                 '<span class="badge badge-danger">'.date("d/m/Y", strtotime($proximo_contato)).'</span>';
                                                    }
                                                    $normal = '<span class="d-none">b'.$proximo_contato.'</span>'.(date("d/m/Y", strtotime($proximo_contato)));
                                                ?>
                                                <td>
                                                    <?php 
                                                    $proximo_contato = end($captura->atendimento)->proximo_contato??'';
                                                    if($proximo_contato == 0 || $proximo_contato == '0000-00-00 00:00:00'){
                                                         $proximo_contato = '';
                                                         $alert = '<span class="d-none">z'.$proximo_contato.'</span>';
                                                    }else{
                                                        $alert = '<span class="d-none">a'.$proximo_contato.'</span>'.
                                                                 '<span class="badge badge-danger">'.date("d/m/Y", strtotime($proximo_contato)).'</span>';
                                                    }
                                                    $normal = '<span class="d-none">b'.$proximo_contato.'</span>'.(date("d/m/Y", strtotime($proximo_contato)));
                                                    
                                                    e($proximo_contato <= date("Y-m-d H:i:s") ? $alert:$normal);
                                                    ?>
                                                </td>
                                               
                                                <td class="tdAction_<?php e($id) ?>" >
                                                    <span class='d-none'><?php e(empty($captura->atendimento) ? 0 : 1); ?></span>
                                                    
                                                    <a href="<?php e(base_url()); ?>administrativo/usuarios/perfil/<?php e($captura->id_cadastro??0)?>/<?php e($captura->id_captura??0)?>" target="_blank" class="btn btn-secondary mb-1" data-toggle="tooltip" data-original-title="Visualizar perfil">
                                                            <i class="icon-user"></i> 
                                                    </a>
                                                    <?php if(!empty($captura->atendimento)){ ?>
                                                    <a href="<?php e(base_url().'administrativo/atendimento/atendimento_geral/elleven/'.$captura->atendimento[0]->id_atendimento); ?>" class="actAtendimento btn btn-success mb-1" data-id="<?php e($id); ?>" data-toggle="tooltip" data-original-title="Visualizar atendimento">
                                                        <i class="icon-check"></i>
                                                    </a>
                                                    <?php }else{ ?>
                                                    <a href="javascript:;" class="addAtendimentoGeral btn btn-primary mb-1" data-interesse="elleven" data-atendimento='<?php e(json_encode($captura)) ?>' data-toggle="tooltip" data-original-title="Adicionar atendimento">
                                                        <i class="icon-plus"></i>
                                                    </a>
                                                    <?php } ?>
                                                    
                                                    <?php if($captura->status_captura < 10){ ?>
                                                            <li class="list-inline-item" data-toggle="tooltip" data-placement="top" title="" data-original-title="Dispensar">
                                                                <button class="btn btn-danger mb-1 set_leed" data-id="<?php e($captura->id_captura); ?>" data-origem="olx" type="button" data-toggle="modal" data-target="#dangerModal">
                                                                    <i class="icon-dislike"></i>
                                                                </button>
                                                            </li>
                                                    <?php } ?>
                                                </td>
                                            </tr>
                                            <?php } ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="modalResend" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
    <div class="modal-dialog modal-success" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">Reenviar E-mail de Ativação</h4>
                <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">
                <p>Tem certeza que deseja reenviar o e-mail de ativação para o cliente?</p>
            </div>
            <div class="modal-footer">
                <a href="javascript:;" class="btn btn-success btn_resend">Reenviar</a>
                <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancelar</button>
            </div>
        </div>
    </div>
</div>