<?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;
}
//+++++
$POL_USU_PER_ELI=USU_PER_GET_EX("ELI_CON");
//
$StrGT=""; $LStrMsg=""; $LStrFoc=""; $LStrMM="";
$StrId=V($_POST['TxtId']);
$StrCmd=V($_POST['TxtAc']);
$LStrPag=V($_POST['TxtPag']);
include("contratos_fun.php");
$w="ID>0";
$VP_RegXPag=20;
$LStrTR=gn("count(*)","vis_contratos",$w);
$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>Contratos</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/funcionez.js"></script>
<script type="text/javascript" src="fe/contratos3.js"></script>
<script type="text/javascript" src="fe/leo.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;
   }
        
});
</script>
<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 {height:650px;width:1100px;position:relative;top:0px;background-color:#666666;}

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

-->
</style>

</head>
<body  <?php echo $LStrMsg;?>>
<form id="Frm" name="Frm" method="post" action="contratos.php" onsubmit="return false;">
<center> 
<div Id="DivFRM"  class="centrarFrm" >

<div class="s1" style="left: 29px; top: 137px; width: 78px;">EMPRESA</div>
<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:29px; top:156px; width: 102px;" 
onkeydown="return SoloTextoEx(event,'CboAlm');" 
onchange="EM_OC();"
tabindex="1">
<?php 
	echo LE($StrEmp,"N","N"); 
?>
</select>


<div class="s1" style="position:absolute; left: 149px; top: 137px; width: 106px;">
PUNTO DE VENTA</div>
<select name="CboAlm" id="CboAlm" 
style="left: 149px; top: 156px; width:100px;" 
onkeydown="return SoloTextoEx(event,'TxtFec');" 
tabindex="2" >
<?php
	echo LA($StrEmp,$StrAlm,"N","S"); 
?>
</select>





<?php if(strlen($StrFec)==0)$StrFec=date("d-m-y");?>
<div class="EV" style="left: 266px; top: 137px; ; width: 88px; color:#FF0"><u><a onclick="fFecServer('TxtFec')">(dd-mm-yy) +</a></u></div>
<div class="s1" style="left: 266px; top: 121px; width: 87px;">
FECHA
</div>
<input name="TxtFec" type="text" id="TxtFec" 
style="position:absolute; left: 266px; top: 156px; width: 76px; " 
value="<?php echo $StrFec;?>"   
onkeydown="return SoloFec(this,event,'TxtNum');" 
tabindex="3" />
  
<div class="s1" style="left: 360px; top: 137px; width: 80px;">NUMERO</div>
<input name="TxtNum" type="text" id="TxtNum" 
style="left: 359px; top: 156px; width: 68px;" 
value="<?php echo $StrNum;?>"  
onkeydown="return snNum(this,event,'CmdSel');" 
tabindex="4" />

<div class="s1" style="left: 444px; top: 137px; width: 202px;">
CLIENTE / RAZON SOCIAL</div>
<input name="TxtCli" type="text" id="TxtCli" 
style="left: 440px; top: 156px; width: 304px; background-color:#CCCCCC" 
readonly="readonly"
value="<?php echo $StrCli;?>"  
onKeyDown="return SoloTextoEx(event,'CmdSel');"  
tabindex="5" />

<input type="button" name="CmdSel" id="CmdSel" value="..." 
onClick="Ow('ventas_clientes_buscar.php?W=C',800*ZO(),600*ZO())" 
tabindex="6"
style="position:absolute; left: 757px; top: 156px; width: 38px;"
/>

<div class="s1" style="left:806px; top: 137px; width: 56px;"> TOTAL
</div>
<input name="TxtTot" type="text" id="TxtTot" 
style="position:absolute; left: 806px; top: 156px; width:65px; text-align:right" 
value="<?php echo $StrTot;?>"  
onkeydown="return SoloNum(this,event,'TxtAde');" 
tabindex="7"  onkeyup="Cal();"
onfocus="selecciona_value(this);"
/>

<div class="s1" style="left:884px; top: 137px; width: 77px;"> ADELANTO
</div>
<input name="TxtAde" type="text" id="TxtAde" 
style="position:absolute; left:884px; top: 156px; width: 71px; text-align:right" 
value="<?php echo $StrAde;?>"  
onkeydown="return SoloNum(this,event,'CboTad');" 
onkeyup="Cal();"
tabindex="8" 
onfocus="selecciona_value(this);"
/>

<div class="s1" style="left: 971px; top: 137px; width: 94px; height: 18px;">MODALIDAD</div>
<select name="CboTad" id="CboTad" 
style="position:absolute; left: 968px; top:156px; width: 89px;"
onKeyDown="return SoloTextoEx(event,'CmdG');"  tabindex="9">
<?php echo FCBO_("au_item","auxiliar","au_tab='MODA'",$StrTad,"","S");?>
</select>

<div class="s1" style="left:29px; top: 192px; width: 82px;"> T. ACUENTA
</div>
<input name="TxtAcu" type="text" id="TxtAcu" 
style="position:absolute; left:29px; top: 212px; width: 102px; text-align:right; background-color:#CCCCCC" 
value="<?php echo $StrAcu;?>"   readonly="readonly"
onkeydown="return SoloNum(this,event,'CmdG');" 
tabindex="10" 
onfocus="selecciona_value(this);"
/>

<div class="s1" style="left:149px; top: 192px; width: 43px;">SALDO
</div>
<input name="TxtSal" type="text" id="TxtSal" 
style="position:absolute; left:149px; top: 212px; width: 100px; text-align:right; background-color:#CCCCCC" 
value="<?php echo $StrSal;?>"  
onkeydown="return SoloNum(this,event,'CmdG');"  readonly="readonly"
tabindex="11" 
onfocus="selecciona_value(this);"
/>

<div class="s1" style="left:266px; top: 192px; width: 64px;">USADO
</div>
<input name="TxtUsa" type="text" id="TxtUsa" 
style="position:absolute; left:266px; top: 212px; width: 76px; text-align:right; background-color:#CCCCCC" 
value="<?php echo $StrUsa;?>"  
onkeydown="return SoloNum(this,event,'CmdG');"  readonly="readonly"
tabindex="12" 
onfocus="selecciona_value(this);"
/>


<div id="layer4" style="position:absolute; left: 30px; 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{
	if(vbval($StrAku)>0){
		echo " value=\"Guardar\"   disabled=\"disabled\" ";
	}else{
		echo " value=\"Modificar\"  ";
	}
}
?>
onclick="fGuardar();" style="width:80px" tabindex="13"/>

