<?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');
	if (isset($_GET['idPieza']) && $_GET['idPieza'] != ''){
		$query = "DELETE FROM piezascodigos WHERE idPieza = " . $_GET['idPieza'];
		$mysqli->query($query);
		$query = "DELETE FROM piezas WHERE id = " . $_GET['idPieza'];
		$mysqli->query($query);
	}
	
	$urlReferer = $_SERVER['HTTP_REFERER'];
	header("Location: " . $urlReferer);
	exit();
?>