<?php
	require '../Com.php';
	valUs();
	$consec = $_POST["clave"];
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Modificar fibra</title>
	<link rel="stylesheet" type="text/css" href="../css/bootstrap/css/bootstrap.min.css">
    <script src="../css/bootstrap/js/bootstrap.bundle.min.js"></script>
    <link rel="icon" href="../images/icon.png">
    <style type="text/css">
		form{
			width: 80%;
			margin: 10% auto;
		}

		.form-floating{
			margin: 2% 0;
		}
	</style>
	<script type="text/javascript">
		function cambioCat(){
			var cat = document.getElementById("cat").value;
			if (cat == "anilina"){
				document.getElementById("colorC").style.display = "block";
				document.getElementById("color").required = true;
				document.getElementById("tipoC").style.display = "none";
				document.getElementById("tipo").required = false;
			}
			else{
				document.getElementById("colorC").style.display = "none";
				document.getElementById("color").required = false;
				document.getElementById("tipoC").style.display = "block";
				document.getElementById("tipo").required = true;
			}
		}
	</script>
</head>
<body>
	<?php
		require '../nav.php';
		$actual = mysqli_fetch_assoc(mysqli_query($con, "SELECT * FROM Materias WHERE Consec='$consec'"));
		echo '
		<h5>Modificar fibra</h5>
	<form action="guardFib.php" method="POST">
		<input type="hidden" name="clave" value="', $consec,'">
		<div class="form-floating">
			<input type="text" name="nombre" id="nombre" value="', $actual["Nombre"],'" required class="form-control">
			<label for="nombre">Nombre</label>
		</div>
		<div class="form-floating">
			<select class="form-select" id="tip" name="tip" required >
		';
		if ($actual["Tipo"]=="alg"){
		    echo '
		        <option value="alg" selected>Algodón</option>
		    ';
		}
		else{
		    echo '
		        <option value="alg">Algodón</option>
		    ';
		}
		echo '
			</select>
			<label for="cat">Tipo</label>
		</div>
		';
		    echo '
		<div class="form-floating">
			<select class="form-select" id="um" name="um" required >
		';
		if ($actual["Unidad"]=="kg"){
		    echo '
				<option value="kg" selected>Kgs.</option>
		    ';
		}
		else{
		    echo '
				<option value="kg">Kgs.</option>
		    ';
		}
		echo '
			</select>
			<label for="um">Unidad de medida</label>
		</div>
		';
		echo '
		<div class="form-floating">
			<input type="text" name="den" id="den" value="', $actual["Denier"],'" required class="form-control">
			<label for="den">Denier</label>
		</div>
		<div class="form-floating">
			<input type="text" name="gxm" id="gxm" value="', $actual["Gmsxmt"],'" required class="form-control">
			<label for="gxm">Gms. por metro</label>
		</div>
		<br>
		<button type="submit" class="btn btn-primary">Guardar</button>
		';
	?>
	</form>
</body>
</html>

