
	<script language="javascript">

  window.onkeydown = tecla;

  function tecla(event) {
	  
	  


  if( event.keyCode > 111 && event.keyCode < 123 || event.keyCode ==27	) {    num = event.keyCode;

if(num==113)abreVentana(); // f3  busqueda de clientes 
if(num==115){ ventanaArticulos(); } // f8 busqueda de articulos
 
  }  }

          /////////   deshabilitar el f5 refrecar del navegador ///////////

//desactivar tecla f5
function f5()
{
var tecla=window.event.keyCode;
if (tecla==116) { event.keyCode=0;
event.returnValue=false;}
}


 





function eliminar_linea(codfactura,numlinea,importe)
{
	if (confirm(" Desea eliminar esta linea ? "))

		
		document.getElementById("frame_datos").src="eliminar_linea_modificar.php?codfactura="+codfactura+"&numlinea=" + numlinea;
}
function nobackbutton(){	
   window.location.hash="no-back-button";	
   window.location.hash="Again-No-back-button" //chrome	
   window.onhashchange=function(){window.location.hash="no-back-button";}	
}

function pon_prefijo(filas,preciotot,baseiva,basedes,baseimp) {
	parent.document.formulario_lineas.filas.value=filas;
	parent.document.formulario_lineas.preciotot.value=preciotot;
	parent.document.formulario_lineas.baseiva.value=baseiva;
	parent.document.formulario_lineas.basedes.value=basedes;
	parent.document.formulario_lineas.baseimp.value=baseimp;
    
}

function modificar(cont,codfactura,cdgbar,canart,numlinea,dscart,cosart, fleart , despro , desfac, utiart1) {
	
//	alert(cont);
	posicion=(cont*28)-80;
	//parent.document.formulario_lineas.codfactura2.value=codfactura;
	parent.document.formulario_lineas.numlinea.value=numlinea;
	parent.document.formulario_lineas.canart.value=canart;
	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.fleart.value=fleart;
	parent.document.formulario_lineas.despro.value=despro;
	parent.document.formulario_lineas.desfac.value=desfac;
	parent.document.formulario_lineas.utiart1.value=utiart1;
	
	parent.document.formulario_lineas.posicion.value=posicion; /// indica la posicion del scroll bar
	//parent.document.formulario_lineas.cdgbar.focus();  
    parent.validararticulo();
    var elmnt = document.getElementById("xdetalleAW");  // NOMBRE DEL DIV DONDE PERTENECE EL SCROLL 
    elmnt.scrollLeft =posicion; 
    elmnt.scrollTop =posicion;

}

	function modificar_articulo(codfactura,numlinea,cdgbar,canart,dscart) {
	


		parent.validararticulo_xml(codfactura,numlinea,cdgbar,canart,dscart);

}


		
		function validararticulo_xml(codfactura,numlinea,cdgbar,canart,dscart){


		  miPopup = window.open("comprobararticulo_xml_2.php?cdgbar="+cdgbar+"&dscart="+dscart+"&codfactura="+codfactura+"&numlinea="+numlinea,"frame_datos12","width=900,height=90,scrollbars=yes");
		
			
			}
		
	
					function inicio() {
    var elmnt = document.getElementById("xdetalleAW");
    var posicion=document.getElementById("posicion").value;
    elmnt.scrollLeft =posicion;
    elmnt.scrollTop =posicion;
}
	
	
		function modificar_codigo(codfactura,numlinea,canart) {

	miPopup = window.open("cambiar_codigo.php?codfactura="+codfactura+"&numlinea="+numlinea+"&canart="+canart,"miwin","width=950,height=450,scrollbars=yes");

}



</script>

