<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> Contatos</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>Telefone</th>
                                                <th class="sorting_asc_custom">Data</th>
                                                <th>Assunto</th>
                                                <th style="min-width: 130px;">Mensagem</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($contatos as $id=>$contato) { ?>
                                            <tr class="trData" data-atendimento='<?php e(json_encode($contato->atendimento)) ?>'>
                                                <td><?php e($contato->nome); ?></td>
                                                <td><?php e($contato->email); ?></td>
                                                <td><?php e($contato->telefone); ?></td>
                                                <td><span class="d-none"><?php e($contato->data_hora); ?></span><?php e(date("d/m/Y H:i:s", strtotime($contato->data_hora))); ?></td>
                                                <td><?php e($contato->assunto); ?></td>
                                                <td><?php e($contato->mensagem); ?></td>
                                                <td><p class="resumo-text m-0"><?php e(end($contato->atendimento)->observacao??''); ?></p></td>
                                                <?php 
                                                    $proximo_contato = end($contato->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($contato->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) ?>" >
                                                    <a href="<?php e(base_url()); ?>administrativo/usuarios/perfil/<?php e($contato->cadastro->id_cadastro??0)?>/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($contato->atendimento)){ ?>
                                                    <a href="<?php e(base_url().'administrativo/atendimento/atendimento_geral/contato/'.$contato->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="contato" data-atendimento='<?php e(json_encode($contato->data_atendimento)) ?>' data-toggle="tooltip" data-original-title="Adicionar atendimento">
                                                        <i class="icon-plus"></i>
                                                    </a>
                                                    <?php } ?>
                                                </td>
                                            </tr>
                                            <?php } ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>