<?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("ajustes_fun.php");
//
$IdU=vbval(V($_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>Ajustes de Stock</title>
<!--INI_SCRIPT------------------------------------------------------------------------------>
<?php AddJs(); ?>
<script type="text/javascript" src="ja/funciones.js"></script>
<script type="text/javascript" src="ja/ajustes.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 FOCO=0;
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) {	
  if(e.which==65 && e.altKey){
    document.getElementById("CmdAdd").click();
	return;
  }
  if(e.which==84 && e.altKey){
    document.getElementById("CboTdp").focus();
	return;
  }
  if(e.which==71 && e.altKey){
	if(document.getElementById("CmdG").disabled==false){		
    	document.getElementById("CmdG").click();
		return;
	}
  }
});
</script>
</head>

<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="ajustes.php"  
autocomplete="off" 
style="margin:0px; padding:0px; display:inline;" onSubmit="return false;">
<!--INI_TITULO--------------------------------->
<div id="DivT" class="dT" >
<img src="img/transferencia.png" class="iT" />
<div class="tT">AJUSTES DE STOCK</div>
</div>
<!--FIN_TITULO--------------------------------->

<div class="s1" style="left: 35px; top: 128px; width: 79px;">(dd-mm-yy)</div>
<div class="s1" style="left: 35px; top: 112px; width: 75px;">FECHA *</div>
<input name="TxtFec" type="text" id="TxtFec" 
class="fe" style="left: 35px; top: 147px; width: 80px" 
value="<?php echo $StrFec;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 127px; top: 128px; width: 84px;">ALMACEN *</div>
<select name="CboAlm" id="CboAlm" 
class="lt" style="left: 127px; top: 147px; width: 150px" 
tabindex="<?php echo ++$TI;?>">
<?php echo ListALM($StrAlm); ?>
</select>

<div class="s1" style="left: 283px; top: 128px; width: 97px;">NRO.AUTOMATIC</div>
<input name="TxtNum" type="text" id="TxtNum" 
class="roi" style="left: 283px; top: 147px; width: 100px; background: #CCC" 
value="<?php echo $StrNum;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 394px; top: 128px; width: 86px;">ACCION *</div>
<select name="CboAcc" id="CboAcc" 
class="lt" style="left: 394px; top: 147px; width: 100px" 
tabindex="<?php echo ++$TI;?>">
<?php
	if(substr($StrAcc,0,1)=="Q" || strlen($StrAcc)==0){
		echo "<option value=\"QUITAR\" selected=\"selected\">QUITAR</option>";
		echo "<option value=\"AGREGAR\" >AGREGAR</option>";
	}else{
		echo "<option value=\"QUITAR\">QUITAR</option>";
		echo "<option value=\"AGREGAR\"  selected=\"selected\">AGREGAR</option>";
	}
?>
</select>

<div class="s1" style="left: 505px; top: 128px; width: 209px;">OBSERVACION</div>
<input name="TxtObs" type="text" id="TxtObs" 
class="lt" style="left: 505px; top: 147px; width: 218px" 
value="<?php echo $StrObs;?>"  
tabindex="<?php echo ++$TI;?>"/>

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

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

<div class="s1" style="left: 894px; top: 207px; width: 100px;">MARCA</div>
<input name="TxtMarca" type="text" id="TxtMarca" 
class="lt" style="left: 894px; top: 225px; width: 116px" 
value="<?php echo $StrMARCA;?>"  
onkeyup="document.getElementById('TxtHora').value=GetHora();"
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 1020px; top: 207px; width: 45px;">CANT</div>
<input name="TxtCant" type="text" id="TxtCant" 
class="ndd" style="left: 1019px; top: 225px; width: 60px" 
value="<?php echo $StrCant;?>"       
onfocus="selecciona_value(this);"          
tabindex="<?php echo ++$TI;?>"/>


<input type="button" name="CmdAdd" 
style="position: absolute; left: 1088px; top: 224px; width: 83px; height: 25px;"
id="CmdAdd" value="Agregar" 
onclick="fAgregar();" 
tabindex="<?php echo ++$TI;?>"/>

<input type="button" name="CmdCls" 
style="position: absolute; left: 1179px; top: 224px; width: 37px; height: 25px;"
id="CmdCls" value="X" 
onclick="fCls();" 
tabindex="<?php echo ++$TI;?>"/>


<div class="s1" style="left: 35px; top: 69px; width: 672px; height: 26px;">
<input name="CmdB" type="button" id="CmdG" class="btm"
onclick="fGuardar();"
<?php
if(strlen($StrId)==0){
	echo "value=\"Guardar\"";
}else{
	echo "value=\"Modificar\"";
$StrAnu=gs("anu","ajustes","id_ajuste=$StrId");
if($StrAnu=="S"){
    echo " disabled=\"disabled\"";
}
}
?>
tabindex="<?php echo ++$TI;?>"/>

