<?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
extract($_POST);
   $id_cd=$sesion->id;



if($continua==2){
 	$qPP = "SELECT idreg, inversionista.nombre as elnombre, appat, apmat, apagar, cd, banco.nombre as elbanco, nocuenta, status FROM `regs2` join inversionista on 
    inversionista.id_inver=regs2.id_inver left join banco on banco.idbanco=inversionista.banco_idbanco WHERE `status`=8 or status=10 ORDER BY $listacd DESC";


}
    else{
  	$qPP = "SELECT idreg, inversionista.nombre as elnombre, appat, apmat, apagar, cd, banco.nombre as elbanco, nocuenta, status FROM `regs2` join inversionista on 
    inversionista.id_inver=regs2.id_inver left join banco on banco.idbanco=inversionista.banco_idbanco WHERE `status`=8 or status=10";
    
    
    }
	

 $totalin = 0;
  $totalin2 = 0;

$rPP = mysql_query($qPP) or die ('ErrPP: '. mysql_error());

 echo"<br><form name=\"Agrega3\" action=\"entransito.php\" method=\"post\">
  Ordenar Depositos por:<select name = \"listacd\">
   <option value=\"elbanco\">Banco</option>
<option value=\"pagado\">Cantidad</option>
<option value=\"appat\">Apellido P.</option>
<option value=\"idreg\">ID Regalia</option>
  <option value=\"cd\">Centro Dist</option>

 </select>

  <input type=hidden name=continua value=\"2\" />

  <input type=\"submit\" name=\"lista2\"  value=\"Continuar\" />
  
  
  
  </form>";


   
if(!mysql_affected_rows($conexion))
{
	echo "<center>No hay Regalias en Transito por el momento.</center><br>";
    exit;
}




echo "<html>
			<body>
			
			
			<center><b>REGALIAS EN TRANSITO</b>
			
			<br>

	        <table border=\"1\" align=\"center\"><form name=\"transito\" action=\"mandarruta.php\" method=\"post\">
	 ";
	
	
echo " <th></th><th>Estatus</th><th>ID</th><th>Nombre</th><th>A Depositar</th><th>CD</th><th>Banco</th><th>Cuenta</th><th>Pagar</th><th>Regresar a</th>";

while (($objetoPP=mysql_fetch_object($rPP)) )
{
$paga=round($objetoPP->pagado*.93)
$totalin+=$paga;  

	echo "<tr>";
	if($objetoPP->status==10){echo"<td></td><td>En ruta</td>";}else{echo"<td><input type=checkbox name=regas[] value=$objetoPP->idreg ></td><td>Pendiente</td>";}
	
	echo"
			 <td>$objetoPP->idreg</td><td>$objetoPP->elnombre $objetoPP->appat $objetoPP->apmat</td><td>$paga</td><td>$objetoPP->cd</td>
             <td>$objetoPP->elbanco</td><td>$objetoPP->nocuenta</td>
             <td><form name=\"pagar\" action=\"pago_regs.php\" method=\"post\"><input type=hidden name=id_regalia value=$objetoPP->idreg><input type=\"submit\" value=\"PAGAR\" name=\"pago\"></form></td>
             <td><form name=\"pagar\" action=\"regresaregalia.php\" method=\"post\"><input type=hidden name=id_regalia value=$objetoPP->idreg><input type=\"submit\" value=\"POR PAGAR\" name=\"pago\"></form></td>
             ";
             
		
            
		
                 
	echo"
		  </tr> 
		 ";
   
}
echo "</table>
El total de regalias a depsitar $ $totalin<br><br><br><input type=\"submit\" value=\"Enviar a Ruta\" name=\"pago\"></form>"; 
   

?>