<?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;
}
//++++++
$Z=V($_POST['Z']);
if(strlen($Z)==0)$Z=V($_GET['Z']);
//	
$W=V($_GET['W']);	
if(strlen(V($_POST['TxtW']))>0){
	$W=V($_POST['TxtW']);
}
$StrId=V($_POST['TxtId']);
$StrCmd=V($_POST['TxtAc']);
$Dep=V($_POST['Dep']);		
$Pro=V($_POST['Pro']);		
$Dis=V($_POST['Dis']);
//-------------------------
if($StrCmd=="F"){
	$StrPag="0";
}
//-------------------------
$Dep_=$Dep."%";
$Pro_=$Pro."%";
$Dis_=$Dis."%";
//-------------------------
$WW="ID>0 AND DEP LIKE '$Dep_' AND PROV LIKE '$Pro_' AND DIS LIKE '$Dis_' ";
//-------------------------
$LStrTR=gn("count(*)","lista_ubigeo",$WW);
//-------------------------
$LStrPag=V($_POST['TxtPag']);	
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=17;
$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>Departamento - Seleccionar</title>
<script type="text/javascript" src="fe/funcionez.js"></script>
<script type="text/javascript" src="fe/leo.js"></script>
<script>
function Z(Dep,Pro,Dis,Ubi){
	var W=gv("TxtW");
	if(W=="CLI"){
		window.opener.document.Frm.UbiDep.value=Dep;
		window.opener.document.Frm.UbiPro.value=Pro;
		window.opener.document.Frm.UbiDis.value=Dis;
		window.opener.document.Frm.UbiPai.focus();
		window.close();
		return;
	}	
}
</script>
<style type="text/css">
<!--
body {
	background-color: #666;
}
#Layer1 {
	position:absolute;
	left:345px;
	top:115px;
	width:123px;
	height:35px;
	z-index:1;
}
.centrarFrm{
	width:800px;
	height:500px;
	position:absolute;
	left:50%;
	top:0px;
	background-color:#999999;
	margin:0 0 0 -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;}
.x4 {color: #000099}
.Estilo5 {color: #000000}

-->
</style>

</head>
<body  onload="document.getElementById('Dep').focus();"   >
<form id="Frm" name="Frm" method="post" action="departamento_seleccionar.php" onsubmit="return false;" autocomplete="off">
<input name="L_USU" type="hidden" id="L_USU" value="<?php echo vbval(V($_SESSION['SYS_USER_ID']))?>">
<input name="Z" type="hidden" id="Z" value="<?php echo $Z?>" />
<center> 
<div Id="DivFRM"  class="centrarFrm" >

<div id="layer3" style="position:absolute; left: 16px; top: 115px; width: 761px; height: 383px; overflow:auto">
<div align="left" class="f2">
<table width="758" border="1" cellpadding="0" cellspacing="0">
<tr>
<td colspan="6" bgcolor="#666666" align="center" height="20px">
<?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?>
</td>
</tr>
<tr>
<td width="298" bgcolor="#999999"><span class="x4">DEPARTAMENTO</span></td>
<td width="177" bgcolor="#999999"><span class="x4">PROVINCIA</span></td>
<td width="250" bgcolor="#999999"><span class="x4">DISTRITO</span></td>
<td width="23" bgcolor="#999999">&nbsp;</td>
</tr>
<?php		
$s="SELECT * FROM lista_ubigeo WHERE $WW ORDER BY DEP,PROV,DIS  ";
$X1="<td bgcolor=\"#FFFFFF\"><span class=\"Estilo5\">";
$X2="</span></td>";
$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);
$rs = grs($s);				
while ($r = $rs->fetch_assoc()){					
echo "<tr ondblclick=\"Z('$r[DEP]','$r[PROV]','$r[DIS]','$r[UBIGEO]');\" >";					
echo $X1.VV($r[DEP]).$X2;
echo $X1.VV($r[PROV]).$X2;
echo $X1.VV($r[DIS]).$X2;		
echo "<td bgcolor=\"#FFFFFF\" align=\"center\">
     <a href=\"javascript:void(null)\"
     onclick=\"Z('$r[DEP]','$r[PROV]','$r[DIS]','$r[UBIGEO]');\">
     <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: 24px;">
<div align="left" class="Estilo1">DEPARTAMENTO - SELECCIONAR
<input name="TxtId" type="hidden" id="TxtId" value="<?php echo $StrId;?>"/>
<input name="TxtW" type="hidden" id="TxtW" value="<?php echo $W;?>"/>
<input name="TxtPag" type="hidden" id="TxtPag" value="<?php echo $LStrPag; ?>" />
<input name="TxtAc" type="hidden" id="TxtAc" value="" />
</div>
</div>

<div style="position:absolute; left: 18px; top: 68px; width: 168px;">
<div align="left" class="f2">DEPARTAMENTO</div>
</div>
<input name="Dep" type="text" id="Dep" 
style="position:absolute; left: 17px; top: 84px; width: 174px;" 
value="<?php echo $Dep;?>"  
onkeydown="return SoloTextoEx(event,'Pro');"  
tabindex="1" />

<div style="position:absolute; left: 208px; top: 68px; width: 100px;">
<div align="left" class="f2">PROVINCIA</div>
</div>
<input name="Pro" type="text" id="Pro" 
style="position:absolute; left: 205px; top: 84px; width: 167px;" 
value="<?php echo $Pro;?>"  
onkeydown="return SoloTextoEx(event,'Dis');"  
tabindex="2" />

<div style="position:absolute; left: 389px; top: 68px; width: 100px;">
<div align="left" class="f2">DISTRITO</div>
</div>
<input name="Dis" type="text" id="Dis" 
style="position:absolute; left: 388px; top: 84px; width: 312px;"
value="<?php echo $Dis;?>"  
onkeydown="return SoloTextoEx(event,'CmdB');"  tabindex="3" />
<div id="LblTit" style="position:absolute; left: 57px; top: 2px; width: 64px;">
<div align="left" class="Estilo1"><img src="img/buscar.png" width="57" height="60" /></div>
</div>
<input name="CmdB" type="button" id="CmdB" 
style="position:absolute; left: 713px; top: 84px; width: 57px;" 
value="Filtrar" onclick="fFiltrar();"  tabindex="4"/>

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