<?php
session_start();
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
//
if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}
if(vbval($_SESSION['SYS_USER_GI'])!=USU_GET_GI($_SESSION['SYS_USER_ID'])){
	JsDir("cerrar.php");	
	return;
}
//
$HW=$_SESSION['SYS_HW'];
$StrGT="";$LStrMsg="";$LStrFoc="";$LStrMM="";
$LStrPag=V($_POST['TxtPag']);
//
include("productoz_buscar_fun.php");
//
$VP_RegXPag=26;
$LStrTR=gn("count(*)","vproductos",$FF);
//
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);	
$TI=0;
?>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Reporte de productos mas vendidos</title>
<!--INI_SCRIPT------------------------------------------------------------------------------>
<?php AddJs(); ?>
<script type="text/javascript" src="fe/funcionex.js"></script>
<!--FIN_SCRIPT------------------------------------->
<link rel="stylesheet" type="text/css" href="estilox.css"  />
<link rel="stylesheet" type="text/css" href="basix.css"  />
<style type="text/css">
.cF {height:770px;width:1300px;position:relative; <?php echo "top:0px";?>}
</style>
<script>
$(document).ready(function(){  
   Inicializar();   
});
</script>
<script language="javascript">
$(document).ready(function() {
	$(".botonExcel").click(function(event) {
		$("#datos_a_enviar").val( $("<div>").append( $("#Exportar_a_Excel").eq(0).clone()).html());
		$("#FormularioExportacion").submit();
});
});


</script>
</head>

<body  <?php echo $LStrMsg;?>  >
<div align="center">

<div Id="DivFRM"  class="cF" style="background-color:#FFFFFF;" >
<form id="Frm" name="Frm" method="post" action="productoz_buscar.php">
<!--INI_TITULO-->
<div id="DivT" class="dT"  style="width:1300px">
<img src="img/unidades.png" class="iT" />
<div class="tT" style="width:1000px" >REPORTE DE PRODUCTOS MAS VENDIDOS (Ordenado por mayor numero de piezas vendidas)</div>
</div>
<!--FIN_TITULO-->
<div class="s1" style="left:177px; top: 114px; width: 142px; height: 18px;">
  <?php
	if(strlen($_PDF)>0){
		echo "<a href=\"$_PDF\" target=\"_new\">DESCARGAR</a>";	
	}
?>  
</div>

<div class="s1" style="left:35px; top: 132px; width: 65px; height: 18px;">CODIGO</div>
<input name="Cod"  type="text" 
class="lt"  id="Cod" 
style="left:35px; top: 149px; width: 104px;"
maxlength="150" 
tabindex="<?php echo ++$TI;?>"
value="<?php echo $Cod;?>"   />

<div class="s1" style="left:150px; top: 132px; width: 216px; height: 18px;">DESCRIPCION</div>
<input name="Des"  type="text" 
class="lt"  id="Des" 
style="left:149px; top: 149px; width: 236px;"
maxlength="150" 
tabindex="<?php echo ++$TI;?>"
value="<?php echo $Des;?>"   />

<div class="ad" style="left:398px; top:132px; width: 104px; height: 18px;">LINEA</div>
<select name="Lin" id="Lin" 
class="lty" style="left:396px; top:149px; width: 130px;"
tabindex="<?php echo ++$TI;?>"  >
<?php
echo FCBO("lin_nombre","lineas","id_linea>0",$Lin,"S","N");
?>
</select>

<div class="ad" style="left:538px; top:132px; width: 80px; height: 18px;">EN USO</div>
<select name="Uso" id="Uso" 
class="lty" style="left:535px; top:149px; width: 85px;"
tabindex="<?php echo ++$TI;?>"  >
<?php
echo FCBO("au_item","auxiliar","au_tab='SI_NO'",$Uso,"S","N");
?>
</select>


<input name="CmdF" type="button" id="CmdF"  style="position:absolute; top:149px; left:628px; width: 76px;"
value="Filtrar" onClick="fFiltrar();"  
tabindex="<?php echo ++$TI;?>" />

<!--INI_TABLA----->
<div class="s1"
style="background:#ECF9FF; position:absolute; left: 35px; top: 182px; width: 1262px; height: 550px; overflow:auto;">
  <div class="s1" style="left: 0px; top: 0px; width: 1242px; z-index:0; ">
  <table id="Exportar_a_Excel" class="f4t" width="1223" border="1" style="border-collapse: collapse">
   <tr>
      <td colspan="8" bgcolor="#CCCCCC" height="18" align="center">
      <?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?>
      </td>
      </tr>   
    <tr>
      <td width="106" bgcolor="#CCCCCC">CODIGO</td>
      <td width="570" bgcolor="#CCCCCC">DESCRIPCION</td>
      <td width="180" bgcolor="#CCCCCC">LINEA</td>
      <td width="69" bgcolor="#CCCCCC">PC DOL</td>
      <td width="97" bgcolor="#CCCCCC">PV MIN</td>
      <td width="86" bgcolor="#CCCCCC">PV MAX</td>
      <td width="47" bgcolor="#CCCCCC">EN USO</td>
      <td width="16" bgcolor="#CCCCCC">#</td>
    </tr>   
    <?php		
		$s="SELECT * FROM vproductos WHERE $FF ORDER BY DESCRIPCION ";
		$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);
		$rs = grs($s);
		while ($r = $rs->fetch_assoc()){		
	?>
    <tr>
        <td onDblClick="location.href='productos.php?Id=<?php echo $r['ID'];?>&Pag=0'"><?php echo $r['COD'];?></td>
        <td><?php echo $r['DESCRIPCION'];?></td>
        <td><?php echo $r['LINEA'];?></td>
        <td class="td_n"><?php echo $r['PC_SOL'];?></td>
        <td class="td_n"><?php echo NF2($r['PV_MIN'],0);?></td>
        <td class="td_n"><?php echo NF2($r['PV_MAX'],2);?></td>
        <td><?php echo $r['USO'];?></td>
        <td><a href="productos.php?Id=<?php echo $r['ID'];?>&Pag=0" ><img src="e.png"  border="0"/></a></td>
    </tr>			
    <?php
		}
	?>
  </table>
</div>
</div>
<!--FIN_TABLA----->
<!--INI_OCULTOS-------------------------------->
<?php include("ocultox.php");?>
<!--FIN_OCULTOS-------------------------------->
<!--INI_BOTONES----->
<div id="DivBtn"  align="left"
style="position:absolute; left: 33px; top: 71px; width: 703px; height: 26px;">
<input name="CmdB" type="button" id="CmdZ" class="btm"
value="Volver" onClick="fBuscar('productos.php');"  
tabindex="<?php echo ++$TI;?>" />
</div>
<!--FIN_BOTONES-->
</form>
<form action="ficheroExcel.php" method="post" target="_blank" id="FormularioExportacion" >
<div style="position:absolute; left: 149px; top: 72px; width: 45px; height: 15px;">  
<input name="" type="button" class="botonExcel" value="Exportar" />
<input type="hidden" id="datos_a_enviar" name="datos_a_enviar" />
</div>
</form>

</div>
</div>
</body>
</html>
