<?php	
// $cone=$_SESSION['con'];
 include "emenux.php";
 require("funciones.php");
 require ("conecta.php");
 $codigo=$_GET['codigo'];
 $sql="select cantidad,precio,llave from adai02 where cod_interno='$codigo' order by llave ;";  
 $result=mysql_query($sql,$con) or die( mysql_error());
 
 ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>Busqueda</TITLE>
<!--<script language="javascript" src="fstandar.js"></script>!-->
<link rel="stylesheet" href="styles.css">
<style type="text/css">
<!--
.Estilo3 {color: #FFFFFF}
-->
</style>

 <SCRIPT language="javascript">  
  
   function envia(interno,glosa,codprov){    
	//document.write(a.substring(4,8));
    opener.document.form1.interno.value = interno;
	opener.document.form1.hdcod.value = interno;
	opener.document.form1.glosa.value = glosa;
	opener.document.form1.codprov.value = codprov;
	opener.document.form1.codprov.focus();
	//seleccionado.substr(seleccionado,9);	
	close(); 
   } 
  </script> 

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /></HEAD>
<BODY>

<TABLE height="56%" cellSpacing=0 cellPadding=0 width="83%" align=left 
border=0>
  <TBODY>
  <TR>
    <TD vAlign=top height="100%">
      <TABLE height=135 cellSpacing=0 cellPadding=0 width=763 border=0>
        <TBODY>
        <TR>
          <TD width="717" height=22>
            <TABLE height=22 cellSpacing=0 cellPadding=0 width="100%" 
              border=0><TBODY>
              <TR>
                <TD vAlign=top align=left width=24><A 
                  href="index.php"><IMG src="images/xc_left.gif" alt="Inicio" width=24 
                  height=22 
                  border=0></A></TD>
                <TD vAlign=top align=left width="100%"><IMG height=22 
                  src="images/xc_center.gif" width="100%" 
                border=0></TD>
              <TD vAlign=top align=right width=24><IMG height=22 
                  src="images/xc_right.gif" width=24 
              border=0></TD></TR></TBODY></TABLE>
            </TD>
        </TR>
        <TR>
          <TD class=BottomTable vAlign=top 
          background=images/xc_stripes.gif height="100%"><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#C4D2E2" class="Emphasize">
            <tr>
              <th width="4%" class="m0l0oout" scope="col"><div align="left" class="m0l0oout Estilo3">Cant.</div></th>
              <th width="28%" class="m0l0oout" scope="col"><p align="left" class="Estilo3">Proveedor</p></th>
              <th width="8%" class="m0l0oout" scope="col"><div align="left" class="Estilo3">Precio</div></th>
              <th width="7%" class="m0l0oout" scope="col"><div align="center" class="Estilo3">%Desc.1</div></th>
              <th width="7%" class="m0l0oout Estilo3" scope="col"><span class="Estilo3">%Desc.2</span></th>
              <th width="7%" class="m0l0oout" scope="col"><p class="Estilo3">%Desc.3</p></th>
			  <th width="9%" class="m0l0oout" scope="col"><p class="Estilo3">Neto</p></th>
              <th width="10%" class="m0l0oout Estilo3" scope="col">Fecha</th>
              <th width="9%" class="m0l0oout Estilo3" scope="col">Recepc.</th>
              <th width="11%" class="m0l0oout Estilo3" scope="col">Fctura</th>
            </tr>
            <?php	
				   $indice=0;	
				   //if (strlen($numero)>0){//si#		  
				   //$sqld="select * from m07001 where glosa='$glosa%' ;";
				   //$resd=mysql_query($sqld,$cone) or die(mysql_error());				   
				   while ($filad=mysql_fetch_row($result)){
				     $cant=$filad[0];
					 $pre=$filad[1];
					 $lla=substr($filad[2],0,7);
					 $sql2="select nombre,d1,d2,d3,fecha,fact from adae02 where numero='$lla';";
					 $res2=mysql_query($sql2,$con);
					 while ($filae=mysql_fetch_row($res2)){
					  $nombre=$filae[0];
					  $d1=$filae[1];
					  $d2=$filae[2];
					  $d3=$filae[3];
					  $fecha=editafecha($filae[4]);
					  $fact=$filae[5];					  
					 }
				     echo "<tr>";
					 echo "<td>$cant</td>";
					 echo "<td>$nombre</td>";
					 echo "<td align='right'>" . number_format($pre,0,".",",") . "</td>";
					 echo "<td align='right'>". number_format($d1,2,".",",") . "</td>";
					 echo "<td align='right'>" . number_format($d2,2,".",",") . "</td>";
					 echo "<td align='right'>". number_format($d3,2,".",",") ."</td>";
					 $neto=$pre - round(($pre * $d1 / 100));
					 $neto=$neto - round(($neto * $d2 / 100));
					 $neto=$neto - round(($neto * $d3 / 100));
					 echo "<td align='right'>". number_format($neto,0,".",",") ."</td>";  
					 echo "<td align='right'>$fecha</td>";
					 echo "<td align='right'>$lla</td>";
					 echo "<td align='right'>$fact</td>";
					echo "</tr>";
				    }
					//}
				   ?>
          </table>
            <p>&nbsp;</p></TD>
        </TR></TBODY></TABLE>
      <span class="Emphasize">ho&ntilde;a</span></TD>
  </TR></TBODY>
</TABLE>
<?php mysql_close($con); ?>
</BODY>
</HTML>

