<?php
session_start();
if (!isset($_SESSION['nick'])){
 header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/index.php" );
}
 include("emenux.php");
 require "funciones.php";
 //------INI-Coneccion Local
 require ("conecta.php");
 //-----INI-Coneccion Local
 //Recibe Fechas
 $fechai=editafechag($_POST['fechai']);
 $fechat=editafechag($_POST['fechat']);
 $sql="SELECT m06006.nick,sum(m02005.neto) 
FROM m02005 inner join m06006 on m02005.usuario=m06006.nick where m02005.fecha >= '$fechai' and m02005.fecha <= '$fechat' and ((m02005.cod_tipo_d*1) < 3)
GROUP BY m02005.usuario order by 2 desc ;";
 $res=mysql_query($sql,$con) or die(mysql_error());
 $cont=0;
 
?>
<!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>Detalle de Filtro Venta</TITLE>

<link rel="stylesheet" href="styles.css">
<SCRIPT language=JavaScript><!--
function popup(COD_TIPO_D,NUMERO,desc){ 
  var durl=new String();
  durl="detalven.php?COD_TIPO_D=" + COD_TIPO_D + "&NUMERO=" + NUMERO + "&desc=" + desc;
  open(durl,"detalle", "width=1000,height=500,left=0 resizable=YES ");
}
//--></SCRIPT>
<style type="text/css">
<!--
.Estilo1 {color: #FFFFFF}
-->
</style>
</HEAD>
<BODY>
<TABLE height="100%" cellSpacing=0 cellPadding=0 width="100%" align=center 
border=0>
  <TBODY>
  <TR>
    <TD vAlign=center align=middle height="100%">
      <TABLE height=400 cellSpacing=0 cellPadding=0 width=718 border=0>
        <TBODY>
        <TR>
          <TD width="718" 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 
                  height=22 src="images/xc_left.gif" width=24 
                  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 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 cellSpacing=0 cellPadding=0 width="715" 
              border=0>
              <TBODY>
              <TR>
                <TD width=23 height=18>&nbsp;</TD>
                <TD height=18 align=left vAlign=top class="LeftMenu">Resultado de Ranking de Vendedores: <span class="Emphasize"></span> <strong><?php echo $cont . "    fecha inicial: " . $_POST['fechai'] . "    fecha final: " . $_POST['fechat']  ?></strong></TD>
                <TD align=left vAlign=top class="LeftMenu">&nbsp;</TD>
                <TD width=20 height=18>&nbsp;</TD></TR>
              <TR>
                <TD width=23 height="100%">&nbsp;</TD>
                <TD height="100%" colspan="2" align=left vAlign=top class="contentcell"><form id="form1" name="form1" method="post" onSubmit="return validar(this)" action="resfilven.php">
                    <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#003366">
                      <tr>
                        <td width="56%" class="m0l0oout Estilo1" scope="row"><div align="center" class="LeftMenu Estilo1">
                          <div align="center">Vendedor</div>
                        </div></td>
                        <td width="21%" class="m0l0oout" scope="row"><div align="center" class="Estilo1">
                            <div align="left" class="LeftMenu">
                              <div align="center">Venta Neta </div>
                            </div>
                        </div></td>
                        <td width="23%" class="m0l0oout Estilo1" scope="row"><div align="left" class="LeftMenu">
                          <div align="center">Venta Burta </div>
                        </div></td>
                        </tr>
						<?php 						
						 while($fila=mysql_fetch_row($res)){
						  $vende=$fila[0];
						  $neto=$fila[1];
						  $bruto=round($fila[1] * 1.19);
                          echo "<tr>";
                          echo "<td scope='row'>$vende</td>";
                          echo "<td scope='row' align='right'>". number_format($neto,0,".",",") . "</td>";
                          echo "<td scope='row' align='right'>". number_format($bruto,0,".",",") . "</td>";
                          echo "</tr>";
						  }
						?>
                      </table>
                  </form>                  <p align="center"><span class="LeftMenu"><acronym><a href="M0202001.php">Volver a Buscar<br />
                  </a></acronym>
                      <label></label>
                  </span></p></TD>
                <TD width=20 height="100%">&nbsp;</TD></TR>
              <TR>
                <TD width=23 height=8>&nbsp;</TD>
                <TD height=8 colspan="2">&nbsp;</TD>
                <TD width=20 
      height=8>&nbsp;</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY>
<!-- /Footer -->
<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
	mysql_close($con);
?>	
</HTML>