<?php
require_once("comun/conex_ver.php");
require_once("comun/conexion3.php");

require_once("comun/actions.php");

require_once("comun/funciones.php");

$action = new actions();
$link_impo=con_impo();$link=con_ver();
  function valorate($valor){
	$valor = str_replace("'","\'",$valor);
	return $valor;
}
$rol= valorate($_GET['rol']);
$user= valorate($_GET['user']);
$email_aa= valorate($_GET['email']);
$txtbooking= trim(valorate($_POST['h_booking']));

if($txtbooking==''){
	$txtbooking= trim(valorate($_GET['booking']));
}
//   $action->alert($email_aa);
 //  $action->alert($txtbooking);
$q=data($link_impo,"select * from bookingexpint where booking_interteam like '$txtbooking%'");

if($q[files]==''){
	/*$action->add_js_code("document.getElementById('mensaje').innerHTML='Este booking no existe';
    document.getElementById('submit').disabled=true;
	document.getElementById('submit1').disabled=true;
	");*/
	$action->text('booking','');
	$action->text('pol','');
	$action->text('pod','');
	$action->text('final_destination','');
	$action->text('vessel','');
	$action->text('referencia','');
	$action->text('shipper_file','');
	
			$action->text('shipper1','');
			$action->text('shipper2','');
			$action->text('shipper3','');
			$action->text('shipper4','');
			$action->text('shipper5','');
			$action->text('shipper6','');
			
			$action->text('consignee1','');
			$action->text('consignee2','');
			$action->text('consignee3','');
			$action->text('consignee4','');
			$action->text('consignee5','');
			$action->text('consignee6','');
			
			$action->text('notify1','');
			$action->text('notify2','');
			$action->text('notify3','');
			$action->text('notify4','');
			$action->text('notify5','');
			$action->text('notify6','');
	
	$action->text('h_booking','');
	$action->text('h_pol','');
	$action->text('h_pod','');
	$action->text('h_final_destination','');
	$action->text('h_vessel','');
	$action->text('h_referencia','');
	$action->text('h_shipper_file','');
	
}else{
 		$datos=data($link_impo,"select * from datosexpint where files = '".$q[files]."'");
 
		if($datos[files]==''){
			/*$action->add_js_code("document.getElementById('mensaje').innerHTML='Este booking no existe';
			document.getElementById('submit').disabled=true;
			document.getElementById('submit1').disabled=true;
			");*/
			$action->text('booking','');
			$action->text('pol','');
			$action->text('pod','');
			$action->text('final_destination','');
			$action->text('vessel','');
			$action->text('referencia','');
			$action->text('shipper_file','');
			
			$action->text('status','');
			$action->text('registrado_por','');
			$action->text('status_cambiado','');
			$action->text('h_status','');
			$action->text('h_status_cambiado','');
			
			$action->text('shipper1','');
			$action->text('shipper2','');
			$action->text('shipper3','');
			$action->text('shipper4','');
			$action->text('shipper5','');
			$action->text('shipper6','');
			
			$action->text('consignee1','');
			$action->text('consignee2','');
			$action->text('consignee3','');
			$action->text('consignee4','');
			$action->text('consignee5','');
			$action->text('consignee6','');
			
			$action->text('notify1','');
			$action->text('notify2','');
			$action->text('notify3','');
			$action->text('notify4','');
			$action->text('notify5','');
			$action->text('notify6','');
		
			$action->text('h_booking','');
			$action->text('h_pol','');
			$action->text('h_pod','');
			$action->text('h_final_destination','');
			$action->text('h_vessel','');
			$action->text('h_referencia','');
			$action->text('h_shipper_file','');
			
			//$action->text('registrado_por','');
		
			
		}else{
 

		$demas_datos = data($link ,"select * from hblexpint where booking = '".$txtbooking."' and tipo = 'MBL'");
		
		$action->add_js_code("limpiar_hbl();");
		 
			$action->text('status',$demas_datos[status]);
			$action->text('registrado_por',valorate($demas_datos[registrado_por]));
			$action->text('status_cambiado',$demas_datos[status]);
			$action->text('h_status','');
			$action->text('h_status_cambiado','');
			
			$action->text('tarja',valorate($demas_datos[tarja]));
			
		$action->text('booking',valorate($txtbooking));
		$action->text('pol',valorate($datos[pol]).', '.valorate($datos[pol_country]));
		$action->text('pod',valorate($datos[pod]).', '.valorate($datos[pod_country]));
		$action->text('final_destination',valorate($datos[finaldestination]));
		$action->text('vessel',valorate($datos[vessel]));
		$action->text('referencia',valorate($datos[referencia_interteam]));
		$action->text('shipper_file',valorate($demas_datos[shipper_file]));
		
		// &&&&& DATOS DE SHIPPER CONSIGNEE Y NOTIFY &&&&&&&&&&&&&&
		$action->text('shipper1',valorate($demas_datos[shipper]));
        $action->text('shipper2',valorate($demas_datos[shipper2]));
        $action->text('shipper3',valorate($demas_datos[shipper3]));
        $action->text('shipper4',valorate($demas_datos[shipper4]));
        $action->text('shipper5',valorate($demas_datos[shipper5]));
        $action->text('shipper6',valorate($demas_datos[shipper6]));
        
        $action->text('consignee1',valorate($demas_datos[consignee]));
        $action->text('consignee2',valorate($demas_datos[consignee2]));
        $action->text('consignee3',valorate($demas_datos[consignee3]));
        $action->text('consignee4',valorate($demas_datos[consignee4]));
        $action->text('consignee5',valorate($demas_datos[consignee5]));
        $action->text('consignee6',valorate($demas_datos[consignee6]));
        
        $action->text('notify1',valorate($demas_datos[notify]));
        $action->text('notify2',valorate($demas_datos[notify2]));
        $action->text('notify3',valorate($demas_datos[notify3]));
        $action->text('notify4',valorate($demas_datos[notify4]));
        $action->text('notify5',valorate($demas_datos[notify5]));
        $action->text('notify6',valorate($demas_datos[notify6]));
		// &&&&& DATOS DE SHIPPER CONSIGNEE Y NOTIFY &&&&&&&&&&&&&&
		
		$action->text('h_booking',valorate($txtbooking));
		$action->text('h_pol',valorate($datos[pol]).', '.valorate($datos[pol_country]));
		$action->text('h_pod',valorate($datos[pod]).', '.valorate($datos[pod_country]));
		$action->text('h_final_destination',valorate($datos[finaldestination]));
		$action->text('h_vessel',valorate($datos[vessel]));
		$action->text('h_referencia',valorate($datos[referencia_interteam]));
		$action->text('h_shipper_file',valorate($demas_datos[shipper_file]));
		 
		 $cargo = data($link ,"select * from detailcargaexpint where bookingno = '".$txtbooking."' and tipo_bl = 'MBL'");
		
 //$action->alert("select * from detailcargaexpint where bookingno = '".$txtbooking."' and tipo_bl = 'MBL'");
			$action->text('largo',valorate($cargo[largo]));
			$action->text('ancho',valorate($cargo[ancho]));
			$action->text('alto',valorate($cargo[alto]));
			
		    $action->text('marks',valorate($cargo[markandnos]));
			$action->text('quantity',valorate($cargo[bulk]));
			$action->text('type_of_bulks',valorate($cargo[type_of_bulks]));
			$action->text('description',valorate($cargo[cargo]));
			$action->text('no_piezas',valorate($cargo[number_of_pieces]));
			$action->text('gross_weight',valorate($cargo[weight]));
			$action->text('net_weight',valorate($cargo[netweight]));
			$action->text('volume',valorate($cargo[measurement]));
			$action->text('harmonized_code',valorate($cargo[harmonized_code]));
			$action->text('ams',valorate($cargo[ams]));
			
		
 	}
}