<input name="CmdB" type="button" id="CmdC"  class="btm"
value="Nuevo" onClick="fCancelarPHP();"  
tabindex="<?php echo ++$TI;?>" />
        
<input name="CmdB" type="button" id="CmdA" class="btm" 
value="Anular" onClick="fAnular();"
<?php
if(strlen($StrId)==0){
    echo "disabled=\"disabled\"";
}else{
    $StrAnu=gs("anu","ajustes","id_ajuste=$StrId");
    if($StrAnu=="S"){
        echo "disabled=\"disabled\"";
    }
}
?>
tabindex="<?php echo ++$TI;?>"/>

<input name="CmdB" type="button" id="CmdE" class="btm"
value="Eliminar" onClick="fEliminar();"
<?php
if(strlen($StrId)==0){
    echo "disabled=\"disabled\"";
}else{
    $StrAnu=gs("anu","ajustes","id_ajuste=$StrId");
    if($StrAnu=="S"){
        echo "disabled=\"disabled\"";
    }
}
?>
tabindex="<?php echo ++$TI;?>"/>

<input name="CmdB" type="button" id="CmdB" class="btm"
value="Buscar" onClick="fBuscar('ajustes_buscar.php');"  
tabindex="<?php echo ++$TI;?>" />

<input name="CmdB" type="button" id="CmdB" class="btm"
value="Buscar.Det" onClick="fBuscar('ajustes_buscar_det.php');"  
tabindex="<?php echo ++$TI;?>" />

</div>

<div class="datagrid" style="position: absolute; left: 35px; top: 255px; width: 1180px; height: 306px;overflow:auto">
<table width="75%">
<thead>

<tr>
<th width="12%">CODIGO</th>
<th width="51%">DESCRIPCION</th>
<th width="28%">MARCA</th>
<th width="7%" style="text-align:right;">CANT</th>
<th width="2%">&nbsp;</th>
</tr>

</thead>
<tbody>

<?php
	$StrHWND_A=V($_SESSION['SYS_HW']."_A");
	$s="SELECT * FROM temp_compras WHERE cod_temc='$StrHWND_A' ORDER BY temc_index";
	$result = grs($s);
	while ($row = $result->fetch_row()){
		$X_ID=$row[1];
		$X_CO=VV(gs("COD","vproductos","ID=$X_ID"));
		$X_DE=gs("DESCRIPCION","vproductos","ID=$X_ID");
		$X_MA=gs("MARCA","vproductos","ID=$X_ID");
		$X_CA=$row[2];		
		?>
		<tr>
		<!----------------------------------------------->
		<td ><?php echo $X_CO;?></td>
		<td ><?php echo $X_DE;?></td>
		<td ><?php echo $X_MA;?></td>
		<td style="text-align:right"><?php echo $X_CA;?></td>
		<!----------------------------------------------->
		<td bgcolor="#FFFFFF" align="center">
		<a href="javascript:void(0)" onClick="fKiller(<?php echo $row[5];?>);">
		<img src="img/eliminar.png"  border="0"/></a></td>
		</tr>
		<?php
	}	
?>
  
</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=""/>
<input name="Pro_TxtMarca" type="hidden" id="Pro_TxtMarca" value=""/>
<input name="TxtRuc_" type="hidden" id="TxtRuc_"  />
</div>

<style type="text/css">
.gr1{
	visibility:hidden;
	overflow-x: hidden;
	overflow-y: scroll;
	color: #0FF;
	background-color: #FFFFFF;
	layer-background-color: #CCCCCC;
	border: 1px none #000000;
}
.gr2{
	visibility:hidden;	
	color: #0FF;
	background-color: #CCCCCC;
	layer-background-color: #CCCCCC;
	border: 1px none #000000;	
}
</style>

<div id="TAB_AJAX" class="datagrid gr1" 
style="height: 202px; width: 1126px; position: absolute; left: 32px; top: 271px;" align="left"></div>
<div id="TAB_CAPTION" class="datagrid gr2" 
style="height: 20px; width: 1126px; position: absolute; left: 32px; top: 256px;">
<table width="804" border="1" cellpadding="0" cellspacing="0" bgcolor="#d4e3e5">   
<tbody>
<tr>
<td width="80" bgcolor="#CCCCCC">CODIGO</td>
<td width="160" bgcolor="#CCCCCC">TIPO DE PRODUCTO</td>
<td width="344" bgcolor="#CCCCCC">DESCRIPCION</td>
<td width="120" bgcolor="#CCCCCC">MARCA</td>
<td width="50" align="right" bgcolor="#CCCCCC">STOCK</td>
<td width="50" align="right" bgcolor="#CCCCCC">&nbsp;</td>
</tr>
</tbody>
</table>
<div style="position: absolute; top: 0px; left: 1067px"><input name="CmdClose" type="button" value="Cerrar" onClick="CerrarDIV();" style="background-color:#F90" /></div>
</div>


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