<?php
	session_start();
	include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
	if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}
		
	$StrId=V($_POST['TxtId']);
	$StrCmd=V($_POST['TxtAc']);
	$StrNom=V($_POST['TxtNom']);		
	$StrCon=V($_POST['TxtCon']);		
	$StrRuc=V($_POST['TxtRuc']);		
	//-------------------------
	if($StrCmd=="F"){
		$StrPag="0";
	}
	//-------------------------
	$StrNomT="%".$StrNom."%";
	$StrConT="%".$StrCon."%";
	$StrRucT=$StrRuc."%";
	//-------------------------
	$LStrTR=gn("count(*)","vclientes","ID>0 AND 
							NOMBRE LIKE '$StrNomT' AND
							CONTACTO LIKE '$StrConT' AND
							RUC LIKE '$StrRucT'");
	//-------------------------
	$LStrPag=V($_POST['TxtPag']);	
	if($StrCmd=="F"){$LStrPag="1";}
	$VP_RegXPag=14;
	$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);
?>

<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ventas - Clientes - Seleccionar</title>
<!----------------------------------------->
<?php AddJs(); ?>
<script type="text/javascript" src="ja/funciones.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">
.cF {height:580px;width:780px;position:relative;top:0px}
</style>

<!----------------------------------------->
<script>
$(document).ready(function(){  
   Inicializar();
   jF("TxtNom");
});
</script>
<!----------------------------------------->

<body  <?php echo $LStrMsg;?>  >
<div align="center">

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

<!----------------------------------------->
<div id="DivT" class="dT"  style="width:780px;">
<img src="b.png" class="iT" />
<div class="tT" style="width: 500px;">CLIENTES - SELECCIONAR</div>
</div>
<!----------------------------------------->

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

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

<div class="s1" style="left: 441px; top: 117px; width: 100px;">
RUC</div>
<input name="TxtRuc" type="text" id="TxtRuc" 
class="lt" style="left: 436px; top: 134px; width:150px"
value="<?php echo $StrRuc;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div id="DivBtn" align="left" style="position:absolute; left: 33px; top: 71px; width: 551px; height: 26px;">
<input name="CmdB" type="button" id="CmdB" class="btm"
value="Buscar" onClick="fFiltrar();"  
tabindex="<?php echo ++$TI;?>" />
</div>
     
<div class="datagrid" style="position: absolute; left: 35px; top: 165px; width: 708px; height: 350px; overflow: auto">
<table width="100%">
<thead>
<tr>
<td colspan="6" align="center"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>
</tr>

<tr>
<th width="31%">NOMBRE</th>
<th width="23%">CONTACTO</th>
<th width="12%">RUC</th>
<th width="14%">TELEFONO</th>
<th width="17%">CELULAR</th>
<th width="3%">&nbsp;</th>
</tr>
</thead>
<tbody>

<?php		
$s="SELECT ID,NOMBRE,CONTACTO,RUC,TEL,CEL,DIRECCION,EMAIL,DNI
	FROM vclientes 
	WHERE ID>0 AND NOMBRE Like '$StrNomT' AND 
	CONTACTO Like '$StrConT' AND RUC Like '$StrRucT' ORDER BY NOMBRE ";
	
$X1="<td bgcolor=\"#FFFFFF\"><span class=\"Estilo5\">";
$X2="</span></td>";
$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);
$result = grs($s);				
while ($row = $result->fetch_assoc()){
	echo "<tr 
		  ondblclick=\"
		  window.opener.document.Frm.TxtIdCliente.value='$row[0]';
		  window.opener.document.Frm.TxtCliente.value='$row[1]';
		  window.opener.document.Frm.TxtRuc.value='$row[3]';
		  window.opener.document.Frm.TxtDIR.value='$row[6]';
		  window.opener.document.Frm.TxtTel.value='$row[TEL]';
		  window.opener.document.Frm.TxtEma.value='$row[EMAIL]';
		  window.opener.document.Frm.TxtDni.value='$row[DNI]';
		  window.opener.document.Frm.CboVend.focus();
		  window.close();
		  \">";
	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(null)\"
		 onclick=\"
		 window.opener.document.Frm.TxtIdCliente.value='$row[0]';
		 window.opener.document.Frm.TxtCliente.value='$row[1]';
		 window.opener.document.Frm.TxtRuc.value='$row[3]';
		 window.opener.document.Frm.TxtDIR.value='$row[6]';
		 window.opener.document.Frm.TxtTel.value='$row[TEL]';
		 window.opener.document.Frm.TxtEma.value='$row[EMAIL]';
		 window.opener.document.Frm.TxtDni.value='$row[DNI]';
		 window.opener.document.Frm.CboVend.focus();
		 window.close();
		 \"
		 >
		 <img src=\"img/b_edit.png\"  border=\"0\"/>
		 </a>
		 </td>";
	echo "</tr>";
}
?>		  
<tr  >
<td bgcolor="#FFFFFF">
</td>
<td bgcolor="#FFFFFF" ></td>
<td bgcolor="#FFFFFF" ></td>
<td bgcolor="#FFFFFF" ></td>
<td bgcolor="#FFFFFF" ></td>
<td bgcolor="#FFFFFF" ></td>
</tr>
          
</tbody>
</table>
</div>

  
  
<!--INI_OCULTOS-------------------------------->
<?php include("ocultos.php");?>
	
</form>
</div>
</div>
</body>
</html>