if($datos[files]==''){
			con_ver();
			$referencia_cliente = busquedaB($link,"select referencia from hblexpint where booking like '".$txtbooking."%'","referencia");
			$datos=data($link ,"select * from datosbooking where referencia_cliente = '".$referencia_cliente."' and referencia_cliente<>''"); 
			//BUSZALO10
			//ZAPATA
			
			$action->add_js_code("limpiar_hbl();");
			$action->text('h_booking',valorate($txtbooking));
			$action->text('h_pol','ALTAMIRA, TAMAULIPAS');
			$action->text('h_pod',valorate($datos[pod]) );
			$action->text('h_final_destination',valorate($datos[finaldestination]));
			$action->text('h_vessel',valorate($datos[vessel]));
			$action->text('h_referencia',valorate($datos[referencia_cliente]));
			$action->text('h_shipper_file',valorate($demas_datos[referencia_cliente]));
			
			$action->text('booking',valorate($txtbooking));
			$action->text('pol','ALTAMIRA, TAMAULIPAS');
			$action->text('pod',valorate($datos[pod]) );
			$action->text('final_destination',valorate($datos[finaldestination]));
			$action->text('vessel',valorate($datos[vessel]));
			$action->text('referencia',valorate($datos[referencia_cliente]));
			
			
			$demas_datos = data($link, "select * from hblexpint where booking = '".$txtbooking."' and tipo = 'MBL'");
			
			$action->text('registrado_por',valorate($demas_datos[registrado_por]));			
					$action->text('status',$demas_datos[status]);	

					$action->text('shipper_file',valorate($demas_datos[referencia_cliente]));
					$action->checked('cargo_vacio',$demas_datos[cargo_vacio]);
					
					// &&&&& DATOS DE SHIPPER CONSIGNEE Y NOTIFY &&&&&&&&&&&&&&
					$action->text('shipper1',valorate($demas_datos[shipper]));
					$action->text('shipper2',valorate($demas_datos[shipper2]));
					$action->text('shipper3',valorate($demas_datos[shipper3]));
					$action->text('shipper4',valorate($demas_datos[shipper4]));
					$action->text('shipper5',valorate($demas_datos[shipper5]));
					$action->text('shipper6',valorate($demas_datos[shipper6]));
					
					$action->text('consignee1',valorate($demas_datos[consignee]));
					$action->text('consignee2',valorate($demas_datos[consignee2]));
					$action->text('consignee3',valorate($demas_datos[consignee3]));
					$action->text('consignee4',valorate($demas_datos[consignee4]));
					$action->text('consignee5',valorate($demas_datos[consignee5]));
					$action->text('consignee6',valorate($demas_datos[consignee6]));
					
					$action->text('notify1',valorate($demas_datos[notify]));
					$action->text('notify2',valorate($demas_datos[notify2]));
					$action->text('notify3',valorate($demas_datos[notify3]));
					$action->text('notify4',valorate($demas_datos[notify4]));
					$action->text('notify5',valorate($demas_datos[notify5]));
					$action->text('notify6',valorate($demas_datos[notify6]));
		
					$cargo = data($link,"select * from detailcargaexpint where bookingno = '".$txtbooking."' and 
								  tipo_bl = 'MBL'");
				
					
					$action->text('marks',valorate($cargo[markandnos]));
					$action->text('quantity',valorate($cargo[bulk]));
					$action->text('type_of_bulks',valorate($cargo[type_of_bulks]));
					$action->text('description',valorate($cargo[cargo]));
					$action->text('no_piezas',valorate($cargo[number_of_pieces]));
					$action->text('gross_weight',valorate($cargo[weight]));
					$action->text('net_weight',valorate($cargo[netweight]));
					$action->text('volume',valorate($cargo[measurement]));
					$action->text('harmonized_code',valorate($cargo[harmonized_code]));
					$action->text('ams',valorate($cargo[ams]));
					
		}
		
		$action->add_js_code("document.getElementById('mensaje').innerHTML='<br>';
		document.getElementById('submit').disabled=false;
		document.getElementById('submit1').disabled=false;	
		document.getElementById('booking').click();
		"); //LstAjax('divPartidas','partidas_bl.php?booking=".$txtbooking."');
$action->send_response();

return;

?> 

