<? session_start();
include("header.php");
require_once("comun/conex_ver.php");
require_once("comun/conexion3.php");
require_once("comun/funciones.php");
$link_impo=con_impo();$link=con_ver();
$booking_interteam = $_GET[booking_interteam];
$id = $_GET[id];
$id_bl = $_GET[id_bl];
$referencia = $_GET[referencia];
$referencia_cliente = $_GET[referencia_cliente];

/* echo 'id '.$id.'<br>';
echo 'id bl '.$id_bl.'<br>';
echo 'referencia '.$referencia.'<br>';
echo 'referencia_cliente '.$referencia_cliente.'<br>'; */

if(isset($_GET[id_destino])){
	$qry1=mysqli_query($link,"select * from destinos_mbl where id = '".$_GET[id_destino]."'");
	$bl2=mysqli_fetch_array($qry1);
}
 
if($referencia!=''){
$bl = data($link,"select * from datosbooking where referencia_lpv = '".$referencia."' ");
}elseif($referencia_cliente!=''){
$bl = data($link,"select * from datosbooking where referencia_cliente = '".$referencia_cliente."' ");	
}

if($referencia_cliente==''){
	$referencia_cliente = $bl[referencia_cliente];
}

if($referencia==''){
	$referencia = $bl[referencia_lpv];
}
if($bl[referencia_cliente]=='' or $bl[referencia_lpv]==''){
	$bl = data($link,"select * from referencias_veracruz where referencia_cliente = '".$referencia_cliente."' or referencia = '".$referencia."' ");
	$referencia_cliente = $bl[referencia_cliente];
	$referencia = $bl[referencia];
}

	
if($referencia_cliente!=''){
$datos_mbl = data($link,"select * from mbl_naviera where referencia_cliente = '".$referencia_cliente."'");
}elseif($referencia!=''){
$datos_mbl = data($link,"select * from mbl_naviera where referencia = '".$referencia."'");
}

//if($referencia_cliente==''){
 if($referencia_cliente==''){
	$valroRC = data($link,"select * from referencias_veracruz where referencia like '".$referencia."' and referencia<>''");
	$referencia_cliente=$valroRC[referencia_cliente];
}

?> 
<link rel="stylesheet" type="text/css" href="style.css" media="all" />
	<!--[if IE 7]>
	<link rel="stylesheet" type="text/css" href="style-ie.css" />
	<![endif]-->
    
<script type="text/javascript" src="js/jquery.js"></script>
 
<script type="text/javascript" src="js/funciones.js"></script>
<script type="text/javascript" src="js/autocomplete/jquery.autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="js/autocomplete/jquery.autocomplete.css" media="all" />
<script src="js/windowfiles/dhtmlwindow.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="js/windowfiles/dhtmlwindow.css" media="all" />
<SCRIPT type="text/javascript" src="../../../js/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js"></script>
<link type="text/css" rel="stylesheet" href="../../../js/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css" media="screen"></LINK>
  
<div align="justify" style="line-height:18px;margin-top:-20px; position:absolute; height:100% ">
<? if($_GET[referencia_cliente]!=''){?>
<form id="forma" name="forma" action="mblguarda.php?referencia_cliente=<?=$_GET[referencia_cliente]?>&booking=<?=$_GET[booking]?>" method="post">
<? }elseif($_GET[referencia]!=''){?>
<form id="forma" name="forma" action="mblguarda.php?referencia=<?=$_GET[referencia]?>&booking=<?=$_GET[booking]?>" method="post">
<? } ?>

<input type="hidden" id="email_2" name="email_2" value="<?=$_SESSION[email]?>" />
<span style="color:#00AF4B">&nbsp;Registro del MBL de navieras &raquo;</span><br />
 
&nbsp;<a href="registro_destinos.php?referencia_cliente=<?=$_GET[referencia_cliente]?>&referencia=<?=$_GET[referencia]?>&booking=<?=$_GET[booking]?>"  style="color:#00AF4B;text-align:center;text-decoration:underline;">Catálogo  de destinos &raquo;</a> 
 
