<?php
ini_set("session.cookie_lifetime",60*60*10);
ini_set("session.gc_maxlifetime", 60*60*10);
session_start();
?>
<!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" />
<?php
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
$SYS_MSG="";$SYS_FOC="";$OK=1;
$StrId=V($_POST['TxtId']);$StrCmd=V($_POST['TxtAc']);$LStrPag=V($_POST['TxtPag']);
//++
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;
}
//--------------------------------------------------------------------------++
$Rnd="NO";
include("sis_clientes_fun.php");
//--------------------------------------------------------------------------
$VP_RegXPag=20;
$LStrTR=gn("count(*)","vclientes","ID>0");
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);	
$TI=0;
?>
<title>Clientes</title>
<?php AddJs(); ?>


<script type="text/javascript" src="js/sis_funciones.js"></script>
<script type="text/javascript" src="js/sis_clientes24.js"></script>


<link rel="stylesheet" type="text/css" href="css/estiloss.css"  />
<link rel="stylesheet" type="text/css" href="css/basic.css"  />

<style type="text/css">
.mM {height:34px;width:1250px;position:relative;top:0px;background-color:#09C; z-index:500;}
.cF {height:600px;width:1250px;position:relative;top:0px}
</style>

<script>
$(document).ready(function(){  
   Inicializar();
   SYS_LOAD();
});
</script>

</head>
<body>

<div align="center">
<div Id="DivFRM"  class="cF" style="background-color:#FFFFFF;">
<form id="Frm" name="Frm" method="post" action="sis_clientes.php" autocomplete="off"  onSubmit="return false;">

<!--INI_TITULO--------------------------------->
<div id="DivT" class="dT" >
<img src="bng/cliente.png" class="iT" style="width:48px; height:48px" />
<div class="tT">CLIENTES*</div>
</div>
<!--FIN_TITULO--------------------------------->

<div class="s1" style="left: 35px; top: 117px; width: 199px">
NOMBRES / RAZON SOCIAL</div>
<input name="TxtNom" type="text" id="TxtNom" 
class="lt" style="left: 35px; top: 134px; width: 278px;" 
value="<?php echo $StrNom;?>"  
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 322px; top: 117px; width: 104px">
CONTACTO</div>
<input name="TxtCon" type="text" id="TxtCon" 
class="lt" style="left: 322px; top: 134px; width: 161px;" 
value="<?php echo $StrCon;?>"  
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 492px; top: 117px; width: 199px">
DIRECCION</div>
<input name="TxtDir" type="text" id="TxtDir" 
class="lt" style="left: 492px; top: 134px; width: 723px;" 
value="<?php echo $StrDir;?>"  
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 35px; top: 171px;">
DEPARTAMENTO</div>
<select name="CboDis" id="CboDis" 
class="lt" style="left: 35px; top: 188px; width: 140px;" 
tabindex="<?php echo ++$TI;?>">
<?php
echo FCBO_("dis_nombre","distritos","id_distrito>0",$StrDis,"N","S");
?>
</select>
    
<div class="s1" style="left: 187px; top: 171px; width: 70px">
RUC</div>
<input name="TxtRuc" type="text" id="TxtRuc" 
class="lt" style="left: 183px; top: 188px; width: 114px;" 
value="<?php echo $StrRuc;?>"  
tabindex="<?php echo ++$TI;?>" maxlength="11" />


<div class="s1" style="left: 305px; top: 169px; width: 92px">
Consultar ruc</div>
<input type="button" name="CmdXRuc" id="CmdXRuc" 
value="<<<" 
onClick="fxRuc();" style="position: absolute; left:305px; top: 188px; width: 94px; background-color:#E393EC"
/>


<div class="s1" style="left: 406px; top: 171px; width: 171px">
N° DE DOC. DE IDENTIDAD</div>
<input name="TxtDni" type="text" id="TxtDni" 
class="lt" style="left: 406px; top: 188px; width: 160px;" 
value="<?php echo $StrDni;?>"  
tabindex="<?php echo ++$TI;?>" maxlength="20" />

<div class="s1" style="left: 575px; top: 171px; width: 189px">
TIPO DE DOC. DE IDENTIDAD</div>
<select name="TipDoc" id="TipDoc" 
class="lt" style="left: 575px; top: 188px; width: 172px;" 
tabindex="<?php echo ++$TI;?>">
<?php
echo FCBO("des","sunat_catalogos","cat='TIP_DOC'",$TipDoc,"N","S");
?>
</select>


<div class="s1" style="left: 759px; top: 169px; width: 92px">
Consultar dni</div>
<input type="button" name="CmdXDni" id="CmdXDni" 
value="<<<" 
onClick="fxDni();" style="position: absolute; left:759px; top: 188px; width: 79px; background-color:#0AE9DE"
/>

<div class="s1" style="left: 847px; top: 171px; width: 115px;">
TELEFONO FIJO</div>
<input name="TxtTel" type="text" id="TxtTel" 
class="lt" style="left: 846px; top: 188px; width: 132px;" 
value="<?php echo $StrTel;?>"  
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 986px; top: 171px; width: 106px">
TLF. CELULAR</div>
<input name="TxtCel" type="text" id="TxtCel" 
class="lt" style="left: 987px; top: 188px; width: 116px;" 
value="<?php echo $StrCel;?>"  
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 1110px; top: 171px;">
FAX</div>
<input name="TxtFax" type="text" id="TxtFax" 
class="lt" style="left: 1111px; top: 188px; width: 112px;" 
value="<?php echo $StrFax;?>"  
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 35px; top: 221px;">
EMAIL</div>
<input name="TxtEma" type="text" id="TxtEma" 
class="lt" style="left: 35px; top: 238px; width: 447px;" 
value="<?php echo $StrEma;?>"  
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 501px; top: 222px; width: 135px;">
TIPO DE CLIENTE</div>
<select name="CboTip" id="CboTip" 
class="lt" style="left: 498px; top: 238px; width: 183px;" 
tabindex="<?php echo ++$TI;?>">
<?php
echo FCBO_("clit_nombre","clientes_tipos","id_clit>0",$StrTip,"N","S");
?>
</select>

<input type="button" name="CmdSel" id="CmdSel" value="Sucursales" 
onClick="OpenWin('sis_clientes_suc.php?IC=<?php echo vbval($StrId); ?>',720*ZO(),490*ZO())" 
tabindex="<?php echo ++$TI;?>"
<?php if(vbval($StrId)==0)echo " disabled=\"disabled\" "; ?>
style="position: absolute; left: 687px; top: 237px; width: 88px;"
/>

<?php if(strlen($Rnd)==0)$Rnd="NO";?>
<div class="s1" style="left: 802px; top: 222px; width: 67px;">
RANDOM</div>
<select name="Rnd" id="Rnd" 
class="lt" style="left: 801px; top: 238px; width: 68px;" 
tabindex="<?php echo ++$TI;?>"
onkeydown="return SoloTextoEx(event,'TxtRojo');">
<?php 
echo FCBO_("au_item","auxiliar","au_tab='SI_NO'",$Rnd,"N","N");
?>
</select>

<script>
function ClsUbi(){
	sv("UbiDep","");
	sv("UbiPro","");
	sv("UbiDis","");
}
</script>
<?php if(strlen($UbiPai)==0)$UbiPai="PERU";?>

<div class="s1" style="left: 32px; top: 272px; width: 135px;">
PAIS</div>
<select name="UbiPai" id="UbiPai" 
class="lt" style="left: 32px; top: 289px; width: 163px;" 
onChange="ClsUbi();" 
tabindex="<?php echo ++$TI;?>">
<?php
echo FCBO("pai_nom","lista_paises","id_pais>0",$UbiPai,"N","S");
?>
</select>

<div class="s1" style="left: 213px; top: 272px;">
DEPARTAMENTO</div>
<input name="UbiDep" type="text" id="UbiDep" 
class="roi" style="left: 213px; top: 289px; width: 179px;" 
value="<?php echo $UbiDep;?>"/>

<div class="s1" style="left: 407px; top: 272px;">
PROVINCIA</div>
<input name="UbiPro" type="text" id="UbiPro" 
class="roi" style="left: 407px; top: 289px; width: 179px;" 
value="<?php echo $UbiPro;?>"/>

<div class="s1" style="left: 605px; top: 272px;">
DISTRITO</div>
<input name="UbiDis" type="text" id="UbiDis" 
class="roi" style="left: 605px; top: 289px; width: 174px;" 
value="<?php echo $UbiDis;?>"/>
<input type="button" name="CmdUbi" id="CmdUbi" 
value="Seleccionar" 
onClick="SelUbi();" 
style="position: absolute; left: 796px; top: 287px; width: 88px;"
/>

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

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

<!--INI_BOTONES-------------------------------->
<div id="DivBtn" align="left" style="position:absolute; left: 33px; top: 71px; width:1000px; height: 26px;">
<input name="CmdB" type="button" id="CmdG" class="btm" 
<?php GOM($StrId);?>
onclick="fGuardar();"  
tabindex="<?php echo ++$TI;?>"/>

<input name="CmdB" type="button" id="CmdC"  class="btm" 
value="Nuevo" onClick="fCancelar();"  
tabindex="<?php echo ++$TI;?>" />

<input name="CmdB" type="button" id="CmdE" class="btm" 
value="Eliminar" onClick="fEliminar();"
<?php DIS($StrId);?>
tabindex="<?php echo ++$TI;?>" />

<input name="CmdB" type="button" id="CmdB" class="btm"
value="Buscar" onClick="fBuscar('sis_clientes_b.php');"  
tabindex="<?php echo ++$TI;?>" />

<input name="CmdB" type="button" id="CmdB" class="btm"
value="Menu" onClick="fBuscar('menu.php');"  
tabindex="<?php echo ++$TI;?>" />
</div>
<!--FIN_BOTONES-------------------------------->

<div style="position: absolute; left: 35px; top: 320px; width: 1180px; height: 22px;">
<table  style="font-size:0.9rem; width:100%" >
<thead>
<tr>
<td colspan="5"  align="center"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>
</tr>
</thead>
</table>
</div>

<div class="tableFixHead" style="position: absolute; left: 35px; top: 345px; width: 1180px; height: 231px;">
<table  style="font-size:0.9rem; width:100%" >
<thead>
<tr align="left">
<th width="34%">NOMBRE</th>
<th width="21%">CONTACTO</th>
<th width="12%">RUC</th>
<th width="14%">TELEFONO</th>
<th width="15%">CELULAR</th>
<th width="4%">&nbsp;</th>
</tr>
</thead>
<tbody>
<?php
$PX=0;

$s="SELECT ID,NOMBRE,CONTACTO,RUC,TEL,CEL FROM vclientes
WHERE ID> 0 ORDER BY NOMBRE";

$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);	  				
$result = grs($s);
while ($r = $result->fetch_assoc()){
	$PX++;
	$CSS="";
	if($PX%2==0)$CSS=' style="background-color:#D4D4D4" ';
		?>
        <tr <?php echo $CSS;?> onDblClick="fActivar(<?php echo $r['ID'];?>);">
        <!----------------------------------------------->
        <td ><?php echo $r['NOMBRE'];?></td>
        <td ><?php echo $r['CONTACTO'];?></td>
        <td ><?php echo $r['RUC'];?></td>
        <td ><?php echo $r['TEL'];?></td>
        <td ><?php echo $r['CEL'];?></td>
        <!----------------------------------------------->       
        <td>
        <a href="javascript:void(0)" onClick="fActivar(<?php echo $r['ID'];?>);">
        <img src="img/b_edit.png"  border="0"/></a>
        </td>    
        </tr>
		<?php
    }    
?>	  
          
</tbody>
</table>
</div>

<?php include("sis_ocultos.php");?>
 
</form>
</div>
</div>
</body>
</html>