<html>
<link href="../estilos/estilos.css" type="text/css" rel="stylesheet">
<body  onKeyDown="javascript:f5()"  onLoad="nobackbutton(); inicio();">
<?php 
include ("../conexion.php");
//echo "frame lineas modificar ";


       $parametros = "SELECT * FROM web_0000 ";
       $result_parametros = $mysqli->query($parametros);
       $row_para = $result_parametros->fetch_array();
     
	   $tipmoneda =  $row_para["tipmoneda"];    // se agrega en la version 4.4 
	   $cantippre =  $row_para["cantippre"];    // se agrega en la version 4.4
	   
	   
	   
   if (!isset($_POST["codfactura2"])) { $codfactura=""; } else  {  $codfactura=$_POST["codfactura2"]; }
   if (!isset($_POST["posicion"])) {  $posicion="";  } else  {$posicion=$_POST["posicion"]; }
   if (!isset($_POST["codlineatmp"])) { $codlineatmp=""; } else  { $codlineatmp = $_POST["codlineatmp"]; }
   if (!isset($_POST["cdgbar"])) {$cdgbar =""; } else  {   $cdgbar  = $_POST["cdgbar"]; }
   if (!isset($_POST["chkbon"])) {$chkbon =""; } else  {  $chkbon  = $_POST["chkbon"]; }




  if ($posicion == "")
   {   $enfoque =""; } else  {  $enfoque1 = $posicion  + 80;
							  $enfoque = $enfoque1  / 28;
																  } 
  												
 	$baseimp = 0;
	$baseiva = 0;
	$basedes = 0;
	 
 
 if ($codfactura=="") {                ///  Si no obtiene codigo de de factura  por POST
		$codlineatmp=$_GET["codfactura"];     // Llama el codigo linea por get 
			$cdgbar="NO";                    
			$retorno=1; }


		if ($cdgbar=="") {	  ////////////////  si codigo es vacio //////////////

		 $consulta6 = "DELETE FROM  factulineatmp_compra  WHERE codfactura ='$codlineatmp'";
		 $mysqli->query($consulta6); 	  ////   Limpia la tabla temporal de lineas compras 
	


	$consulta ="SELECT * FROM factulinea_compra WHERE codfactura='$codfactura'  ORDER BY numlinea ASC";
	

$contador=0;
if ($resultado = $mysqli->query($consulta)) 


    while ($fila2 = $resultado->fetch_assoc()) {

	
	            $numlinea = $fila2["numlinea"];
				$cdgbar  = $fila2["codigo"];
				$dscart  = $fila2["dscart"];
				$cdglin  = $fila2["cdglin"];
				$cdgfam  = $fila2["cdgfam"];
				$canart  = $fila2["canart"];
				$cosart  = $fila2["cosart"];
				$utiart1 = $fila2["utiart1"];
				$utiart2 = $fila2["utiart2"];  
				$PRE001  = $fila2["PRE001"];
				$PRE002  = $fila2["PRE002"];
				$importe = $fila2["importe"];
				$desfac  = $fila2["desfac"];
				$despro  = $fila2["despro"];  
				$impart  = $fila2["impart"];
				$fleart  = $fila2["fleart"];
				$implin  = $fila2["implin"];
				$deslin  = $fila2["deslin"];
				$flelin  = $fila2["flelin"];
				$chkbon  = $fila2["chkbon"];
				
				$cdgcabys  = $fila2["cdgcabys"];
				$cdgimp  = $fila2["cdgimp"];
				$cdgtar  = $fila2["cdgtar"];
				$tarimp  = $fila2["tarimp"];
	
	
	

		
	$sel_insertar2="INSERT INTO factulineatmp_compra(codfactura,numlinea,codigo,cdgcabys,dscart,cdgfam,cdglin,canart,cosart, utiart1, utiart2, PRE001, PRE002,importe,desfac,despro,impart, fleart, implin,deslin, flelin, borrado, chkbon, cdgimp ,cdgtar,tarimp ) VALUES ('$codlineatmp' , '$numlinea','$cdgbar','$cdgcabys','$dscart','$cdgfam','$cdglin','$canart','$cosart', '$utiart1', '$utiart2','$PRE001', '$PRE002','$importe','$desfac','$despro','$impart' ,'$fleart','$implin','$deslin' ,'$flelin','0' , '$chkbon','$cdgimp' ,'$cdgtar' ,'$tarimp')";

 $mysqli->query($sel_insertar2);   // inserta en la tabla lineas compras temporal para traba jar 
		

		} 	
		

		}  else if ($cdgbar=="NO" ){     /// codigo despues de ser eliminado 


			}  else {                 ////////////// si es un codigo de barras completo 
			
	
			
			
                 if ($chkbon == ""){      //  si no es bonificacion
	
			 	$cdgbar  = $_POST["cdgbar"];
				$dscart  = $_POST["dscart"];
				$cdglin  = $_POST["cdglin"];
				$cdgfam  = $_POST["cdgfam"];
				$canart  = $_POST["canart"];
				$cosart  = $_POST["cosart"];
				$utiart1 = $_POST["utiart1"];
				$utiart2 = $_POST["utiart2"];
				$PRE001  = $_POST["PRE001"];
				$PRE002  = $_POST["PRE002"];
				$importe = $_POST["importe"];
				$desfac  = $_POST["desfac"];
				$despro  = $_POST["despro"];   ///// aplica el mismo descuento de la factura pasar a despro  /////////
				$impart  = $_POST["impuesto_producto"];
				$fleart  = $_POST["fleart"];
				$flelin  = $_POST["flete_producto"];
				$implin  = $_POST["impuesto_factura"];
				$deslin  = $_POST["descuento_factura"];
				$codlineatmp=$_POST["codlineatmp"];
				
		$ultimo_valor_precio001=substr($PRE001,-1);
		$ultimo_valor_precio002=substr($PRE002,-1);	  // sustraigo el utimo digito del precio 

		
		if ( $tipmoneda == "CRC") {
				
		$ultimo_valor_precio001=substr($PRE001,-1);
		$ultimo_valor_precio002=substr($PRE002,-1);	  // sustraigo el utimo digito del precio 
	
				$PRE001=round($PRE001);
			    $PRE002=round($PRE002);

       }

		
		//if ($ultimo_valor_precio001 == 0) {              // redondeo precio 1
//			$PRE001=$_POST["PRE001"]; 
//		
//		} else if ($ultimo_valor_precio001  ==  5){ 
//			$PRE001=$_POST["PRE001"];
//		
//		} else if ($ultimo_valor_precio001  >  5){ 
//			$PRE001=round($PRE001,-1);
//		
//		}else { 
//	   	$PRE001=round($PRE001,-1);
//		$PRE001=$PRE001+5;
//		}                                  //////////////////////////////////////////////
//
//
//		if ($ultimo_valor_precio002 == 0) {              // redondeo precio 2
//			$PRE002=$_POST["PRE002"]; 
//		
//		} else if ($ultimo_valor_precio002  ==  5){ 
//			$PRE002=$_POST["PRE002"];
//		
//		} else if ($ultimo_valor_precio002  >  5){ 
//			$PRE002=round($PRE002,-1);
//		
//		}else { 
//	   	$PRE002=round($PRE002,-1);
//		$PRE002=$PRE002+5;
//		}  

	if ($result = $mysqli->query("SELECT * FROM factulineatmp_compra WHERE codfactura ='$codlineatmp' AND codigo ='$cdgbar' ")) {
    $fila = $result->fetch_array(); 
    $filas = $result->num_rows;
 
}
	
	if ($filas > 0) {   ////   si el codigo ya existe en la factura 
	
	$cdgbar_tabla =	$fila["codigo"];  
	$numlinea     = $fila["numlinea"];

			
		} else 	 {                     ///   si no existe en la factura  
	
	$cdgbar_tabla = "";	
	$posicion=6000;	                   ///   ubica el scroll en la ultima posicion
		}	
		
	$cdgbar_comodin=101;             // declara los valores comodines 
	$cdgbar_comodin2=102;	
	$cdgbar_comodin4=111;	
	$cdgbar_comodin3="";	
			
    if (  $cdgbar_comodin==$cdgbar_tabla  || $cdgbar_comodin2==$cdgbar_tabla  || $cdgbar_comodin3==$cdgbar_tabla || $cdgbar_comodin4==$cdgbar_tabla )   {
   	$posicion=6000;	                   ///   ubica el scroll en la ultima posicion
    ////  verifica los valores de la tabla si alguno es comodin 
	 $cdgbar_tabla ;
	 $sel_insert="INSERT INTO factulineatmp_compra (codfactura,numlinea,codigo,dscart,cdgfam,cdglin,canart,cosart, utiart1, utiart2, PRE001, PRE002,importe,desfac,despro,impart, fleart, implin,deslin, flelin,  borrado) VALUES ('$codlineatmp'  ,'','$cdgbar','$dscart','$cdgfam','$cdglin','$canart','$cosart', '$utiart1', '$utiart2','$PRE001', '$PRE002','$importe','$desfac','$despro','$impart','$fleart','$implin','$deslin' ,'$flelin' ,'0' )";

	$mysqli->query($sel_insert);   //// inserta el producto nuevo 
	
		} else 	 {     //////  si no son valores comodines 
			


	$consulta8 = "DELETE FROM factulineatmp_compra  WHERE codfactura ='$codlineatmp' AND codigo ='$cdgbar' ";
	$mysqli->query($consulta8); 	 //// quita el producto de la tabla 
		
	$sel_insert="INSERT INTO factulineatmp_compra (codfactura,numlinea,codigo,dscart,cdgfam,cdglin,canart,cosart, utiart1, utiart2, PRE001, PRE002,importe,desfac,despro,impart,fleart, implin,deslin, flelin, borrado) VALUES ('$codlineatmp'  ,$numlinea,'$cdgbar','$dscart','$cdgfam','$cdglin','$canart','$cosart', '$utiart1', '$utiart2','$PRE001', '$PRE002','$importe','$desfac','$despro','$impart','$fleart','$implin','$deslin' ,'$flelin','0' )";

		$mysqli->query($sel_insert);        ///// coloca el producto de la tabla 
		

		
}

}else { // abre que es bonificacion

	
			 	$cdgbar  = $_POST["cdgbar"];
				$dscart  = $_POST["dscart"];
				$cdglin  = $_POST["cdglin"];
				$cdgfam  = $_POST["cdgfam"];
				$canart  = $_POST["canart"];
				$cosart  = 0;  // es bonificacion
				$utiart1 = 0;
				$utiart2 = 0;
				$PRE001  = 0;
				$PRE002  = 0;
				$importe = 0;
				$desfac  = 0;
				$despro  = 0;   ///// aplica el mismo descuento de la factura pasar a despro  /////////
				$impart  = $_POST["impuesto_producto"];
				$fleart  = 0;
				$flelin  = 0;
				$implin  = $_POST["impuesto_factura"];
				$deslin  = 0;
				$codlineatmp=$_POST["codlineatmp"];
				
		$ultimo_valor_precio001=0;
		$ultimo_valor_precio002=0;	  // sustraigo el utimo digito del precio 

		

	$cdgbar_tabla = "";	
	$posicion=6000;	                   ///   ubica el scroll en la ultima posicion
			
	$cdgbar_comodin=101;             // declara los valores comodines 
	$cdgbar_comodin2=102;	
	$cdgbar_comodin3="";	
			

	 $cdgbar_tabla ;
	 $sel_insert="INSERT INTO factulineatmp_compra (codfactura,numlinea,codigo,dscart,cdgfam,cdglin,canart,cosart, utiart1, utiart2, PRE001, PRE002,importe,desfac,despro,impart, fleart, implin,deslin, flelin,  borrado, chkbon) VALUES ('$codlineatmp'  ,'','$cdgbar','$dscart','$cdgfam','$cdglin','$canart','$cosart', '$utiart1', '$utiart2','$PRE001', '$PRE002','$importe','$desfac','$despro','$impart','$fleart','$implin','$deslin' ,'$flelin' ,'0', '$chkbon' )";

	$mysqli->query($sel_insert);   //// inserta el producto nuevo 
	

		
}   // cierra que es bonificacion   //////////
}
?>
<div id="xdetalleAW">
  <iframe id="frame_datos" name="frame_datos" width="0%" height="0" frameborder="0">
  <ilayer width="0" height="0" id="frame_datos" name="frame_datos"></ilayer>
  </iframe>
  
  
    <iframe id="frame_datos12" name="frame_datos12" width="0%" height="0" frameborder="0">
  <ilayer width="0" height="0" id="frame_datos12" name="frame_datos12"></ilayer>
  </iframe>
  
  <table class="fuente9" width="100%" cellspacing=0 cellpadding=0 border=0 ID="Table1">
