<?php
if ($_SESSION['usuariologin']['usuario_perfil'] > 1):
    header('Location: painel.php?exe=indice/index');
    exit();
endif;

$Read = new Read;
$Read->ExeRead("usuarios");
$contUsuarios = $Read->getRowCount();
?>
<ul class="page-breadcrumb breadcrumb">
    <li>
        <span>Home</span>
        <i class="fa fa-circle"></i>
    </li>
    <li>
        <span>Dashboard</span>
    </li>
</ul>

<br>
<!--<div class="row widget-row">
    <div class="col-md-3">
         BEGIN WIDGET THUMB 
        <div class="widget-thumb widget-bg-color-white text-uppercase margin-bottom-20 bordered">
            <h4 class="widget-thumb-heading">Total de Pedidos</h4>
            <div class="widget-thumb-wrap">
                <i class="widget-thumb-icon bg-blue fa fa-shopping-cart"></i>
                <div class="widget-thumb-body">
                    <span class="widget-thumb-subtitle">QTD</span>
                    <span class="widget-thumb-body-stat" data-counter="counterup" data-value="7,644"><?= $contPedidos ?></span>
                </div>
            </div>
        </div>
         END WIDGET THUMB 
    </div>
    <div class="col-md-3">
         BEGIN WIDGET THUMB 
        <div class="widget-thumb widget-bg-color-white text-uppercase margin-bottom-20 bordered">
            <h4 class="widget-thumb-heading">Total de vendas</h4>
            <div class="widget-thumb-wrap">
                <i class="widget-thumb-icon bg-blue fa fa-credit-card"></i>
                <div class="widget-thumb-body">
                    <span class="widget-thumb-subtitle">R$</span>
                    <span class="widget-thumb-body-stat" data-counter="counterup" data-value="1,293"><?= $contVendas ?></span>
                </div>
            </div>
        </div>
         END WIDGET THUMB 
    </div>
    <div class="col-md-3">
         BEGIN WIDGET THUMB 
        <div class="widget-thumb widget-bg-color-white text-uppercase margin-bottom-20 bordered">
            <h4 class="widget-thumb-heading">Total de clientes</h4>
            <div class="widget-thumb-wrap">
                <i class="widget-thumb-icon bg-blue fa fa-user"></i>
                <div class="widget-thumb-body">
                    <span class="widget-thumb-subtitle">QTD</span>
                    <span class="widget-thumb-body-stat" data-counter="counterup" data-value="815"><?= $contUsuarios ?></span>
                </div>
            </div>
        </div>
         END WIDGET THUMB 
    </div>
    <div class="col-md-3">
         BEGIN WIDGET THUMB 
        <div class="widget-thumb widget-bg-color-white text-uppercase margin-bottom-20 bordered">
            <h4 class="widget-thumb-heading">Pessoas Online</h4>
            <div class="widget-thumb-wrap">
                <i class="widget-thumb-icon bg-blue fa fa-users"></i>
                <div class="widget-thumb-body">
                    <span class="widget-thumb-subtitle">QTD</span>
                    <span class="widget-thumb-body-stat" data-counter="counterup" data-value="5,071">1</span>
                </div>
            </div>
        </div>
         END WIDGET THUMB 
    </div>
</div>-->
<div class="row">
    <div class="col-md-4">
        <div class="portlet light bordered">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-calendar font-dark"></i>
                    <span class="caption-subject font-dark bold uppercase">Acessos Recentes</span>
                </div>
            </div>
            <div class="portlet-body">
                <div class="slimScrollDiv"><div class="scroller" style="height: 300px; overflow: hidden; width: auto;" data-always-visible="1" data-rail-visible="0" data-initialized="1">
                        <ul class="feeds">
                            <?php
                            $Read->ExeRead("acessos", "order by acesso_id desc LIMIT :limit", "limit=5");
                            foreach ($Read->getResult() as $acessos):
                                extract($acessos);

                                $data = date('Y-m-d', strtotime($acesso_data));
                                $hora = date('H:i', strtotime($acesso_data));

                                if ($data == date('Y-m-d')):
                                    $data_hora = $hora;
                                else:
                                    $data_hora = date('d/m/y', strtotime($acesso_data));
                                endif;
                                ?>
                                <li>
                                    <div class="col1">
                                        <div class="cont">
                                            <div class="cont-col1">
                                                <div class="label label-sm label-info">
                                                    <i class="fa fa-check"></i>
                                                </div>
                                            </div>
                                            <div class="cont-col2">
                                                <div class="desc"> <?= $usuario_nome; ?>.

                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col2">
                                        <div class="date"> <?= $data_hora; ?> </div>
                                    </div>
                                </li>
                                <?php
                            endforeach;
                            ?>
                        </ul>
                    </div><div class="slimScrollBar" style="background: rgb(187, 187, 187); width: 7px; position: absolute; top: 0px; opacity: 0.4; display: block; border-radius: 7px; z-index: 99; right: 1px; height: 161.002px;"></div><div class="slimScrollRail" style="width: 7px; height: 100%; position: absolute; top: 0px; display: none; border-radius: 7px; background: rgb(234, 234, 234); opacity: 0.2; z-index: 90; right: 1px;"></div></div>
                <div class="scroller-footer">
                    <div class="btn-arrow-link pull-right">
                        <a href="javascript:;">Veja todas</a>
                        <i class="icon-arrow-right"></i>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-8">
        <!-- Begin: life time stats -->
        <div class="portlet light bordered">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-users font-dark"></i>
                    <span class="caption-subject font-dark bold uppercase">Ultimos Usuários</span>
                    <span class="caption-helper"></span>
                </div>
            </div>
            <div class="portlet-body">
                <div class="table-scrollable table-scrollable-borderless">
                    <table class="table table-hover table-light">
                        <thead>
                            <tr class="uppercase">
                                <th> Usuário </th>
                                <th> E-mail </th>
                                <th> Status </th>
                                <th> Data </th>
                                <th>  </th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $Read->ExeRead("usuarios", "order by usuario_id desc LIMIT :limit", "limit=5");
                            foreach ($Read->getResult() as $usuarios):
                                extract($usuarios);
                                //0 = bloqueado | 1 = Ativo
                                if ($usuario_status = 0):
                                    $name_status_user = 'Bloqueado';
                                    $color_status = 'error';
                                else:
                                    $name_status_user = 'Ativo';
                                    $color_status = 'success';
                                endif;
                                ?>

                                <tr>
                                    <td> <?= $usuario_nome; ?> </td>
                                    <td> <?= $usuario_email; ?> </td>
                                    <td> <span class="label label-sm label-<?= $color_status; ?>"> <?= $name_status_user; ?> </span> </td>
                                    <td> <?= date('d/m/Y', strtotime($usuario_data_cad)); ?> </td>
                                    <td>  </td>
                                </tr>
                                <?php
                            endforeach;
                            ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!-- End: life time stats -->
    </div>
</div>