<?php
session_start();
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
//
if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}
//
$IdUsu=$_SESSION['SYS_USER_ID'];

include("deos_ingresos_bx.php");

$AT=gs("at","usuarios","id_usuario=$IdUsu");
?>

<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ingresos buscar</title>
<!----------------------------------------->
<?php AddJs(); ?>
<script type="text/javascript" src="funciones.js"></script>

<!----------------------------------------->
<link rel="stylesheet" type="text/css" href="z2/estiloss.css"  />
<link rel="stylesheet" type="text/css" href="z2/basic.css"  />
<link rel="stylesheet" type="text/css" href="css/mnu.css"  />

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

<!----------------------------------------->
<script>
$(document).ready(function(){  
   Inicializar();
   jF("CboAlm");
});

$(document).keydown(function(e){
	var AT=gv("TxtAT");

	if(e.which==66 && e.altKey){
		if(AT=="1"){	
		document.getElementById("CmdB").click();
		return;
		}
	}

	if(e.which==86 && e.altKey){
		if(AT=="1"){
		document.getElementById("CmdZ").click();
		return;
		}
	}
  
});
</script>
<!----------------------------------------->

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

<div class="mM" align="left" style="font-size:12px">
<?php
$HTM=file_get_contents("http://inversionessounduniversal.com/ventas/phpmnu.php?USER_ID=$IdUsu");
echo $HTM;
?>
</div>

<div Id="DivFRM"  class="cF" style="background-color:#FFFFFF;" >
<form id="Frm" name="Frm" method="post" action="ingresos_buscar.php">

<!----------------------------------------->
<div id="DivT" class="dT"  style="width:1250px;">
<img src="b.png" class="iT" />
<div class="tT">INGRESOS - BUSCAR</div>
</div>
<!----------------------------------------->

<div class="s1" style="left: 35px; top: 121px; width: 102px;">
ALMACEN</div>
<select name="CboAlm" id="CboAlm" 
class="lt" style="left: 35px; top: 138px; width: 177px" 
tabindex="<?php echo ++$TI;?>">
<?php 
	if($IdUsu>=1 && V($_SESSION['SYS_USER_ALM'])!="%"){
		echo ListALM($StrAlm); 
	}else{
    	echo FCBO("alm_nombre","almacenes","id_almacen>0",$StrAlm,"S","N");
    }
?>
</select>

<div class="s1" style="left: 222px; top: 121px; width: 137px;">
TIPO DE EGRESO</div>
<select name="CboTde" id="CboTde" 
class="lt" style="left: 220px; top: 138px; width: 328px" 
tabindex="<?php echo ++$TI;?>">
<?php echo FCBO_("nombre","ingresos_tipos","id_it>0",$StrTde,"S","N")?>
</select>

<div class="s1" style="left: 558px; top: 121px; width: 45px;">
DESDE</div>
<input name="TxtDex"  type="text" id="TxtDex"
class="fe" style="left: 558px; top: 138px; width: 73px;" 
value="<?php echo $StrDex;?>" 
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 640px; top: 121px; width: 60px;">
HASTA</div>
<input name="TxtHax"  type="text" id="TxtHax"
class="fe" style="left: 641px; top: 138px; width: 73px;" 
value="<?php echo $StrHax;?>" 
tabindex="<?php echo ++$TI;?>"/>

<!----------------------------------------->
<?php $VOLVER="ingresos.php";?>
<?php include("botones_b.php");?>;

<!-----------------------------------------> 

<div class="datagrid" style="position: absolute; left: 35px; top: 165px; width: 1180px; height: 416px; overflow: auto">
<table width="100%">
<thead>
<tr>
<td colspan="13" align="center"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>
</tr>

<tr>
<th width="69">FECHA</th>
<th width="197">ALMACEN</th>
<th width="259">TIPO DE INGRESO</th>
<th width="544">OBSERVACIONES</th>
<th width="60" style="text-align:right;">TOTAL</th>
<th width="21">&nbsp;</th>
</tr>
</thead>
<tbody>

<?php	
$TOTAL=0; 		
$s="SELECT ID,DATE_FORMAT(FEC,'%d-%m-%y'),SUBSTRING(ALM,1,27) AS ALM,
	TDI,OBS,TOT
	FROM vingresos 
	WHERE $FF ORDER BY FEC,ALM,TDI ";

$result = grs($s);				
while ($r = $result->fetch_row()){
		?>	
		<tr onDblClick="location.href='ingresos.php?Id=<?php echo $r[0];?>&Pag=0'">
		<!----------------------------------------------->
		<td><?php echo $r[1];?></td>
        <td><?php echo $r[2];?></td>
        <td><?php echo $r[3];?></td>
        <td><?php echo $r[4];?></td>
        <td style="text-align:right;"><?php echo $r[5];?></td>
		<!----------------------------------------------->
		<td bgcolor="#FFFFFF" align="center">
		<a href="ingresos.php?Id=<?php echo $r[0];?>&Pag=0">
		<img src="img/b_edit.png"  border="0"/></a></td>
		</tr>
		<?php
		$TOTAL=$TOTAL + $r[5];
}

?>	
	  
<tr>
<td colspan="4" bgcolor="#999999" style="text-align:right"><span class="Estilo4"><b>TOTAL</b></span></td>
<td width="60" bgcolor="#999999" style="text-align:right"><span class="Estilo4"><b><?php echo NF2($TOTAL,1);?></b></span></td>
<td bgcolor="#999999" style="text-align:right"><span class="Estilo4"><b>&nbsp;</b></span></td>
</tr>
       
</tbody>
</table>

</div>
  
<!----------------------------------------->    
<?php include("ocultos.php");?>
  
</form>
</div>
</div>
</body>
</html>
