<?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();
$CONIMPO=con_impo();

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['booking']));

if($txtbooking==''){
	$txtbooking= trim(valorate($_GET['booking']));
}
//   $action->alert($email_aa);
 //  $action->alert($txtbooking);
$q=data($CONIMPO,"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;
	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->add_js_code("limpiar_hbl();");
	
			$action->text('tarja','');
			$action->text('largo','');
			$action->text('ancho','');
			$action->text('alto','');
			
			$action->text('marks','');
			$action->text('quantity','');
			$action->text('type_of_bulks','');
			$action->text('description','');
			$action->text('no_piezas','');
			$action->text('gross_weight','');
			$action->text('net_weight','');
			$action->text('volume','');
			$action->text('harmonized_code','');
			$action->text('ams','');
	
}else{
 		$datos=data($CONIMPO,"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('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->add_js_code("limpiar_hbl();");
			$action->text('tarja','');
			$action->text('largo','');
			$action->text('ancho','');
			$action->text('alto','');
					
			$action->text('marks','');
			$action->text('quantity','');
			$action->text('type_of_bulks','');
			$action->text('description','');
			$action->text('no_piezas','');
			$action->text('gross_weight','');
			$action->text('net_weight','');
			$action->text('volume','');
			$action->text('harmonized_code','');
			$action->text('ams','');
		
		}else{
$CONVER=con_ver();
		//$shipper_file = busquedaB("select shipper_file from hblexpint where referencia = '".$datos[referencia_interteam]."' and booking = '".$txtbooking."'","shipper_file");

		$demas_datos = data($CONVER,"select * from hblexpint where booking = '".$txtbooking."' and tipo = 'MBL'");
		
		
					
		$action->text('status',$demas_datos[status]);
		$action->text('status_cambiado',$demas_datos[status]);

		$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]));
		
				$action->add_js_code("limpiar_hbl();");
		 
		$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]));


		if($demas_datos[booking]==''){
			$action->alert("El agente aduanal no documento Master BL");
			/*$action->add_js_code("document.getElementById('mensaje').innerHTML='<br>';
			document.getElementById('submit').disabled=false;
			document.getElementById('submit1').disabled=false;");*/
			$action->add_js_code("limpiar_hbl();limpiar_mbl();");
			$action->send_response();
			return;
		}else{
			
		$action->text('tarja',$demas_datos[tarja]);
		$action->text('registrado_por',valorate($demas_datos[registrado_por]));	
		// &&&&& 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($CONVER,"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]));
			
		}
		// &&&&& DATOS DE SHIPPER CONSIGNEE Y NOTIFY &&&&&&&&&&&&&&
		 
		/*$action->add_js_code("document.getElementById('mensaje').innerHTML='<br>';
		document.getElementById('submit').disabled=false;
		document.getElementById('submit1').disabled=false;
		"); */
  
	}
}
if($datos[files]==''){
			$CONVER=con_ver();
			$referencia_cliente = busquedaB($CONVER,"select referencia from hblexpint where booking like '".$txtbooking."%'","referencia");
			$datos=data($CONVER,"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','VERACRUZ, VERACRUZ');
			$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','VERACRUZ, VERACRUZ');
			$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($CONVER,"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($CONVER,"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;

?> 

