<?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="";$LStrMsg="";$LStrFoc="";$LStrMM="";
//++
$StrId=V($_POST['TxtId']);
$StrCmd=V($_POST['TxtAc']);
$LStrPag=V($_POST['TxtPag']);
//
$POL_USU_PER_ELI=USU_PER_GET_EX("ELI_ING");
$LIMPIAR=0;
//
include("ingresos_fun.php");
//-------------------------	
$LStrTR=gn("count(*)","vingresos","ID>0");
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=15;	
$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>Otros ingresos</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/ingresos2.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 EM_OC(){
	var Emp=gv("CboEmp");	
	var r=AX("02",Emp);
	if(r=="X"){
		CBO_CLS("CboAlm",1);
	}else{
		CBO_FILL("CboAlm",r,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: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;
}

-->
</style>

</head>
<body  <?php echo $LStrMsg;?>>
<form id="Frm" name="Frm" method="post" action="ingresos.php">
<center> 
  <div Id="DivFRM"  class="centrarFrm" >
  
    <div id="layer4" style="position:absolute; left: 60px; top: 85px; width: 442px; height: 26px;">
      <div align="left" class="f2">
        <input name="CmdB" type="button" id="CmdG"
		<?php
		if(vbval($StrId)==0){
			echo "value=\"Guardar\"";
		}else{
			echo "value=\"Modificar\"";
		}
		if(vbval($StrId)>0 && $OK==0){
			$ANU=gs("anu","ingresos","id_ingreso=$StrId");
			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(strlen($StrId)==0){
			echo "disabled=\"disabled\"";
			$OK=1;
		}
		if(strlen($StrCmd)==0 && $OK==0){
			$OK=1;
			echo " disabled=\"disabled\" ";
		}
		if(vbval($StrId)>0 && $OK==0){
			$ANU=gs("anu","ingresos","id_ingreso=$StrId");
			if($ANU=="S"){
				 echo " disabled=\"disabled\" ";
			}
		}
		?>
		 tabindex="4"/>
         
        <input name="CmdB" type="button" id="CmdA" value="Anular" onclick="flAnular();"
        <?php
            $OK=0;
			if(strlen($StrId)==0){
				echo "disabled=\"disabled\"";
				$OK=1;
			}
            if(strlen($StrCmd)==0 && $OK==0){
                $OK=1;
                echo " disabled=\"disabled\" ";
            }
            if(vbval($StrId)>0 && $OK==0){
                $ANU=gs("anu","ingresos","id_ingreso=$StrId");
				if($ANU=="S"){
					 echo " disabled=\"disabled\" ";
					 $OK=1;
				}
            }			
        ?>
		tabindex="12"/>

		 <input name="CmdB" type="button" id="CmdB" 
         value="Buscar" onclick="fBuscar('ingresos_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: 264px; width: 748px; height: 320px; overflow:auto">
<div align="left" class="f2">
<table width="738" height="19" 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="81" bgcolor="#999999"><span class="Z4">N°INGRESO</span></td>
<td width="81" bgcolor="#999999"><span class="Z4">FECHA</span></td>
<td width="121" bgcolor="#999999"><span class="Z4">ALMACEN</span></td>
<td width="256" bgcolor="#999999"><span class="Z4">TIPO DE INGRESO</span></td>
<td width="83" bgcolor="#999999" style="text-align:right"><span class="Z4">TOTAL</span></td>
<td width="131" bgcolor="#999999" ><span class="Z4">USUARIO</span></td>
<td width="35" bgcolor="#999999" ><span class="Z4">ANU</span></td>
<td width="15" bgcolor="#999999">&nbsp;</td>
</tr>
<?php
$s="SELECT ID,DATE_FORMAT(FEC,'%d-%m-%y'),
ALM,TDI,TOT,USU_NOM,ANU FROM vingresos WHERE ID>0 ORDER BY FEC DESC ";		 
$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR); 		
$rs = grs($s);
while ($row = $rs->fetch_row()){
	echo "<tr ondblclick=\"fActivar($row[0]);\">";
	echo "<td bgcolor=\"#FFFFFF\">
	<span class=\"Estilo5\">$row[0]</span></td>";
	
	echo "<td bgcolor=\"#FFFFFF\">
	<span class=\"Estilo5\">$row[1]</span></td>";
	echo "<td bgcolor=\"#FFFFFF\">
	<span class=\"Estilo5\">$row[2]</span></td>";
	
	echo "<td bgcolor=\"#FFFFFF\">	
	<span class=\"Estilo5\">$row[3]</span></td>";
	
	echo "<td bgcolor=\"#FFFFFF\" style=\"text-align:right\">
	<span class=\"Estilo5\" 
	>".NF2($row[4],2)."</span></td>";
	
	echo "<td bgcolor=\"#FFFFFF\">	
	<span class=\"Estilo5\">$row[5]</span></td>";
	
	echo "<td bgcolor=\"#FFFFFF\">	
	<span class=\"Estilo5\">$row[6]</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>OTROS INGRESOS</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: 800px; 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: 142px; width: 92px;">
<div align="left" class="f2">NUMERO DE INGRESO</div>
</div>
<?php if(strlen($StrNum)==0)$StrNum="******";?>
<input name="TxtNum" type="text" id="TxtNum" 
style="position:absolute; left: 30px; top: 175px; width: 85px; background-color:#CCC" 
value="<?php echo $StrNum;?>"   readonly="readonly" />


<?php if(strlen($StrFec)==0)$StrFec=date("d-m-y");?>
<input name="TxtFec" type="text" id="TxtFec" 
style="position:absolute; left: 130px; top: 175px; width: 82px; background-color:#CCC" 
value="<?php echo $StrFec;?>"   
onkeydown="return SoloFec(this,event,'CboEmp');" 
tabindex="2" />

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

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

<div style="position:absolute; left: 401px; top: 156px; width: 128px;">
<div align="left" class="f2">ALMACEN</div>
</div>
<select name="CboAlm" id="CboAlm" style="position:absolute; left: 402px; top: 175px; width: 140px;" 
onkeydown="return SoloTextoEx(event,'CboTde');" tabindex="0">
<?php echo LA($StrEmp,$StrAlm,"N","N"); ?>
</select>


<div class="EV" style="left: 130px; top: 156px; width: 88px; color:#FF0"><u><a onclick="fFecServer('TxtFec')">(dd-mm-yy) +</a></u></div>
<div id="layer10" style="position:absolute; left: 552px; top: 156px; width: 167px;">
<div align="left" class="f2">TIPO DE INGRESO</div>
</div>
<select name="CboTde" id="CboTde" style="position:absolute; left: 553px; top: 175px; width: 212px;" 
onkeydown="return SoloTextoEx(event,'TxtTot');" tabindex="0">
<?php
$s="SELECT nombre FROM ingresos_tipos WHERE id_it>= 0 ORDER BY nombre";
$result = grs($s);
while ($row = $result->fetch_row()){
if($StrTde==$row[0]){
echo "<option value=\"$row[0]\" selected=\"selected\">$row[0]</option>";
}else{
echo "<option value=\"$row[0]\" >$row[0]</option>";
}
}
?>
</select>


<div id="layer12" style="position:absolute; left: 30px; top: 213px; width: 71px;">
<div align="left" class="f2">TOTAL</div>
</div>
<input name="TxtTot" type="text" id="TxtTot" style="position:absolute; left: 30px; top: 231px; width: 85px;" 
value="<?php echo $StrTot;?>"  
onkeydown="return SoloNum(this,event,'TxtObs');" 
tabindex="13" 
onfocus="selecciona_value(this);"
/>


<div id="layer13" style="position:absolute; left: 130px; top: 213px; width: 110px;">
<div align="left" class="f2">OBSERVACION</div>
</div>

<input name="TxtObs" type="text" id="TxtObs" style="position:absolute; left: 129px; top: 231px; width: 637px;" 
value="<?php echo $StrObs;?>"  
onKeyDown="return SoloTextoEx(event,'CmdG');" 
tabindex="1" />

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