<?php
	session_start();	
	//-------------------------	
	include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
	include("phpmnu_fun.php");
	if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}
	$StrGT="";
	$VP_RegXPag=10;
	$LStrMsg="";
	$LStrFoc="";
	$LStrMM="";
	$LStrPag=V($_POST['TxtPag']);	
	include("kardex_fun.php");
	$StrHWND_K=$_SESSION['SYS_HW']."_K";

$IdUsu=$_SESSION['SYS_USER_ID'];
$AT=gs("at","usuarios","id_usuario=$IdUsu");
?>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Kardex</title>
<!--INI_SCRIPT------------------------------------------------------------------------------>
<?php AddJs(); ?>
<script type="text/javascript" src="ja/funciones.js"></script>
<script type="text/javascript" src="ja/kardex.js"></script>
<!--FIN_SCRIPT------------------------------------->
<link rel="stylesheet" type="text/css" href="css/estiloss.css"  />
<link rel="stylesheet" type="text/css" href="css/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();
});
</script>

<script>
var myVar=setInterval(function(){myTimer()},500);
function myTimer(){
	t=GetHora();
	tt=document.getElementById("TxtHora").value;
	if(tt>0){
		if(t-tt>=1){
			document.getElementById("TxtHora").value=0;
			fGetTabla();			
		}
	}
}
function myStopFunction(){
	clearInterval(myVar);
}


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

	if(e.which==71 && e.altKey){		
		if(AT=="1"){	
		document.getElementById("CmdG").click();
		return;
		}
	}
	
	if(e.which==78 && e.altKey){
		if(AT=="1"){
		document.getElementById("CmdC").click();
		return;
		}
	}

	if(e.which==86 && e.altKey){
		if(AT=="1"){
		document.getElementById("CmdZ").click();
		return;
		}
	}
  
});
</script>
</head>
<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>
<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 GEN_MENU($IdUsu);
?>
</div>

<div Id="DivFRM"  class="cF" style="background-color:#FFFFFF;" onunload="myStopFunction();">
<form id="Frm" name="Frm" method="post" action="kardex.php"  autocomplete="off" style="margin:0px; padding:0px; display:inline;" onSubmit="return false;">

<!--INI_TITULO--------------------------------->
<div id="DivT" class="dT" >
<img src="img/kardex2.png" class="iT" />
<div class="tT">KARDEX</div>
</div>
<!--FIN_TITULO--------------------------------->

<div class="s1" style="left: 35px; top: 144px; width: 104px;">
ALMACEN</div>
<select name="CboAlm" id="CboAlm" 
class="lt" style="left: 35px; top: 163px; width: 154px"
tabindex="<?php echo ++$TI;?>">
<?php echo ListALM($StrAlm);?>
</select>

<div class="s1" style="left: 199px; top: 144px; width: 54px;">
CODIGO</div>
<input name="TxtCod" type="text" id="TxtCod" 
class="lt" style="left: 200px; top: 163px; width: 160px" 
value="<?php echo $StrCod;?>"  
onkeydown="return cCod(event);" 
onkeyup="return cCodUP(event);" 
onfocus="FOCO=0;"
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 373px; top: 144px; width: 100px;">
DESCRIPCION</div>
<input name="TxtDes" type="text" id="TxtDes" 
class="lt" style="left: 374px; top: 163px; width: 400px" 
value="<?php echo $StrDes;?>"  
onkeydown="return cDes(event);"
onkeyup="return cDesUP(event);" 
onfocus="FOCO=1;"
tabindex="<?php echo ++$TI;?>"/>



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

<input name="CmdB" type="button" id="CmdC"  class="btm" 
value="Nuevo" onClick="fCancelarPHP();"  
tabindex="<?php echo ++$TI;?>" />

