<?php
 session_start();
 require "funciones.php";
 include "emenux.php";
 //------INI-Coneccion Local
 require ("conecta.php");
 //------INI-Coneccion Local
 //Recibe descripcion
 //$TIPOD=$_GET['COD_TIPO_D'];
 $NUMEROV=$_GET['NUMERO'];
 $TABLA=$_GET['tabla'];
 if ($TABLA=="adai01"){
  $tipod="Pedido";
  }else{
   $tipod="Recepción";
 }
 $d1=$_GET['d1'];
 $d2=$_GET['d2'];
 $d3=$_GET['d3'];
 //$desc=$_GET['desc'];
 $llaverv=$NUMEROV;
 $sqlb="select cantidad,cod_interno,glosa,precio,stotal from $TABLA where llave like '$NUMEROV%';";
 $resb=mysql_query($sqlb,$con) or die(mysql_error());
 // contador de resultados en "0";
 $cant=0;
 if (mysql_num_rows($resb)>0){
   while ($filab = mysql_fetch_row($resb)){
    $cant++;
   }//while
  }//fin si
?>
<!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>Resultado de busqueda</TITLE>

<link rel="stylesheet" href="styles.css">
<style type="text/css">
<!--
.Estilo1 {
	color: #FFFFFF;
	font-weight: bold;
}
-->
</style>
</HEAD>
<BODY>
<TABLE height="100%" cellSpacing=0 cellPadding=0 width="107%" align=center 
border=0>
  <TBODY>
  <TR>
    <TD vAlign=center align=middle height="100%">
      <TABLE height=400 cellSpacing=0 cellPadding=0 width=896 border=0>
        <TBODY>
        <TR>
          <TD width="718" height=22>
            <TABLE width="872" height=22 
              border=0 cellPadding=0 cellSpacing=0>
              <TBODY>
              <TR>
                <TD vAlign=top align=left width=24><A 
                  href="index.php"><IMG 
                  height=22 src="images/xc_left.gif" width=24 
                  border=0></A></TD>
                <TD vAlign=top align=left width="690"><img height="22" 
                  src="images/xc_center.gif" width="111%" 
                border="0" /></TD>
              <TD vAlign=top align=right width=98>&nbsp;</TD>
              </TR></TBODY></TABLE>            </TD>
        </TR>
        <TR>
          <TD class=BottomTable vAlign=top 
          background=images/xc_stripes.gif height="100%">
            <TABLE class=IconsTable height=33 cellSpacing=0 cellPadding=0 
            width="100%" border=0>
              <TBODY>
              <TR>
                <TD height="32"><div align="right" class="larger">
                  <div align="right">Vemol</div>
                </div></TD>
                </TR></TBODY></TABLE>
            <TABLE width="894" 
              border=0 cellPadding=0 cellSpacing=0 bordercolor="#595959">
              <TBODY>
              <TR>
                <TD width=23 height=18>&nbsp;</TD>
                <TD height=18 align=left vAlign=top>&nbsp;</TD>
                <TD width=20 height=18>&nbsp;</TD></TR>
              <TR>
                <TD width=23 height="100%">&nbsp;</TD>
                <TD height="100%" align=left vAlign=top><form id="form1" name="form1" method="post" action="">
                  <table width="91%" border="1" cellpadding="0" cellspacing="0">
                      <tr>
                        <td colspan="5" scope="col"><div align="center">
                          <p><strong><span class="MainMenuHead">Detalle <?php echo $tipod . " Nº " . $NUMEROV ?></strong></p>
                          </div></td>
                        </tr>

                      <tr>
					    <td width="11%" class="m0l0oout Estilo1" scope="row"><div align="center" class="Estilo1">
                            <div align="left">Cantidad</div>
                        </div></td>
                        <td width="13%" class="m0l0oout Estilo1" scope="row"><div align="left">Cod_Interno</div></td>
                        <td width="46%" class="m0l0oout Estilo1" scope="row"><div align="left">Glosa</div></td>
                        <td width="12%" class="m0l0oout Estilo1" scope="row"><div align="center">Precio</div></td>
                        <td width="18%" class="m0l0oout Estilo1" scope="row"><div align="center">Total</div></td>
                      </tr>
					  <?php
					   //Definimos los colores a usar
					   $color0 = "#A4B4C1";
					   $color1 = "#D5E7FB";
					   $color2 = "#E8F2FC";
					   $color3 = "#E0FAC5";
					   $color = $color1;
					   $resb=mysql_query($sqlb,$con);
					   $sumaneto=0;
					   if (mysql_num_rows($resb)>0){					    
					    while ($filab = mysql_fetch_row($resb)){										
						$CANTIDAD=$filab[0];
						$COD_INTERNO=$filab[1];						
						$GLOSA=$filab[2];
						$PRECIO_V=number_format($filab[3],0,".",",");
						$TOTAL=number_format($filab[4],0,".",",");	
						$sumaneto=$sumaneto + $filab[4];
						//$preciocd=round($PRECIO_V - ($PRECIO_V*$desc/100));//precio con descuento incl.
						//$preciont=round($CANTIDAD *$preciocd / 1.19);
						//$sumaneto += $preciont;
						//$sumacosto+=$costo;
						//$difpeso=$preciont - $costo; 
						//$difpor=$difpeso*100/$costo;
						//$difpore=number_format($difpor,2,".",",") . "%";
						 // empezando una tabla html
						 echo "<tr style=\"background-color:$color\" onMouseOver=\"this.style.backgroundColor='$color3'\" onMouseOut=\"this.style.backgroundColor='$color'\">";
						 //echo "<td> $tipogl </td>";
						 //echo "<td> $numdoc </td>";
						 echo "<td align='right'>$CANTIDAD</td>";
						 echo "<td>$COD_INTERNO</td>";
						 echo "<td>$GLOSA</td>";
						 echo "<td align='right'>$PRECIO_V</td>";
						 echo "<td align='right'>$TOTAL</td>";
						 //echo "<td align='right'>$preciont</td>";
						 //echo "<td align='right'>$costo</td>";
						 //echo "<td align='right'>$difpeso</td>";
						 //echo "<td align='right'>$difpore</td>";
						 echo "</tr>";
						 if ($color == $color1){
						  $color = $color2;
						  }else{
						  $color = $color1;
						 }
						}//while
						
					   }//fin si 
					  ?>
					  <tr>
                        <td scope="row">&nbsp;</td>
						<td scope="row">&nbsp;</td>
						<td scope="row">&nbsp;</td>
						<td scope="row" align="right"><b>Total</b></td>
						<td scope="row" align="right"><b><?php echo number_format($sumaneto,0,".",","); ?></b></td>						
					  </tr>
					  <tr>
                        <td scope="row">&nbsp;</td>
						<td scope="row">&nbsp;</td>
						<td scope="row">&nbsp;</td>
						<td scope="row" align="right"><b>%Desc.1</b></td>
						<td scope="row" align="right"><b><?php echo number_format($d1,2,".",",") ; ?></b></td>						
					  </tr>
					  <tr>
                        <td scope="row">&nbsp;</td>
						<td scope="row">&nbsp;</td>
						<td scope="row">&nbsp;</td>
						<td scope="row" align="right"><b>%Desc.2</b></td>
						<td scope="row" align="right"><b><?php echo number_format($d2,2,".",","); ?></b></td>						
					  </tr>
					  <tr>
                        <td scope="row">&nbsp;</td>
						<td scope="row">&nbsp;</td>
						<td scope="row">&nbsp;</td>
						<td scope="row" align="right"><b>%Desc.3</b></td>
						<td scope="row" align="right"><b><?php echo number_format($d3,2,".",",") ; ?></b></td>						
					  </tr>
					  <?php
					   $neto=$sumaneto - round(($sumaneto * $d1 / 100));
					   $neto=$neto - round(($neto * $d2 /100));
					   $neto=$neto - round(($neto * $d3 /100));
					   $iva=round($neto * 0.19);
					   $total=$neto + $iva;
					  ?>
					  <tr>
                        <td scope="row">&nbsp;</td>
						<td scope="row">&nbsp;</td>
						<td scope="row">&nbsp;</td>
						<td scope="row" align="right"><b>Neto</b></td>
						<td scope="row" align="right"><b><?php echo number_format($neto,0,".",",") ; ?></b></td>						
					  </tr>
					  <tr>
                        <td scope="row">&nbsp;</td>
						<td scope="row">&nbsp;</td>
						<td scope="row">&nbsp;</td>
						<td scope="row" align="right"><b>Iva</b></td>
						<td scope="row" align="right"><b><?php echo number_format($iva,0,".",",") ; ?></b></td>						
					  </tr>
					  <tr>
                        <td scope="row">&nbsp;</td>
						<td scope="row">&nbsp;</td>
						<td scope="row">&nbsp;</td>
						<td scope="row" align="right"><b>Total</b></td>
						<td scope="row" align="right"><b><?php echo number_format($total,0,".",",") ; ?></b></td>						
					  </tr>
                      <tr>
                        <td colspan="5" scope="row"><label>
                          <div align="center" class="LeftMenu"><acronym><a href="javascript:window.close();">Volver a Buscar<br />
</a></acronym>
                            <label></label>
</div>
                          </label></td>
                        </tr>
                      <tr>
                        <th colspan="5" scope="row"><label></label></th>
                        </tr>
                    </table>
                </form>
                  <p>&nbsp;</p>                  <p><a href="buscar"></a> </p></TD>
                <TD width=20 height="100%">&nbsp;</TD></TR>
              <TR>
                <TD width=23 height=8>&nbsp;</TD>
                <TD height=8>&nbsp;</TD>
        <TD width=20 
      height=8>&nbsp;</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY>
	  <script language="JavaScript" src="menu.js"></script>
<script language="JavaScript" src="menu_tpl.js"></script>
<script language="JavaScript">
	new menu (MENU_ITEMS, MENU_POS);
</script>
</TABLE>
</BODY>
<?php
 //------FIN-Coneccion Local
 mysql_close($con)
 //------FIN-Coneccion Local
 ?>
</HTML>