<?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");
	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;
	}
	//
	$StrGT="";
	$VP_RegXPag=6;
	$LStrMsg="";
	$LStrFoc="";
	$LStrMM="";
	$LStrPag=V($_POST['TxtPag']);	
	include("ajustes_fun.php");
	include("ajustes_pdf.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ajustes de Stock</title>
<script src="jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="jquery.maskedinput.min.js" type="text/javascript"></script>
<script type="text/javascript" src="fe/ajustes.js"></script>
<script type="text/javascript" src="fe/funcionez.js"></script>
<script type="text/javascript" src="fe/leo.js"></script>
<script>
$(document).ready(function(){
   $("#TxtFec").mask("99-99-99");    
});
</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);

}
</script>
<link rel="stylesheet" type="text/css" href="basic.css"  />
<style type="text/css">
<!--
.estilo888 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #003366;
	font-weight: bold;
}
#TAB_CAPTION .estilo888 {
	color: #000;
}
-->
</style>
<style type="text/css">
<!--
.estilo777 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #003366;
}
-->
</style>
<style type="text/css">
<!--
body {
	background-color: #CCC;
	background-image: url();
}
#Layer1 {
	position:absolute;
	left:345px;
	top:115px;
	width:123px;
	height:35px;
	z-index:1;
}
.centrarFrm{
	width:800px;
	height:600px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-300px";?> 0 0 <?php echo "-400px";?>;
}
#Layer2 {
	position:absolute;
	left:409px;
	top:205px;
	width:82px;
	height:24px;
	z-index:1;
}
.Estilo1 {
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
	color: #FFFFFF;
}
.f2 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #FFFFFF; font-size: 12px; }
.Estilo3 {color: #FFFFFF; font-size: 12px; font-family: Arial, Helvetica, sans-serif;}
.z4 {color: #000099}
.Estilo5 {color: #000000}
#Frm center #DivFRM #layer .Estilo1 strong {
	color: #900;
}
#Frm center #DivFRM #layer3 .f2 table tr td {
	color: #000;
}
#Frm center #DivFRM #layer3 .f2 table {
	color: #999;
}

-->
</style>

</head>
<body  <?php echo $LStrMsg;?> onunload="myStopFunction();">
<div Id="DivFRM"  class="centrarFrm" >
<form id="Frm" name="Frm" method="post" action="ajustes.php"  autocomplete="off">


<div class="dT" style="left: 0px; top: 0px; width: 800px; height: 79px;">

<div class="ICONO" style=" left: 52px; top: 15px; width: 64px; z-index: 100;">
<img src="img/ajustes.png" width="56" height="52" / onclick="fGetProdDatos_Id('2');"></div>

<div class="TITULO" style="left: 116px; top: 30px; width: 412px; height: 24px;">AJUSTES DE STOCK</div>

</div>

  
<div id="layer4" style="position:absolute; left: 61px; top: 85px; width: 688px; height: 26px;">
<div align="left" class="f2">
<input name="CmdB" type="button" id="CmdG"
<?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\"";
}
}
?>
onclick="fGuardar();" style="width:80px" tabindex="17"/>
<input name="CmdB" type="button" id="CmdC" value="Nuevo" onclick="fCancelarPHP();"  tabindex="18"/>

<input name="CmdB" type="button" id="CmdA" 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="19"/>

<input name="CmdB" type="button" id="CmdE" 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="20"/>
<input name="CmdB" type="button" id="CmdB" 
value="Buscar" onclick="fBuscar('ajustes_buscar.php');"  tabindex="21"/>
<input name="CmdB" type="button" id="CmdB" 
value="Buscar detallado" onclick="fBuscar('ajustes_buscar_det.php');"  tabindex="22"/>

<input name="CmdPDF" type="button" id="CmdPDF" 
value="Generar PDF" onclick="fGenPDF();"
<?php
if(strlen($StrId)==0){
echo "disabled=\"disabled\"";
}else{
$StrAnu=gs("anu","transferencias","id_trans=$StrId");
if($StrAnu=="S"){
echo "disabled=\"disabled\"";
}
}
?>
/>


