<?php
	session_start();
	include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
	if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}
	//-------------------------	
	$StrGT="";
	$LStrMsg="";
	$LStrFoc="";
	$LStrMM="";
	//-------------------------
	$StrCmd=V($_POST['TxtAc']);
	$StrValor=V($_POST['TxtValor']);
	$StrValorAct="";
	//-------------------------
	if(strlen($StrCmd)==0){
		$StrValor=gs("valor","valores","dato='T_CAMBIO'");
	}
	//FUNCIONES DE ACTUALIZACION
	if($StrCmd=="M"){
		if(strlen($StrValor)==0){
			$LStrMsg="Ingrese el tipo de cambio correspondiente";
			$LStrFoc="document.getElementById('TxtValor').focus();";						
			$StrGT="S";
		}
		if(strlen($StrGT)==0){
			$s="UPDATE valores SET valor='$StrValor' WHERE dato='T_CAMBIO'";
			ejt($s);
			if($LStrMM=="S")	$LStrMsg="Datos actualizados";
			$LStrFoc="document.getElementById('TxtValor').focus();";
			$LStrMsg="El tipo de cambio ha sido actualizado a : $StrValor";
			$LStrFoc="document.getElementById('TxtValor').focus();";						
			$StrGT="S";
		}
	}	
	$StrValorAct=gs("valor","valores","dato='T_CAMBIO'");
	//////////////////////////////////
	if($StrGT=="S"){
		if(strlen($LStrMsg)>0){
			if(strlen($LStrFoc)==0){
				$LStrMsg="onload=\"alert('$LStrMsg');\"";
			}else{
				$LStrMsg="onload=\"alert('$LStrMsg');$LStrFoc;\"";
			}
		}else{
			if(strlen($LStrFoc)>0){
				$LStrMsg="onload=\"$LStrFoc;\"";
			}
		}
	}else{
		$LStrFoc="document.getElementById('TxtValor').focus();";
		$LStrMsg="onload=\"$LStrFoc;\"";
	}

$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>Tipo de cambio</title>
<!--INI_SCRIPT------------------------------------------------------------------------------>
<?php AddJs(); ?>
<script type="text/javascript" src="ja/funciones.js"></script>
<script type="text/javascript" src="ja/tcambio.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();
});

$(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==86 && e.altKey){
		if(AT=="1"){
		document.getElementById("CmdZ").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 $HTM;
?>
</div>

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

<!--INI_TITULO--------------------------------->
<div id="DivT" class="dT" >
<img src="img/cambio.png" class="iT" />
<div class="tT">TIPO DE CAMBIO</div>
</div>
<!--FIN_TITULO--------------------------------->

<div class="s1" style="left: 60px; top: 157px; width: 157px;">TIPO DE CAMBIO</div>
<input name="TxtValor" type="text" id="TxtValor" 
style="left: 60px; top: 177px; width:100px" 
value="<?php echo $StrValor;?>"  
onKeyDown="return SoloNum(this,event,'CmdG');" 
tabindex="1" />

<div class="s1" style="left: 63px; top: 231px; width: 157px;">VALOR ACTUAL</div>
<div class="s1" style="left: 64px; top: 252px; width: 27px;">S/.</div>

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

</div>


<div id="layer6" style="position:absolute; left: 90px; top: 251px; width: 415px; font-weight: bold; font-family: Verdana, Geneva, sans-serif; font-size: 50px; color:#000; height: 216px;">
<div align="left" >
<?php
echo $StrValorAct;
?>
</div>
</div>

<!--INI_OCULTOS-------------------------------->
<?php include("ocultos.php");?>
<!--FIN_OCULTOS-------------------------------->

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