<?

require_once("comun/funciones.php");
 
$query = mysqli_query($link,"select * from hblexpint where booking like '".trim($booking)."%' ");
//echo "select * from hblexpint where booking like '".trim($booking)."%' ";

$q1 = mysqli_query($link,"select referencia from hblexpint where booking like '".trim($booking)."%' ");
$rq1=mysqli_fetch_array($q1);
$referencia=$rq1[referencia];
if($referencia==''){
$q1 = mysqli_query($link,"select referencia_cliente from booking_ssl where booking_ssl like '".trim($booking)."%' ");
 
$rq1=mysqli_fetch_array($q1);
$referencia=$rq1[referencia_cliente];
}
$q2 = mysqli_query($link,"select referencia_lpv from datosbooking where referencia_cliente like '".trim($referencia)."%' ");
$rq2=mysqli_fetch_array($q2);
$referencia_lpv=$rq2[referencia_lpv];

if($referencia==''){
 
	$q12 = mysqli_query($link_impo,"select D.referencia_interteam from datosexpint D inner join bookingexpint B on
	D.files=B.files and B.booking_interteam like '".trim($booking)."%' and D.referencia_interteam<>'' ");
	 
$rq12=mysqli_fetch_array($q12);
	$referencia_interteam=$rq12[referencia_interteam];
 
}

$suma_pza_mbl = "";
$suma_peso_mbl = "";
	 
 
?>
<style>
a.ANCLA1 {
    outline: 0;
    text-decoration: underline; 
	cursor:pointer
}
/*a.ANCLA1{
	color: #0099FF;
}
a.ANCLA1:link {
    color: #0099FF;
}*/

a.ANCLA1:visited {
    color:#090;
	background-color:#0FF;
}

a.ANCLA1:hover {
    /*color:#900; font-weight:bold*/
	color: #F00;
	
}

a.ANCLA1:active {
    color: #33FF66;
}
table.tablas_con_bordes_ tr.yellow td {
	 
	background: #FFC;
	 
	font-weight:bold; 
	text-align:center;
	 border:1PX solid #333;
	vertical-align:middle;
	/*border-collapse:collapse*/
	
	}

	table.tablas_con_bordes_ tr.comun td {
	 border:1PX solid #333;
	text-align:left;
	
	vertical-align:middle;
	 
	/*background: #FFC;*/
	}
	
	table.tablas_con_bordes_{
		  border-collapse:collapse;
		 /* border-collapse:collapse;border-collapse:collapse; */
	}
	</style>
<br />
 
<table width="2000" id="exportar" border="1" class="tablas_con_bordes_" style="font-size:11px" >
  <tr class="yellow" style="text-align:center">
    <TD colspan="2" style="border:none; background-color:transparent">
    <B>
    <b><?= $referencia_lpv !='' ? 'REFERENCIA PUERTO:<br> '.$referencia_lpv : 'HBL SIN REFERENCIA<br>'?>  
    <b><?= ($referencia !='' or $referencia_interteam!='') ? 'REFERENCIA CLIENTE:<br> '.($referencia=='' ? $referencia_interteam : $referencia) : ''?> 
    </B>
    <br /><a style="color:#039; text-decoration:underline"  onClick="todos(this);" >Seleccionar todos los bls</a>
    </TD>
    <td width="250"  align="center" >Booking</td>
    <td  nowrap="nowrap" >Pago MEI</td>
    <td  >Autorizar      </td>
    <td  nowrap="nowrap" >Fecha/Usuario Autorización</td>
    <td width="100"  >Carga Peligrosa</td>
    <td width="100"  >Fecha/Usuario IMO</td>
    <td width="100"  >IMO</td>
    <td width="100"  >Fotos</td>
    <td width="265"  >Marcas</td>
    <td width="86"  >Gross weight</td>
    <td width="103" ><div align="center">Quantity</div></td>
    <td width="83" ><div align="center">Volume</div></td>
    <td width="147" >Pedimento entregado</td>
    <td width="118" >Fecha documentaci&oacute;n</td>
    <td width="167" ><div align="center">Fecha de registro</div></td>
    <!--<td width="124" >Registr&oacute;</td>-->
    <td width="129" ><div align="center">Revisi&oacute;n</div></td>
    <td width="109" ><div align="center">Fecha Revisi&oacute;n</div></td>
  	<td width="176" >Agencia Aduanal</td>
  	<td width="128" >Registrado por</td>
  	<td width="129" >Comentarios</td>
  </tr>
  
<? if(mysqli_num_rows($query)<1){ 
 $array[]='';
 $array1[]=$referencia_interteam;
}
?>
   <?   $k = 1;
   
   
   while($row=mysqli_fetch_array($query)){
   
   
   $array[]=$row[booking];
   $array1[$row[bookingno]]=$referencia;
   $esi=0;$sh='';

   //Validar Carga IMO TOP CEHO
   $vmsgcarimo = "0";
   $qimo=mysqli_query($link ,"select * from booking_ssl where booking_ssl like '%".$row[booking]."%' ");
   if(mysqli_num_rows($qimo)>0){
	$nreg=mysqli_fetch_array($qimo);   
	$vcarga_imo=$nreg[carga_imo];
	if ($vcarga_imo == "1"){$vmsgcarimo = "1";}
	else{$vmsgcarimo = "0";}
   }
   $qimo2=mysqli_query($link ,"select * from detailcargaexpint where bookingno like '%".$row[booking]."%' ");
   $nreg2=mysqli_fetch_array($qimo2);   
   $vusuimo=$nreg2[usuario_imo];
   $vfecimo=$nreg2[fecha_registro];
   if($vfecimo == "0000-00-00 00:00:00"){$vfecimo = "";}
   $vusuimo = $vusuimo."<br>".$vfecimo;
   //Validar Carga IMO END
 
   $query1= mysqli_query($link,"select * from detailcargaexpint where id_bl  = '".$row[idhbl]."'");
 
 
	$qry3=mysqli_query($link_impo,"select booking_interteam from booking_canceled where booking_interteam='".$row[booking]."'");
	$cancelado=0;
	/* esis dhl 25.6.2018 */ 
	if(strpos($row[booking],'EXIT')!==false){
	$queryInt=mysqli_query($link_impo,"SELECT booking FROM `bookingexpint` WHERE booking_interteam LIKE '".$row[booking]."'");
	 if(mysqli_num_rows($queryInt)>0){
		 $rqueryInt=mysqli_fetch_array($queryInt);
		 $bkg=$rqueryInt[0];
		 $sql = mysqli_query($link_impo,"SELECT *  FROM hblexpint_actualizaciones where booking= '$bkg' order by id desc limit 1"); 
		
		if(mysqli_num_rows($sql)>0){
			$rs=mysqli_fetch_array($sql);
			$sh=$rs[shipper];
			$sh1=explode(' ',$rs[shipper]);
			$cn=$rs[consignee];
			$n1=$rs[notify];
			$sh='';
			if(strpos($sh,'DHL')!==false or strpos($sh,'DHL')!==false or strpos($sh,'DHL')!==false){
			$sh='DHL';	
			}
			if(strpos($sh,'KUEHNE')!==false or strpos($sh,'KUEHNE')!==false or strpos($sh,'KUEHNE')!==false){
			$sh='KUEHNE';	
			}
			if(strpos($sh,'JAS ')!==false or strpos($sh,'JAS ')!==false or strpos($sh,'JAS ')!==false){
			$sh='JAS ';	
			}
			if(strpos($sh,'PANALPINA')!==false or strpos($sh,'PANALPINA')!==false or strpos($sh,'PANALPINA')!==false){
			$sh='PANALPINA';	
			}
			if(strpos($sh,'AGILITY')!==false or strpos($sh,'AGILITY')!==false or strpos($sh,'AGILITY')!==false){
			$sh='AGILITY';	
			}
			if($sh==''){
				$sh=$sh1[0];
			}
			$esi=1;
		}
	 }
	}
 
	if(mysqli_num_rows($qry3)>0){
	$cancelado=1;	
	mysqli_query($link,"update hblexpint set status='CANCELADO' where booking = '".$row[booking]."' and booking<>'' "); 
	}
	/* fin de cambio 25.1.2017 */ 
	
  $row1=mysqli_fetch_array($query1);  
  
   $markandnos=$row1[markandnos];
	 $markandnos=$row1[markandnos];
	if($row1[markandnos]=='' and $row1[id_carga_esi_interteam]*1!=0){
		  
			$q1=mysqli_query($link_impo,"select markandnos from detailcargaexpint where id='".$row1[id_carga_esi_interteam]."'");
			 
			if(mysqli_num_rows($q1)>0){
				$rq1=mysqli_fetch_array($q1);
				$markandnos=$rq1[markandnos];
			 
				mysqli_query($link,"update detailcargaexpint  set markandnos='".$rq1[markandnos]."' where 
				id_carga_esi_interteam='".$row1[id_carga_esi_interteam]."'");
				 
			}
 	 
	}
	
  $referencia_cliente = busquedaB($link,"select referencia from hblexpint where idhbl = '".$row1[id_bl]."'",'referencia');
  $referencia_veracruz = busquedaB($link,"select referencia from referencias_veracruz where referencia_cliente = '".$referencia_cliente."'",'referencia');
	//echo '2';
	if(trim($row[status])=='ROLADO' or trim($row[status])=='CANCELADO' or $cancelado==1){ 
				$style='style=" color:red;text-decoration:line-through;text-align:center;  background-color:#CECE9D;"';

	}else{
		$style='style="text-align:center;  background-color:#CECE9D;"';
	}
	//echo trim($bl[status]).' '.$style;
   ?>	   
   <tr class="comun" <?=$style?> >
 
  
    <TD align="center" style="text-align:center" width="40"><?=$k?> 
     
      <a id="bor" href="#"><img title="Borrar BL" align="absbottom" onclick="
     
     if(confirm('Borra este booking <?=$row1[tipo_bl]?>?')){ 
     <? if($row1[tipo_bl]=='MBL'){ ?>
       document.location='../borra_mbl.php?idhbl=<?=$row1[id]=='' ? $row[id] : $row1[id]?>&booking=<?=$row1[bookingno]=='' ? $row[bookingno] : $row1[bookingno]?>&idpater=<?= $row1[id_bl]=='' ? $row[idhbl] : $row1[id_bl]?>&referencia_cliente=<?=$referencia_cliente?>';
      <? }elseif($row1[tipo_bl]=='HBL'){ ?> 
       document.location='../borra_mbl.php?idhbl=<?=$row1[id]=='' ? $row[id] : $row1[id]?>&booking=<?=$row1[bookingno]=='' ? $row[bookingno] : $row1[bookingno]?>&idpater=<?= $row1[id_bl]=='' ? $row[idhbl] : $row1[id_bl]?>&referencia_cliente=<?=$referencia_cliente?>';
      <? }else{ ?>  
       document.location='../borra_mbl.php?idhbl=<?=$row1[id]=='' ? $row[id] : $row1[id]?>&booking=<?=$row1[bookingno]=='' ? $row[bookingno] : $row1[bookingno]?>&idpater=<?= $row1[id_bl]=='' ? $row[idhbl] : $row1[id_bl]?>&referencia_cliente=<?=$referencia_cliente?>';

      <? } ?>
     }" src="https://<?= $_SERVER["SERVER_NAME"]?>/images/eliminar.png"  border="0" style="cursor:pointer" /> 
     </a>
     
    </TD>
 
    
    <TD align="center" style="text-align:center" width="126">
    
     <? if($row1[tipo_bl]=='MBL'){ ?>
     <input name="<?=$k?>" id="<?=$k?>" type="checkbox" value="../pdf/mbl_n.php?booking=<?=base64_encode($row1[bookingno])?>&idhbl=<?=base64_encode($row1[id_bl])?>" />
       
     <a class="ANCLA1"  target="_blank" href="../pdf/mbl_n.php?booking=<?=base64_encode($row1[bookingno])?>&idhbl=<?=base64_encode($row1[id_bl])?>" style="color:#039;text-align:center;text-decoration:underline; cursor:pointer;" title="Exportar a PDF" id="pdf">Recibase MBL ID <?=$row1[id_bl]?></a> 
     <? }else{ ?>
     <input name="<?=$k?>" id="<?=$k?>" type="checkbox" value="../pdf/hbl_n.php?booking=<?=base64_encode($row1[bookingno])?>&idhbl=<?=base64_encode($row1[id_bl])?>" />
     <a class="ANCLA1"  target="_blank" href="../pdf/hbl_n.php?booking=<?=base64_encode($row1[bookingno])?>&idhbl=<?=base64_encode($row1[id_bl])?>" style="color:#039;text-align:center;text-decoration:underline; cursor:pointer;" title="Exportar a PDF" id="pdf">Recibase HBL ID <?=$row1[id_bl]?></a> 
     <? } ?>
     
    </TD>
        <input name="jid_bl[]" type="hidden" id="jid_bl[]" value="<?=$row1[id_bl]?>" />
    <input name="jbookingno[]" type="hidden"  id="jbookingno[]" value="<?=$row1[bookingno]?>" />
    <input name="jtipo[]" type="hidden" id="jtipo[]" value="<?=$row1[tipo_bl]?>"  />
  
    
    <!--<TD align="center" colspan="2" style="text-align:center">
    REVISION</a>
    </TD>-->
    <td style="text-align:center" ><a style="text-decoration:underline; color:#039;text-align:center;cursor:POINTER"  onclick="this.style.color='purple'"  title="Modificar BL" href="../registro_manifiesto.php?id=<?=$row1[id_bl]?>&id_bl=<?=$row1[id_bl]?>&bookingno=<?=$row[booking]?>"/><?=$row1[bookingno]?></a>&nbsp;
      <? if((strpos($row[registrado_por],'DHL')!==false or strpos($row[registrado_por],'KUEHNE')!==false  or strpos($row[registrado_por],'JAS')!==false) or strpos($row[comentarios],'**ESI ON')!==false){ ?>
      <SPAN style="background-color:white; border:2PX SOLID blue; cursor:pointer;text-align:center;"><a  title="<?=$sh //$sh!='DHL' ? $sh : 'DHL'?>" href="../registro_manifiesto.php?bkg=<?=$bkg?>&esi=1&id=<?=$row1[id_bl]?>&id_bl=<?=$row1[id_bl]?>&bookingno=<?=$row[booking]?>#ancla_esi"/>&nbsp;<?=$sh?> <?=$row[CommunicationReference]=='' ? $row[CustomerReference] : $row[CommunicationReference]?></a> </SPAN>
      <? } ?>
      <?
				//$medidas='';
				$volumen='';$numero_bultos=''; 
				 
				$dimen1 =	mysqli_query($link,"select DISTINCT D.booking,D.largo,D.ancho,D.alto,D.fecha_recepcion,D.hora_registro_ingreso,D.numero_bultos from dimensiones D where  booking ='".$row1[bookingno]."' "); // echo mysqli_num_rows($dimen1);
				if(mysqli_num_rows($dimen1)<1){
				$dimen1 =	mysqli_query($link,"select DISTINCT D.booking,D.largo,D.ancho,D.alto,D.fecha_recepcion,D.hora_registro_ingreso,D.numero_bultos from dimensiones D where D.id_partida = '".$row1[id_bl]."' ");	
				}
				 
				if(mysqli_num_rows($dimen1)>0){ 
				   while($rd1=mysqli_fetch_array($dimen1)){
				   //$volumen+=$rd1[largo]*$rd1[ancho]*$rd1[alto]*$rd1[numero_bultos]/1000000;
				   $volumen+=number_format(($rd1[largo]/100) * ($rd1[alto]/100) * ($rd1[ancho]/100) * $rd1[numero_bultos]*1,3);
				   //$medidas.= $rd1[largo].'x'.$rd1[ancho].'x'.$rd1[alto].(mysqli_num_rows($dimen1)>0 ? '<br>' : '');
				   $numero_bultos+=$rd1[numero_bultos];
				   }
				}
			//	echo 'reg '. $row[registrado_por];
				if(mysqli_num_rows($dimen1)<1 /*and (strtoupper(strpos($row[registrado_por],'DHL'))!==false 
				or strtoupper(strpos($row[registrado_por],'KUEHNE'))!==false
				or strtoupper(strpos($row[registrado_por],'JAS'))!==false)*/ ){
				$dimen1 =	mysqli_query($link,"select * from detailcargaexpint where bookingno='".$row1[bookingno]."' 
				and id_bl= '".$row1[id_bl]."'");
				//echo "select * from detailcargaexpint where bookingno='".$row1[bookingno]."' and id_bl= '".$row1[id_bl]."' ";
				$rd1=mysqli_fetch_array($dimen1);
				$numero_bultos=$rd1[bulk];
				//$volumen=$rd1[measurement];
 $weight=$rd1[weight];
				}
				
	?>
      
    </td>
    
    <td style="text-align:center" id="divPagoMei<?=$k?>" <?=$row[pago_mei]=='PENDIENTE' ?
	' bgcolor="red" ' : ($row[pago_mei]=='PAGADO' ?  ' bgcolor="green" ' : "") ?>>
  
    <input name="booking_mei<?=$k?>" id="booking_mei<?=$k?>" type="hidden"  value="<?=$row[booking]?>" />
    
    <input name="TDBOK<?=$k?>" type="hidden"  id="TDBOK<?=$k?>" value="<?=$row[booking]?>" />
	<input name="TDIDBOK<?=$k?>" type="hidden"  id="TDIDBOK<?=$k?>" value="<?=$row[idhbl]?>" />
    <input name="TDREG_POR<?=$k?>" type="hidden"  id="TDREG_POR<?=$k?>" value="<?=$row[registrado_por]?>" />
    <input name="TDPED<?=$k?>" type="hidden"  id="TDPED<?=$k?>" value="<?=$row[pedimento]?>" />
    
     
         <?= ($row[autorizacion]!='Autorizar' and $row[autorizacion]!='NO Autorizar' and $row[autorizacion]!='')  ? 'NA' : $row[pago_mei] ?>

    </td>
    
    <td style="text-align:center">
    <select name="autorizar<?=$k?>" id="autorizar<?=$k?>"
    onchange=" /* REG_POR='<?=$row[registrado_por]?>';PED='<?=$row[pedimento]?>';TBOK='<?=$row[booking]?>';
 
  for(t=1;t<=document.getElementById('cantFilas').value;t++){ 
            if(document.getElementById('TDPED'+t).value!=''){
                if(document.getElementById('TDPED'+t).value==PED && document.getElementById('TDPED'+t).value!='' && document.getElementById('TDBOK'+t).value==TBOK){
                document.getElementById('autorizar'+t).value=this.value;   
                }
            } 
            if(document.getElementById('TDPED'+t).value==''){
                if(document.getElementById('TDREG_POR'+t).value==REG_POR && document.getElementById('TDBOK'+t).value==TBOK){ 
                document.getElementById('autorizar'+t).value=this.value;
                }
            }
    } */">
      <option value=""  <?=$row[autorizacion]=='' ? 'selected="selected"' : ''?>></option>
      <option value="Autorizar" <?=$row[autorizacion]=="Autorizar" ? 'selected="selected"' : ''?>>Autorizar</option>
      <option value="NO Autorizar" <?=$row[autorizacion]=="NO Autorizar" ? 'selected="selected"' : ''?>>NO Autorizar</option>
      
         <option value="MEI EXENTO // LESCHACO" <?=$row[autorizacion]=="MEI EXENTO // LESCHACO" ? 'selected="selected"' : ''?>>MEI EXENTO // LESCHACO</option>
      <option value="MEI EXENTO // DHL" <?=$row[autorizacion]=="MEI EXENTO // DHL" ? 'selected="selected"' : ''?>>MEI EXENTO // DHL</option>
  	  <option value="MEI EXENTO // DSV" <?=$row[autorizacion]=="MEI EXENTO // DSV" ? 'selected="selected"' : ''?>>MEI EXENTO // DSV</option>
      <option value="MEI EXENTO // PAC" <?=$row[autorizacion]=="MEI EXENTO // PAC" ? 'selected="selected"' : ''?>>MEI EXENTO // PAC</option>
 	  <option value="MEI EXENTO // EMERSON" <?=$row[autorizacion]=="MEI EXENTO // EMERSON" ? 'selected="selected"' : ''?>>MEI EXENTO // EMERSON</option>
      <option value="MEI EXENTO // KN" <?=$row[autorizacion]=="MEI EXENTO // KN" ? 'selected="selected"' : ''?>>MEI EXENTO // KN</option>
      <option value="MEI EXENTO // SOLIC. ITT" <?=$row[autorizacion]=="MEI EXENTO // SOLIC. ITT" ? 'selected="selected"' : ''?>>MEI EXENTO // SOLIC. ITT</option>
      <option value="MEI EXENTO // DESP. ITT" <?=$row[autorizacion]=="MEI EXENTO // DESP. ITT" ? 'selected="selected"' : ''?>>MEI EXENTO // DESP. ITT</option> 
    </select>
    </td>
    <td  nowrap="nowrap"  style="text-align:center"><div id="divAutorizo<?=$k?>"><?=$row[usuario_autorizo].' '.$row[fecha_usuario_autorizo]?></div></td>
    <td style="text-align:center">
    <select name="cargimo<?=$k?>" id="cargimo<?=$k?>" onchange="">
	<? if($vmsgcarimo == "1"){?>
      <option value="SI">SI</option>
	<?}else{?>  
      <option value="NO">NO</option>
      <option value="SI">SI</option>
	<?}?>  
    </select>
    </td>
    <td style="text-align:center">
      <?=$vusuimo?>
    </td>
    
    <? $k++;?>
	
	<?
	$suma_pza_mbl  = doubleval($row1[number_of_pieces])+doubleval($row1[no_piezasimoh]);
	$suma_peso_mbl = doubleval($row1[weight])+doubleval($row1[gross_weightimoh]);
	?>
      
    <td style="text-align:center" ><?=$row1[valimoh]?></td>
    <td style="text-align:center"><?= $row[fotos]!='' ? '<a href="'.$row[fotos].'" target="_blank">Fotos</a>' : ''?></td> 
    <td align="center" ><?=$markandnos?></td>
    <td align="center"><?=$suma_peso_mbl?></td>
                 
    
    <td ><div align="center">
    <?=($row[ultimo_update_golmex]!='0000-00-00 00:00:00' and $row[ultimo_update_golmex]!='') ? '<span style="color:green; font-style:italic">**' : ''?>
      <?=$suma_pza_mbl?>
      <?=($row[ultimo_update_golmex]!='0000-00-00 00:00:00' and $row[ultimo_update_golmex]!='') ? '**</span>' : ''?>
    </div></td>
    <td ><div align="center">
    <?=($row[ultimo_update_golmex]!='0000-00-00 00:00:00' and $row[ultimo_update_golmex]!='') ? '<span style="color:green; font-style:italic">**' : ''?>
      <?=number_format($volumen*1,3)?>
      <?=($row[ultimo_update_golmex]!='0000-00-00 00:00:00' and $row[ultimo_update_golmex]!='') ? '**</span>' : ''?>
    </div></td>
    <td ><?=$row[pedimento]?></td>
    <td width="118" style="text-align:center" ><?= ($row[status]=='' ? 'REVISANDO' : $row[status])?> </td>
    <td align="center"><div align="center">
      <?=$row[fechaRegistro]?>
    </div></td>
    <!--<td ><?=$row[registrado_por]?></td>-->
    <td ><div align="center">
      <?=$row[revision]?>
    </div></td>
    <td ><div align="center">
      <?=$row[fecha_revision]?>
    </div></td>
    
         <?
		 
		$link_impo=con_impo();
	

		$datos_aa = data($link_impo,"SELECT A.*,C.nombre_contacto,C.telefono_contacto FROM `agentes_aduanales` A 
		INNER JOIN contactos_agentes_aduanales C
		on A.patente=C.patente and A.id=C.idaa and (A.registro = 'ALTAMIRA' or A.registro = 'INTERTEAM') and C.email_contacto LIKE '%".$row["registrado_por"]."%' ");

		$agente_aduanal  = $datos_aa[nombre_agente_aduanal];
		$nombre_empresa  = $datos_aa[nombre_empresa];
		$nombre_contacto  = $datos_aa[nombre_contacto];
		$telefono_contacto  = $datos_aa[telefono_contacto];
		con_ver();
		?>
        
    <td style="font-size:10px"><?=$nombre_empresa?></td>
    <td align="center" ><?=$row[registrado_por]?></td>
    <td >
	<?=($row[ultimo_update_golmex]!='0000-00-00 00:00:00' and $row[ultimo_update_golmex]!='') ? 
	'<span style="color:green; font-style:italic">**Webservice Golmex** '.$row[ultimo_update_golmex].'</span>' : ''?>
	<?=$row[comentarios]!='' ? $row[comentarios].'<br>' : $row[comentarios]?> 
	<?=  str_replace("\n","<br>",$row1[comentarios]) ?>
	</td>
  

    
    </td>
  </tr>

 
  <? } 
  $cant = $k-1;
  
  ?>  
  
  
   <input name="cantFilas" id="cantFilas" type="hidden" value="<?=$cant ?>" />
  
  
  <!--- carga sin documentar ------>
  <? 
  if(mysqli_num_rows($query)<1 and $referencia_interteam!=''){
 
	$qry3=mysqli_query($link_impo,"select files,booking_interteam from bookingexpint where booking_interteam like '".trim($booking)."%' ");
	 
	$r8=mysqli_fetch_array($qry3);
	$files=$r8["files"];
	$unicos=array_unique($array);
	 
	$cantidad_bookings = count(array_unique($array));
 
/*$qry3=mysqli_query("select booking_interteam,customsagent from bookingexpint where referencia_int like '".trim($referencia_cliente)."%' order by booking_interteam");
		if(mysqli_num_rows($qry3)<1){
$qry3=mysqli_query("select booking_interteam,customsagent from bookingexpint where files='".$files."' order by booking_interteam");
	
		}*/
	$qry3=mysqli_query($link_impo,"select booking_interteam,customsagent from bookingexpint where booking_interteam='".$booking."' order by booking_interteam");
	//echo "select booking_interteam,customsagent from bookingexpint where files='".$files."' order by booking_interteam";
	// echo mysqli_num_rows($qry3);
	//}
 
	 
		while($r8=mysqli_fetch_array($qry3)){
			 //echo $r8[booking_interteam].'  ---> r i '.$array1[$r8[booking_interteam]]. ' rc v '.$referencia_cliente.'<br>';
			 
				$finales[]=$r8[booking_interteam];
				$customsagent[]=$r8[customsagent];
			 
		}
	
	 

	$i=0;	
	if(count($finales)>0){
	while($i<count($finales)){
		?>
    <tr class="comun" <?=$style?>  >
    <TD align="center" style="text-align:center;" width="40px"><?=$k?></TD>
    
    <TD align="center" style="text-align:center" width="150px"></TD>
    
    <? $k++;?>
    
  
    <td style="text-align:center"> <SPAN style="background-color:#FFF; COLOR:blue; border:2PX SOLID blue">&nbsp;<a style="text-decoration:underline; color:#039;text-align:center;cursor:POINTER" title="REVISION" href="../registro_manifiesto3.php?booking_interteam=<?=$finales[$i]?>"/><?=$finales[$i]?></a>&nbsp;</SPAN> </td>
    <td ></td>
    <td ></td>
    <td ></td>
    <td style="text-align:center">&nbsp;</td>
    <td style="text-align:center">&nbsp;</td> 
    <td style="text-align:center">&nbsp;</td> 
    <td style="text-align:center">&nbsp;</td> 
    <td align="center" > <SPAN style="background-color:#FFF; COLOR:blue; border:2PX SOLID blue">&nbsp;SIN DOCUMENTAR&nbsp;</SPAN></td>
    <td style="text-align:center">&nbsp;</td> 
    <td align="center"><?=$row1[weight]?></td>
         
    
    <td ><div align="center">
      <?=$numero_bultos?>
    </div></td>
    <td ><div align="center">
      <?=number_format($volumen*1,3)?>
    </div></td>
    <td > </td>
    <td width="150" style="text-align:center" ></td>
    <td align="center"><div align="center">
      <?=$row1[fechaRegistro]?>
    </div></td>
  
    <td ><div align="center">
     
    </div></td>
    <td ><div align="center">
      
    </div></td>
    <td style="font-size:10px"> <SPAN style="background-color:#FFF; COLOR:blue; border:2PX SOLID blue">&nbsp;<?=$customsagent[$i]?>&nbsp;</SPAN></td>
    <td align="center" > </td>
    <td > </td>
  </tr>
    <? $i++;
	} }
	}
		con_ver();
	?>
    
     <? 
	 if(mysqli_num_rows($query)<1 and $referencia_interteam==''){
	//%%%%%%%%%%%%%%%%%%%%%% BOOKINGS SIN DOCUMENTAR DE REFERENCIAS DE VERACRUZ %%%%%%%%%%%%%%%%%%%%%% 
 
 
	unset($finales);unset($customsagent);
	$unicos=array_unique($array);
	$cantidad_bookings = count(array_unique($array));
 
	$qry3=mysqli_query($link,"SELECT * FROM booking_ssl where booking_ssl like '".trim($booking)."%' order by booking_ssl");
 $r8=mysqli_fetch_array($qry3);
				$finales[]=$r8[booking_ssl];
		 
	
	 

	$i=0;	
	if(count($finales)>0){
	while($i<count($finales)){
		?>
    <tr class="comun" <?=$style?>  >
    <TD align="center" style="text-align:center;" width="40px"><?=$k?></TD>
    
    <TD align="center" style="text-align:center" width="150px"></TD>
    
    <? $k++;?>
    
  
    <td style="text-align:center"> <SPAN style="background-color:#FFF; COLOR:blue; border:2PX SOLID blue">&nbsp;<a style="text-decoration:underline; color:#039;text-align:center;cursor:POINTER" title="REVISION" href="../registro_manifiesto3.php?booking_interteam=<?=$finales[$i]?>"/><?=$finales[$i]?></a>&nbsp;</SPAN> </td>
    <td ></td>
    <td ></td>
    <td ></td>
    <td style="text-align:center">&nbsp;</td>
    <td style="text-align:center">&nbsp;</td> 
    <td style="text-align:center">&nbsp;</td> 
    <td style="text-align:center">&nbsp;</td> 
    <td align="center" > <SPAN style="background-color:#FFF; COLOR:blue; border:2PX SOLID blue">&nbsp;SIN DOCUMENTAR&nbsp;</SPAN></td>
    <td style="text-align:center">&nbsp;</td> 
    <td align="center"><?=$row1[weight]?></td>
         
    
    <td ><div align="center">
      <?=$numero_bultos?>
    </div></td>
    <td ><div align="center">
      <?=number_format($volumen*1,3)?>
    </div></td>
    <td > </td>
    <td width="150" style="text-align:center" ></td>
    <td align="center"><div align="center">
      <?=$row1[fechaRegistro]?>
    </div></td>
  
    <td ><div align="center">
     
    </div></td>
    <td ><div align="center">
      
    </div></td>
     <td style="font-size:10px"></td>
    <td align="center" > </td>
    <td > </td>
  </tr>
    <? $i++;
	} }}
		?>
  </table>
<div style="width:2000px" align="left">
  <input name="input" type="button" value="Guardar" onclick=" 
                  <? if($_SESSION['user']==''){ ?>
                  alert('Se perdio la sesion. Vuelva a iniciar sesion.');
                  return;
                  <? } ?> 
                  <? 
				  for($fila=1;$fila<=$k;$fila++){?>
                  realizaProceso('<?=$fila?>',<?=$k-1;?>);
                  <? } ?>  
                  " />
</div>
<br />