<?php include "../index/conexion.inc" ?>
<?php include "../index/validacion.php" ?>
<!doctype html>
<html lang="es">
	<head>
		<?php include '../index/head.php'; ?>
		<script language="javascript">
			function recargar()
			{
				var v01 = $('select[name=opcion]').val();
				var v02 = $('select[name=bodega]').val();
				var v03 = $('input[name=desde]').val();
				var v04 = $('input[name=hasta]').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_06.php", {v1:v01,v2:v02,v3:v03,v4:v04}, 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_06_pdf.php" enctype="multipart/form-data" onsubmit="valida_campos(this);" target="_blank">
								<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-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>
								<div class="col-md-3">
									<select id="heard" class="form-control" name="opcion">
										<option value="1">BASICO</option>
										<option value="2">BOXMASTER</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>
		<?php include '../index/footer.php'; ?>
		<?php include '../index/fbody.php'; ?>
	</body>
</html>
<script>
	var mipopup;
	function popup01(d01)
	{
		v01 = d01;
		posicion_x=(screen.width/2)-(1000/2);
		posicion_y=(screen.height/2)-(600/2)-50;
		mipopup = window.open("reporte_06_toma.php?id="+v01, "neo", "width=1000, Height=600, menubar=0, toolbar=0,directories=0,scrollbars=no,resizable=no,left="+posicion_x+",top="+posicion_y+"");
		mipopup.focus()
	}
</script>
<script>
	var mipopup;
	function popup03(d01, d02, d03)
	{
		v01 = d01;
		v02 = d02;
		v03 = d03;
		posicion_x=(screen.width/2)-(1000/2);
		posicion_y=(screen.height/2)-(320/2)-50;
		mipopup = window.open("reporte_06_net.php?id="+v01+"&id2="+v02+"&id3="+v03, "neo", "width=1000, Height=320, menubar=0, toolbar=0,directories=0,scrollbars=no,resizable=no,left="+posicion_x+",top="+posicion_y+"");
		mipopup.focus()
	}
</script>
<script>
	function popup04(d01)
	{
		v01 = d01;
		posicion_x=(screen.width/2)-(600/2);
		posicion_y=(screen.height/2)-(300/2)-50;
		mipopup = window.open("reporte_06_est.php?id="+v01, "neo", "width=600, Height=300, menubar=0, toolbar=0,directories=0,scrollbars=no,resizable=no,left="+posicion_x+",top="+posicion_y+"");
		mipopup.focus()
	}
</script>
<script>
	function popup05(d01)
	{
		v01 = d01;
		posicion_x=(screen.width/2)-(600/2);
		posicion_y=(screen.height/2)-(300/2)-50;
		mipopup = window.open("reporte_06_fec.php?id="+v01, "neo", "width=600, Height=300, menubar=0, toolbar=0,directories=0,scrollbars=no,resizable=no,left="+posicion_x+",top="+posicion_y+"");
		mipopup.focus()
	}
</script>
<script>
	function excel06()
	{
		var v01 = $('select[name=opcion]').val();
		var v02 = $('select[name=bodega]').val();
		var v03 = $('input[name=desde]').val();
		var v04 = $('input[name=hasta]').val();
		window.open("reporte_06_xlsx.php?id1="+v01+"&id2="+v02+"&id3="+v03+"&id4="+v04);
	}
</script>
<script>
	function confirmar_mov(f)
	{
		if(this.brazaletes.cBZT02.value == '')
		{
			alert("Ingrese una Ubicacion.")
			this.brazaletes.cBZT02.focus();
			return false;
		}
		if(this.brazaletes.cBZT03.value == '')
		{
			alert("Ingrese una Caja master.")
			this.brazaletes.cBZT03.focus();
			return false;
		}
		if(this.brazaletes.cBZT04.value == '')
		{
			alert("Ingrese un Codigo de barras.")
			this.brazaletes.cBZT04.focus();
			return false;
		}
		if(this.brazaletes.cBZT05.value == 0)
		{
			alert("Ingrese unidades.")
			this.brazaletes.cBZT05.focus();
			return false;
		}
		if(this.brazaletes.cBZT06.value == 0)
		{
			alert("Ingrese el numero de gondola.")
			this.brazaletes.cBZT06.focus();
			return false;
		}
	}
</script>