<?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;}
$StrId=V($_POST['TxtId']);
$StrCmd=V($_POST['TxtAc']);
//-------------------------
$StrI=V($_GET['I']);	
$StrH=V($_GET['H']);	
$StrM=V($_GET['M']);	
$StrMax=0;
//-------------------------
if(strlen($StrI)>0){	
	$StrMax=gn("temc_imp","temp_compras","temc_index=$StrI AND cod_temc='$StrH'");
	$StrCan=gn("temc_cant","temp_compras","temc_index=$StrI AND cod_temc='$StrH'");
	$StrPre=gn("temc_precio","temp_compras","temc_index=$StrI AND cod_temc='$StrH'");
	$IDPRO=gn("temc_id_producto","temp_compras","temc_index=$StrI AND cod_temc='$StrH'");
	$StrUni=gn("dscto","temp_compras","temc_index=$StrI AND cod_temc='$StrH'");
}else{	
	$StrPre="";
	$StrCan="";
	$StrUni="";
}
//-------------------------
if($StrCmd=="OK"){
	$StrC=V($_POST['TxtCan']);
	$StrP=V($_POST['TxtPre']);
	$StrU=V($_POST['TxtUni']);
	$StrI=V($_POST['TxtI']);
	$StrH=V($_POST['TxtH']);
	//
	$SQL="UPDATE temp_compras SET 
		temc_cant=$StrC, 
		dscto=$StrU,
		temc_precio=$StrP
		WHERE cod_temc='$StrH' AND temc_index=$StrI";
	ejt($SQL);		
	//
	$StrMsg="onload=\"window.opener.document.Frm.CmdUP.click();window.close();\"";	
}else{
	$StrMsg="onload=\"jFocus('TxtCan');document.getElementById('TxtCan').select();\"";	
}
?>
<!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>GUIA - EDITAR</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/funciones.js"></script>
<script type="text/javascript">

function Aceptar(){	
	var c=document.getElementById("TxtCan").value;
	var u=document.getElementById("TxtUni").value;
	if(jVal(c)<=0){
		alert("La cantidad debe ser un numero positivo");
		jFocus("TxtCan");
		return;
	}
	if(jVal(u)<0){
		alert("la unidad no puede ser un valor negativo");
		jFocus("TxtPre");
		return;
	}
	if(gv("TxtM")=="GI"){
		if(jVal(c)>jVal(gv("TxtMax"))){
			alert("La cantidad no puede ser superior a : "+gv("TxtMax"));
			jFocus("TxtCan");
			return;			
		}
	}
	document.getElementById("TxtAc").value="OK";
	document.getElementById("Frm").submit();
}
</script>
<script>
$(document).ready(function(){
   $("#TxtDex").mask("99-99-99");
   $("#TxtHax").mask("99-99-99");
});
</script>
<link rel="stylesheet" type="text/css" href="estiloss.css"  />
<link rel="stylesheet" type="text/css" href="basic.css"  />
<style type="text/css">
<!--
body {
background-color: #CCC;
}
#Layer1 {
position:absolute;
left:345px;
top:115px;
width:123px;
height:35px;
z-index:1;
}
.centrarFrm{
	width:550px;
	height:280px;
	position:absolute;
	left:50%;
	top:50%;
	background-color:#646464;
	margin:-140px 0 0 -275px;
}
#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;}
.Estilo4 {color: #000099}
.Estilo5 {color: #000000}

-->
</style>

</head>
<body  <?php echo $StrMsg;?>>
<form id="Frm" name="Frm" method="post" action="guias_editar.php">
<center> 
<div Id="DivFRM"  class="centrarFrm" >
<div id="layer" style="position:absolute; left: 16px; top: 12px; width: 425px; height: 24px;">
<div align="left" class="Estilo1">GUIA EDITAR</div></div>
<div >
<input name="TxtId" type="hidden" id="TxtId" value="<?php echo $StrId;?>"/>
<input name="TxtI" type="hidden" id="TxtI" value="<?php echo $StrI;?>"/>
<input name="TxtH" type="hidden" id="TxtH" value="<?php echo $StrH;?>"/>
<input name="TxtM" type="hidden" id="TxtM" value="<?php echo $StrM;?>"/>
<input name="TxtMax" type="hidden" id="TxtMax" value="<?php echo $StrMax;?>"/>
<input name="TxtAc" type="hidden" id="TxtAc" value="" />
</div>

<div class="s1" style="left: 19px; top: 39px; width: 465px;">
COD : <?php 
$SEPARADOR=gs("aux_des","auxiliares","aux_tip='SIM'");
if(strlen($SEPARADOR)==0){$SEPARADOR="x";}
echo gs("COD","vproductos","ID=$IDPRO").$SEPARADOR.$StrUni;?></div>
<div class="s1" style="left: 19px; top: 70px; width: 515px;">
DES : <?php echo gs("DESCRIPCION","vproductos","ID=$IDPRO");?></div>
<div class="s1" style="left: 19px; top: 105px; width: 461px;">
MAR : <?php echo gs("MARCA","vproductos","ID=$IDPRO");?></div>

<div class="s1" style="left: 20px; top: 152px; width: 59px;">CANTIDAD</div>
<input name="TxtCan" type="text" id="TxtCan" 
style="left: 20px; top: 169px; width: 70px;"
value="<?php echo $StrCan;?>"  
onkeydown="return SoloNum(this,event,'TxtPre');" 
tabindex="1" />
<?php
$StrM="GI";
?>
<div class="s1" style="left: 101px; top: 152px; width: 59px;">PRECIO</div>
<input name="TxtPre" type="text" id="TxtPre" 
style="left: 101px; top: 169px; width: 70px; 
<?php 
	if($StrM=="GI"){
		echo " background-color:#999;";
	}
?>"
value="<?php echo $StrPre;?>"   
<?php 
	if($StrM=="GI"){
		echo " readonly=\"readonly\" ";
	}
?>
onkeydown="return SoloNum(this,event,'TxtUni');" 
tabindex="2" />

<div class="s1" style="left: 184px; top: 152px; width: 59px;">
PIEZAS</div>
<input name="TxtUni" type="text" id="TxtUni" 
style="left: 183px; top: 169px; width: 70px; background-color:#999"
value="<?php echo $StrUni;?>"   readonly="readonly"
onkeydown="return SoloNum(this,event,'CmdB');" 
tabindex="3" />


<input name="CmdB" type="button"  class="ps"
style="left: 268px; top: 170px; width: 76px;"
id="CmdB" value="Aceptar" onclick="Aceptar();" tabindex="4" />
</div>
</center>	
</form>
</body>
</html>
