<?php include "../index/conexion.inc" ?>
<?php include "../index/validacion.php" ?>
<!doctype html>
<html lang="es">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<!-- Meta, title, CSS, favicons, etc. -->
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="icon" href="../images/me.ico" type="image/ico" />
		<title>Join Manager</title>
		<!-- Bootstrap -->
		<link href="../config/vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
		<!-- Font Awesome -->
		<link href="../config/vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
		<!-- NProgress -->
		<link href="../config/vendors/nprogress/nprogress.css" rel="stylesheet">
		<!-- iCheck -->
		<link href="../config/vendors/iCheck/skins/flat/green.css" rel="stylesheet">	
		<!-- Datatables -->
		<link href="../config/vendors/datatables.net-bs/css/dataTables.bootstrap.min.css" rel="stylesheet">
		<link href="../config/vendors/datatables.net-buttons-bs/css/buttons.bootstrap.min.css" rel="stylesheet">
		<link href="../config/vendors/datatables.net-fixedheader-bs/css/fixedHeader.bootstrap.min.css" rel="stylesheet">
		<link href="../config/vendors/datatables.net-responsive-bs/css/responsive.bootstrap.min.css" rel="stylesheet">
		<link href="../config/vendors/datatables.net-scroller-bs/css/scroller.bootstrap.min.css" rel="stylesheet">
		<!-- Custom Theme Style -->
		<link href="../config/build/css/custom.min.css" rel="stylesheet">
	</head>
	<body>
		<div class="top_nav">
			<div class="container body">
				<div class="main_container">
					<!-- page content -->
					<div class="right_col" role="main">
						<div class="clearfix"></div>
						<div class="x_panel">
							<div class="x_title">
								<?php
									$Carcod = 0;
									$CarNom = '';
									$CarTe1 = '';
									$CarTe2 = '';
									$CarTe3 = '';
									//
									$Pddv01 = '';
									$Pddv02 = '';
									$Pddv03 = '';
									$Pddv04 = '';
									$Pddv05 = '';
									$Pddv06 = '';
									$Pddv07 = '';
									$Pddv08 = '';
									//
									$Pddv99 = '';
									//
									$Pddv10 = 0;
									$Pddv11 = '';
									// 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 CABECER DEL CLIENTE
										$sql = "SELECT TOTNETO, L.CODCLIENTE, CONVERT(NVARCHAR(254), L.NOMBRECLIENTE) AS NOMBRECLIENTE, ISNULL(L.TELEFONO1, '') AS TELEFONO1, ISNULL(L.TELEFONO2, '') AS TELEFONO2, ISNULL(L.MOBIL, '') AS MOBIL  \n"
											  ."FROM PEDVENTACAB AS C INNER JOIN PEDVENTALIN AS PL ON C.NUMSERIE = PL.NUMSERIE AND C.NUMPEDIDO = PL.NUMPEDIDO \n"
											  ."INNER JOIN CLIENTES AS L ON (C.CODCLIENTE = L.CODCLIENTE) \n"
											  ."WHERE (C.NUMSERIE = '".$_GET['id']."') AND (C.NUMPEDIDO = ".$_GET['id2'].")  GROUP BY TOTNETO,L.CODCLIENTE, NOMBRECLIENTE, TELEFONO1, TELEFONO2, MOBIL ,PL.UNIDADESPEN ";
										$pa1 = array();
										$op1 = array('scrollable' => SQLSRV_CURSOR_KEYSET);
										// Lanzar la consulta
										$re1 = sqlsrv_query($conexion, $sql, $pa1, $op1);
										while($fila = sqlsrv_fetch_array($re1))
										{
											$Carcod = $fila['CODCLIENTE'];
											$CarNom = $fila['NOMBRECLIENTE'];
											$CarTe1 = $fila['TELEFONO1'];
											$CarTe2 = $fila['TELEFONO2'];
											$CarTe3 = $fila['MOBIL'];
											$Pddv10 = $fila['TOTNETO'];
										}
										sqlsrv_free_stmt($re1);
										// CONSULTA SQL
										$sql = "SELECT CONVERT(NVARCHAR(MAX), C.POBLADO_DE_ENTREGA + '.' + P.DESCRIPCION) AS POBLADOS, C.* \n"
											  ."FROM PEDVENTACAMPOSLIBRES AS C \n"
											  ."LEFT JOIN JOIN_POBLADOS_CAX AS P ON (C.POBLADO_DE_ENTREGA = P.CODIGOPOBLADO) \n"
											  ."WHERE (C.NUMSERIE = '".$_GET['id']."') AND (C.NUMPEDIDO = ".$_GET['id2'].")";
										$pa1 = array();
										$op1 = array('scrollable' => SQLSRV_CURSOR_KEYSET);
										// Lanzar la consulta
										$re1 = sqlsrv_query($conexion, $sql, $pa1, $op1);
										while($fila = sqlsrv_fetch_array($re1))
										{
											$Pddv01 = $fila['FACTURAR'];
											$Pddv02 = $fila['FORMA_DE_ENVIO'];
											$Pddv03 = $fila['MUNICIPIO_ENTREGA'];
											$Pddv04 = $fila['DIAS_DE_VENCIMIENTO'];
											$Pddv05 = $fila['DIRECCION_ENTREGA'];
											$Pddv06 = $fila['POBLADOS'];
											$Pddv07 = $fila['ESTADO_AD'];
											$Pddv08 = $fila['ESTADO_AD'];
											$Pddv11 = $fila['FORMA_PAGO'];
											$s1 = '';
											$s2 = '';
											$s3 = '';
											if ($Pddv01 == 'F')
												$s1 = 'Selected';
											if ($Pddv01 == 'T')
												$s2 = 'Selected';
											if ($Pddv01 == '')
												$s3 = 'Selected';
										}
										sqlsrv_free_stmt($re1);
										// CONSULTA SQL
										$sql = "SELECT * FROM PEDVENTACAB \n"
											  ."WHERE (NUMSERIE = '".$_GET['id']."') AND (NUMPEDIDO = ".$_GET['id2'].")";
										$pa1 = array();
										$op1 = array('scrollable' => SQLSRV_CURSOR_KEYSET);
										// Lanzar la consulta
										$re1 = sqlsrv_query($conexion, $sql, $pa1, $op1);
										while($fila = sqlsrv_fetch_array($re1))
										{
											$Pddv99 = $fila['OBSERVRESERVA'];
										}
										sqlsrv_free_stmt($re1);
									}
									sqlsrv_close($conexion);
								?>
								<h2>Datos de envio | Serie: <?php echo $_GET['id']; ?> | Pedido No.: <?php echo $_GET['id2']; ?></h2>
								<div class="clearfix"></div>
							</div>
							<div class="x_content">
								<form name="envios" class="form-vertical" method="POST" action="reporte_03_reg.php?id=<?php echo $_GET['id'] ?>&id2=<?php echo $_GET['id2'] ?>" enctype="multipart/form-data" onsubmit="return confirmar();valida_campos(this);">
									<?php
										if ($_GET['id3'] == '-1' ||  $_GET['id3'] == '1' ||  $_GET['id3'] == '3' ||  $_GET['id3'] == '36'  )
										{
											echo "
											<div class='row'>
												<div class='col-sm-2'>
													<div class='form-group'>
														<label>Cod.Cliente</label>
														<input type='number' class='form-control' name='CarCod' value='".$Carcod."' readonly>
													</div>
												</div>
												<div class='col-sm-4'>
													<div class='form-group'>
														<label>Cliente</label>
														<input type='text' class='form-control' name='CarNom' value='".$CarNom."' readonly>
													</div>
												</div>
												<div class='col-sm-2'>
													<div class='form-group'>
														<label>Telefono1</label>
														<input type='text' class='form-control' name='CarTe1' value='".$CarTe1."'>
													</div>
												</div>
												<div class='col-sm-2'>
													<div class='form-group'>
														<label>Telefono2</label>
														<input type='text' class='form-control' name='CarTe2' value='".$CarTe2."'>
													</div>
												</div>
												<div class='col-sm-2'>
													<div class='form-group'>
														<label>Movil</label>
														<input type='text' class='form-control' name='CarTe3' value='".$CarTe3."'>
													</div>
												</div>
											</div>
											<div class='row'>
												<div class='col-sm-2'>
													<div class='form-group'>
														<label>Facturar</label>
														<select class='form-control' name='cV01'>
															<option value='' ".$s3.">NINGUNO</option>
															<option value='F' ".$s1.">NO</option>
															<option value='T' ".$s2.">SI</option>
														</select>
													</div>
												</div>
												<div class='col-sm-4'>
													<div class='form-group'>
														<label>Metodo de envio</label>
														<select class='form-control' name='cV02'>";
															// 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 * FROM CAMPOSLIBRESPOSIBLES \n"
																	  ."WHERE (TABLA = 12) AND (CAMPO = 'FORMA_DE_ENVIO') \n"
																	  ."ORDER BY VALOR ASC";
																$pa1 = array();
																$op1 = array('scrollable' => SQLSRV_CURSOR_KEYSET);
																// Lanzar la consulta
																$re1 = sqlsrv_query($conexion, $sql, $pa1, $op1);
																while($fila = sqlsrv_fetch_array($re1))
																{
																	if ($Pddv02 == $fila['POSICION'])
																		$s = 'Selected';
																	else
																		$s = '';
																	echo "
																	<option value = '".$fila['POSICION']."' ".$s.">".$fila['VALOR']."</option>
																	";
																}
																sqlsrv_free_stmt($re1);
															}
															sqlsrv_close($conexion);
															echo"
														</select>
													</div>
												</div>
												<div class='col-md-5'>
													<div class='form-group'>
														<label>Municipio de entrega</label>
														<div class='input-group'>
															<input type='text' class='form-control' name='cV03' value='".$Pddv03."' readonly>
															<span class='input-group-btn'>
																<button type='button' class='btn btn-dark' onclick='popup01()'><i class='fa fa-search'></i></button>
															</span>
														</div>
													</div>
												</div>
												<div class='col-md-1'>
													<div class='form-group'>
														<label>-</label>
														<input type='number' class='form-control' value='0' name='cV04' readonly>
													</div>
												</div>
											</div>
											
											<div class='row'>
												<div class='col-md-12'>
													<div class='form-group'>
														<label>Dirección de entrega</label>";
														$vDireccion = '';
														// 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 C.DIRECCION1 \n"
																  ."FROm PEDVENTACAB AS P INNER JOIN CLIENTES AS C ON P.CODCLIENTE = C.CODCLIENTE \n"
																  ."WHERE (P.NUMSERIE = '".$_GET['id']."') AND (P.NUMPEDIDO = ".$_GET['id2'].")";
															$pa1 = array();
															$op1 = array('scrollable' => SQLSRV_CURSOR_KEYSET);
															// Lanzar la consulta
															$re1 = sqlsrv_query($conexion, $sql, $pa1, $op1);
															while($fila = sqlsrv_fetch_array($re1))
															{
																$vDireccion = $fila['DIRECCION1'];
															}
															if ($Pddv05 == '')
																$Pddv05 = $fila['DIRECCION1'];
															sqlsrv_free_stmt($re1);
														}
														sqlsrv_close($conexion);
														echo"
														<input type='text' class='form-control' value='".$Pddv05."' name='cV05'>
													</div>
												</div>
											</div>
											<div class='row'>
												<div class='col-md-6'>
													<div class='form-group'>
														<label>Población</label>
														<div class='input-group'>
															<input type='text' class='form-control' name='cV06' value='".$Pddv06."' readonly>
															<span class='input-group-btn'>
																<button type='button' class='btn btn-dark' onclick='popup02()'><i class='fa fa-search'></i></button>
															</span>
														</div>
													</div>
												</div>
												<div class='col-md-6'>
													<div class='form-group'>
														<label>Estado adicional</label>
														<select class='form-control' name='cV07'>";
															// 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 VALOR \n"
																	  ."FROM CAMPOSLIBRESPOSIBLES \n"
																	  ."WHERE (TABLA = 12) AND (CAMPO = 'ESTADO_AD') \n"
																	  ."ORDER BY VALOR DESC";
																$pa1 = array();
																$op1 = array('scrollable' => SQLSRV_CURSOR_KEYSET);
																// Lanzar la consulta
																$re1 = sqlsrv_query($conexion, $sql, $pa1, $op1);
																while($fila = sqlsrv_fetch_array($re1))
																{
																	$cDefualt = '';
																	if ($Pddv06 == $fila['VALOR'])
																		$cDefualt = 'selected';
																	if ($fila['VALOR'] == 'NINGUNO' and $cDefualt == '')
																		$cDefualt = 'selected';
																	echo "
																	<option value = '".$fila['VALOR']."' ".$cDefualt.">".$fila['VALOR']."</option>
																	";
																}
																sqlsrv_free_stmt($re1);
															}
															sqlsrv_close($conexion);
															echo"
														</select>
													</div>
												</div>
											</div>
											<div class='row'>
												<div class='col-md-12'>
													<div class='form-group'>
														<label>Observaciones</label>
														<input type='text' class='form-control' value='".$Pddv99."' name='cV08'>
													</div>
												</div>
											</div>											
											<div class='row'>
												<div class='col-md-2'>
													<div class='form-group'>
														<label>Total Pedido</label>
														<input type='text' class='form-control' value='".$Pddv10."' readonly>
													</div>
												</div>
												<div class='col-sm-4'>
													<div class='form-group'>
														<label>Metodo de pago</label>
														<select class='form-control' name='cV09'>";
															// 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 UPPER(DESCRIPCION) as DESCRIPCION FROM FORMASPAGO \n"
																	  ."ORDER BY DESCRIPCION ASC";
																$pa1 = array();
																$op1 = array('scrollable' => SQLSRV_CURSOR_KEYSET);
																// Lanzar la consulta
																$re1 = sqlsrv_query($conexion, $sql, $pa1, $op1);
																while($fila = sqlsrv_fetch_array($re1))
																{
																	if ($Pddv11 == $fila['DESCRIPCION'])
																		$s = 'Selected';
																	else
																		$s = '';
																	echo "
																	<option value = '".$fila['DESCRIPCION']."' ".$s.">".$fila['DESCRIPCION']."</option>
																	";
																}
																sqlsrv_free_stmt($re1);
															}
															sqlsrv_close($conexion);
															echo"
														</select>
													</div>
												</div>
												<div class='col-sm-4'>
													<div class='form-group'>
														<label>Metodo de pago (2)</label>
														<select class='form-control' name='cV10'>";
															// 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 UPPER(DESCRIPCION) as DESCRIPCION FROM FORMASPAGO \n"
																	  ."ORDER BY DESCRIPCION ASC";
																$pa1 = array();
																$op1 = array('scrollable' => SQLSRV_CURSOR_KEYSET);
																// Lanzar la consulta
																$re1 = sqlsrv_query($conexion, $sql, $pa1, $op1);
																while($fila = sqlsrv_fetch_array($re1))
																{
																	if ($Pddv11 == $fila['DESCRIPCION'])
																		$s = 'Selected';
																	else
																		$s = '';
																	echo "
																	<option value = '".$fila['DESCRIPCION']."' ".$s.">".$fila['DESCRIPCION']."</option>
																	";
																}
																sqlsrv_free_stmt($re1);
															}
															sqlsrv_close($conexion);
															echo"
														</select>
													</div>
												</div>
											</div>
											<button type='submit' class='btn btn-dark' name='Guardar'>
												Guardar/Actualizar
											</button>
											<button type='button' class='btn btn-danger' name='Cancelar' onclick='self.close();'>
												Cancelar
											</button>";
										}
									?>
								</form>
							</div>
						</div>
						<div class="x_panel">
							<div class="x_title">
								<h2>Serie: <?php echo $_GET['id'];?> | Pedido No.: <?php echo $_GET['id2'];?></h2>
								<div class="clearfix"></div>
							</div>
							<div class="x_content">
							<table id="datatable" class="table table-striped table-bordered">
								<thead>
									<tr>
										<th>LINEA</th>
										<th>CODARTICULO</th>
										<th>PRECIO</th>
										<th>REFERENCIA</th>
										<th>DESCRIPCION</th>
										<th>TALLA</th>
										<th>COLOR</th>
										<th>UND SOLICITADAS</th>
										<th>UND SIN FACTURAR</th>
									</tr>
								</thead>
								<tbody>
									<?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
										{
											$cV00 = $_GET['id'];
											$cV01 = $_GET['id2'];
											// CONSULTA SQL
											$sql = "SELECT   CAST( ( ( TOTAL*1.12)/UNIDADESTOTAL) AS DECIMAL(7,2)) TOTIVA, * \n"
												  ."FROM PEDVENTALIN \n"
												  ."WHERE (NUMSERIE='".$cV00."') AND (NUMPEDIDO = ".$cV01.") \n"
												  ."ORDER BY NUMLIN ASC";
											$pa1 = array();
											$op1 = array("scrollable" => SQLSRV_CURSOR_KEYSET);
											// Lanzar la consulta
											$re1 = sqlsrv_query($conexion, $sql, $pa1, $op1);
											while($fila = sqlsrv_fetch_array($re1))
											{
												$cV01 = $_GET['id'];
												$cV02 = $_GET['id2'];
												$cV03 = $fila['NUMLIN'];
												$cV04 = $fila['UNIDADESPEN'];
												echo "
													<tr>
														<td>".$fila['NUMLIN']."</td>
														<td>".$fila['CODARTICULO']."</td>
														<td>".$fila['TOTIVA']."</td>
														<td>".$fila['REFERENCIA']."</td>
														<td>".$fila['DESCRIPCION']."</td>
														<td>".$fila['TALLA']."</td>
														<td>".$fila['COLOR']."</td>
														<td>".$fila['UNIDADESTOTAL']."</td>
												";
												if ($_SESSION["mEmpleado"] == 5)
												{
													if ($_GET['id3']==3 || $_GET['id3']==-1)
													{
														echo "
															<td>
																<button class='btn btn-sm btn-dark' type='button' data-placement='top' onclick=popup03('$cV01','$cV02','$cV03','$cV04') data-toggle='tooltip' data-original-title='Cambio de unidades'>".$fila['UNIDADESPEN']."</button>
															</td>
														";
													}
													else
													{
														echo "<td>".$fila['UNIDADESPEN']."</td>";
													}
												}
												else
												{
													echo "<td>".$fila['UNIDADESPEN']."</td>";
												}
												echo "
													</tr>
												";
											}
										}
									?>
								</tbody>
							</table>
							</div>
						</div>
					</div>
					<!-- /page content -->
				</div>
			</div>
		</div>
	</body>
    <!-- jQuery -->
    <script src="../config/vendors/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="../config/vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <script src="../config/vendors/fastclick/lib/fastclick.js"></script>
    <!-- NProgress -->
    <script src="../config/vendors/nprogress/nprogress.js"></script>
    <!-- iCheck -->
    <script src="../config/vendors/iCheck/icheck.min.js"></script>
    <!-- Datatables -->
    <script src="../config/vendors/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="../config/vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
    <script src="../config/vendors/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
    <script src="../config/vendors/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>
    <script src="../config/vendors/datatables.net-buttons/js/buttons.flash.min.js"></script>
    <script src="../config/vendors/datatables.net-buttons/js/buttons.html5.min.js"></script>
    <script src="../config/vendors/datatables.net-buttons/js/buttons.print.min.js"></script>
    <script src="../config/vendors/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>
    <script src="../config/vendors/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>
    <script src="../config/vendors/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
    <script src="../config/vendors/datatables.net-responsive-bs/js/responsive.bootstrap.js"></script>
    <script src="../config/vendors/datatables.net-scroller/js/dataTables.scroller.min.js"></script>
    <script src="../config/vendors/jszip/dist/jszip.min.js"></script>
    <script src="../config/vendors/pdfmake/build/pdfmake.min.js"></script>
    <script src="../config/vendors/pdfmake/build/vfs_fonts.js"></script>
    <!-- Custom Theme Scripts -->
    <script src="../config/build/js/custom.min.js"></script>
	</body>