<input name="CmdB" type="button" id="CmdZ" 
value="Menu" onclick="fBuscar('menu.php');"  tabindex="23"/>
</div>
</div>

<div id="layer3" style="position:absolute; left: 30px; top: 281px; width: 735px; height: 288px; overflow:auto">
<div align="left" class="f2">
<table width="100%" height="19" border="1" cellpadding="0" cellspacing="0">
<tr class="Estilo5">
<td width="4%" bgcolor="#999999"><span class="z4">Nº</span></td>
<td width="14%" bgcolor="#999999"><span class="z4">CODIGO</span></td>
<td width="42%" bgcolor="#999999"><span class="z4">DESCRIPCION</span></td>
<td width="17%" bgcolor="#999999"><span class="z4">LINEA</span></td>
<td width="7%" bgcolor="#999999" align="right"><span class="z4">CANT</span></td>
<td width="7%" bgcolor="#999999" align="right"><span class="z4">PIEZAS</span></td>
<td width="2%" bgcolor="#999999" align="center">&nbsp;</td>
<td width="7%" bgcolor="#999999" align="center">&nbsp;</td>
</tr>

<?php
	$_TP=0;
	$_IT=0;
	$StrHWND_A=$_SESSION['SYS_HW']."_A";
	$SEPARADOR=gs("aux_des","auxiliares","aux_tip='SIM'");
	if(strlen($SEPARADOR)==0){$SEPARADOR="-";}
	//
	$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("LINEA","vproductos","ID=$X_ID");
		$X_CA=$row[2];
		$X_CAU=$row[8];
		$_TP=$_TP + $X_CA;
		$_IT++;
echo "<tr class=\"Estilo5\">";
echo "<td bgcolor=\"#FFFFFF\">".$_IT."</td>";
echo "<td bgcolor=\"#FFFFFF\">".$X_CO.$SEPARADOR.$X_CAU."</td>";
echo "<td bgcolor=\"#FFFFFF\">$X_DE</td>";
echo "<td bgcolor=\"#FFFFFF\">$X_MA</td>";
echo "<td bgcolor=\"#FFFFFF\" align=\"right\">$X_CA</td>";
echo "<td bgcolor=\"#FFFFFF\" align=\"right\">$X_CAU</td>";
echo "<td bgcolor=\"#FFFFFF\" align=\"center\">";
echo "<a href=\"javascript:void(0)\" onclick=\"fKiller('$row[5]');\" >";
echo "<img src=\"img/eliminar.png\" width=\"16\" height=\"16\" />";
echo "</a>";
echo "</td>";
	echo "<td width=\"15\" bgcolor=\"#FFFFFF\" align=\"center\">";
	echo "<a href=\"javascript:void(0)\" onclick=\"fEditar('$row[5]');\" >";
	echo "<img src=\"img/b_edit.png\"  border=\"0\"/>";
	echo "</a>";
	echo "</td>";
echo "</tr>";	
	}	
?>
<tr class="Estilo5">
<td bgcolor="#CCCCCC">&nbsp;</td>
<td bgcolor="#CCCCCC">&nbsp;</td>
<td bgcolor="#CCCCCC">&nbsp;</td>
<td bgcolor="#CCCCCC" align="right">TOTAL CAJAS</td>
<td bgcolor="#CCCCCC" align="center"><?php echo NF4($_TP);?></td>
<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
</tr>
<tr>
  
</tr>
</table>
      </div>
    </div>

    <div id="layer" style="position:absolute; left: 116px; top: 21px; width: 412px; height: 45px; z-index: 100;">
      <div align="left" class="Estilo1">
		<input type="button" name="CmdUP" id="CmdUP" value="UP" 
		onclick="fLoad();" 
		style="position:absolute; left: 83px; top: -282px; width: 49px; visibility:hidden"/>
		<input name="TxtHW" type="hidden" id="TxtHW" value="<?php echo $StrHWND_A;?>"/>

        <input name="TxtId" type="hidden" id="TxtId" value="<?php echo $StrId;?>"/>
		<input name="TxtAc" type="hidden" id="TxtAc" value="" />
        <input name="TxtHora" type="hidden" id="TxtHora" value="0" />
		<input name="TxtPag" type="hidden" id="TxtPag" value="<?php echo $LStrPag; ?>" />
        <input name="TxtRuc_" type="hidden" id="TxtRuc_"  /> 
		<input name="FEC_SERVER" type="hidden" id="FEC_SERVER" value="<?php echo date("d-m-y");?>"/>         
     
      </div>
