<?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;
	}
	$STR_HW=$_SESSION['SYS_HW']."_AP";
	$ID_USU=$_SESSION['SYS_USER_ID'];
	//
	$StrGT="";
	$VP_RegXPag=6;
	$LStrMsg="";
	$LStrFoc="";
	$LStrMM="";
	$LStrPag=V($_POST['TxtPag']);	
	include("ajustes_piezas_fun.php");
	include("ajustes_piezas_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 presentaciones</title>
<!--CSS_NEW------------------------------------->
<link rel="stylesheet" type="text/css" href="estiloss.css"  />
<link rel="stylesheet" type="text/css" href="basic.css"  />
<!--CSS_NEW------------------------------------->
<?php AddJs();?>
<script type="text/javascript" src="fe/funcionez.js"></script>
<script type="text/javascript" src="fe/ajustes_piezas.js"></script>
<script type="text/javascript" src="fe/leo.js"></script>
<script>
$(document).ready(function(){  
   Inicializar();
});
</script>
<!--FIN_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>
<script>
$(document).ready(function(){
$("#TxtFec").mask("99-99-99");
});
</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:1000px;
	height:600px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-300px";?> 0 0 <?php echo "-500px";?>;
}
#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_piezas.php"  autocomplete="off">  

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

<div class="TITULO" style="left: 116px; top: 21px; width: 412px;">AJUSTES DE STOCK PIEZAS</div>
<div class="ICONO" style=" left: 52px; top: 15px; width: 64px; z-index: 100;">
<img src="img/ajustes.png" width="56" height="52"></div>

</div>


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

<input name="TxtFec" type="text" id="TxtFec" 
class="fe" style="left:28px; top: 177px; width: 83px;"
value="<?php echo $StrFec;?>"  
tabindex="<?php echo ++$TI;?>" />



<div class="s1" style="left:126px; top: 158px; width: 90px;">EMPRESA </div>
<select name="CboEmp" id="CboEmp" 
class="lt"
style="position:absolute; left:124px; top:177px; width: 109px;" 
onchange="EM_OC();"
tabindex="<?php echo ++$TI;?>">
<?php 
	echo LE($StrEmp,"N","S"); 
?>
</select>


<div class="s1" style="left: 243px; top: 158px; width: 90px;">ALMACEN </div>
<select name="CboAlm" id="CboAlm" 
class="lt" style="left: 239px; top: 177px; width: 127px;"
tabindex="<?php echo ++$TI;?>" >
<?php echo LA($StrEmp,$StrAlm,"N","N"); ?>
</select>

<div class="s1" style="left: 378px; top: 142px; width: 97px;">NUMERO AUTOGENERADO</div>
<input name="TxtNum" type="text" id="TxtNum" 
class="lt" style="left: 379px; top: 177px; width: 100px; background:#CCC" 
value="<?php echo $StrNum;?>"  
tabindex="<?php echo ++$TI;?>" />

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

<div  class="s1" style="left: 602px; top: 158px; width: 240px;">OBSERVACION</div>
<input name="TxtObs" type="text" id="TxtObs" 
class="lt" style="left: 598px; top: 177px; width: 270px;"
value="<?php echo $StrObs;?>"  
tabindex="<?php echo ++$TI;?>" />


<div class="EL" style="left: 28px; top: 219px; width: 84px;"><u><a onclick="fLimDet()">CODIGO +</a></u></div>
<input name="D_Cod" type="text" id="D_Cod" 
class="lt" style="left: 28px; top: 237px; width: 85px;" 
value="<?php echo $D_Cod;?>"
onkeyup="document.getElementById('TxtHora').value=GetHora();"
tabindex="<?php echo ++$TI;?>" />

<div  class="s1" style="left: 128px; top: 219px; width: 100px;">DESCRIPCION</div>
<input name="D_Des" type="text" id="D_Des"
class="lt" style="left: 128px; top: 237px; width: 357px;" 
value="<?php echo $D_Des;?>"
onkeyup="document.getElementById('TxtHora').value=GetHora();"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 496px; top: 219px; width: 99px;">LINEA</div>
<input name="D_Lin" type="text" id="D_Lin" 
class="lt" style="left: 496px; top: 237px; width: 123px;" 
value="<?php echo $D_Lin;?>"  
onkeyup="document.getElementById('TxtHora').value=GetHora();"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 633px; top: 219px; width: 45px;">CAJAS</div>
<input name="D_Caj" type="text" id="D_Caj" 
class="ne" style="left: 630px; top: 237px; width: 42px;" 
value="<?php echo $D_Caj;?>"         
onfocus="selecciona_value(this);"  
onkeydown="return SoloNum(this,event,'D_Pie');"        
tabindex="<?php echo ++$TI;?>" />
  

<div class="s1" style="position:absolute; left: 685px; top: 219px; width: 51px;">PIEZAS</div>
<input name="D_Pie" type="text" id="D_Pie" 
class="ne" style="position:absolute; left: 682px; top: 237px; width: 55px;" 
value="<?php echo $D_Pie;?>"       
onfocus="selecciona_value(this);"   
onkeydown="return SoloNum(this,event,'D_Can');"       
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="position:absolute; left: 750px; top: 219px; width: 124px;">QUITAR (Piezas)</div>
<input name="D_Can" type="text" id="D_Can" 
class="ne" style="left: 748px; top: 237px; width: 43px;" 
value="<?php echo $D_Can;?>"        
onfocus="selecciona_value(this);"
onkeydown="return SoloNum(this,event,'CmdAdd');"           
tabindex="<?php echo ++$TI;?>" />

