<?php 
	if(!isset($_SESSION))
		session_start();
	if (!isset($_SESSION['usuarioLogin']) || $_SESSION['usuarioLogin'] == ""){
		session_unset();
		session_destroy();
		header("Location: login.php");
		exit();
	}
?>
<?php
	require_once('../../Connections/catalogo.php');
	
	$marcas = $mysqli->query("SELECT * FROM marcaspiezas ORDER BY marca");
	
	if(!$marcas)
		echo "Error: " . $mysqli->error;	
?> 
    	<div class="table-row" style="border:none">
			<div class="col" style="border:none">
            	
            </div>
			<div class="col" style="border:none">
            	<H2>Piezas</H2>
            </div>            
			<div class="col" style="border:none">
            	<a href="javascript:MostrarAltaEditar('marcaspie','')">
                	<img class="btn_buscar" src="imagenes/agregar.png" width="85" height="85" />
            	</a>
            </div>
        </div>
<div class="heading">
    <div class="col">Editar</div>
    <div class="col">Marca</div>
    <div class="col">Eliminar</div>
</div>
<?php 
if ($marcas->num_rows > 0){
	while ($row = $marcas->fetch_object()){ 
	?>
		<div class="table-row">
			<div class="col">
            	<a href='javascript:MostrarAltaEditar("marcaspie", <?php echo $row->id ?>)'>
            		<img src="imagenes/editar.png" width="48" height="48" />
               	</a>
           	</div> 
			<div class="col"><?php echo $row->marca ?></div>
			<div class="col">
            	<a href='javascript:confirmarEliminar("marcaspie", "<?php echo $row->id ?>")'>	
                	<img src="imagenes/power-on-off.png" width="48" height="48" />
                </a>
            </div>
		</div>           
	<?php
	}
}   
else{
	echo "No existen marcas de piezas.";
}
?>
                

