<?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;
}
//
$StrId=V($_POST['TxtId']);
$StrCmd=V($_POST['TxtAc']);
$StrNom=V($_POST['TxtNom']);		
$StrCon=V($_POST['TxtCon']);		
$StrRuc=V($_POST['TxtRuc']);		

$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=1000;	
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);
//
if($StrCmd=="PDF"){	
//
$TI="REPORTE DE CLIENTES";
$s="SELECT NOMBRE,RUC,TEL,CEL,EMAIL FROM vclientes 
WHERE ID>0 AND NOMBRE Like '$StrNomT' AND 
CONTACTO Like '$StrConT' AND RUC Like '$StrRucT' ORDER BY NOMBRE ";
$T="NOMBRE,RUC,TELEFONO,CELULAR,EMAIL";
$E="28,13,7,9,25";
$A=" 0, 0,0,0,0";		
//
$_ID=GenId("id","reportes");
PDF_TIT($_ID,$TI);
PDF_SQL($_ID,$s);
PDF_CAM($_ID,$T);
PDF_ESP($_ID,$E);
PDF_ANC($_ID,$A);		
$StrFilePDF=PDF_CREATE($_ID);	
//
JsDir($StrFilePDF);
return;			
}
//


?>
<!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>Reporte de clientes</title>
<?php AddJs();?>
<script type="text/javascript" src="fe/funciones.js"></script>
<script language="javascript">
$(document).ready(function() {
	$(".botonExcel").click(function(event) {
		$("#datos_a_enviar").val( $("<div>").append( $("#Exportar_a_Excel").eq(0).clone()).html());
		$("#FormularioExportacion").submit();
});
});
</script>
<style type="text/css">
<!--
body {
	background-color: #CCC;
}
#Layer1 {
	position:absolute;
	left:345px;
	top:115px;
	width:123px;
	height:35px;
	z-index:1;
}
.centrarFrm{
	width:900px;
	height:600px;
	position:absolute;
	left:50%;
	top:50%;
	background-color:#006699;
	margin:-300px 0 0 -450px;
}
#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}

-->
</style>

</head>
<body  <?php echo $StrMsg;?>>
<div Id="DivFRM"  class="centrarFrm" >
<form id="Frm" name="Frm" method="post" action="rep_clientes.php">

  
<div id="layer6" style="position:absolute; left: 30px; top: 86px; width: 200px;">
<div align="left" class="f2">NOMBRE / RAZON SOCIAL</div></div>

    <div id="layer5" style="position:absolute; left: 116px; top: 50px; width: 85px; height: 28px;">
      <div align="left" class="f2">
        <input name="CmdV" type="button" id="CmdV" 
        value="Volver" onclick="fVolver('menu.php');" />
        <input type="hidden" name="TxtAc" id="TxtAc" />
        <input name="TxtPag" id="TxtPag" type="hidden" value="<?php echo $LStrPag; ?>" />
      </div>
    </div>

<div id="layer3" style="position:absolute; left: 30px; top: 138px; width: 838px; height: 406px; overflow:auto">
<div align="left" class="f2">
<table id="Exportar_a_Excel" width="822" height="20" 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="199" bgcolor="#999999"><span class="Estilo4">NOMBRE</span></td>
<td width="120" bgcolor="#999999"><span class="Estilo4">CONTACTO</span></td>
<td width="100" bgcolor="#999999"><span class="Estilo4">RUC</span></td>
<td width="93" bgcolor="#999999"><span class="Estilo4">TELEFONO</span></td>
<td width="86" bgcolor="#999999"><span class="Estilo4">CELULAR</span></td>
<td width="210" bgcolor="#999999"><span class="Estilo4">EMAIL</span></td>
</tr>

<?php		  		
$s="SELECT ID,SUBSTRING(NOMBRE,1,24) AS NOMBRE,CONTACTO,RUC,TEL,CEL,EMAIL 
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_row()){
echo "<tr>";
echo $X1.$row[1].$X2;
echo $X1.$row[2].$X2;
echo $X1.$row[3].$X2;
echo $X1.$row[4].$X2;
echo $X1.$row[5].$X2;
echo $X1.$row[6].$X2;
echo "</tr>";
}

?>
</table>
</div>
</div>


    <div id="layer" style="position:absolute; left: 116px; top: 30px; width: 412px; height: 24px;">
      <div align="left" class="Estilo1">REPORTE DE CLIENTES</div>
    </div>
          <input name="TxtNom" type="text" id="TxtNom" style="position:absolute; left: 30px; top: 109px; width: 173px;" value="<?php echo $StrNom;?>"  onkeydown="return SoloTextoEx(event,'TxtCon');"  tabindex="1" />

    <div id="LblTit" style="position:absolute; left: 57px; top: 25px; 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: 572px; top: 109px; width: 47px;"
value="Filtrar" onclick="fFiltrar();" />

    <div id="layer7" style="position:absolute; left: 226px; top: 86px; width: 100px;">
      <div align="left" class="f2">CONTACTO</div>
    </div>
        <input name="TxtCon" type="text" id="TxtCon" 
        style="position:absolute; left: 223px; top: 109px; width: 173px;x" value="<?php echo $StrCon;?>"  
        onkeydown="return SoloTextoEx(event,'TxtRuc');" 
        tabindex="1" />

        <input name="TxtRuc" type="text" id="TxtRuc" style="position:absolute; left: 412px; top: 109px; width: 141px;"
        value="<?php echo $StrRuc;?>" 
        onkeydown="return SoloTextoEx(event,'CmdB');"   tabindex="1" />

    <div id="layer10" style="position:absolute; left: 417px; top: 86px; width: 100px;">
      <div align="left" class="f2">RUC</div>
    </div>
        <input name="CmdB" type="button" id="CmdB" 
style="position:absolute; left: 626px; top: 109px; width: 57px;"
value="Imprimir" onclick="fPDF();" />

</form>

<form action="ficheroExcel.php" method="post" target="_blank" id="FormularioExportacion" >
<div style="position:absolute; left: 183px; top: 50px; width: 45px; height: 15px;">  
<input name="" type="button" class="botonExcel" value="Exportar" />
<input type="hidden" id="datos_a_enviar" name="datos_a_enviar" />
</div>
</form>
</div>
</body>
</html>
