<?php
	if (!isset($_SESSION["admin"]["id"])) {
		echo "<script>location.href='index.php';</script>";
	}
?>

<div class="container" id="menu">
<br><br>
	<div class="panel panel-default">
	  <div class="panel-heading"><strong>Acesso Rápido</strong></div>
	  <div class="panel-body">
	    	<div class="row">
				<div class="col-md-3 col-sm-2 col-xm-4">
					
						<a href="cadastro/email" class="thumbnail text-center" title="Cadastrar Pesquisa">
							<h1>
								<i class="glyphicon glyphicon-envelope"></i>
							</h1>
							<p>
							Enviar Boletos<br>por E-mail
							</p>
						</a>
					
				</div>
				<div class="col-md-3 col-sm-2 col-xm-4">
					
						<a href="cadastro/boletos" class="thumbnail text-center" title="Cadastrar Arquivo">
							<h1>
								<i class="glyphicon glyphicon-save"></i>
							</h1>
							<p>
							Importar <br>Boletos e Notas
							</p>
						</a>
					
				</div>
				<div class="col-md-3 col-sm-2 col-xm-4">
					
						<a href="cadastro/importar" class="thumbnail text-center" title="Cadastrar Arquivo">
							<h1>
								<i class="glyphicon glyphicon-transfer"></i>
							</h1>
							<p>
							Importar <br>Dados de Clientes
							</p>
						</a>
					
				</div>
				<div class="col-md-3 col-sm-2 col-xm-4">
					
						<a href="cadastro/arquivo" class="thumbnail text-center" title="Cadastrar Arquivo">
							<h1>
								<i class="glyphicon glyphicon-barcode"></i>
							</h1>
							<p>
							Cadastrar Novo <br>Arquivo
							</p>
						</a>
					
				</div>
				<div class="col-md-3 col-sm-2 col-xm-4">
					
						<a href="cadastro/cliente" class="thumbnail text-center" title="Cadastrar Notícia">
							<h1>
								<i class="glyphicon glyphicon-user"></i>
							</h1>
							<p>
							Cadastrar Novo <br>Cliente
							</p>
						</a>
					
				</div>
				

				<div class="col-md-3 col-sm-2 col-xm-4">
					
						<a href="cadastro/configuracao" class="thumbnail text-center" title="Configurações">
							<h1>
								<i class="glyphicon glyphicon-cog"></i>
							</h1>
							<p>
							
							Configurações <br>do Site
							</p>
						</a>
					
				</div>

				<div class="col-md-3 col-sm-2 col-xm-4">
					
						<a href="senha" class="thumbnail text-center" title="Trocar Senha">
							<h1>
								<i class="fa fa-unlock-alt"></i>
							</h1>
							<p>
							Trocar sua<br>
							Senha
							</p>
						</a>
					
				</div>

				<div class="col-md-3 col-sm-2 col-xm-4">
					
						<a href="sair" class="thumbnail text-center" title="Sair do Sistema">
							<h1>
								<i class="glyphicon glyphicon-off"></i>
							</h1>
							<p>
							Sair do<br>
							Sistema
							</p>
						</a>
					
				</div>
			</div>
	  </div>
	</div>


	<div class="panel panel-default">
	  <div class="panel-heading"><strong>Relatórios Rápidos</div>
		  <div class="panel-body">
		    <div class="row">
			<div class="col-md-6">
				<a href="cadastro/envios" class="thumbnail pull-left" style="width:100%;padding:10px 10px 0px;">
					<div class="info pull-right">
						<p><strong>Total de Arquivos Enviados:</strong></p>
						<span style="color:red;font-size:1.5em">
						<?php

							$sql = "select * from envio";
							$consulta = $db->prepare($sql);
                			$consulta->execute();
                			echo @(int)$consulta->rowCount();
						?>
						</span>
					</div>
					<div class="icon pull-left">
						<i class="glyphicon glyphicon-tasks"></i>
					</div>
				</a>
			</div>

			<div class="col-md-6">
				<a  href="" class="thumbnail pull-left" style="width:100%;padding:10px 10px 0px;">
					<div class="info pull-right">
						<p><strong>Total de Arquivos Enviados este Mês:</strong></p>
						<span style="color:red;font-size:1.5em">
						<?php
							$data = date("Y-m");
							$sql = "select * from envio 
							where data like '$data%'";
							$consulta = $db->prepare($sql);
                			$consulta->execute();
                			echo @(int)$consulta->rowCount();;
						?>
						</span>		
						
					</div>
					<div class="icon pull-left">
						<i class="glyphicon glyphicon-envelope"></i>
					</div>
				</a>
			</div>
		</div>
	  </div>
	</div>

	<div class="panel panel-default">
	  <div class="panel-heading"><strong>Últimos Acessos de Clientes:</strong></div>
	  <div class="panel-body">
	    <table class="table table-bordered table-hover table-striped">
			<thead>
				<tr>
					<td>Nome do Cliente</td>
					<td>Data de Acesso</td>
					<td>Opções</td>
				</tr>
			</thead>
			<tbody>
				<?php
					$sql = "select distinct(c.id), a.id aid, a.ip, date_format(a.data,'%d/%m/%Y %H:%s') data, c.nome from acesso a inner join cliente c on (c.id = a.cliente_id) group by c.id order by a.data desc limit 10";
					$consulta = $db->prepare($sql);
	                $consulta->execute();

	                while ( $dados = $consulta->fetch(PDO::FETCH_OBJ) ) {

	                    echo "<tr><td>$dados->nome</td><td>$dados->data</td><td>
	                    	<a href='#' class='btn btn-success' title='Detalhes'><i class='glyphicon glyphicon-search' style='color:#fff'></i></a>
	                    </td></tr>";

	                }

				?>
			</tbody>
		</table>
	  </div>
	</div>

</div>
<style type="text/css">
	.info {
		width: 80%;
	}

	.icon {
		width: 20%;
		font-size: 4em;

	}
</style>