<?php
session_start();
   
   include_once("../scripts/connect.php");
   $conexion=conecta_default();
   
   include_once("../scripts/session.php");
   //Validar Session

    $sesion=new Sesion("","","");/*Se crea un objeto nuevo con el privilegio necesario para la pag. actual*/

    if(!$sesion->isValida("4")){ /*Sesion invalida*/

	 header("Location: ../index.php?err=NoSesion");

    }/*no hay sesion*/

    else{

       $dato=explode("|",$_SESSION['usuario']);
       $sesion->setDatos($dato[0],$dato[1],$dato[2]);
       $sesion->setSesion();

    }
    //fin validar session
   $filtro = $_POST['filtro']; 

   if($filtro == '0')
   $qa = "SELECT id_inver, rfc, nombre, appat, apmat, tel1, tel2, ciudad, estatus_idestatus, referencia FROM inversionista WHERE rfc LIKE '%".$_POST['busq']."%' OR nombre LIKE '%".$_POST['busq']."%' OR appat LIKE '%".$_POST['busq']."%' OR apmat LIKE '%".$_POST['busq']."%' OR ciudad LIKE '%".$_POST['busq']."%' OR referencia LIKE '%".$_POST['busq']."%'";
   else 
   $qa = "SELECT id_inver, rfc, nombre, appat, apmat, estatus_idestatus FROM inversionista WHERE $filtro LIKE '%".$_POST['busq']."%'";
   $ca = mysqli_query($conexion, $qa) or die ('Error (Registro No Encontrado): ' . mysqli_error($conexion));

   if(mysqli_affected_rows($conexion))
   {
       	
   	
	$id = $ra->id_inver;
    $rfc = $ra->rfc;
	$nombre = $ra->nombre;
	$apat = $ra->appat;
	$amat = $ra->apmat;
    $estatus = $ra->estatus_idestatus;
    
		echo "<html>";
		echo "<head> </head>";
 		echo "<body>";
 		echo "<center>";
 		echo "<div style='background: url(logotransp2.gif); width:500;'>";
  	
 		echo "<br /><br />";
  		echo "<center><label style='color:#5C3C12; font-size:28px; font-weight:bold'>INVERSIONISTAS ENCONTRADOS</label></center>";
  		echo "<br />";
  		echo "<table border='1' width='500' align='center'><th>RFC.</th><th>Nombre</th><th>telefono</th><th>telefono</th><th>Ciudad</th><th>Referencia</th>";
		while($ra = mysqli_fetch_object($ca))
		{
 		echo "<tr height='40'><td>$ra->rfc</td> <td>$ra->nombre $ra->appat $ra->apmat</td><td>$ra->tel1</td><td>$ra->tel2</td><td>$ra->ciudad</td><td>$ra->referencia</td>
		<td><form name=\"busca\" action=\"updateusr.php\" method=\"post\">
			<input type=hidden name=idinv value=$ra->id_inver />
<input type=\"submit\" name=\"buscar\" id=\"continuar\" value=\"Modificar\" /></form></td>
		</tr>";
		}
		echo "</table>";
  		echo "</form>";
  		echo "</div>";
  		echo "</center>";
 		echo "</body>";
		echo "</html>";

   }
   else
   {
   	echo "<html>";
   	echo "<head><meta http-equiv='Refresh' content='3;URL=javascript: history.go(-1)'></head>";
    echo "<center>";
   	echo "<div style='width:500px; height:400; background: url(logotransp2.gif)'";
   	echo "<form name='form1' action='index.php' method='post' style='padding-top:120px'>";
   	echo "<label style='color:#FF0000; font-weight:bold; font-size:26px; padding-left:30px;'>ERROR:</label> <br /> <label style='color:#5C3C12; font-weight:bold; font-size:22px; padding-left:30px;'> NO HAY COINCIDENCIAS ENCONTRADAS FAVOR DE VERIFICAR.</label>";
    echo "<br /><br />Pulsa <a onclick='javascript: history.go(-1)' style='cursor:pointer; color:#5C3C12'>aqu&iacute;</a> si tu navegador no te redirecciona automaticamente";
   	
   	echo "</form>";
   	echo "</div>";
    echo "</center>";
    echo "</html>";
   }
?>