<?php
ini_set("session.cookie_lifetime",60*60*10);
ini_set("session.gc_maxlifetime", 60*60*10);
session_start();
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
$SYS_MSG="";$SYS_FOC="";$OK=1;
$StrId=V($_POST['TxtId']);$StrCmd=V($_POST['TxtAc']);$LStrPag=V($_POST['TxtPag']);
//+++++++
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;
}
//--------------------------------------------------------------------------
$Cod=V($_POST['Cod']);
$Des=V($_POST['Des']);
$Lin=VT($_POST['Lin']);
$Uso=VT($_POST['Uso']);
//
$Cod_=$Cod."%";
$Des_=$Des."%";
$Lin_=LIKE($Lin);
$Uso_=LIKE($Uso);
//
$FF="ID>0 AND COD LIKE '$Cod_' AND DESCRIPCION LIKE '$Des_' AND LINEA LIKE '$Lin_' AND CAST(USO AS CHAR) LIKE '$Uso_' ";
//--------------------------------------------------------------------------
$VP_RegXPag=500;
$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>
<?php AddJs(); ?>


<script type="text/javascript" src="js/sis_funciones.js"></script>

<link rel="stylesheet" type="text/css" href="css/estiloss.css"  />
<link rel="stylesheet" type="text/css" href="css/basic.css"  />

<style type="text/css">
.mM {height:34px;width:1250px;position:relative;top:0px;background-color:#09C; z-index:500;}
.cF {height:600px;width:1250px;position:relative;top:0px}
</style>

<script>
$(document).ready(function(){  
   Inicializar();
   SYS_LOAD();
   jF("Cod");
});
</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>

<div align="center">
<div Id="DivFRM"  class="cF" style="background-color:#FFFFFF;">
<form id="Frm" name="Frm" method="post" action="sis_productos_b.php" autocomplete="off">
<!--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: 107px; 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: 129px; width: 65px; height: 18px;">CODIGO</div>
<input name="Cod"  type="text" id="Cod"
class="lt" style="left:35px; top: 146px; width: 104px;"
maxlength="150" 
tabindex="<?php echo ++$TI;?>"
value="<?php echo $Cod;?>"   />

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

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

<div class="s1" style="left:536px; top:129px; width: 82px; height: 18px;">EN USO</div>
<select name="Uso" id="Uso" 
class="lt" style="left:535px; top:146px; width: 85px;"
tabindex="<?php echo ++$TI;?>"  >
<?php
echo FCBO("au_item","auxiliar","au_tab='SI_NO'",$Uso,"S","N");
?>
</select>


<!--INI_BOTONES-------------------------------->
<div id="DivBtn" align="left" style="position:absolute; left: 33px; top: 71px; width:1000px; height: 26px;">
<input name="CmdB" type="button" id="CmdC"  class="btm" 
value="Filtrar" onClick="fFiltrar();"  
tabindex="<?php echo ++$TI;?>" />

<input name="CmdB" type="button" id="CmdB" class="btm"
value="Volver" onClick="fBuscar('sis_productos.php');"  
tabindex="<?php echo ++$TI;?>" />
</div>
<!--FIN_BOTONES-------------------------------->

<div style="position: absolute; left: 35px; top: 180px; width: 1180px; height: 22px;">
<table  style="font-size:0.9rem; width:100%" >
<thead>
<tr>
<td colspan="5"  align="center"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>
</tr>
</thead>
</table>
</div>

<div class="tableFixHead" style="position: absolute; left: 35px; top: 205px; width: 1180px; height: 361px;">
<table id="Exportar_a_Excel" style="font-size:0.9rem; width:100%" >
<thead>
<tr align="left">
<th width="8%">CODIGO</th>
<th width="35%">DESCRIPCION</th>
<th width="17%">LINEA</th>
<th width="8%">PC DOL</th>
<th width="7%">PV MIN</th>
<th width="15%">PV MAX</th>
<th width="5%">EN USO</th>
<th width="3%">UND</th>
<th width="2%">&nbsp;</th>
</tr>
</thead>
<tbody>
<?php
$PX=0;		
$s="SELECT * FROM vproductos WHERE $FF ORDER BY DESCRIPCION ";
//echo $s."<br>";
$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);
$rs = grs($s);
while ($r = $rs->fetch_assoc()){
	$PX++;
	$CSS="";
	$UND=$r['UNIDAD'];//PRO_UND_GET($r['ID']);
	if($PX%2==0)$CSS=' style="background-color:#D4D4D4" ';		
	?>
	<tr>
    <tr <?php echo $CSS;?> onDblClick="location.href='sis_productos.php?Id=<?php echo $r['ID'];?>&Pag=0'">
	<td><?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><?php echo $UND;?></td>
	<td><a href="sis_productos.php?Id=<?php echo $r['ID'];?>&Pag=0" ><img src="e.png"  border="0"/></a></td>
	</tr>			
	<?php
}
?>
</tbody>
</table>
</div>

<?php include("sis_ocultos.php");?>


</form>

<form action="ficheroExcel.php" method="post" target="_blank" id="FormularioExportacion" >
<div style="position: absolute; left: 221px; top: 71px; width: 45px; height: 15px;">  
<input name="" type="button" class="botonExcel btm" value="Exportar" />
<input type="hidden" id="datos_a_enviar" name="datos_a_enviar" />
</div>
</form>

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