<?php
   
   include("../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, estatus_idestatus, referencia, vip FROM inversionista WHERE rfc LIKE '%".$_POST['busq']."%' OR nombre LIKE '%".$_POST['busq']."%' OR appat LIKE '%".$_POST['busq']."%' OR apmat LIKE '%".$_POST['busq']."%' OR referencia LIKE '%".$_POST['busq']."%' OR ciudad LIKE '%".$_POST['busq']."%'";
   else 
   $qa = "SELECT id_inver, rfc, nombre, appat, apmat, estatus_idestatus, referencia, vip FROM inversionista WHERE $filtro LIKE '%".$_POST['busq']."%'";
   $ca = mysql_query($qa) or die ('Error (Registro No Encontrado): ' . mysql_error());

   if(mysql_affected_rows())
   {
       	
   	
	$id = $ra->id_inver;
    $rfc = $ra->rfc;
	$nombre = $ra->nombre;
	$apat = $ra->appat;
	$amat = $ra->apmat;
    $estatus = $ra->estatus_idestatus;
	$ref = $ra->referencia;
	
		echo "<html>";
		echo "<head> </head>";
 		echo "<body>";
 		echo "<center>";
 		echo "<div style='background: url(logotransp2.gif); width:500;'>";
  		echo "<form name='f1' action='regwithprom.php' method='post'>";
 		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>Referencia</th><th>Tipo</th>";
		while($ra = mysql_fetch_object($ca))
		{
			
			$vip = $ra->vip;
    if($vip==0){$tipo="RRB";}else{$tipo="<font color=\"blue\">VIP</font>";}
			
			
 		echo "<tr height='40'><td>$ra->rfc </td><td>$ra->nombre $ra->appat $ra->apmat</td><td> $ra->referencia</td><td> $tipo</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>";
   }
?>