<?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
     $id_cd=$sesion->id; $asd="";
 $q2 = "SELECT cantidad, puntos, fechat, transacciones.idtransacciones, tipostr_idtipostr, consec, usuarios_ci_idusuarios_ci, status, rastreo, descripcion, web, statusenvio, telefono, paqueterias.id_paq, referencia, nombre, appat, apmat FROM transacciones join depositos on transacciones.idtransacciones=depositos.transacciones_idtransacciones join inversionista on inversionista.id_inver=transacciones.inversionista_id_inver join pagovta on transacciones.idtransacciones=pagovta.idtransacciones left join guias on guias.idtransacciones=transacciones.idtransacciones left join paqueterias on paqueterias.id_paq=guias.id_paq  WHERE usuarios_ci_idusuarios_ci=$id_cd and (cdentrega=8 or cdentrega=12)and fechat >= NOW() - INTERVAL 10 day order by idtransacciones desc";


  $c2 = mysqli_query($conexion, $q2) or die ('Error en la consulta' . mysqli_error($conexion));

  echo"<center><br><label style='color:#2b385d; font-size:22px; font-weight:bold'>Seguimiento a Pedidos </label><br><br><form name=\"transito\" action=\"agrega_guia.php\" method=\"post\"><center><table border=\"0\"> <tr bgcolor=\"#2b385d\">

			<th></th><th><font color=\"white\">Pedido</th><th></th><th><font color=\"white\">Fecha</th><th><font color=\"white\">Nombre</th><th><font color=\"white\">Cant</th><th><font color=\"white\">Telefono</font></th><th><font color=\"white\">Paqueteria</font></th><th><font color=\"white\">Rastreo</font></th>
			<th><font color=\"white\">Acciones</font></th><th><font color=\"white\">Stat Envio</font></th>

			</tr>";

  for($i=0;$r1 = mysqli_fetch_row($c2);$i++)

   {

	   $a0 = $r1[0];

	   $a1 = $r1[1];

	   $a2 = $r1[2];

	   $a3 = $r1[3];

	   $a4 = $r1[4];

	  $a5 = $r1[5];

	  $a6 = $r1[6];

	  $a7 = $r1[7];
	  
	  $a8 = $r1[8];
	  
	  $a9 = $r1[9];
	   $a10 = $r1[10];
$a11 = $r1[11];$a12 = $r1[12];$a13 = $r1[13];$a14 = $r1[14];$a15 = $r1[15];$a16 = $r1[16];$a17 = $r1[17];
	 	  
if($a4==10){$tipon="VENTA";$conti=1;}if($a4==11){$tipon="SALIDA";$conti=1;}
if($a4==12){$tipon="Asignacion";}
	   $tot+=$a4;
if($a8>0){$conti=0;}
/* $qPP = "select id_pedreal from pedido_real where transacciones=$a7";

$rPP = mysqli_query($conexion, $qPP) or die ('ErrPP: '. mysqli_error($conexion));	   
if (mysqli_affected_rows($conexion)){
	  */

echo"<tr bgcolor=\"#c3dfed\">";
if($a13=1){$asd="?";}
if($conti==1){echo"<td><input type=checkbox name=guias[] value=$a3 ></td>";}else{echo"<td></td>";}

echo"<td>$a6-$a5</td><td>

	<form name=\"pagar\" action=\"pedidos_masinfo.php\" target=\"_blank\" method=\"post\">

			<input type=hidden name=dist value=$id_dist>

			<input type=hidden name=pedido value=$a3>
<input type=hidden name=tipons value=$a9>
			

								 <input type=\"submit\" value=\"INFO\" name=\"infoped\"></form></td><td>$a2</td><td>$a15 $a16 $a17</td><td>$a0</td><td>$a12</td><td>$a9</td><td>$a8</td>";
	if(isset($a8))	{						 
								 
								echo" <td>

	<form name=\"pagar\" action=\"$a10$a8?\" target=\"_blank\" method=\"post\">

			
			

								 <input type=\"submit\" value=\"Rastrear\" name=\"infoped\"></form></td>";}else{
								echo" <td>

	<form name=\"pagar\" action=\"agrega_guia.php\" target=\"_blank\" method=\"post\">
<input type=hidden name=pedsol value='1'>
			

			<input type=hidden name=pedido value=$a3>

			

								 <input type=\"submit\" value=\"+ Guia\" name=\"infoped\"></form></td>
								 ";}

								 echo"<td>$a11</td>
								 
									<td><form name=\"laguia\" action=\"pedido_recibido.php\" method=\"post\">

			<input type=hidden name=dist value=$id_dist>

			<input type=hidden name=pedido value=$a3>
<input type=hidden name=tipons value=$a9><input type=hidden name=elstatu value=$a11>";
			
if($a11=="GENERADO" || $a11=="AVISADO"){ echo"<input type=\"submit\" value=\"llamada\" name=\"infoped\"> ";}
								
								 
								 
								 
								 
								 echo"</form></td></tr>";

	}
	//}

	echo"</table><br><br><input type=\"submit\" value=\"Agregar Guia\" name=\"pago\"></form>";
			
			
?>