<input type="button" name="CmdAdd" 
class="ps" style="left: 805px; top: 236px; width: 68px;"
id="CmdAdd" value="Agregar" onclick="fAgregar();" 
tabindex="<?php echo ++$TI;?>" />
<div class="ps" style=" left: 28px; top: 85px; width: 609px;">
      <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="fCancelar();"  tabindex="18"/>
		<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_piezas_buscar.php');"  tabindex="21"/>
<input name="CmdB" type="button" id="CmdB" 
value="Buscar detallado" onclick="fBuscar('ajustes_piezas_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 class="datagrid" style="position:absolute; left: 26px; top: 275px; width: 937px; height: 280px; overflow:auto">
<table width="100%" height="19" border="1" cellpadding="0" cellspacing="0">
<thead>

<tr>
<td colspan="9" height="18"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>
</tr>
<tr>
<td width="4%" bgcolor="#999999"><span class="z4">Nº</span></td>
<td width="11%" bgcolor="#999999"><span class="z4">CODIGO</span></td>
<td width="37%" bgcolor="#999999"><span class="z4">DESCRIPCION</span></td>
<td width="19%" bgcolor="#999999"><span class="z4">LINEA</span></td>
<td width="6%" bgcolor="#999999" align="right"><span class="z4">CAJAS</span></td>
<td width="6%" bgcolor="#999999" align="right"><span class="z4">PIEZAS</span></td>
<td width="6%" bgcolor="#999999" align="right"><span class="z4">QUITAR</span></td>
<td width="3%" bgcolor="#999999" align="center">&nbsp;</td>
<td width="8%" bgcolor="#999999" align="center">&nbsp;</td>
</tr>

</thead>
<?php
	$_TP=0;
	$StrHWND_A=$_SESSION['SYS_HW']."_A";
	//$SEPARADOR=gs("aux_des","auxiliares","aux_tip='SIM'");
	//if(strlen($SEPARADOR)==0){$SEPARADOR="-";}
	//
	$_IT=0;
	$s="SELECT * FROM ajustes_presentacion_det_temp WHERE aju_hw='$STR_HW' ORDER BY item";
	$result = grs($s);
	while ($row = $result->fetch_row()){
		$X_ID=$row[2];
		$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_CAJ=$row[3];
		$X_PIE=$row[4];
		$X_CAN=$row[5];
		$_TP=$_TP + $X_CAJ;
		$_IT++;
	echo "<tr>";
	echo "<td bgcolor=\"#FFFFFF\">".$_IT."</td>";
	echo "<td bgcolor=\"#FFFFFF\">".$X_CO."</td>";
	echo "<td bgcolor=\"#FFFFFF\">$X_DE</td>";
	echo "<td bgcolor=\"#FFFFFF\">$X_MA</td>";
	echo "<td bgcolor=\"#FFFFFF\" align=\"right\">$X_CAJ</td>";
	echo "<td bgcolor=\"#FFFFFF\" align=\"right\">$X_PIE</td>";
	echo "<td bgcolor=\"#FFFFFF\" align=\"right\">$X_CAN</td>";

	echo "<td bgcolor=\"#FFFFFF\" align=\"center\">";
	echo "<a href=\"javascript:void(0)\" onclick=\"fKiller('$row[1]');\" >";
	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[1]','$STR_HW');\" >";
	echo "<img src=\"img/b_edit.png\"  border=\"0\"/>";
	echo "</a>";
	echo "</td>";
	echo "</tr>";	
	}	
?>
<tr>
<td width="4%" bgcolor="#999999">&nbsp;</td>
<td width="11%" bgcolor="#999999">&nbsp;</td>
<td width="37%" bgcolor="#999999">&nbsp;</td>
<td width="19%" bgcolor="#999999"><span class="z4">TOT. CAJAS</span></td>
<td width="6%" bgcolor="#999999" align="right"><span class="z4"><?php echo NF4($_TP);?></span></td>
<td width="6%" bgcolor="#999999" align="right">&nbsp;</td>
<td width="6%" bgcolor="#999999" align="right">&nbsp;</td>
<td width="3%" bgcolor="#999999" align="center">&nbsp;</td>
<td width="8%" bgcolor="#999999" align="center">&nbsp;</td>
</tr>
</table>
</div>



<div id="DivH">
<input type="hidden" name="CmdUP" id="CmdUP" value="UP" 
onclick="fLoad();" />

		<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="TxtKill" type="hidden" id="TxtKill"  value="" />
		<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 id="TAB_AJAX" style="visibility: hidden; height:200px; width:766px; overflow-x:hidden; position:absolute; left: 26px; 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: 26px; 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>

<?php
if(strlen($StrDESCARGAR)>0){
echo "<div id=\"layer51\" 
	  style=\"position:absolute; left: 487px; 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>