<table width="921" style="line-height:22px"  >
 
  <tr>
    <td colspan="2">  
     <input align="left" type="button"  value="Guardar MBL" onClick="if(document.getElementById('referencia').value=='' || document.getElementById('referencia_cliente').value=='') {alert('Ingrese la referencia de Veracruz y la referencia de cliente');}else{ document.getElementById('forma').submit();}"  style="border:none; margin-left:-8px;background-color:transparent;color:#00AF4B;text-decoration:underline;font-family:Arial, Helvetica, sans-serif; font-size:14px"> &nbsp;&nbsp;
      
      <a id="regresar" style="cursor:default;color:#00AF4B;text-align:center;text-decoration:underline;"  
 	  <? if($_GET[referencia]!=''){ ?>
       href="avisos/index.php?referencia=<?=$_GET[referencia]?>&interteam=1">Regresar</a>
	  <? }elseif($_GET[referencia_cliente]!=''){ ?>
      href="avisos/index.php?referencia_cliente=<?=$_GET[referencia_cliente]?>&interteam=1">Regresar</a>
      <? } elseif($_GET[booking]!='') { ?>
      href="avisos/index.php?booking=<?=$_GET[booking]?>&interteam=1">Regresar</a>
      <? } ?>
      <? if($_GET[referencia_cliente]=='' and $_GET[referencia]=='' and $_GET[booking]==''){ ?> 
       href="avisos/index.php">Regresar</a> 
      <? } ?>
    </tr>
  <!---<tr>
    <td><b>DIMENSIONES</b></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2"><table width="420" border="1" >
      <tr align="center">
        <td width="25">&nbsp;</td>
        <td width="136">Numero de bultos</td>
        <td width="54">Largo</td>
        <td width="91">Ancho</td>
        <td width="80">Alto</td>
      </tr>
      <tr>
        <td align="center">1</td>
        <td align="center"><input type="text" name="numero_bultos[0]" id="numero_bultos[0]" size="5" value="<?=$numero_bultos[0]?>"/></td>
        <td align="center"><input type="text" name="largo[0]" id="largo[0]" size="5" value="<?=$largo[0]?>" /></td>
        <td align="center"><input type="text" name="ancho[0]" id="ancho[0]" size="5" value="<?=$ancho[0]?>" /></td>
        <td align="center"><input type="text" name="alto[0]" id="alto[0]" size="5"  value="<?=$alto[0]?>"/></td>
      </tr>
      <tr>
        <td align="center">2</td>
        <td align="center"><input type="text" name="numero_bultos[1]" id="numero_bultos[1]" size="5" value="<?=$numero_bultos[1]?>"/></td>
        <td align="center"><input type="text" name="largo[1]" id="largo[1]" size="5" value="<?=$largo[1]?>" /></td>
        <td align="center"><input type="text" name="ancho[1]" id="ancho[1]" size="5" value="<?=$ancho[1]?>" /></td>
        <td align="center"><input type="text" name="alto[1]" id="alto[1]" size="5"  value="<?=$alto[1]?>"/></td>
      </tr>
      <tr>
        <td align="center">3</td>
        <td align="center"><input type="text" name="numero_bultos[2]" id="numero_bultos[2]" size="5" value="<?=$numero_bultos[2]?>"/></td>
        <td align="center"><input type="text" name="largo[2]" id="largo[2]" size="5" value="<?=$largo[2]?>" /></td>
        <td align="center"><input type="text" name="ancho[2]" id="ancho[2]" size="5" value="<?=$ancho[2]?>" /></td>
        <td align="center"><input type="text" name="alto[2]" id="alto[2]" size="5"  value="<?=$alto[2]?>"/></td>
      </tr>
      <tr>
        <td align="center">4</td>
        <td align="center"><input type="text" name="numero_bultos[3]" id="numero_bultos[3]" size="5" value="<?=$numero_bultos[3]?>"/></td>
        <td align="center"><input type="text" name="largo[3]" id="largo[3]" size="5" value="<?=$largo[3]?>" /></td>
        <td align="center"><input type="text" name="ancho[3]" id="ancho[3]" size="5" value="<?=$ancho[3]?>" /></td>
        <td align="center"><input type="text" name="alto[3]" id="alto[3]" size="5"  value="<?=$alto[3]?>"/></td>
      </tr>
      <tr>
        <td align="center">5</td>
        <td align="center"><input type="text" name="numero_bultos[4]" id="numero_bultos[4]" size="5" value="<?=$numero_bultos[4]?>"/></td>
        <td align="center"><input type="text" name="largo[4]" id="largo[4]" size="5" value="<?=$largo[4]?>" /></td>
        <td align="center"><input type="text" name="ancho[4]" id="ancho[4]" size="5" value="<?=$ancho[4]?>" /></td>
        <td align="center"><input type="text" name="alto[4]" id="alto[4]" size="5"  value="<?=$alto[4]?>"/></td>
      </tr>
      <tr>
        <td align="center">6</td>
        <td align="center"><input type="text" name="numero_bultos[5]" id="numero_bultos[5]" size="5" value="<?=$numero_bultos[5]?>"/></td>
        <td align="center"><input type="text" name="largo[5]" id="largo[5]" size="5" value="<?=$largo[5]?>" /></td>
        <td align="center"><input type="text" name="ancho[5]" id="ancho[5]" size="5" value="<?=$ancho[5]?>" /></td>
        <td align="center"><input type="text" name="alto[5]" id="alto[5]" size="5"  value="<?=$alto[5]?>"/></td>
      </tr>
      <tr>
        <td align="center">7</td>
        <td align="center"><input type="text" name="numero_bultos[6]" id="numero_bultos[6]" size="5" value="<?=$numero_bultos[6]?>"/></td>
        <td align="center"><input type="text" name="largo[6]" id="largo[6]" size="5" value="<?=$largo[6]?>" /></td>
        <td align="center"><input type="text" name="ancho[6]" id="ancho[6]" size="5" value="<?=$ancho[6]?>" /></td>
        <td align="center"><input type="text" name="alto[6]" id="alto[6]" size="5"  value="<?=$alto[6]?>"/></td>
      </tr>
      <tr>
        <td align="center">8</td>
        <td align="center"><input type="text" name="numero_bultos[7]" id="numero_bultos[7]" size="5" value="<?=$numero_bultos[7]?>"/></td>
        <td align="center"><input type="text" name="largo[7]" id="largo[7]" size="5" value="<?=$largo[7]?>" /></td>
        <td align="center"><input type="text" name="ancho[7]" id="ancho[7]" size="5" value="<?=$ancho[7]?>" /></td>
        <td align="center"><input type="text" name="alto[7]" id="alto[7]" size="5"  value="<?=$alto[7]?>"/></td>
      </tr>
      <tr>
        <td align="center">9</td>
        <td align="center"><input type="text" name="numero_bultos[8]" id="numero_bultos[8]" size="5" value="<?=$numero_bultos[8]?>"/></td>
        <td align="center"><input type="text" name="largo[8]" id="largo[8]" size="5" value="<?=$largo[8]?>" /></td>
        <td align="center"><input type="text" name="ancho[8]" id="ancho[8]" size="5" value="<?=$ancho[8]?>" /></td>
        <td align="center"><input type="text" name="alto[8]" id="alto[8]" size="5"  value="<?=$alto[8]?>"/></td>
      </tr>
      <tr>
        <td align="center">10</td>
        <td align="center"><input type="text" name="numero_bultos[9]" id="numero_bultos[9]" size="5" value="<?=$numero_bultos[9]?>"/></td>
        <td align="center"><input type="text" name="largo[9]" id="largo[9]" size="5" value="<?=$largo[9]?>" /></td>
        <td align="center"><input type="text" name="ancho[9]" id="ancho[9]" size="5" value="<?=$ancho[9]?>" /></td>
        <td align="center"><input type="text" name="alto[9]" id="alto[9]" size="5"  value="<?=$alto[9]?>"/></td>
      </tr>
    </table></td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>--->
  <tr>
    <td>SELECCIONAR DESTINO</td>
    <td>
	<select name="destino" id="destino" onChange="document.getElementById('forma').action='registro_mbl_navieras.php?referencia=<?=$_GET[referencia]?>&referencia_cliente=<?=$_GET[referencia_cliente]?>&booking=<?=$_GET[booking]?>&id_destino='+this.options[this.selectedIndex].value;document.getElementById('forma').submit()">
    <option value="">[Seleccionar]</option>
	<?
    $queryDestinos=mysqli_query($link,"select * from destinos_mbl order by destino"); echo 'del mbl '.$datos_mbl[destino].' de los detinos '.$row[destino];
	while($row=mysqli_fetch_array($queryDestinos)){
		echo  '<option ';
		if(isset($_GET[id_destino])){
		if($row[id]==$_GET[id_destino] ) { echo 'selected="selected"';}
		}else{
			if($row[id] == $datos_mbl[destino]){
				echo 'selected="selected"';
			}
		}
		echo 'value="'.$row[id].'">'.$row[destino].'</option>';
	}
	?>	
    </select>
	</td>
  </tr>
  <tr>
    <td>ID BL</td>
    <td><input type="text" class="aa" name="idhbl" id="idhbl" size="40" readonly value="<?=$datos_mbl[id]?>"/></td>
  </tr>
 
  <tr>
    <td width="226" id="t_nombre">REFERENCIA</td>
    <td><input type="text" class="aa" name="referencia_cliente" id="referencia_cliente" size="40" value="<?=$referencia_cliente?>"/></td>
  </tr>
  
  <tr>
    <td id="t_nombre2">REFERENCIA PUERTO</td>
    <td>
    <? if(trim($referencia_cliente)!=''){
	$referencia = busquedaB($link,"select referencia from referencias_veracruz where referencia_cliente = '".trim($referencia_cliente)."'","referencia");
	}
	?>
    <input type="text" class="aa" name="referencia" id="referencia" size="40" value="<?=$referencia?>" /></td>
  </tr>
  
  <tr>
    <td >REGISTRADO POR</td>
    <td ><input type="text" readonly class="aa" name="registrado_por" id="registrado_por" size="40"  value="<?=($datos_mbl[registrado_por]!='' ? $datos_mbl[registrado_por] : $_SESSION[email])?>" /></td>
  </tr>
  <tr>
    <td colspan="2" >&nbsp;</td>
  </tr>
   
  <tr>
    <td width="226"><b>SHIPPER</b></td>
    <td>&nbsp;</td>
  </tr>
  
  <tr>
    <td width="226">NAME</td>
    <td><input type="text" class="aa" name="shipper1" id="shipper1" size="40" value="<?=($bl2[shipper]!='' ? $bl2[shipper] : $datos_mbl[shipper])?>"  /></td>
  </tr>
  
  <tr>
    <td>ADDRESS</td>
    <td><input type="text" class="aa" name="shipper2" id="shipper2" size="40" value="<?=($bl2[shipper2]!='' ? $bl2[shipper2] : $datos_mbl[shipper2])?>" /></td>
  </tr>
  <tr>
    <td>PO BOX, CITY &amp; COUNTRY</td>
    <td><input type="text" class="aa" name="shipper3" id="shipper3" size="40" value="<?=($bl2[shipper3]!='' ? $bl2[shipper3] : $datos_mbl[shipper3])?>" /></td>
  </tr>
  <tr>
    <td>RFC</td>
    <td><input type="text" class="aa" name="shipper4" id="shipper4" size="40" value="<?=($bl2[shipper4]!='' ? $bl2[shipper4] : $datos_mbl[shipper4])?>" /></td>
  </tr>
  <tr>
    <td>CTC</td>
    <td><input type="text" class="aa" name="shipper5" id="shipper5" size="40" value="<?=($bl2[shipper5]!='' ? $bl2[shipper5] : $datos_mbl[shipper5])?>" /></td>
  </tr>
  <tr>
    <td>PHONE</td>
    <td><input type="text" class="aa" name="shipper6" id="shipper6" size="40" value="<?=($bl2[shipper6]!='' ? $bl2[shipper6] : $datos_mbl[shipper6])?>" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td id="t_nombre"><b>CONSIGNEE</b></td>
    <td>&nbsp;</td>
    </tr>
  <tr>
    <td>NAME      </td>
    <td><input type="text" class="aa" name="consignee1" id="consignee1" size="40" value="<?=($bl2[consignee]!='' ? $bl2[consignee] : $datos_mbl[consignee])?>" /></td>
    </tr>
  <tr>
    <td>ADDRESS</td>
    <td><input type="text" class="aa" name="consignee2" id="consignee2" size="40" value="<?=($bl2[consignee2]!='' ? $bl2[consignee2] : $datos_mbl[consignee2])?>" /></td>
  </tr>
  <tr>
    <td>PO BOX, CITY &amp; COUNTRY</td>
    <td><input type="text" class="aa" name="consignee3" id="consignee3" size="40" value="<?=($bl2[consignee3]!='' ? $bl2[consignee3] : $datos_mbl[consignee3])?>" /></td>
  </tr>
  <tr>
    <td>RFC</td>
    <td><input type="text" class="aa" name="consignee4" id="consignee4" size="40"  value="<?=($bl2[consignee4]!='' ? $bl2[consignee4] : $datos_mbl[consignee4])?>"/></td>
  </tr>
  <tr>
    <td>CTC</td>
    <td><input type="text" class="aa" name="consignee5" id="consignee5" size="40" value="<?=($bl2[consignee5]!='' ? $bl2[consignee5] : $datos_mbl[consignee5])?>" /></td>
  </tr>
  <tr>
    <td width="226">PHONE</td>
    <td><input type="text" class="aa" name="consignee6" id="consignee6" size="40" value="<?=($bl2[consignee6]!='' ? $bl2[consignee6] : $datos_mbl[consignee6])?>" /></td>
  </tr>
   
  <tr>
    <td colspan="2" >&nbsp;</td>
  </tr>
  <tr>
    <td id="t_nombre"><b>NOTIFY </b>
      <input name="chk_copy" id="chk_copy" type="checkbox" title="Copy from consignee"  
      onclick="if(this.checked){
      $('#notify1').val($('#consignee1').val());
      $('#notify2').val($('#consignee2').val());
      $('#notify3').val($('#consignee3').val());
      $('#notify4').val($('#consignee4').val());
      $('#notify5').val($('#consignee5').val());
      $('#notify6').val($('#consignee6').val());
      }else{
      $('#notify1').val('');
      $('#notify2').val('');
      $('#notify3').val('');
      $('#notify4').val('');
      $('#notify5').val('');
      $('#notify6').val('');
      }" /></td>
    <td>&nbsp;</td>
    </tr>
  <tr>
    <td>NAME</td>
    <td><input type="text" class="aa" name="notify1" id="notify1" size="40" value="<?=($bl2[notify]!='' ? $bl2[notify] : $datos_mbl[notify])?>" /></td>
    </tr>
  <tr>
    <td>ADDRESS</td>
    <td><input type="text" class="aa" name="notify2" id="notify2" size="40" value="<?=($bl2[notify2]!='' ? $bl2[notify2] : $datos_mbl[notify2])?>" /></td>
    </tr>
  <tr>
    <td>PO BOX, CITY &amp; COUNTRY</td>
    <td><input type="text" class="aa" name="notify3" id="notify3" size="40" value="<?=($bl2[notify3]!='' ? $bl2[notify3] : $datos_mbl[notify3])?>" /></td>
    </tr>
  <tr>
    <td>RFC</td>
    <td><input type="text" class="aa" name="notify4" id="notify4" size="40" value="<?=($bl2[notify4]!='' ? $bl2[notify4] : $datos_mbl[notify4])?>" /></td>
    </tr>
  <tr>
    <td>CTC</td>
    <td><input type="text" class="aa" name="notify5" id="notify5" size="40" value="<?=($bl2[notify5]!='' ? $bl2[notify5] : $datos_mbl[notify5])?>" /></td>
    </tr>
  <tr>
    <td>PHONE</td>
    <td><input type="text" class="aa" name="notify6" id="notify6" size="40" value="<?=($bl2[notify6]!='' ? $bl2[notify6] : $datos_mbl[notify6])?>" /></td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
 
 <!-- <tr>
    <td><b>CARGO</b></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>MARKS</td>
    <td><input type="text" class="aa" name="marks" id="marks" size="40" value="<?=$partida[markandnos]?>" /></td>
  </tr>
  <tr>
    <td>QUANTITY</td>
    <td><input type="text" class="aa" name="quantity" id="quantity" size="40" value="<?=$partida[bulk]?>" /></td>
  </tr>
  <tr>
    <td valign="top">TYPE OF BULKS</td>
    <td><input type="text" class="aa" name="type_of_bulks" id="type_of_bulks" size="40" value="<?=$partida[type_of_bulks]?>" /></td>
  </tr>
  <tr>
    <td valign="top">DESCRIPTION OF GOODS<BR /> DECLARED BY SHIPPER <img align="absbottom" src="images/info_gray.png" title="Por favor escriba en inglés la descripción de la mercancía, dado que las compañías navieras sólo aceptan este idioma para esta descripción. // Please write in english language the description of goods, as Shipping Lines only accept english for this description." alt="" onMouseover="ddrivetip('Por favor escriba en inglés la descripción de la mercancía, dado que las compañías navieras sólo aceptan este idioma para esta descripción. // Please write in english language the description of goods, as Shipping Lines only accept english for this description.','yellow', 300)"