<?php	



			
$consulta ="SELECT * FROM factulineatmp_compra WHERE codfactura='$codlineatmp'  ORDER BY numlinea ASC";
$cont=1;

if ($resultado = $mysqli->query($consulta)) 


    while ($fila2 = $resultado->fetch_assoc()) {

	
	            $numlinea = $fila2["numlinea"];
				$cdgbar  = $fila2["codigo"];
				$dscart  = $fila2["dscart"];
				$cdglin  = $fila2["cdglin"];
				$cdgfam  = $fila2["cdgfam"];
				$canart  = $fila2["canart"];
				$cosart  = $fila2["cosart"];
				$utiart1 = $fila2["utiart1"];
				$utiart2 = $fila2["utiart2"];  ///// aplica la misma utilidad 1 a utilidad 2  /////////
				$PRE001  = $fila2["PRE001"];
				$PRE002  = $fila2["PRE002"];
				$importe = $fila2["importe"];
				$desfac  = $fila2["desfac"];
				$despro  = $fila2["despro"];  
				$impart  = $fila2["impart"];
				$fleart  = $fila2["fleart"];
				$implin  = $fila2["implin"];
				$deslin  = $fila2["deslin"];
				$flelin  = $fila2["flelin"];
				$chkbon  = $fila2["chkbon"];
			
				
				
	$baseimp=$importe+$baseimp;
	$baseiva=$implin+$baseiva;
	$basedes=$deslin+$basedes;
	
	$tarred=0; // declaro tarifa reducida a cero
	$tarimp=0; // declaro tarifa impuesto a cero
if ($result2 = $mysqli->query("SELECT *  FROM web_1001 WHERE CDGBAR='$cdgbar'")) {
   $filas2 = $result2->num_rows;

}
	
	
	if ($filas2 > 0) { 
	
	
$consulta2 = "SELECT COB_IV, PRE001, EXIACT, ivporc , tarred, DSCART  FROM web_1001 WHERE CDGBAR='$cdgbar'";
$resultado2 = $mysqli->query($consulta2);
$row = $resultado2->fetch_array();


$COB_IV   = $row["COB_IV"];
$precio_anterior   = $row["PRE001"];
$existencia   = $row["EXIACT"];
	$tarimp  = $row["ivporc"];	
	$tarred  = $row["tarred"];	

	if  ($COB_IV == 1)  { 
		$exento="(G)";
	
	} else  { 

	$exento="(E)";
    } 
	
	 } else  { 

	$exento="";
	$precio_anterior = 1;
	
	
				//$cdgcabys  = $fila2["cdgcabys"];
				//$cdgimp  = $fila2["cdgimp"];
				//$cdgtar  = $fila2["cdgtar"];
				$tarimp  = $fila2["tarimp"];
	 }

 if  ( $posicion==6000 ) {    //////  si es una linea nueva asigna el enfoque a la ultima  ///////
			
if ($result3 = $mysqli->query("SELECT * FROM  factulineatmp_compra WHERE codfactura='$codlineatmp'")) {
   $enfoque = $result3->num_rows;
   
  

}
	
 
  } 
 
        ///////  RESUELVE LA LINEA DEL ENFOQUE O SI CAMBIA DE PRECIO /////////

  if  ($enfoque == $cont) { 
		
		$fondolinea="registro_enfocado"; 
	
 } elseif ($precio_anterior != $PRE001) {
 
 			$fondolinea="cambio_precio";
		
 } else {  
 
 		$fondolinea="itemImparTabla";
 
  }
  
  
  if($chkbon == 1 ) { $fondolinea="salto_consecutivo";   }
  
  ///////////////////////////////////////////////////////////////////////////////////
 
 
 ?>			  <tr class="<?php echo $fondolinea?>">      
			 <?php  if ($cantippre > 1 )  {  ?>
			   <td width="5%"><div align="left"><?php echo $cdgbar?></td>
			  <td width="5%" class=""><div align="center"><?php echo $canart?></div></td>
			<?php	   $dscart = substr($dscart." ", 0, 28);$dscart3 = substr($dscart." ", 0, 35); ?>
              <td width="23%"><div align="left"><?php echo $dscart?></div></td>
              <td width="4%"><div align="right"><?php echo $tarimp?></div></td>
 		      <td width="4%"><div align="right"><?php echo $tarred?></div></td>				
			  <td width="5%"><div align="right"><?php echo number_format($cosart,2,".",",")?></div></td>
			  <td width="5%"><div align="right"><?php echo number_format($fleart,2,".",",")?></div></td>
			  <td width="5%"><div align="right"><?php echo number_format($utiart1,2,".",",")?></div></td>
              <td width="5%"><div align="right"><?php echo number_format($despro,2,".",",")?></div></td>
			  <td width="7%"><div align="right"><?php echo number_format($precio_anterior,2,".",",")?></div></td>
			  <td width="7%"><div align="right"><?php echo number_format($PRE001,2,".",",")?></div></td>
			  <td width="4%"><div align="right"><?php echo number_format($desfac,2,".",",")?></div></td>
			  <td width="4%"><div align="right"><?php echo number_format($utiart2,2,".",",")?></div></td>		  
	          <td width="5%"><div align="right"><?php echo number_format($PRE002,2,".",",")?></div></td>
			  <td width="6%"><div align="right"><?php echo number_format($importe,2,".",",")?></div></td>
		<?php	 } else {  	?>
			
			 <td width="5%"><div align="left"><?php echo $cdgbar?></td>
			 <td width="5%" class=""><div align="center"><?php echo $canart?></div></td>
		<?php	   $dscart = substr($dscart." ", 0, 28);$dscart3 = substr($dscart." ", 0, 35); ?>
             <td width="23%"><div align="left"><?php echo $dscart?></div></td>
             <td width="4%"><div align="right"><?php echo $tarimp?></div></td>
 		     <td width="6%"><div align="right"><?php echo $tarred?></div></td>				
			  <td width="7%"><div align="right"><?php echo number_format($cosart,2,".",",")?></div></td>
			  <td width="5%"><div align="right"><?php echo number_format($fleart,2,".",",")?></div></td>
			  <td width="5%"><div align="right"><?php echo number_format($utiart1,2,".",",")?></div></td>
              <td width="5%"><div align="right"><?php echo number_format($despro,2,".",",")?></div></td>
			  <td width="8%"><div align="right"><?php echo number_format($precio_anterior,2,".",",")?></div></td>
			  <td width="8%"><div align="right"><?php echo number_format($PRE001,2,".",",")?></div></td>
			  <td width="4%"><div align="right"><?php echo number_format($desfac,2,".",",")?></div></td>				
			  <td width="8%"><div align="right"><?php echo number_format($importe,2,".",",")?></div></td>
				 <?php } ?>
				 
				 
<td width="10%"><div align="center"><a href="#"><img src="../img/Edit_Male_User_Icon_32.png" alt="modificar" width="25" height="25" border="0" title="Modificar Linea" onClick="validararticulo_xml(<?php echo $codlineatmp?>,<?php echo $numlinea?>,'<?php echo $cdgbar?>',<?php echo $canart ?>,'<?php echo $dscart3?>') ; modificar(<?php echo $cont ?>,<?php echo $codlineatmp ?>,'<?php echo $cdgbar?>','<?php echo $canart ?>','<?php echo $numlinea?>','<?php echo $dscart?>','<?php echo $cosart?>','<?php echo $fleart?>','<?php echo $despro?>','<?php echo $desfac?>','<?php echo $utiart1?>')"></a><a href="javascript:eliminar_linea(<?php echo $codlineatmp?>,<?php echo $numlinea?>,<?php echo $importe ?>)"><img src="../img/Symbol-Delete_32x32-32.png" width="25"  height="25" border="0"></a><a href="#"><img src="../img/Zoom-in_32x32-32.png" alt="modificar_articulo" width="25" height="25" border="0" title="Agregar articulo" onClick="modificar_articulo(<?php echo $codlineatmp?>,<?php echo $numlinea?>,'<?php echo $cdgbar?>',<?php echo $canart ?>,'<?php echo $dscart3?>')"></a></div></td>
			
			<?php  
					 if (	$filas2 > 0	 )   {		
			
			 if ($existencia < 0 )   {  ?>
			<td width="15%" class="existencia_negativa"><?php echo $existencia?>
			
		<?php /*?>	<a href="#"><img src="../img/lector-de-codigos-de-barras-ds-1D-datamark.png" alt="modificar_articulo" width="25" height="25" border="0" title="Modificar_codigo" onClick="modificar_codigo('<?php echo $codlineatmp?>',<?php echo $numlinea ?>,<?php echo $canart ?>)"></a></td>
			*/?>
			
			
		<?php	 } else {   ?>

			<td width="15%"  class="existencia_positiva" ><?php echo $existencia?></td>
			
						
		<?php /*?>	<a href="#">
			<img src="../img/lector-de-codigos-de-barras-ds-1D-datamark.png" alt="modificar_articulo" width="25" height="25" border="0" title="Modificar_codigo" onClick="modificar_codigo('<?php echo $codlineatmp?>',<?php echo $numlinea ?>,<?php echo $canart ?>)"></a><?php */?>
			
			
			<?php  }  } ?>
			</tr>

<?php 

$preciotot=$baseimp+$baseiva-$basedes;

if ($result4 = $mysqli->query("SELECT * FROM factulineatmp_compra WHERE  codfactura=$codlineatmp"  )) {
   $filas = $result4->num_rows;

}
$cont ++;


}


