<?php 
	/*
		UserPie Version: 1.0
		http://userpie.com
		

	*/
	require_once("models/config.php");
	if(isUserLoggedIn()) { 
		
	}else{
		header("Location: index.php"); die(); 
	}	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Ingram Connect | <?php echo $websiteName; ?> </title>
<?php require_once("head_inc.php"); ?>



</head>
<body>
<?php require_once("navbar.php"); ?>
	<div id="content">
		<div class="container">
			<div class="row-fluid">
				<div class="span3" id="navbar">
					<h1>DigiByte</h1>
					<p>Bienvenido <strong><?php echo $loggedInUser->display_username; ?></strong></p>
					<nav>
						<ul class="nav nav-pills nav-stacked">
							<li><a href="userpage.php">Inventario</a></li>
							<li class="active"><a href="userpage-categorias.php">Categorias</a></li>
							<li><a href="userpage-marcas.php">Marcas</a></li>
							<li><a href="userpage-ordenes.php">Ordenes</a></li>
						</ul>
					</nav>
				</div>
				<div class="span9">
					
			       
			        <p align="right"><a target="_blank" class="btn btn-default" href="/api/categorias"><i class="icon-download-alt"></i> .json</a></p>
			        
					<?php
						include("db.php");		
						$rs = $link->query("select * from categorias_ingram"); 									
						$num = $rs->num_rows;
			        ?>
		            <?php
						if($num>0)
						{
							echo "<table class=\"table\">
							<caption>$num categorias</caption>
							<thead>
								<tr>
									<th>ID</th>
									<th>CATEGORIA</th>
								</tr>
							</thead>
							<tbody>";
							while($categoria = $rs->fetch_array())
							{
									echo "<tr>
									<td>".$categoria["id"]."</td>
									<td>".utf8_encode($categoria["nombre"])."</td>
									</tr>";														
							}
							echo "</tbody></table>";
						}
						else
						{
							echo "<div class=\"error\"><p>no se encontraron categorias</p></div>";
						}

			        ?>  			        
				</div>
			</div>			
		</div>
	</div>
</body>
</html>


