<?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">
								<h2>Pedido | Serie <?php echo $_GET['id'];?> Numero <?php echo $_GET['id2'];?></h2>
								<div class="clearfix"></div>
							</div>
							<div class="x_content">
							<table id="datatable-responsive" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
								<thead>
									<tr>
										<th>LINEA</th>
										<th>CODARTICULO</th>
										<th>REFERENCIA</th>
										<th>DESCRIPCION</th>
										<th>TALLA</th>
										<th>COLOR</th>
										<th>UNIDADES</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 * \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['REFERENCIA']."</td>
														<td>".$fila['DESCRIPCION']."</td>
														<td>".$fila['TALLA']."</td>
														<td>".$fila['COLOR']."</td>
												";
												if ($_GET['id3']==3)
												{
													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>";
												}
												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)-(350/2)-50;
		mipopup = window.open("reporte_03_und.php?id="+v01+"&id2="+v02+"&id3="+v03+"&id4="+v04, "unidades", "width=500, Height=350, 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>