?>

					<script languaje="javascript">
	pon_prefijo("<?php echo $filas ?>","<?php echo $preciotot ?>","<?php echo $baseimp ?>","<?php echo $baseiva ?>","<?php echo $basedes ?>");
	
		</script>
</table>

</table>
<blockquote>&nbsp;	</blockquote>
</div>

<div id="ztotalesaw" align="right">
			 <input id="posicion" name="posicion" type="hidden" value=" <?php echo $posicion ?>" >
            <table width="98%" border=0 align="right" cellpadding=0 cellspacing=0 class="fuente8">
			  <tr>
			    <td width="70%" class="busqueda"><b>Sub-total</b></td>
				<td width="30%" align="right"><div align="right">
			      <input class="cajaTotales" name="baseimponible" type="text" id="baseimponible" size="12" value="<?php echo number_format($baseimp,2,",",".");?>" align="right" readonly> 
		        </div></td>																					 
	

			  </tr>
			  <tr>
			    <td class="busqueda"><b>Descuento</b></td>
			    <td align="right"><div align="right">
			      <input class="cajaTotales" name="basedescuento2" type="text" id="basedescuento2" size="12" value="<?php echo number_format($basedes,2,",",".");?>" align="right" readonly>
		        </div></td>
		      </tr>
			  <tr>
				<td class="busqueda"><b>IVA</b></td>
				<td align="right"><div align="right">
			      <input class="cajaTotales" name="baseimpuestos" type="text" id="baseimpuestos" size="12" align="right" value="<?php echo number_format($baseiva,2,",",".");?>" readonly> 
		        </div></td>
			  </tr>
			  <tr>
				<td class="busqueda"><b>Precio Total</b></td>
			
				<td align="right"><div align="right">
			      <input class="cajaTotales" name="preciototal" type="text" id="preciototal" size="12" align="right" value="<?php echo number_format($preciotot,2,",",".");?>" readonly> 
							  

		        </div></td>
			  </tr>
			</table>
			
</div>

</body>
</html>