<div class="row">
    <div class="col-lg-12">
        <div class="card card-accent-primary">
            <div class="card-header">
                <div class="row">
                    <div class="col-lg-12">
                        <h3 class="box-title" id="table-label-Atendimento">
                           Negociações                       
                        </h3> 
                    </div>
                </div>
            </div>
            <div class="card-body">
                <div class="table-container table-responsive">
                    <table id="dataTable" class="table table-striped table-bordered" style="width:100%">
                        <thead>
                            <tr>
                                <th>Id Chat</th>
                                <th>Interessado</th>
                                <th>Dono</th>
                                <th>Imovel</th>
                                <th>Bairro</th>
                                <th>Status</th>
                                <th>Etapa</th>
                                <th>nº msgs</th>
                                <th>Data</th>
                                <th>Ver Chat</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach($bairros as $bairro=>$imoveis) { ?>
                                <?php foreach($imoveis as $id_imovel=>$imovel) { ?>
                                    <?php foreach($imovel->chats as $id_chat=>$chat) { ?>
                                        <tr class="trData">
                                            <td><?php e($id_chat); ?></td>
                                            <td><a href="<?php e(base_url().'administrativo/usuarios/perfil/'.$chat->id_interessado); ?>" target="_blank"><i class="icon-user-follow icons font-2xl"></i> </a></td>
                                            <td><a href="<?php e(base_url().'administrativo/usuarios/perfil/'.$chat->id_dono); ?>" target="_blank"><i class="icon-user icons font-2xl"></i> </a></td>
                                            <td><a href="<?php e(base_url().'imovel/'.$id_imovel); ?>" target="_blank"> <?php e($imovel->endereco); ?></a></td>
                                            <td><?php e($bairro); ?></td>
                                            <td>
                                                <?php if($chat->chat_status == 2){e("Status ".$chat->chat_status." - Aguardando o dono aceitar o interessado");} ?>
                                                <?php if($chat->chat_status == 3){e("Status ".$chat->chat_status." - aceitou o interessado");} ?>
                                                <?php if($chat->chat_status == 4){e("Status ".$chat->chat_status." - negou o interessado");} ?>
                                            </td>
                                            <td><?php e($chat->etapa); ?></td>
                                            <td><?php e(count($chat->msgs) -1); ?></td>
                                            <td><?php e(end($chat->msgs)->dt_msg); ?></td>
                                            <td><a href="<?php e(base_url().'administrativo/braco_direito/chat/'.$id_imovel.'/'.$id_chat); ?>" target="_blank"><i class="icon-speech font-2xl"></i></a></td>
                                        </tr>
                                    <?php } ?>    
                                <?php } ?>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>