<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=""/>
</div>
</div>




<div id="layer6" style="position:absolute; left: 30px; top: 142px; width: 54px;">
<div align="left" class="f2">FECHA </div></div>


<div class="EV" style="left: 30px; top: 158px; width: 88px; color:#FF0"><u><a onclick="fFecServer('TxtFec')">(dd-mm-yy) +</a></u></div>

<input name="TxtFec" type="text" id="TxtFec" 
style="position:absolute; left: 30px; top: 177px; width: 83px;"
value="<?php echo $StrFec;?>"  
onkeydown="return SoloFec(this,event,'CboEmp');" 
tabindex="1" />

<div style="position:absolute; left: 124px; top: 158px; width: 118px;">
<div align="left" class="f2">EMPRESA </div></div>
<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:124px; top:177px; width: 124px;" 
onchange="EM_OC();"
onkeydown="return SoloTextoEx(event,'CboAlm');" tabindex="1">
<?php 
	echo LE($StrEmp,"N","S"); 
?>
</select>


<div style="position:absolute; left: 256px; top: 158px; width: 135px;">
<div align="left" class="f2">ALMACEN </div></div>
<select name="CboAlm" id="CboAlm" 
style="position:absolute; left: 255px; top: 177px; width: 139px;"
onkeydown="return SoloTextoEx(event,'CboAcc');" tabindex="2">
<?php echo LA($StrEmp,$StrAlm,"N","N"); ?>
</select>

<div id="layer30" style="position:absolute; left: 403px; top: 142px; width: 97px;">
<div align="left" class="f2">NUMERO AUTOGENERADO</div></div>
<input name="TxtNum" type="text" id="TxtNum" 
style="position:absolute; left: 404px; top: 177px; width: 106px; background:#CCC" 
value="<?php echo $StrNum;?>"  
onkeydown="return SoloTextoEx(event,'CboAcc');" 
tabindex="3"  readonly="readonly"/>

<div id="layer9" style="position:absolute; left: 531px; top: 158px; width: 72px;">
  <div align="left" class="f2">ACCION</div></div>
<select name="CboAcc" id="CboAcc" 
style="position:absolute; left: 526px; top: 177px; width: 80px;" 
onkeydown="return SoloTextoEx(event,'TxtObs');" tabindex="0">
<?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="EL" style="left: 30px; top: 231px; width: 84px;"><u><a onclick="fLimDet()">CODIGO +</a></u></div>

<input name="TxtCod" type="text" id="TxtCod" 
class="ps" style="position:absolute; left: 30px; top: 249px; width: 85px;" 
value="<?php echo $StrCod;?>"  
onkeydown="return SoloTextoEx(event,'TxtDes');"
onkeyup="document.getElementById('TxtHora').value=GetHora();"
tabindex="11" />


<div id="layer16" style="position:absolute; left: 133px; top: 231px; width: 123px;">
<div align="left" class="f2">DESCRIPCION</div></div>


  <input name="TxtDes" type="text" id="TxtDes"
style="position:absolute; left: 132px; top: 249px; width: 280px;" 
value="<?php echo $StrDes;?>"  
onkeydown="return SoloTextoEx(event,'TxtMarca');"
onkeyup="document.getElementById('TxtHora').value=GetHora();"
tabindex="12" />


<input type="button" name="CmdSel" id="CmdSel" value="Trasformaciones" 
onClick="Ow('transformaciones_2.php',905*ZO(),390*ZO())"
style="position:absolute; left: 290px; top: 223px; width: 123px;"
/>


