<?php
session_start();

include_once("../scripts/connect.php");
               include("../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: ../login.php?err=NoSesion");
    }/*no hay sesion*/

    else{
       $dato=explode("|",$_SESSION['usuario']);
       $sesion->setDatos($dato[0],$dato[1],$dato[2]);
    }
    //fin validar session

  $conexion=conecta_default();

   
	   
	echo"
	<br><center><label style='color:#5C3C12; font-size:28px; font-weight:bold'>5 Generaciones Arriba</label><br><br>Ingresa el RFC<br><br></center>
	<form name=\"Agrega\" action=\"5gen.php\" method=\"post\">
	<div align=\"center\">
	<table>
		<tr>
	<td>
	Cantidad:<td/>
	<td><input type=\"text\" name=\"rfc\" value=\"\"></td>";
	 echo"<td>
	<br><input type=\"submit\" name=\"generar\" id=\"aceptar\" value=\"Generar\" />
	</td>
							</tr>
						
	
	
	  
      </table>
  </form><br><br>";
  
 
  $total =$_POST['rfc'];
  
  
  
 $qcc1 = "SELECT rfc, nombre, appat, apmat, idprom FROM inversionista WHERE rfc = \"$total\" ";
           $ccc1 = mysqli_query($conexion, $qcc1) or die ('No se pudo hacer la consulta cc1' . mysqli_error($conexion));
           $rrc = mysqli_fetch_row($ccc1);
  
          echo "<b>$rrc[0] $rrc[1] $rrc[2] $rrc[3]</b><br>"; $promotor=$rrc[4];
          
          
          echo "<table border=\"1\"><tR><th>Gen Arriba</th><th>R.F.C.</th><th>Nombre</th></tr>";
 
 $qcc1 = "SELECT rfc, nombre, appat, apmat, idprom FROM inversionista WHERE id_inver = \"$promotor\" ";
           $ccc1 = mysqli_query($conexion, $qcc1) or die ('No se pudo hacer la consulta cc1' . mysqli_error($conexion));
           $rrc = mysqli_fetch_row($ccc1);
  
          echo "<tr><td>Primera 10%</td><td>$rrc[0]</td><td> $rrc[1] $rrc[2] $rrc[3]</td></tr>"; $promotor=$rrc[4];
          
 
  $qcc1 = "SELECT rfc, nombre, appat, apmat, idprom FROM inversionista WHERE id_inver = \"$promotor\" ";
           $ccc1 = mysqli_query($conexion, $qcc1) or die ('No se pudo hacer la consulta cc1' . mysqli_error($conexion));
           $rrc = mysqli_fetch_row($ccc1);
  
          echo "<tr><td>Segunda 17%</td><td>$rrc[0]</td><td> $rrc[1] $rrc[2] $rrc[3]</td></tr>"; $promotor=$rrc[4];       
            
  $qcc1 = "SELECT rfc, nombre, appat, apmat, idprom FROM inversionista WHERE id_inver = \"$promotor\" ";
           $ccc1 = mysqli_query($conexion, $qcc1) or die ('No se pudo hacer la consulta cc1' . mysqli_error($conexion));
           $rrc = mysqli_fetch_row($ccc1);
  
          echo "<tr><td>Tercera 17%</td><td>$rrc[0]</td><td> $rrc[1] $rrc[2] $rrc[3]</td></tr>"; $promotor=$rrc[4]; 
   $qcc1 = "SELECT rfc, nombre, appat, apmat, idprom FROM inversionista WHERE id_inver = \"$promotor\" ";
           $ccc1 = mysqli_query($conexion, $qcc1) or die ('No se pudo hacer la consulta cc1' . mysqli_error($conexion));
           $rrc = mysqli_fetch_row($ccc1);
  
          echo "<tr><td>Cuarta 17%</td><td>$rrc[0]</td><td> $rrc[1] $rrc[2] $rrc[3]</td></tr>"; $promotor=$rrc[4];
   $qcc1 = "SELECT rfc, nombre, appat, apmat, idprom FROM inversionista WHERE id_inver = \"$promotor\" ";
           $ccc1 = mysqli_query($conexion, $qcc1) or die ('No se pudo hacer la consulta cc1' . mysqli_error($conexion));
           $rrc = mysqli_fetch_row($ccc1);
  
          echo "<tr><td>Quinta 1%</td><td>$rrc[0]</td><td> $rrc[1] $rrc[2] $rrc[3]</td></tr>"; $promotor=$rrc[4];
  
  echo "</table>";
?>