<?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 = $('input[name=desde]').val();
				var v02 = $('input[name=hasta]').val();
				var v03 = $('select[name=bodega]').val();
				var v04 = $('input[name=proveedor]').val();
				var v05 = $('input[name=departamento]').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_16.php", {v1:v01, v2:v02, v3:v03, v4:v04, v5:v05}, function(data){$("#recargado").html(data);});
			}
		</script>
	</head>
	<body class="nav-md" onLoad="recargar();">
		<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_16_xls.php" enctype="multipart/form-data">
								<div class="row">
									<div class="col-sm-2">
										<div class="form-group">
											<input type="date" class="form-control" value="<?php echo date('Y-m-d'); ?>" name="desde">
										</div>
									</div>
									<div class="col-md-2">
										<div class="form-group">
											<input type="date" class="form-control" value="<?php echo date('Y-m-d'); ?>" name="hasta">
										</div>
									</div>
									<div class="col-md-2">
										<div class="form-group">
											<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>
									</div>
									<div class="col-sm-2">
										<div class="input-group">
											<span class="input-group-btn">
												<button type="button" class="btn btn-dark" onclick="popup01();"><i class="fa fa-user"></i></button>
											</span>
											<input type="text" class="form-control" name="proveedor" placeholder="Cod.Proveedor">
										</div>
									</div>
									<div class="col-sm-2">
										<div class="input-group">
											<span class="input-group-btn">
												<button type="button" class="btn btn-dark" onclick="popup02();"><i class="fa fa-building"></i></button>
											</span>
											<input type="text" class="form-control" name="departamento" placeholder="Cod.Departamento">
										</div>
									</div>
									<div class="col-md-4">
										<div class="form-group">
											<button type="button" class="btn btn-dark" onclick="recargar();">
												<span class="glyphicon glyphicon-search" aria-hidden="true"></span> Buscar/Recargar
											</button>
										</div>
									</div>
								</div>
								<div class="row">
									<div class="col-xs-12" id="recargado">
									</div>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
		<?php include '../index/footer.php'; ?>
		<?php include '../index/fbody.php'; ?>
	</body>
</html>
<script>
	var mipopup;
	function popup01()
	{
		posicion_x=(screen.width/2)-(650/2);
		posicion_y=(screen.height/2)-(650/2)-50;
		mipopup = window.open("proveedores.php", "vtnpve", "width=650, Height=650, menubar=0, toolbar=0,directories=0,scrollbars=no,resizable=no,left="+posicion_x+",top="+posicion_y+"");
		mipopup.focus()
	}
</script>
<script>
	var mipopup;
	function popup02()
	{
		posicion_x=(screen.width/2)-(650/2);
		posicion_y=(screen.height/2)-(650/2)-50;
		mipopup = window.open("departamentos.php", "vtndpt", "width=650, Height=650, menubar=0, toolbar=0,directories=0,scrollbars=no,resizable=no,left="+posicion_x+",top="+posicion_y+"");
		mipopup.focus()
	}
</script>