<div id="layer20" style="position:absolute; left: 561px; top: 231px; width: 45px;">
<div align="left" class="f2">CANT</div></div>
<input name="TxtCant" type="text" id="TxtCant" 
class="ps" style="position:absolute; left: 558px; top: 249px; width: 55px;" 
value="<?php echo $StrCant;?>"  
onkeydown="return SoloNum(this,event,'TxtUCAN');"           
onfocus="selecciona_value(this);"          
tabindex="14" />

<div id="layer20" style="position:absolute; left: 623px; top: 231px; width: 54px;">
<div align="left" class="f2">PIEZAS</div></div>
<input name="TxtUCAN" type="text" id="TxtUCAN" 
class="ps" style="position:absolute; left: 623px; top: 249px; width: 55px;" 
value="<?php echo $StrUCAN;?>"  
onkeydown="return SoloNum(this,event,'CmdAdd');"           
onfocus="selecciona_value(this);"          
tabindex="15" />


<input type="button" name="CmdAdd" 
style="position:absolute; left: 688px; top: 248px; width: 68px;"
id="CmdAdd" value="Agregar" onclick="fAgregar();" tabindex="16"/>

<div id="TAB_AJAX" style="visibility: hidden; height:200px; width:766px; overflow-x:hidden; position:absolute; left: 30px; top: 298px; overflow-y:scroll; color: #0FF; background-color: #FFFFFF; layer-background-color: #CCCCCC; border: 1px none #000000;" align="left"></div>
<div id="TAB_CAPTION" style="visibility: hidden; height:20px; width:766px; position:absolute; left: 30px; top: 281px; color: #0FF; background-color: #CCCCCC; layer-background-color: #CCCCCC; border: 1px none #000000;" align="left">
<table width="676" border="1" cellpadding="0" cellspacing="0" bgcolor="#d4e3e5" class="estilo888">
<tbody>
<tr >
<td width="124"  bgcolor="#CCCCCC">CODIGO</td>
<td width="314"  bgcolor="#CCCCCC">DESCRIPCION</td>
<td width="113"  bgcolor="#CCCCCC">MARCA</td>
<td width="60" align="right" bgcolor="#CCCCCC">CANT</td>
<td width="65"  align="right" bgcolor="#CCCCCC">UNIDAD</td>
</tr>
</tbody>
</table>
<div style="position:absolute; top:0px; left:710px; height: 19px;">
<input name="CmdClose" type="button" value="Cerrar" onclick="CerrarDIV();" style="height: 17px; background-color:#F90" />
</div>
</div>


<div id="layer10" style="position:absolute; left: 619px; top: 158px; width: 120px;">
  <div align="left" class="f2">OBSERVACION</div>
</div>

<input name="TxtObs" type="text" id="TxtObs" 
style="position:absolute; left: 615px; top: 177px; width: 138px;"
value="<?php echo $StrObs;?>"  
onkeydown="return SoloTextoEx(event,'TxtCod');" 
tabindex="4" />


<input name="TxtMarca" type="text" id="TxtMarca" 
style="position:absolute; left: 424px; top: 249px; width: 123px;" 
value="<?php echo $StrMARCA;?>"  
onkeydown="return SoloTextoEx(event,'TxtCant');"
onkeyup="document.getElementById('TxtHora').value=GetHora();"
tabindex="12" />


<div id="layer14" style="position:absolute; left: 424px; top: 231px; width: 99px;">
  <div align="left" class="f2">LINEA</div>
</div>
  

<?php
if(strlen($StrDESCARGAR)>0){
echo "<div id=\"layer51\" 
	  style=\"position:absolute; left: 515px; top: 114px; 
	  width: 90px; background-color: #FFCC00; layer-background-color: #FFCC00; 
	  border: 1px none #000000; height: 17px;\">";
echo "<div align=\"center\" class=\"f2\"> ";
echo " <a href=\"$StrDESCARGAR\" download>Descarga.PDF</a> ";
echo "</div>";
echo "</div>";
}
?>


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