<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($contCapturas); ?></div>
                                <small class="text-muted text-uppercase font-weight-bold">Capturas</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>
                                
                            </div>
                        </div>
                        <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($contSolicitar); ?></div>
                                <small class="text-muted text-uppercase font-weight-bold">Solicitar Proposta</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">Ver Imoveis <strong class=""><?php e($contVer); ?></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>
                                </div>
                                <div class="text-value"><?php e($contSimulacoes); ?></div>
                                <small class="text-muted text-uppercase font-weight-bold">Simulações Completas</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>
                                
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div id="accordion">
            
            <!-- /.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 Financiamento</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>Destino</th>
                                                <th class="sorting_asc_custom">Data captura</th>
                                                <th>Cadastro</th>
                                                <th>Simulação</th>
                                                <th>Valor</th>
                                                <th style="min-width: 130px;">Último atendimento</th>
                                                <th style="min-width: 130px;">Proximo atendimento</th>
                                                <th style="min-width: 130px;" class="hiden-filter">Ações</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)));
                                                ?>
                                                <td><?php e($captura->datetime_captura == 0 ? $nenv:$denv); ?></td>
                                                <td><?php e($captura->cadastro??'Não'); ?></td>
                                                <td><?php e($captura->financiamento??'Não'); ?></td>
                                                <td><span class="d-none"><?php e($captura->valor); ?></span><?php e(money($captura->valor)); ?></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) ?>" >
                                                    <?php if($this->session->perfil != '7'){ ?>
                                                        <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((isset($captura->simulacao[0]->step) && $captura->simulacao[0]->step >= 4)){ ?>
                                                    <a href="<?php e(base_url()); ?>administrativo/financiamentos/bancos/<?php e($captura->simulacao[0]->id_simulacao); ?>/0" target="_blank" class="btn btn-secondary mb-1" data-interesse="financiamento-imovel" data-atendimento='' data-toggle="tooltip" data-original-title="Visualizar financiamento">
                                                        <i class="fa fa fa-credit-card"></i>
                                                    </a>
                                                    <?php } else{ ?>
                                                    
                                                    <a href="javascript:;" class="btn btn-danger mb-1" data-toggle="tooltip" data-original-title="Simulação inválida">
                                                        <i class="fa fa fa-credit-card"></i>
                                                    </a>
                                                    <?php } ?>
                                                    <?php if($this->session->perfil != '7'){ ?>
                                                        <?php if(!empty($captura->atendimento)){ ?>
                                                        <a href="<?php e(base_url().'administrativo/atendimento/atendimento_geral/financiamento/'.$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="financiamento" data-atendimento='<?php e(json_encode($captura)) ?>' data-toggle="tooltip" data-original-title="Adicionar atendimento">
                                                            <i class="icon-plus"></i>
                                                        </a>
                                                        <?php } ?>
                                                    <?php } ?>
                                                    
                                                </td>
                                            </tr>
                                            <?php } ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>