</html>
<script>
	var mipopup;
	function popup01()
	{
		posicion_x=(screen.width/2)-(600/2);
		posicion_y=(screen.height/2)-(580/2)-50;
		mipopup = window.open("municipios.php", "window99", "width=600, Height=580, menubar=0, toolbar=0,directories=0,scrollbars=no,resizable=no,left="+posicion_x+",top="+posicion_y+"");
		mipopup.focus()
	}
	function popup02()
	{
		posicion_x=(screen.width/2)-(600/2);
		posicion_y=(screen.height/2)-(580/2)-50;
		mipopup = window.open("poblados.php", "window99", "width=600, Height=580, menubar=0, toolbar=0,directories=0,scrollbars=no,resizable=no,left="+posicion_x+",top="+posicion_y+"");
		mipopup.focus()
	}
	function popup03(d01, d02, d03, d04)
	{
		v01 = d01;
		v02 = d02;
		v03 = d03;
		v04 = d04;
		posicion_x=(screen.width/2)-(500/2);
		posicion_y=(screen.height/2)-(450/2)-50;
		mipopup = window.open("reporte_03_und.php?id="+v01+"&id2="+v02+"&id3="+v03+"&id4="+v04, "unidades", "width=500, Height=450, menubar=0, toolbar=0,directories=0,scrollbars=no,resizable=no,left="+posicion_x+",top="+posicion_y+"");
		mipopup.focus()
	}
</script>
<script>
	function valida_campos(f)
	{
		if (this.envios.cV03.value == '')
		{
			alert("Seleccione un municipio.");
			this.envios.cV03.focus();
			return false;
		}
		if (this.envios.cV04.value == '')
		{
			alert("Ingrese los días de vencimiento o dejelos en cero.");
			this.envios.cV04.focus();
			return false;
		}
		if (this.envios.cV05.value == '')
		{
			alert("Ingrese una dirección de entrega.");
			this.envios.cV05.focus();
			return false;
		}
	}
</script>
<script>function confirmar(){if(confirm('Desea guardar los cambios realizados?'))return true; else return false;}</script>