<?php
session_start();
?>

<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<?php include "includes/scripts.php"; ?>
	<title>CHICLAYO TIERRA DE TODOS | COTIZACIONES</title>
	<link rel="stylesheet" type="text/css" href="css/responsive.css">
	<link rel="icon" href="../img/icologo.ico">
</head>

<body>
	<?php

	include "includes/header.php";
	include "../conexion.php";

	//$querydash   = mysqli_query($conection, "CALL dataDashboard();");
	$querydash = mysqli_query($conection, "SELECT 
    (SELECT COUNT(*) FROM usuario) AS usuarios,
    (SELECT COUNT(*) FROM cliente) AS clientes,
    (SELECT COUNT(*) FROM proveedor) AS proveedores,
    (SELECT COUNT(*) FROM producto) AS productos,
    (SELECT COUNT(*) FROM factura) AS facturas");
	
	$result_dash = mysqli_num_rows($querydash);
	if ($result_dash > 0) {
		$data_dash = mysqli_fetch_assoc($querydash);
		mysqli_close($conection);
	}

	?>
	<section id="container"><br>
		<div class="divContainer">
			<div>
				<h1 class="titlePanelControl">Panel de Control - CHICLAYO TIERRA DE TODOS</h1>
			</div>
			<div class="dashboard">
				<?php
				if ($_SESSION['rol'] == 1) {
				?>
					<a href="lista_usuarios.php">
						<i class="fas fa-users"></i>
						<p>
							<strong>Usuarios</strong><br>
							<span><?= $data_dash['usuarios']; ?></span>
						</p>
					</a>
				<?php } ?>

				<a href="lista_clientes.php">
					<i class="fas fa-clipboard-list"></i>
					<p>
						<strong>Clientes</strong><br>
						<span><?= $data_dash['clientes']; ?></span>
					</p>
				</a>

				<?php
				if ($_SESSION['rol'] == 1 || $_SESSION['rol'] == 2) {
				?>
					<a href="lista_proveedores.php">
						<i class="fas fa-clipboard-list"></i>
						<p>
							<strong>Proveedores</strong><br>
							<span><?= $data_dash['proveedores']; ?></span>
						</p>
					</a>
				<?php } ?>

				<a href="lista_producto.php">
					<i class="fas fa-cube"></i>
					<p>
						<strong>Productos</strong><br>
						<span><?= $data_dash['productos']; ?></span>
					</p>
				</a>

				<a href="cotizaciones.php">
					<i class="far fa-newspaper"></i>
					<p>
						<strong>Cotizaciones</strong><br>
						<span><?= $data_dash['facturas']; ?></span>
					</p>
				</a>

			</div>
		</div><br><br>

		<div class="containerPerfil">
			<div class="containerDataUser">

				<div class="logoUser">
					<img src="../img/logo.png">
				</div>

				<div class="divDataUser">
					<h4>Informacion personal</h4>

					<div>
						<label>Nombre:</label><span><?= $_SESSION['nombre']; ?></span>
					</div>

					<div>
						<label>Correo:</label><span><?= $_SESSION['email']; ?></span>
					</div>

					<br>

					<h4>Datos del usuario</h4>

					<div>
						<label>Rol:</label><span><?= $_SESSION['rol_name']; ?></span>
					</div>

					<div>
						<label>Usuario:</label><span><?= $_SESSION['user']; ?></span>
					</div>

				</div>
			</div>

			<div class="containerDataEmpresa">
				<div class="logoEmpresa">
					<img src="../img/logo.png">
				</div>

				<div class="divDataEmpresa">
					<h4>Datos de la empresa</h4>

					<div>
						<label>Ruc:</label><span>20479966789</span>
					</div>

					<div>
						<label>Nombre de la empresa:</label><span>CHICLAYO TIERRA DE TODOS</span>
					</div>

					<div>
						<label>Razon Social:</label><span>CHICLAYO TIERRA DE TODOS</span>
					</div>

					<div>
						<label>Telefono:</label><span>+51 986 538 204</span>
					</div>

					<div>
						<label>Correo Electronico:</label><span>contacto@chiclayotierradetodos.com</span>
					</div>

					<div>
						<label>Direccion:</label><span>Av. Santa Victoria Nro. 452 Int. 103 - CHICLAYO.</span>
					</div>

				</div>
			</div>
		</div>


	</section>
	<?php include "includes/footer.php"; ?>
</body>

</html>