<?php include "conexion.inc" ?>
<?php include "validacion.php" ?>
<!doctype html>
<html lang="es">
	<head>
		<?php include '../index/head.php'; ?>
		<script language="javascript">
			function recargar()
			{
				var v01 = $('select[name=bodega]').val();
				$('#recargado').html('<div class="d-flex justify-content-center"><img src="../images/loader.gif" width="150" alt="loading"/><br/>Un momento, por favor...</div>');
				$.post("reporte_04.php", {v1:v01}, function(data){$("#recargado").fadeIn(1000).html(data);});
			}
		</script>
	</head>
	<body class="nav-md">
		<div class="container body">
			<div class="main_container">
				<?php include '../index/body.php'; ?>
				<div class="right_col" role="main">
					<div class="">
						<!-- page content -->
						<div class="clearfix"></div>
						<div class="row">
							<div class="col-md-12 col-sm-12 col-xs-12">
								<form name="neo" class="form-vertical" method="POST" action="reporte_04_xls.php" enctype="multipart/form-data">
									<div class="col-md-3">
										<select id="heard" class="form-control" name="bodega">
											<?php
												// conexión
												$servername = $svr_servidor;
												$conectioninfo = array("Database"=>$svr_base, "UID"=>$svr_usuario, "PWD"=>$svr_contrasena, "CharacterSet"=>"UTF-8");
												$conexion = sqlsrv_connect($servername, $conectioninfo);
												if ($conexion == false)
												{
													$mensaje = "Existe un error al intentar conectarse con el servidor...";
												}
												else
												{
													// CONSULTA SQL
													$sql = "SELECT DISTINCT A.BODEGA, B.NOMBREALMACEN AS ALMACEN \n"
														  ."FROM JOIN_INVENTARIO_FISICO AS A \n"
														  ."LEFT JOIN ALMACEN AS B ON (A.BODEGA = B.CODALMACEN COLLATE Latin1_General_CS_AI) \n"
														  ."ORDER BY A.BODEGA ASC";
													$pa1 = array();
													$op1 = array("scrollable" => SQLSRV_CURSOR_KEYSET);
													$re1 = sqlsrv_query($conexion, $sql, $pa1, $op1);
													while($fila = sqlsrv_fetch_array($re1))
													{
														echo "
															<option value=".$fila['BODEGA'].">".$fila['BODEGA'].".- ".$fila['ALMACEN']."</option>
														";
													}
												}
											?>
										</select>
									</div>
									<button type="button" class="btn btn-dark" onclick="recargar();">
										<span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Buscar/Recargar
									</button>
									<div class="row">
										<div class="col-xs-12" id="recargado">
										</div>
									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<?php include '../index/footer.php'; ?>
		<?php include '../index/fbody.php'; ?>
	</body>
</html>