<?php

require_once("../comun/conexion3.php");

require_once("../comun/actions.php");

require_once("../comun/funciones.php");

$action = new actions();
$link_impo=con_impo();
$usuario= strtoupper($_GET['idusuario']);

$txtbooking= trim(strtoupper($_POST['booking']));
   
$q=data($link_impo,"select * from bookingexpint where booking_interteam like '$txtbooking%'");
//$action->alert("select * from bookingexpint where booking_interteam like '$txtbooking%'");
//$action->alert($q[files]);
if($q[files]==''){
	$action->add_js_code("document.getElementById('mensaje').innerHTML='Este booking no existe';
    document.getElementById('submit').disabled=true;");
	$action->text('pol','');
	$action->text('pod','');
	$action->text('final_destination','');
	$action->text('vessel','');
	$action->text('referencia','');
}else{
	if($usuario<>$q[idaa]){
		$r=$q[idaa];
		$action->add_js_code("document.getElementById('mensaje').innerHTML='Este booking no corresponde a este Agente Aduanal';
		document.getElementById('submit').disabled=true;"); // USUARIO $usuario IDAA $r
		$action->text('pol','');
		$action->text('pod','');
		$action->text('final_destination','');
		$action->text('vessel','');
		$action->text('referencia','');
	}else{
		$datos=data($link_impo,"select * from datosexpint where files = '".$q[files]."'");
		//$action->alert($datos[files]);
		if($datos[files]==''){
			$action->add_js_code("document.getElementById('mensaje').innerHTML='Este booking no existe';
			document.getElementById('submit').disabled=true;");
			$action->text('pol','');
			$action->text('pod','');
			$action->text('final_destination','');
			$action->text('vessel','');
			$action->text('referencia','');
		}

		$action->text('pol',$datos[pol].', '.$datos[pol_country]);
		$action->text('pod',$datos[pod].', '.$datos[pod_country]);
		$action->text('final_destination',$datos[finaldestination]);
		$action->text('vessel',$datos[vessel]);
		$action->text('referencia',$datos[referencia_interteam]);
		//$action->alert($datos[pol]);
		$action->add_js_code("document.getElementById('mensaje').innerHTML='<br>';
		document.getElementById('submit').disabled=false;
		");
		/*$action->add_js_code("
		if(confirm('Confirma el ingreso de datos de este BL? NO PODRA REALIZAR NINGUN CAMBIO UNA VEZ ENVIADO.')) {
			Guardar()
		}");*/
	}
}


$action->send_response();

return;

?> 