</div>
<!--FIN_BOTONES-------------------------------->
<div class="datagrid" style="position: absolute; left: 35px; top: 199px; width: 1180px; height: 360px; overflow:auto">
<table id="Exportar_a_Excel" width="100%">
<thead>
<tr>
<td colspan="10" height="18" align="center"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>
</tr>
<tr>
<th width="7%">FECHA</th>
<th width="14%">DOCUMENTO</th>
<th width="8%">NUMERO</th>
<th width="39%">CLIENTE/PROVEEDOR</th>
<th width="8%">INICIAL</th>
<th width="8%">INGRESO</th>
<th width="8%">SALIDA</th>
<th width="8%">SALDO</th>
</tr>
</thead>
<tbody>
<?php
	$s="SELECT DATE_FORMAT(fec,'%d-%m-%y'),doc,num,clipro,ini,ing,sal,fin 
		FROM kardex WHERE hwnd='$StrHWND_K' ORDER BY fec,gi";
	$result = grs($s);
	while ($row = $result->fetch_row()){
		echo "<tr>";
		echo "<td bgcolor=\"#FFFFFF\">".VV($row[0])."</td>";
		echo "<td bgcolor=\"#FFFFFF\">".VV($row[1])."</td>";
		echo "<td bgcolor=\"#FFFFFF\" >".VV($row[2])."</td>";
		echo "<td bgcolor=\"#FFFFFF\" >".VV($row[3])."</td>";
		echo "<td bgcolor=\"#FFFFFF\" style=\"text-align:right\" >".VV($row[4])."</td>";
		echo "<td bgcolor=\"#FFFFFF\" style=\"text-align:right\" >".VV($row[5])."</td>";
		echo "<td bgcolor=\"#FFFFFF\" style=\"text-align:right\" >".VV($row[6])."</td>";
		echo "<td bgcolor=\"#FFFFFF\" style=\"text-align:right\" >".VV($row[7])."</td>";
		echo "</tr>";
	}
?>
</tbody>
</table>
</div>


<!--INI_OCULTOS-------------------------------->
<?php include("ocultos.php");?>
<input name="TxtHora" type="hidden" id="TxtHora" value="0" />
<!--FIN_OCULTOS-------------------------------->
<div id="DivDatosProd">
<input name="Pro_TxtId" type="hidden" id="Pro_TxtId" value=""/>
<input name="Pro_TxtDes" type="hidden" id="Pro_TxtDes" value=""/>
<input name="Pro_TxtPre" type="hidden" id="Pro_TxtPre" value=""/>
<input name="Pro_TxtCod" type="hidden" id="Pro_TxtCod" value=""/>
</div>

    
<div id="TAB_AJAX" class="datagrid" style="visibility:hidden; height: 326px; width: 1126px; overflow-x: hidden; position: absolute; left: 34px; top: 237px; overflow-y: scroll; color: #0FF; background-color: #FFFFFF; layer-background-color: #CCCCCC; border: 1px none #000000;" align="left"></div>
<div id="TAB_CAPTION" class="datagrid" style="visibility:hidden; height: 20px; width: 1125px; position: absolute; left: 34px; top: 218px; color: #0FF; background-color: #CCCCCC; layer-background-color: #CCCCCC; border: 1px none #000000;" align="left">
<table width="1080" border="1" cellpadding="0" cellspacing="0" bgcolor="#d4e3e5" class="estilo888">   
<tbody>
<tr  height="10 px">
<td width="80" bgcolor="#CCCCCC">CODIGO</td>
<td width="68" bgcolor="#CCCCCC">FABRICANTE</td>
<td width="100" bgcolor="#CCCCCC">MODELO</td>
<td width="350" bgcolor="#CCCCCC">DESCRIPCION</td>
<td width="65" align="right" bgcolor="#CCCCCC">PC SOL</td>
<td width="54" align="right" bgcolor="#CCCCCC">PC DOL</td>
<td width="56" align="right" bgcolor="#CCCCCC">&nbsp;</td>
</tr>
</tbody>
</table>
<div style="position:absolute; top:0px; left:1074px"><input name="CmdClose" type="button" value="Cerrar" onClick="CerrarDIV();" style="background-color:#F90" /></div>
</div>

<div class="s1" style="position: absolute; left: 35px; top: 116px; width: 1095px; z-index: 0">
DOCUMENTO : AJUXTE hace referencia a los ajustes automaticos creados al modificar el stock desde el modulo productos</div>



</form>

<form action="ficheroExcel.php" 
    method="post" target="_blank" id="FormularioExportacion" >
    
    <div style="position: absolute; left: 313px; 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>
