<?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;
}
//-------------++++
$StrId=V($_POST['TxtId']);
$StrCmd=V($_POST['TxtAc']);
$LStrPag=V($_POST['TxtPag']);
//-------------------------	
$StrGT=""; $LStrMsg=""; $LStrFoc=""; $LStrMM="";
//
$POL_USU_PER_ELI=USU_PER_GET_EX("ELI_EGR");
$LIMPIAR=0;
//
$ANULADO="N";
//
include("egresos_fun.php");
$VP_RegXPag=15;
$LStrTR=gn("count(*)","vegresos","");
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);		
?>
<!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>Egresos</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/egresos4.js"></script>
<script>
$(document).ready(function(){
   $("#TxtFec").mask("99-99-99");
	var pol_usu_per_eli=gv("POL_USU_PER_ELI");
	if(jVal(pol_usu_per_eli)==0){
		document.getElementById("CmdE").disabled=true;
	}       
});
function CalTC(){
	var tot_s=gv("TxtTot");
	var tot_d=gv("TxtTotDol");
	if(jVal(tot_d)>0){
		if(jVal(tot_s)>0){
			var s=jVal(tot_s);
			var d=jVal(tot_d);
			
			var tc=s/d;
			sv("TxtTC",tc.toFixed(2));
		}else{
			sv("TxtTC","0");	
		}
	}else{
		sv("TxtTC","0");
	}
}
</script>
<style type="text/css">
<!--
body {
	background-color: #CCC;
}
#Layer1 {
	position:absolute;
	left:345px;
	top:115px;
	width:123px;
	height:35px;
	z-index:1;
}
.centrarFrm{
     width:900px;
     height:600px;
     position:absolute;
     left:<?php echo "50%";?>;
     top:<?php echo "50%";?>;
	 background-color:#646464;
	 margin:<?php echo "-300px";?> 0 0 <?php echo "-450px";?>;

}
#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;}
.x4 {color: #000099}
.x5 {color: #000000}
#Frm center #DivFRM #layer .Estilo1 strong {
	color: #900;
}

-->
</style>

</head>
<body  <?php echo $LStrMsg;?>>
<form id="Frm" name="Frm" method="post" action="egresos.php">
<center> 
  <div Id="DivFRM"  class="centrarFrm" >
    
    <div id="layer4" style="position:absolute; left: 30px; top: 85px; width: 519px; height: 26px;">
    <div align="left" class="f2">
    <input name="CmdB" type="button" id="CmdG" 
    <?php
    if(vbval($StrId)==0){
    	echo "value=\"Guardar\"";
    }else{
		$_ANU=gs("anu","egresos","id_egreso=".vbval($StrId)); 
    	echo " value=\"Modificar\" ";
		if($_ANU=="S"){
			echo "  disabled=\"disabled\" ";
		}		
    }
    ?>
    onclick="fGuardar();" style="width:80px" tabindex="2"/>
    <input name="CmdB" type="button" id="CmdC" value="Nuevo" 
    onclick="fCancelar();"  tabindex="3"/>
    
    <input name="CmdB" type="button" id="CmdE" 
    value="Eliminar" onclick="flEliminar();"
    <?php
	$OK=0;
    if(vbval($StrId)==0){
		$OK=1;
    	echo "disabled=\"disabled\"";
    }
	if($OK==0){
		$_ANU=gs("anu","egresos","id_egreso=".vbval($StrId));
		if($_ANU=="S"){
			$OK=1;
    		echo "disabled=\"disabled\"";
		}
	}
    ?>
    tabindex="4"/>
    
    <input name="CmdB" type="button" id="CmdA" 
    value="Anular" onclick="flAnular();"
    <?php
	$OK=0;
    if(vbval($StrId)==0){
		$OK=1;
    	echo "disabled=\"disabled\"";
    }
	if($OK==0){
		$_ANU=gs("anu","egresos","id_egreso=".vbval($StrId));
		if($_ANU=="S"){
			$OK=1;
    		echo "disabled=\"disabled\"";
		}
	}
    ?>
    tabindex="4"/>
    
    
    <input name="CmdB" type="button" id="CmdB" 
    value="Buscar" onclick="fBuscar('egresos_buscar.php');"  tabindex="3"/>
    <input name="CmdB" type="button" id="CmdZ" 
    value="Menu" onclick="fBuscar('menu.php');"  tabindex="3"/>
    </div>
    </div>

<div id="layer3" style="position:absolute; left: 30px; top: 248px; width: 835px; height: 337px; overflow:auto">
<div align="left" class="f2">
<table width="813" height="22" border="1" cellpadding="0" cellspacing="0">

<tr>
<td height="18" colspan="8" bgcolor="#666666" align="center"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>
</tr>

<tr>
<td width="55" bgcolor="#999999"><span class="x4">FECHA</span></td>
<td width="96" bgcolor="#999999"><span class="x4">EMPRESA</span></td>
<td width="96" bgcolor="#999999"><span class="x4">ALMACEN</span></td>
<td width="284" bgcolor="#999999"><span class="x4">TIPO DE EGRESO</span></td>
<td width="59" bgcolor="#999999"><span class="x4">RECIBO</span></td>
<td width="51" bgcolor="#999999" style="text-align:right"><span class="x4">TOTAL</span></td>
<td width="113" bgcolor="#999999"><span class="x4">USUARIO</span></td>
<td width="24" bgcolor="#999999"><span class="x4">ANU</span></td>
<td width="15" bgcolor="#999999">&nbsp;</td>
</tr>
<?php
$s="SELECT ID,DATE_FORMAT(FEC,'%d-%m-%y'),
	ALM,TDE,TOT,NRO,EMPC,USU,ANU 
	FROM vegresos 
	WHERE ID>0 ORDER BY FEC DESC ";
$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);
$result = grs($s);
while ($row = $result->fetch_row()){
	echo "<tr ondblclick=\"fActivar($row[0]);\">";
	echo "<td bgcolor=\"#FFFFFF\">
	<span class=\"x5\">$row[1]</span></td>";
	
	echo "<td bgcolor=\"#FFFFFF\">
	<span class=\"x5\">$row[6]</span></td>";
	
	echo "<td bgcolor=\"#FFFFFF\">
	<span class=\"x5\">$row[2]</span></td>";
	
	
	echo "<td bgcolor=\"#FFFFFF\">
	<span class=\"x5\">$row[3]</span></td>";
	echo "<td bgcolor=\"#FFFFFF\" >
	<span class=\"x5\" 
	>$row[5]</span></td>";
	
	echo "<td bgcolor=\"#FFFFFF\" style=\"text-align:right\">
	<span class=\"x5\" 
	>".NF3($row[4])."</span></td>";
	
	echo "<td bgcolor=\"#FFFFFF\" >
	<span class=\"x5\" 
	>$row[7]</span></td>";
	
	echo "<td bgcolor=\"#FFFFFF\" >
	<span class=\"x5\" 
	>$row[8]</span></td>";
	
	echo "<td bgcolor=\"#FFFFFF\" align=\"center\">
	<a href=\"javascript:void(0)\" onclick=\"fActivar($row[0]);\">
	<img src=\"img/b_edit.png\"  border=\"0\"/>
	</a>
	</td>";
	echo "</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 name="TxtId" type="hidden" id="TxtId" value="<?php echo $StrId;?>"/>
        <input name="POL_USU_PER_ELI" type="hidden" id="POL_USU_PER_ELI" value="<?php echo $POL_USU_PER_ELI;?>"/>
		<input name="TxtAc" type="hidden" id="TxtAc" value="" />
		<input name="TxtPag" type="hidden" id="TxtPag" value="<?php echo $LStrPag; ?>" />
<input name="FEC_SERVER" type="hidden" id="FEC_SERVER" value="<?php echo date("d-m-y");?>"/> 
      <strong>EGRESOS</strong></div>
    </div>




    <div id="LblTit" style="position:absolute; left: 52px; top: 15px; width: 64px; z-index: 100;">
    <div align="left" class="Estilo1"><img src="img/marcas.gif" width="48" height="48" /></div>
  </div>
    <div id="layer8" style="position:absolute; left: 0px; top: 0px; width: 900px; height: 79px; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px none #000000; z-index: 0;">
      <div align="left" class="Estilo1">        
      </div>
</div>


<div style="position:absolute; left: 30px; top: 120px; width: 74px;">
<div align="left" class="f2">NUMERO DE EGRESO </div>
</div>
<?php if(strlen($StrNum)==0)$StrNum="******";?>
<input name="TxtNum" type="text" id="TxtNum" style="position:absolute; left: 30px; top: 154px; width: 80px; background-color:#CCC" 
value="<?php echo $StrNum;?>"   readonly="readonly"
tabindex="2" />


<div style="position:absolute; left: 128px; top: 135px; width: 54px;">
<div align="left" class="f2">FECHA </div>
</div>
<?php if(strlen($StrFec)==0)$StrFec=date("d-m-y");?>
<input name="TxtFec" type="text" id="TxtFec" style="position:absolute; left: 128px; top: 154px; width: 75px; " 
value="<?php echo $StrFec;?>"   
onkeydown="return SoloFec(this,event,'CboEmp');" 
tabindex="2" />

<div style="position:absolute; left: 224px; top: 135px; width: 101px;">
<div align="left" class="f2">EMPRESA</div>
</div>
<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:222px; top:154px; width: 127px;" 
onchange="EM_OC();"
onkeydown="return SoloTextoEx(event,'CboAlm');" tabindex="1">
<?php 
	echo LE($StrEmp,"N","N"); 
?>
</select>

<div style="position:absolute; left: 365px; top: 135px; width: 119px;">
<div align="left" class="f2">ALMACEN</div>
</div>
<select name="CboAlm" id="CboAlm" style="position:absolute; left: 363px; top: 154px; width: 150px;" 
onkeydown="return SoloTextoEx(event,'CboTde');" tabindex="0">
<?php 
	echo LA($StrEmp,$StrAlm,"N","N"); 
?>
</select>

<div id="layer10" style="position:absolute; left: 529px; top: 135px; width: 132px;">
<div align="left" class="f2">TIPO DE EGRESO</div>
</div>
<select name="CboTde" id="CboTde" style="position:absolute; left: 529px; top: 154px; width: 320px;" 
onkeydown="return SoloTextoEx(event,'TxtTot');" tabindex="0">
<?php
echo FCBO_("nombre","egresos_tipos","id_et>0",$StrTde,"N","S");
?>
</select>

<div id="layer12" style="position:absolute; left: 30px; top: 203px; width: 80px;">
<div align="left" class="f2">TOTAL S/</div>
</div>
<input name="TxtTot" type="text" id="TxtTot" 
style="position:absolute; left: 30px; top: 221px; width: 80px;" 
value="<?php echo $StrTot;?>"   onkeyup="CalTC()"
onkeydown="return SoloNum(this,event,'CboMod');" 
tabindex="13" 
onfocus="selecciona_value(this);"
/>

<div id="layer10" style="position:absolute; left: 128px; top: 203px; width: 96px;">
<div align="left" class="f2">TIPO PAGO</div>
</div>
<select name="CboMod" id="CboMod" 
style="position:absolute; left: 128px; top: 221px; width: 145px;" 
onkeydown="return SoloTextoEx(event,'TxtObs');" tabindex="0">
<?php
echo FCBO("au_item","auxiliar","au_tab='ET'",$StrMod,"N","S");
?>
</select>



<div style="position:absolute; left: 288px; top: 203px; width: 157px;">
<div align="left" class="f2">OBSERVACION</div>
</div>
<input name="TxtObs" type="text" id="TxtObs"  
style="position:absolute; left: 285px; top: 221px; width: 228px;" 
value="<?php echo $StrObs;?>"  
onKeyDown="return SoloTextoEx(event,'TxtNro');" 
tabindex="1" />

<div style="position:absolute; left: 531px; top: 203px; width: 113px;">
<div align="left" class="f2">NRO. DE RECIBO</div>
</div>
<input name="TxtNro" type="text" id="TxtNro"  
style="position:absolute; left: 529px; top: 221px; width: 123px;" 
value="<?php echo $StrNro;?>"  
onKeyDown="return SoloTextoEx(event,'TxtTotDol');" 
tabindex="1" />

<div style="position:absolute; left: 668px; top: 186px; width: 173px;">
<div align="left" class="f2">DATOS OPCIONALES</div>
</div>

<div id="layer12" style="position:absolute; left: 670px; top: 203px; width: 61px;">
<div align="left" class="f2">TOTAL $</div>
</div>
<input name="TxtTotDol" type="text" id="TxtTotDol" 
style="position:absolute; left: 668px; top: 221px; width: 80px;" 
value="<?php echo $StrTotDol;?>"   onkeyup="CalTC();"
onkeydown="return SoloNum(this,event,'CmdG');" 

onfocus="selecciona_value(this);"
/>

<div id="layer12" style="position:absolute; left:763px; top: 203px; width: 61px;">
<div align="left" class="f2">T.CAMBIO</div>
</div>
<input name="TxtTC" type="text" id="TxtTC" 
style="background-color:#999;position:absolute; left:763px; top: 221px; width: 85px;" 
value="<?php echo $StrTC;?>"   readonly="readonly"
onfocus="selecciona_value(this);"
/>
  
</div>
</center>	
        </form>
</body>
</html>
