<?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="";
//-------------------------
$LIMPIAR=0;
//-------------------------
$StrId=V($_POST['TxtId']);
$StrCmd=V($_POST['TxtAc']);
$LStrPag=V($_POST['TxtPag']);
$Rnd="NO";
include("clientes_fun.php");
$VP_RegXPag=10;
$LStrTR=gn("count(*)","vclientes","ID>0");
$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>Clientes</title>
<script type="text/javascript" src="fe/funciones.js"></script>
<script type="text/javascript" src="fe/clientes5.js"></script>
<script type="text/javascript" src="fe/leo.js"></script>
<link rel="stylesheet" type="text/css" href="estiloss.css"  />
<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{
	width:1100px;
	height:650px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-325px";?> 0 0 <?php echo "-550px";?>;
}
#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;}
.Estilo4 {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="clientes.php">
<center> 
  <div Id="DivFRM"  class="centrarFrm" >

<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(strlen($StrId)==0){
echo "value=\"Guardar\"";
}else{
echo "value=\"Modificar\"";
}
?>
onclick="fGuardar();" style="width:80px" tabindex="12"/>
<input name="CmdB" type="button" id="CmdC" value="Nuevo" onclick="fCancelar();"  tabindex="13"/>
<input name="CmdB" type="button" id="CmdE" value="Eliminar" onclick="fEliminar();"
<?php
if(strlen($StrId)==0){
echo "disabled=\"disabled\"";
}
?>
tabindex="14"/>
<input name="CmdB" type="button" id="CmdB" 
value="Buscar" onclick="fBuscar('clientes_buscar.php');"  tabindex="15"/>
<input name="CmdB" type="button" id="CmdZ" 
value="Menu" onclick="fBuscar('menu.php');"  tabindex="16"/>
</div>
</div>

<div id="layer3" style="position:absolute; left: 30px; top: 332px; width: 1051px; height: 283px; overflow:auto">
<div align="left" class="f2">
<table width="1030" height="19" border="1" cellpadding="0" cellspacing="0">

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

<tr>
<td width="343" bgcolor="#999999"><span class="Estilo4">NOMBRE</span></td>
<td width="186" bgcolor="#999999"><span class="Estilo4">CONTACTO</span></td>
<td width="143" bgcolor="#999999"><span class="Estilo4">RUC</span></td>
<td width="132" bgcolor="#999999"><span class="Estilo4">TELEFONO</span></td>
<td width="154" bgcolor="#999999"><span class="Estilo4">CELULAR</span></td>            
<td width="37" bgcolor="#999999">&nbsp;</td>
</tr>
<?php
	$s="SELECT ID,NOMBRE,CONTACTO,RUC,SUBSTRING(TEL,1,19),SUBSTRING(CEL,1,19) FROM vclientes
	WHERE ID> 0 ORDER BY NOMBRE";
	$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);	  				
	$result = grs($s);
	$X1="<td bgcolor=\"#FFFFFF\"><span class=\"Estilo5\">";
	$X2="</span></td>";
	while ($row = $result->fetch_row()){
		echo "<tr ondblclick=\"fActivar($row[0]);\">";
		echo $X1.VV($row[1]).$X2;
		echo $X1.VV($row[2]).$X2;
		echo $X1.VV($row[3]).$X2;
		echo $X1.VV($row[4]).$X2;
		echo $X1.VV($row[5]).$X2;
		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 id="DivSunat">
        <input name="T_RS" type="hidden" id="T_RS" value=""/>
        <input name="T_DI" type="hidden" id="T_DI" value=""/>
        <input name="T_TE" type="hidden" id="T_TE" value=""/>
        </div>
      <div align="left" class="Estilo1">
        <input name="TxtId" type="hidden" id="TxtId" value="<?php echo $StrId;?>"/>
		<input name="TxtAc" type="hidden" id="TxtAc" value="" />
		<input name="TxtPag" type="hidden" id="TxtPag" value="<?php echo $LStrPag; ?>" />
      <strong>CLIENTES</strong></div>
    </div>
    
<div class="s1" style="left: 30px; top: 130px; width:199px">NOMBRES / RAZON SOCIAL</div>
<input name="TxtNom" type="text" id="TxtNom" 
style="left: 30px; top: 150px; width: 280px;" 
value="<?php echo $StrNom;?>"  
onKeyDown="return SoloTextoEx(event,'TxtCon');" 
tabindex="1" />

<div id="LblTit" style="position:absolute; left: 52px; top: 15px; width: 64px; z-index: 100;">
<div align="left" class="Estilo1"><img src="img/clientes.png" width="56" height="52" /></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 class="s1" style="left: 328px; top: 128px; width:104px">CONTACTO</div>
<input name="TxtCon" type="text" id="TxtCon" 
style="left: 326px; top: 150px; width: 155px;" 
value="<?php echo $StrCon;?>"  
onkeydown="return SoloTextoEx(event,'TxtDir');" 
tabindex="2" />

<div class="s1" style="left: 497px; top: 129px; width:199px">DIRECCION</div>
<input name="TxtDir" type="text" id="TxtDir" 
style="left: 494px; top: 150px; width: 573px;" 
value="<?php echo $StrDir;?>"  
onkeydown="return SoloTextoEx(event,'CboDis');" 
tabindex="3" />

<div class="s1" style="left: 30px; top: 184px;">DEPARTAMENTO</div>
<select name="CboDis" id="CboDis" 
style="left: 30px; top: 203px; width: 161px;" 
onkeydown="return SoloTextoEx(event,'TxtRuc');" tabindex="4">
<?php
echo FCBO_("dis_nombre","distritos","id_distrito>0",$StrDis,"N","S");
?>
</select>
    
<div class="s1" style="left: 201px; top: 184px; width:70px">RUC</div>
<input name="TxtRuc" type="text" id="TxtRuc" 
style="left: 197px; top: 203px; width: 114px;" 
value="<?php echo $StrRuc;?>"  
onkeydown="return SoloEnterosEx(this,event,'TxtDni');" 
tabindex="5" maxlength="11" />

<div class="s1" style="left: 323px; top: 185px; width:214px">N° DE DOCUMENTO DE IDENTIDAD</div>
<input name="TxtDni" type="text" id="TxtDni" 
style="left: 321px; top: 203px; width: 205px;" 
value="<?php echo $StrDni;?>"  
onkeydown="return SoloTextoEx(event,'TipDoc');" 
tabindex="6" maxlength="20" />

<div class="s1" style="left: 539px; top: 184px; width:234px">TIPO DE DOCUMENTO DE IDENTIDAD</div>
<select name="TipDoc" id="TipDoc" 
style="left:539px; top: 203px; width: 234px;" 
onkeydown="return SoloTextoEx(event,'TxtTel');" tabindex="4">
<?php
echo FCBO("des","sunat_catalogos","cat='TIP_DOC'",$TipDoc,"N","S");
?>
</select>


<div class="s1" style="left: 781px; top: 185px; width: 133px;">TELEFONO FIJO</div>
<input name="TxtTel" type="text" id="TxtTel" 
style="left: 780px; top: 203px; width: 132px;" 
value="<?php echo $StrTel;?>"  
onkeydown="return SoloTextoEx(event,'TxtCel');" 
tabindex="7" />

<div class="s1" style="left: 928px; top: 185px; width:120px">TLF. CELULAR</div>
<input name="TxtCel" type="text" id="TxtCel" 
style="left: 925px; top: 203px; width: 142px;" 
value="<?php echo $StrCel;?>"  
onkeydown="return SoloTextoEx(event,'TxtFax');" 
tabindex="8" />

<div class="s1" style="left: 30px; top: 234px;">FAX</div>
<input name="TxtFax" type="text" id="TxtFax" 
class="ps" style="position:absolute; left: 30px; top: 253px; width: 161px;" 
value="<?php echo $StrFax;?>"  
onkeydown="return SoloTextoEx(event,'TxtEma');" 
tabindex="9" />

<div class="s1" style="left: 211px; top: 234px;">EMAIL</div>
<input name="TxtEma" type="text" id="TxtEma" 
class="ps" style="left: 211px; top: 253px; width: 269px;" 
value="<?php echo $StrEma;?>"  
onkeydown="return SoloTextoEx(event,'CboTip');" 
tabindex="10" />

<div class="s1" style="left: 499px; top: 235px; width: 135px;">TIPO DE CLIENTE</div>
<select name="CboTip" id="CboTip" 
style="position:absolute; left: 496px; top: 253px; width: 183px;" 
onkeydown="return SoloTextoEx(event,'UbiPai');" tabindex="11">
<?php
echo FCBO_("clit_nombre","clientes_tipos","id_clit>0",$StrTip,"N","S");
?>
</select>
<script>
function ClsUbi(){
	sv("UbiDep","");
	sv("UbiPro","");
	sv("UbiDis","");
}
</script>
<?php if(strlen($UbiPai)==0)$UbiPai="PERU";?>
<div class="s1" style="left:30px; top: 286px; width: 135px;">PAIS</div>
<select name="UbiPai" id="UbiPai" 
style="position:absolute; left:30px; top:301px; width: 163px;" 
onkeydown="return SoloTextoEx(event,'CmdG');" onchange="ClsUbi();" tabindex="11">
<?php
echo FCBO("pai_nom","lista_paises","id_pais>0",$UbiPai,"N","S");
?>
</select>

<div class="s1" style="left: 211px; top: 286px;">DEPARTAMENTO</div>
<input name="UbiDep" type="text" id="UbiDep" 
class="ps" style="position:absolute; left:211px; top: 301px; width: 179px; background-color:#CCC" 
value="<?php echo $UbiDep;?>"   readonly="readonly"/>

<div class="s1" style="left: 405px; top: 286px;">PROVINCIA</div>
<input name="UbiPro" type="text" id="UbiPro" 
class="ps" style="position:absolute; left:405px; top: 301px; width: 179px; background-color:#CCC" 
value="<?php echo $UbiPro;?>"   readonly="readonly"/>

<div class="s1" style="left: 603px; top: 286px;">DISTRITO</div>
<input name="UbiDis" type="text" id="UbiDis" 
class="ps" style="position:absolute; left:603px; top: 301px; width: 174px; background-color:#CCC" 
value="<?php echo $UbiDis;?>"   readonly="readonly"/>
<input type="button" name="CmdUbi" id="CmdUbi" 
value="Seleccionar" 
onClick="SelUbi();" 
style="position:absolute; left: 794px; top: 300px; width: 88px;"
/>

<input type="button" name="CmdLim" id="CmdLim" 
value="<< Lima" 
onClick="SetLima();" 
style="position:absolute; left: 888px; top: 300px; width: 77px;"
/>

<input type="button" name="CmdUbiX" id="CmdUbiX" 
value="X" 
onClick="ClsUbi();" 
style="position:absolute; left: 975px; top: 300px; width: 37px;"
/>


<input type="button" name="CmdSel" id="CmdSel" value="Sucursales" 
onClick="OpenWin('clientes_suc.php?IC=<?php echo vbval($StrId); ?>',700*ZO(),500*ZO())" tabindex="15"
<?php if(vbval($StrId)==0)echo " disabled=\"disabled\" "; ?>
style="position:absolute; left: 685px; top: 254px; width: 88px;"
/>

<?php if(strlen($Rnd)==0)$Rnd="NO";?>
<div class="s1" style="left: 800px; top: 235px; width: 81px;">RANDOM</div>
<select name="Rnd" id="Rnd" 
style="position:absolute; left:800px; top: 253px; width: 104px;" tabindex="8"
onkeydown="return SoloTextoEx(event,'TxtRojo');">
<?php 
echo FCBO_("au_item","auxiliar","au_tab='SI_NO'",$Rnd,"N","N");
?>
</select>


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