onMouseout="hideddrivetip()" /></td>
    <td><input type="text" class="aa" name="description" id="description" size="40" value="<?=$partida[cargo]?>" /></td>
  </tr>
  <tr>
    <td align="left">NUMBER OF PIECES CONTAINED</td>
    <td><input type="text" class="aa" name="no_piezas" id="no_piezas" size="40"  value="<?=$partida[number_of_pieces]?>"/></td>
  </tr>
  <tr>
    <td>GROSS WEIGHT KGS.</td>
    <td><input type="text" class="aa" name="gross_weight" id="gross_weight" size="40" value="<?=$partida[weight]?>" /></td>
  </tr>
  <tr>
    <td>NET WEIGHT KGS.</td>
    <td><input type="text" class="aa" name="net_weight" id="net_weight" size="40" value="<?=$partida[netweight]?>" /></td>
  </tr>
  <tr>
    <td>VOLUME</td>
    <td><input type="text" class="aa" name="volume" id="volume" size="40" value="<?=$partida[measurement]?>" /></td>
  </tr>
  <tr>
    <td>HARMONIZED CODE</td>
    <td><input type="text" class="aa" name="harmonized_code" id="harmonized_code" size="40" value="<?=$partida[harmonized_code]?>" /></td>
  </tr>
  <tr>
    <td>CUSTOMER OWN AMS</td>
    <td><input type="text" class="aa" name="ams" id="ams" size="40" value="<?=$partida[ams]?>" /></td>
  </tr>-->
 
   <tr>
       <td colspan="2">&nbsp;<span id="saving_bl" style="color:#F00"></span></td>
    </tr>
 </table>

<br />
  
</form>
 
</div>