<?php
header('Cache-Control: no-cache');
header('Pragma: no-cache'); 
?>
<html>
<head>
<link href="../estilos/estilos.css" type="text/css" rel="stylesheet">
</head>
<script language="javascript">

function pon_prefijo(cdgpro,dscpro,combotipoventa) {
	parent.opener.document.form_busqueda.cdgpro.value=cdgpro;
	parent.opener.document.form_busqueda.dscpro.value=dscpro;
	parent.opener.buscar();
	parent.window.close();

	


}

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


//$dscpro=strtoupper($_POST["dscpro"]);

$cdgbar=$_POST["cdgbar"];
//$cdgpro=$_POST["cdgpro"];


$cuantos =0;

	

?>
<body>
<?php

   if ($result = $mysqli->query("SELECT * FROM factulinea_compra  WHERE codigo='$cdgbar'  AND borrado='0' ")) {
   $cuantos = $result->num_rows;
   $result->close();
}




?>
<div id="tituloForm2" >
<form id="form1" name="form1">
<?php  if ($cuantos>0) { ?>
		<table class="fuente8" width="100%" cellspacing=0 cellpadding=3 border=0>
		  <tr class="cabeceraTabla" >
		    <td width="22%"><div align="center"><span class="cabeceraTabla"><b>NUMERO FACTURA </b></span></div></td>
		    <td width="22%"><div align="center"><span class="cabeceraTabla"><b>FECHA COMPRA</b></span></div></td>
			<td width="1%"><div align="center"><span class="cabeceraTabla"><b></b></span></div></td>
			<td width="57%"><div align="center"><span class="cabeceraTabla"><b>PROVEEDOR</b></span></div></td>
			<td width="8%"><div align="right"><span class="cabeceraTabla"><b>CANTIDAD</b></span></div></td>
			<td width="3%"><div align="center"><span class="cabeceraTabla"><b></b></span></div></td>
			<td width="6%"><div align="right"><span class="cabeceraTabla"><b>COSTO</b></span></div></td>

			<td width="3%"><span class="totalResultado"></span></td>
		  </tr>
		<?php

	
	$consulta= "SELECT * FROM factulinea_compra  WHERE codigo='$cdgbar'  AND borrado='0' ORDER BY codfactura DESC LIMIT 100";
	
	
	
		if ($resultado1 = $mysqli->query($consulta)) {
        $count = 0;
 
  				while ($dato1 = $resultado1->fetch_assoc()) {
				
				$codfactura = $dato1['codfactura']; 
				$canart= $dato1['canart']; 
			    $cosart   = number_format($dato1['cosart'], 2);
				
				
				
			
			
		   $recibos = "SELECT * FROM facturas_compras WHERE codfactura = '$codfactura' ORDER BY codfactura DESC";
       $result_recibos = $mysqli->query($recibos);
       $row_recibos = $result_recibos->fetch_array();
     
	   $fecfac =  $row_recibos["fecfac"];		
	   $fecfac    = implode("-", array_reverse(explode("-", $fecfac))); 
	   $cdgpro =  $row_recibos["cdgpro"];
	   $dscpro =  $row_recibos["dscpro"];
	      $numfac =  $row_recibos["numfac"];
	  
	   

	 
	   
	   		
		?>
			
				            
      <tr>
        <td width="22%"  align="center"><font size=2 ><?php echo $numfac ?></font></td>
        <td width="22%"  align="center">  <font size=2 ><?php echo $fecfac ?></font></td>
		<td width="1%" align="right">  <font size=2 ></font></td>
   	    <td width="57%" align="left">  <font size="2"><?php echo '['.$cdgpro.'] ' .$dscpro ?></font></td>
        <td width="8%" align="right">  <font size=2 > <?php echo $canart ?></font></td>
		<td width="3%" align="right">  <font size=2 ></font></td>
        <td width="6%" align="right">  <font size=2 > <?php echo $cosart ?></font></td>
         <td width="3%" align="right">  <font size=2 ></font></td>
          </tr> 
				  
	
	<?php } ?>
	  </table> 
	
	 <?php }
	 
	 
	
		
		} else { ?>
		
					<table class="fuente8" width="87%" cellspacing=0 cellpadding=3 border=0>
						<tr>
							<td width="100%" class="mensaje"><?php echo "No existen  Documentos que cumpla con los criterios de b&uacute;squeda";?></td>
					    </tr>
					</table>					
					<?php } ?>	
  
  
<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>
<input type="hidden" id="accion" name="accion">
</form>
</div>
</body>
</html>