<input name="CmdB" type="button" id="CmdC" value="Nuevo" 
onclick="fCancelar();"  tabindex="14"/>

<input name="CmdB" type="button" id="CmdE" value="Eliminar" onclick="flEliminar();"
<?php
$OK=0;
if(vbval($StrAku)>0){
    echo " disabled=\"disabled\" ";
    $OK=1;
}
if($LIMPIAR==1 && $OK==0){
    echo "disabled=\"disabled\"";
	$OK=1;
}

if(vbval($StrId)==0 && $OK==0){
    echo "disabled=\"disabled\"";
	$OK=1;
}
?>
tabindex="15"/>

<input name="CmdB" type="button" id="CmdB" 
value="Buscar" onclick="fBuscar('contratos_buscar.php');" 
tabindex="16"/>

<input name="CmdB" type="button" id="CmdZ" 
value="Menu" onclick="fBuscar('menu.php');"  tabindex="17"/>

      </div>
</div>

<div id="layer3" style="position:absolute; left: 30px; top: 254px; width: 1048px; height: 370px; overflow:auto">
<div align="left" class="f2">
<table width="1030" height="22" border="1" cellpadding="0" cellspacing="0">

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

<tr>
<td width="56" bgcolor="#999999" style="color:#000">FECHA</td>
<td width="87" bgcolor="#999999" style="color:#000">NUMERO</td>
<td width="426" bgcolor="#999999" style="color:#000">CLIENTE</td>
<td width="106" bgcolor="#999999" style="text-align:right; color:#000">TOTAL</td>
<td width="92" bgcolor="#999999" style="text-align:right; color:#000">ADELANTO</td>
<td width="92" bgcolor="#999999" style="color:#000">TIP.ADELANTO</td>
<td width="92" bgcolor="#999999" style="text-align:right; color:#000">T. ACUENTA</td>
<td width="70" bgcolor="#999999" style="text-align:right; color:#000">SALDO</td>
<td width="70" bgcolor="#999999" style="text-align:right; color:#000">USUARIO</td>
<td width="26" bgcolor="#999999">&nbsp;</td>
</tr>

<?php

$s="SELECT ID,DATE_FORMAT(FEC,'%d-%m-%y'),NUM,CLI,TOT,ADE,ACU,ROUND(SAL,2),TIP_A,USU 
    FROM vis_contratos 
	WHERE $w ORDER BY ID 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=\"s5\">$row[1]</span></td>";
	echo "<td bgcolor=\"#FFFFFF\"><span class=\"s5\">$row[2]</span></td>";
	echo "<td bgcolor=\"#FFFFFF\"><span class=\"s5\">$row[3]</span></td>";
	echo "<td bgcolor=\"#FFFFFF\" style=\"text-align:right\"><span class=\"s5\">".NF3($row[4])."</span></td>";
	echo "<td bgcolor=\"#FFFFFF\" style=\"text-align:right\"><span class=\"s5\">".NF3($row[5])."</span></td>";
	echo "<td bgcolor=\"#FFFFFF\" ><span class=\"s5\">$row[8]</span></td>";
	echo "<td bgcolor=\"#FFFFFF\" style=\"text-align:right\"><span class=\"s5\" >".NF3($row[6])."</span></td>";
	echo "<td bgcolor=\"#FFFFFF\" style=\"text-align:right\"><span class=\"s5\" >".NF3($row[7])."</span></td>";
	echo "<td bgcolor=\"#FFFFFF\"><span class=\"s5\">$row[9]</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="POL_USU_PER_ELI" type="hidden" id="POL_USU_PER_ELI" value="<?php echo $POL_USU_PER_ELI;?>"/>

<input name="TxtId" type="hidden" id="TxtId" value="<?php echo $StrId;?>"/>
<input name="TxtAc" type="hidden" id="TxtAc" value="" />
<input name="TxtAku" type="hidden" id="TxtAku" value="<?php echo $StrAku;?>" />
<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>CONTRATOS</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: 1100px; height: 79px; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px none #000000; z-index: 0;">
<div align="left" class="Estilo1">        
</div>
</div>
</div>
</center>	
</form>
</body>
</html>
