<div class="navbar-custom-menu">
    <ul class="nav navbar-nav">
        <li class="dropdown messages-menu">
            <!-- User Account: style can be found in dropdown.less -->
            <li class="dropdown user user-menu">
                <a href="#" id="user-menu" class="dropdown-toggle" data-toggle="dropdown" title="Usuário">
                    <i class="fa fa-smile-o" aria-hidden="true"></i>
                    <!--<img src="<?php echo base_url() . 'themes/painel/img/ico-administrator.jpg' ?>" class="user-image" alt="User Image">-->
                    <span class="hidden-xs"><?php echo $userdata['nome_abreviado'] ?></span>
                </a>
                <ul class="dropdown-menu">
                    <!-- User image -->
                    <li class="user-header">
            
                        <i class="fa fa-smile-o" aria-hidden="true"></i>
                        <!--<img src="<?php echo base_url() . 'themes/painel/img/ico-administrator.jpg' ?>" class="img-circle" alt="User Image">-->
                        <p>
                            <?php echo $userdata['nome'] ?>
                            <small><?php echo $userdata['perfil_name'] ?></small>
                        </p>
                        <p>Esse é seu <b><?php echo $userdata['n_acessos_sistema'];?>°</b> acesso.
                        
                        <?php if($userdata['n_acessos_sistema'] > 1) {?>
                        
                        Seu último acesso foi em <b><?php echo $userdata['data_acesso'];?></b> as <b><?php echo $userdata['hora_acesso']; ?></b>.</p>
                        
                        <?php } else{?></p><?php }?>
                    </li>
                    <!-- Menu Footer-->
                    <li class="user-footer">
                        <div class="pull-left">
                            <a href="<?php echo base_url() . 'sistema/usuarios/meus_dados'; ?>" class="btn btn-default btn-flat">Meus Dados</a>
                        </div>
                        <div class="pull-right">
                            <a href="javascript:;" class="btn btn-danger btn-flat btn-logout" title="Sair">Sair</a>
                        </div>
                    </li>
                </ul>
            </li>
            <?php if (isset($contato) && !is_null($contato) && !empty($contato['num'])) { ?>
                
            <li class="dropdown messages-menu">
                <a href="#" id="t-contato" class="dropdown-toggle" data-toggle="dropdown" title="Mensagens">
                    <i class="fa fa-envelope-o"></i>
                    <span class="label label-success"><?php e($contato['num']); ?></span>
                </a>
                <ul class="dropdown-menu">
                    <li class="header">Você possui <?php e($contato['num']); ?> mensagens</li>
                    <?php  
                        if ($contato['num'] > 0) { 
                        foreach ($contato['notes'] as $note) { 
                    ?>
                    <li>
                        <ul class="menu">
                            <li>
                                <a href="<?php echo $note['link']; ?>">
                                    
                                    <?php
                                        $nome = $note['name'];
                                        
                                        if (strlen($nome) > 17) 
                                        {
                                            $corte = substr($nome, 0, 17);
                                            $nome = substr($corte, 0, strrpos($corte, ' ')) . '...';
                                        }
                                    ?>
                                    
                                    <h4><?php echo $nome; ?>
                                    <small><i class="fa fa-clock-o"></i> <?php echo $note['data']; ?></small>
                                    </h4>
                                    <p><?php echo $note['msg']; ?></p>
                                </a>
                            </li>
                        </ul>
                    </li>
                    <?php }} ?>
                    <li class="footer"><a href="<?php echo base_url('blog/conta/inbox'); ?>">Ver todas as Mensagens</a></li>
                </ul>
            </li>
                
            <?php } else { ?>
            
            <li class="dropdown messages-menu">
                <a href="#" id="t-contato" class="dropdown-toggle" data-toggle="dropdown" title="Mensagens">
                  <i class="fa fa-envelope-o"></i>
                  <span class="label label-success">0</span>
                </a>
                <ul class="dropdown-menu">
                    <li class="header text-center">Você não possui mensagens novas</li>
                    <li class="footer"><a href="<?php echo base_url('blog/conta/inbox'); ?>">Ver todas as Mensagens</a></li>
                </ul>
            </li>
    
            <?php } ?>

            <?php if (isset($messages) && Toolbar::has_message()) { ?>
            <li class="dropdown messages-menu">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" title="Mensagens">
                    <i class="fa fa-bell-o"></i>
                    <span class="label label-warning"><?php e($messages['num']); ?></span>
                </a>
                <ul class="dropdown-menu">
                
                    <li class="header">Você possui <?php e($messages['num']); ?> notificações</li>
                
                <?php 
                    if ($messages['num'] > 0) { 
                    foreach ($messages['notes'] as $note) 
                    {
                ?>
                <li>
                    <ul class="menu">
                      <li>
                        <a href="<?php echo $note['link']; ?>">
                          <h4><?php echo $note['title']; ?></h4>
                          <p><?php echo $note['msg']; ?></p>
                        </a>
                      </li>
                    </ul>
                </li>
                  
                  <?php } }?>
                </ul>
            </li>
            
            <?php } ?>

            <li class="user user-menu">
            	<a href="#" id="tour" title="Ajuda">
            	    <i class="fa fa-question-circle" aria-hidden="true"></i><span class="hidden-xs"></span>
            	</a>
            </li>
            
            <li class="no-pointer t-clock" id="t-clock" title="Tempo da sessão"> <span><i class="fa fa-clock-o"></i> <font id="clock"></font></span></li>

            <!-- Logout Button -->
            <li>
                <a id="btn-logout-top" class="btn-logout" title="Sair" javascript:;=""><i class="fa fa-sign-out"></i></a>
            </li>
        </li>
    </ul>
</div>