<?
session_start();
if ($_SESSION['estado'] != "ON")
		{
		?>
		<script>
			parent.location.href = '../index.php';
		</script>
		<? 
		exit();
		}
$id_empresa = $_SESSION['ss_empresa'];
$id_user = $_SESSION['ss_user'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Estadisticas de Ventas</title>
<?
include("../conex.php");

$txtfecha=$_POST["fecha"];

$dia = substr ($txtfecha, 0, 2);
$mes = substr ($txtfecha, 3, 2);
$aņo = substr ($txtfecha, 6, 4);

$ini = $aņo.'/'.$mes.'/01';
$fin = $aņo.'/'.$mes.'/'.$dia;
 
$vende =$_POST["id_vendedor"];

?>



<style type="text/css">
<!--
.Estilo1 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;}
.Estilo2 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color:#FF0000}
-->
</style>
</head>
<body LINK="#000000" VLINK="#000000" ALINK="#000000">  <br>
<div align="center" class="titulos2">VENTAS DEL MES HASTA <?=$txtfecha?></div>
<div align="center">

    <table width="80%" border="0">
      <tr bgcolor="#CCCCCC">
	  	
        <th scope="col"><div align="center">Vendedores</div></th>
      
		<th scope="col"><div align="center">NETO</div></th>
       
		<?		
		$total_neto=0;
	
		$doctos= " (salida.tipo_dcto='1'  or salida.tipo_dcto='2' or salida.tipo_dcto='6' or salida.tipo_dcto='7' or salida.tipo_dcto='33' or salida.tipo_dcto='56' or salida.tipo_dcto='61') ";
	

$sqlfs = "select fecha_emision, sum(salida.factor*neto) as netos,  vendedor,  vendedor.nombres FROM salida,  vendedor WHERE salida.vendedor='$vende' AND (fecha_emision>='$ini' and fecha_emision<='$fin') AND " .$doctos. "  AND salida.vendedor=vendedor.id GROUP BY vendedor";



		  	$resfs = mysql_query($sqlfs,$enlace);	

			$cont=0;
			while (mysql_fetch_object ($resfs))
 				{
									
				
				
				$nombre = mysql_result($resfs, $cont, "nombres");
				
			
				
				$neto= mysql_result($resfs, $cont, "netos");
				$total_neto+=$neto;
				$neto=number_format($neto,0,',','.');
			?>	
				 
			<tr>

				<td style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="left"><span class="Estilo1"><strong>  <?=$nombre?> (<?=$rut?> ) </strong></span></div></td>
              
				<td style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px" align="right"><div align="right"><span class="Estilo1"><strong> <?=$neto?> </strong></span></div></td>
				
	        </tr>	
			<?
			$cont+=1;
			}
			$total_neto=number_format($total_neto,0,',','.');
		
			?>
			<tr>

				<td style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="left"><span class="Estilo1"><strong>
	            
				</strong></span><strong>Total Neto: </strong></div></td>
	
		<td style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="right"><span class="Estilo1"><strong></strong></span><span class="Estilo1"><strong><?=$total_neto?></strong></span></div></td>		
	        </tr>
    </table>
	<form name="form1" method="post" action="">

	  <input type="button" name="salir" id="salir" value="Salir" onClick="cerrar();">
	  <input name="txt_nv" id="txt_nv" type="text" style="visibility:hidden" size="1">
    </form>
  </div>
</body>
</html>

<script language="javascript" type="text/javascript">
function cerrar()
{
window.top.open('','_parent','');
window.top.close();
}

</script>