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

function pon_prefijo(cdgbar,dscart,cosart,utiart1,utiart2, PRE001, PRE002, cob_iv, desart, desfac, cdgfam,cdglin,cantidad,fleart,ivporc,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.utiart1.value=utiart1;
	parent.document.formulario_lineas.utiart2.value=utiart2;
	parent.document.formulario_lineas.tarred.value=tarred;
	parent.document.formulario_lineas.despro.value=desart;
	parent.document.formulario_lineas.desfac.value=desfac;
	parent.document.formulario_lineas.fleart.value=fleart;
	parent.document.formulario_lineas.canart.value=cantidad;
	parent.document.formulario_lineas.PRE001.value=PRE001;
	parent.document.formulario_lineas.PRE002.value=PRE002;
	parent.document.formulario_lineas.cdglin.value=cdglin;
	parent.document.formulario_lineas.cdgfam.value=cdgfam;
	parent.document.formulario_lineas.cob_iv.value=cob_iv;
	parent.document.formulario_lineas.ivporc.value=ivporc;
	parent.document.formulario_lineas.importe.value="";
	parent.document.formulario_lineas.impuesto_producto.value="";
	parent.document.formulario_lineas.impuesto_factura.value="";
	parent.document.formulario_lineas.descuento_producto.value="";
	parent.document.formulario_lineas.descuento_factura.value="";


    
}


function limpiar() {
	parent.document.formulario_lineas.canart.value="";
	parent.document.formulario_lineas.desfac.value="";
	parent.document.formulario_lineas.despro.value="";
	parent.document.formulario_lineas.cdgbar.value="";
	parent.document.formulario_lineas.dscart.value="";
	parent.document.formulario_lineas.dscfac.value="";
	parent.document.formulario_lineas.fleart.value="";
	parent.document.formulario_lineas.cosart.value="";
	parent.document.formulario_lineas.utiart1.value="";
	parent.document.formulario_lineas.utiart2.value="";
	parent.document.formulario_lineas.tarred.value="";
	parent.document.formulario_lineas.PRE001.value="";
	parent.document.formulario_lineas.PRE002.value="";
	parent.document.formulario_lineas.cob_iv.value="";
	parent.document.formulario_lineas.ivporc.value="";
	parent.document.formulario_lineas.cdglin.value="";
	parent.document.formulario_lineas.cdgfam.value="";
	parent.document.getElementById("cdgbar").focus();
	parent.document.getElementById("cdgbar").select();
}

</script>
<?php include ("../conexion.php"); ?>
<body>
<?php
	$cdgbar=strtoupper($_GET["cdgbar"]);
	$cantidad =$_GET["canart"];
	$codfactura=$_GET["codfactura"];
	$numlinea=$_GET["numlinea"];
	$dscart=$_GET["dscart"];

	
$consulta1 ="SELECT * FROM web_1001 WHERE CDGBAR='$cdgbar' or  CDGBAR2='$cdgbar' or  CDGBAR3='$cdgbar' and estart = 1 ";
$resultado1 = $mysqli->query($consulta1);
$fila = $resultado1->fetch_array();
$nrs = $resultado1->num_rows;



	if ( $nrs > 0) {
		?>
		<script languaje="javascript">
		pon_prefijo("<?php echo $fila["CDGBAR"]?>",'<?php echo $fila["DSCART"] ?>',"<?php echo $fila["cosart"] ?>" , "<?php echo $fila["utiart1"] ?>" , "<?php echo $fila["utiart2"] ?>" ,"<?php echo$fila["PRE001"] ?>" , "<?php echo $fila["PRE002"] ?>" , "<?php echo $fila["COB_IV"] ?>" , "<?php echo $fila["DESART"]  ?>" , "<?php echo $fila["DESFAC"]  ?>" , "<?php echo $fila["CDGFAM"]  ?>",  "<?php echo $fila["CDGLIN"]  ?>", "<?php echo $cantidad ?>", "<?php echo $fila["fleart"]  ?>", "<?php echo $fila["ivporc"]  ?>" , "<?php echo $fila["tarred"]  ?>" ); 
					parent.document.getElementById("canart").focus();
					parent.document.getElementById("canart").select();
		</script>
		<?php 
	} else { ?>
	<script>
		if (confirm(" Articulo nuevo desea agregarlo ? "))
	//parent.nuevo_articulo();
	
	parent.nuevo_articulo("<?php echo $cdgbar ?>",'<?php echo $dscart ?>','<?php echo $codfactura ?>','<?php echo $numlinea ?>');
	parent.limpiararticulo();
	</script>
	<?php }
?>
</div>
</body>
</html>
