<?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 -->
					<form name="neo" class="form-vertical" method="POST" action="impresion.php?id=4" enctype="multipart/form-data" target="_blank">
						<div class="right_col" role="main">
							<div class="clearfix"></div>
							<div class="x_panel">
								<div class="x_title">
									<div class="col-sm-2">
										<div class="form-group">
											<label>Serie</label>
											<input type="text" class="form-control" value="<?php echo $_GET['id'];?>" name="serie" readonly>
										</div>
									</div>
									<div class="col-md-2">
										<div class="form-group">
											<label>Pedido No.</label>
											<input type="text" class="form-control" value="<?php echo $_GET['id2'];?>" name="numero" readonly>
										</div>
									</div>
									<div class="col-md-2">
										<button type="submit" class="btn btn-warning" onclick="recargar();">
											<span class="glyphicon glyphicon-print" aria-hidden="true"></span> Imprimir etiquetas
										</button>
									</div>
									<div class="clearfix"></div>
								</div>
								<div class="x_content">								
									<table id="datatable" class="table table-striped table-bordered">
										<thead>
											<tr>
												<th></th>
												<th>LINEA</th>
												<th>CODARTICULO</th>
												<th>REFERENCIA</th>
												<th>DESCRIPCION</th>
												<th>TALLA</th>
												<th>COLOR</th>
												<th>UNIDADES</th>
												<th>ALMACEN</th>
												<th>COD.PROVEEDOR</th>
												<th>PROVEEDOR</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 P.CODPROVEEDOR, PL.CODALMACEN, P.NOMPROVEEDOR, PL.CODARTICULO, PL.REFERENCIA, \n"
														  ."PL.TALLA , PL.COLOR, PL.UNIDADESTOTAL, A.DESCRIPCION, PL.NUMLINEA \n"
														  ."FROM PEDCOMPRACAB AS PC \n"
														  ."INNER JOIN PEDCOMPRALIN AS PL ON (PC.NUMSERIE = PL.NUMSERIE) AND (PC.NUMPEDIDO = PL.NUMPEDIDO) \n"
														  ."INNER JOIN ARTICULOS AS A ON (PL.CODARTICULO = A.CODARTICULO) \n"
														  ."LEFT JOIN PROVEEDORES AS P ON (PC.CODPROVEEDOR = P.CODPROVEEDOR) \n"
														  ."LEFT JOIN TIPOSDOC As T ON (PC.TIPODOC = T.TIPODOC) \n"
														  ."WHERE (PC.NUMSERIE = '".$cV00."') AND (PC.NUMPEDIDO = ".$cV01.") \n"
														  ."ORDER BY PL.NUMLINEA 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))
													{
														$cV03 = $fila['NUMLINEA'];
														echo "
															<tr class='even pointer'>
																<td class='a-center'>
																	<input type='checkbox' class='flat' name='lista[]' value='".$cV03."'>
																</td>
																<td>".$fila['NUMLINEA']."</td>
																<td>".$fila['CODARTICULO']."</td>
																<td>".$fila['REFERENCIA']."</td>
																<td>".$fila['DESCRIPCION']."</td>
																<td>".$fila['TALLA']."</td>
																<td>".$fila['COLOR']."</td>
																<td>".$fila['UNIDADESTOTAL']."</td>
																<td>".$fila['CODALMACEN']."</td>
																<td>".$fila['CODPROVEEDOR']."</td>
																<td>".$fila['NOMPROVEEDOR']."</td>
															</tr>
														";
													}
												}
											?>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</form>
					<!-- /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>