                                                                                                                                                                                                                         
<html>
<head>
<link href="../estilos/estilos.css" type="text/css" rel="stylesheet">
</head>
<script language="javascript">

function pon_prefijo(cdgbar,dscart,cosart,desfac,cob_iv,ivporc,tarred) {
	parent.document.formulario_lineas.tarred.value=tarred;
	parent.document.formulario_lineas.cdgbar.value=cdgbar;
	parent.document.formulario_lineas.dscart.value=dscart;
	parent.document.formulario_lineas.cosart.value=cosart;
	parent.document.formulario_lineas.desfac.value=desfac;
	parent.document.formulario_lineas.cob_iv.value=cob_iv;
	parent.document.formulario_lineas.ivporc.value=ivporc;
	parent.document.formulario_lineas.canart.value=1.00;



}


function limpiar() {

	parent.document.formulario_lineas.tarred.value="";
	parent.document.formulario_lineas.cdgbar.value="";
	parent.document.formulario_lineas.dscart.value="";
	parent.document.formulario_lineas.cosart.value="";
	parent.document.formulario_lineas.desfac.value="";
	parent.document.formulario_lineas.cob_iv.value="";
	parent.document.formulario_lineas.canart.value="";
	parent.document.formulario_lineas.ivporc.value="";
	parent.document.formulario_lineas.cdgbar.select();
	parent.document.formulario_lineas.cdgbar.focus();

}

</script>
<?php include ("../conexion.php"); ?>
<body>
<?php

	$cdgbar=$_GET["cdgbar"];
	

	$consulta = "SELECT * FROM web_1001 WHERE cdgbar='$cdgbar'  ";
	$resultado = $mysqli->query($consulta);
	$nrs  = $resultado->num_rows;
	$fila = $resultado->fetch_array();
	$tipart = $fila["tipart"];
	
	if ($nrs > 0) {
	if ($tipart==2) {
		
		
		?>
		<script languaje="javascript">
		pon_prefijo("<?php echo $fila["CDGBAR"]; ?>",'<?php echo $fila["DSCART"]; ?>',"<?php echo $fila["cosart"]; ?>" , "<?php echo $fila["DESFAC"];?>" , "<?php echo $fila["COB_IV"]; ?>" , "<?php echo $fila["ivporc"]; ?> "  , "<?php echo $fila["tarred"]  ?>" );
		parent.document.formulario_lineas.dscart.select();
		parent.document.formulario_lineas.dscart.focus();
		</script>
		<?php 
 	} else {
		
			
		?>
		<script languaje="javascript">
			pon_prefijo("<?php echo $fila["CDGBAR"]; ?>",'<?php echo $fila["DSCART"]; ?>',"<?php echo $fila["cosart"]; ?>" , "<?php echo $fila["DESFAC"];?>" , "<?php echo $fila["COB_IV"]; ?>"  , "<?php echo $fila["ivporc"]; ?>"  , "<?php echo $fila["tarred"]  ?>"  );
		parent.document.formulario_lineas.canart.select();
		parent.document.formulario_lineas.canart.focus();
		</script>
		<?php 
		
		
		
	}	
		} else {
	
	?>
	<script>
	alert ("No existen articulos registrados con este codigo");
	limpiar();
	</script>


	<?php 
 }	
	
 ?>
 
</body>
</html>
