<?php
	require '../Com.php';
	valUs();
	$ped = $_POST["pedido"];
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Hacer requisición</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">
    <script type="text/javascript">
    	function buscar() {
			var input, filter, table, tr, td, i, txtValue;
			input = document.getElementById("buscador");
			filter = input.value.toUpperCase();
			table = document.getElementById("tabla");
			tr = table.getElementsByTagName("tr");

			for (i = 0; i < tr.length; i++) {
				td = tr[i].getElementsByTagName("td")[0];
				if (td) {
					txtValue = td.textContent || td.innerText;
					if (txtValue.toUpperCase().indexOf(filter) > -1) {
						tr[i].style.display = "";
					} else {
						tr[i].style.display = "none";
					}
				}
			}
		}
    </script>
</head>
<body>
	<?php
		require '../nav.php';
		$prods = mysqli_query($con, "SELECT * FROM productos");
	?>
	<table class="table table-striped" id="tabla">
		<thead>
			<tr>
				<th>Nombre</th>
				<th>Stock</th>
				<th>Stock fábrica</th>
				<th>Stock tienda 1</th>
				<th>Stock tienda 2</th>
				<th>Stock tienda 3</th>
				<th>Stock tienda 4</th>
				<th><input type="text" id="buscador" class="form-control" onkeyup="buscar()" placeholder="Buscar color"></th>
			</tr>
		</thead>
		<tbody>
<?php
	$i = 0;
	while ($p = mysqli_fetch_assoc($prods)){
		echo '
			<form action="levPed.php" method="POST" id="modi', $i,'" style="display: none;">
				<input type="hidden" name="clave" value="', $p["Clave"],'">
				<input type="hidden" name="stock" value="', $p["ExisAlm"], '">
				<input type="hidden" name="stockFab" value="', $p["ExisFab"], '">
				<input type="hidden" name="nombre" value="', $p["Nombre"], '">
				<input type="hidden" name="unidad" value="', $p["Unidad"], '">
				<input type="hidden" name="pedido" value="', $ped, '">
			</form>
			<tr>
				<td>', $p["Nombre"],'</td>
				<td>', $p["ExisAlm"],'</td>
				<td>', $p["ExisFab"],'</td>
				<td>', $p["ExisTien1"],'</td>
				<td>', $p["ExisTien2"],'</td>
				<td>', $p["ExisTien3"],'</td>
				<td>', $p["ExisTien4"],'</td>
				<td><button type="button" class="btn btn-primary" onclick="document.getElementById(\'modi', $i,'\').submit()">Levantar pedido</button></td>
			</tr>
		';
		$i++;
	}
?>
		</tbody>
	</table>
</body>
</html>


