<?php
ini_set("display_errors",1);
include("comun/conexion3.php");
 

con_impo();
$bkg = trim($_GET['bkg']);
 
$sql = mysql_query("SELECT *  FROM hblexpint_actualizaciones where booking= '$bkg' order by id desc limit 1"); 
//echo "SELECT *  FROM hblexpint_actualizaciones where booking= '$bkg' order by id desc limit 1";
if(mysql_num_rows($sql)>0){
	$rs = mysql_fetch_array($sql);
		if(trim($rs['shipper'])!='' ){
	 ?>
<style type="text/css">
body,td,th {
	font-family: Verdana, Geneva, sans-serif;
	font-size: 10px;
}
</style>

  <table>
  <tr>
    <td width="226"><input name="" type="button" value="Actualizar" onclick="
    if(document.getElementById('carga').checked==false){
    alert('Note que no ha seleccionado carga que actualizar');
    };
    
    parent.document.getElementById('idHblexpint_actualizaciones').value=document.getElementById('idHblexpint_actualizacionesTmp').value;
    
    if(document.getElementById('idActualizacionEsiTmp').value!=''){
     	 parent.document.getElementById('idActualizacionEsi').value=document.getElementById('idActualizacionEsiTmp').value;
         parent.document.getElementById('marks').value=document.getElementById('marksTmp').value;
         parent.document.getElementById('quantity').value=document.getElementById('quantityTmp').value;
         parent.document.getElementById('type_of_bulks').value=document.getElementById('type_of_bulksTmp').value;
        
         parent.document.getElementById('description').value=document.getElementById('descriptionTmp').value;
         parent.document.getElementById('imo').value=document.getElementById('imoTmp').value;
         parent.document.getElementById('gross_weight').value=document.getElementById('gross_weightTmp').value;
         parent.document.getElementById('volume').value=document.getElementById('volumeTmp').value;
    }
        parent.document.getElementById('shipper1').value='<?=$rs[shipper]?>';
		parent.document.getElementById('shipper2').value='<?=$rs[shipper2]?>';
		parent.document.getElementById('shipper3').value='<?=$rs[shipper3]?>';
		parent.document.getElementById('shipper4').value='<?=$rs[shipper4]?>';
		parent.document.getElementById('shipper5').value='<?=$rs[shipper5]?>';
		parent.document.getElementById('shipper6').value='<?=$rs[shipper6]?>';
		
		parent.document.getElementById('notify1').value='<?=$rs[notify]?>';
		parent.document.getElementById('notify2').value='<?=$rs[notify2]?>';
		parent.document.getElementById('notify3').value='<?=$rs[notify3]?>';
		parent.document.getElementById('notify4').value='<?=$rs[notify4]?>';
		parent.document.getElementById('notify5').value='<?=$rs[notify5]?>';
		parent.document.getElementById('notify6').value='<?=$rs[notify6]?>';
		 
 		parent.document.getElementById('consignee1').value='<?=$rs[consignee]?>';
		parent.document.getElementById('consignee2').value='<?=$rs[consignee2]?>';
		parent.document.getElementById('consignee3').value='<?=$rs[consignee3]?>';
		parent.document.getElementById('consignee4').value='<?=$rs[consignee4]?>';
		parent.document.getElementById('consignee5').value='<?=$rs[consignee5]?>';
		parent.document.getElementById('consignee6').value='<?=$rs[consignee6]?>';
        parent.document.getElementById('esiBox').close()" /></td>
    <td>&nbsp;</td>
  </tr>
  
    
    </table>
    
    <? $resultA = mysql_query("SELECT * FROM detailcargaexpint_n where bookingno like '$bkg%' order by id desc");
	?>
    <input id="idActualizacionEsiTmp" type="hidden" value="" />
    <input id="marksTmp" type="hidden" value="" />
    <input id="quantityTmp" type="hidden" value="" />
    <input id="type_of_bulksTmp" type="hidden" value="" />
    <input id="descriptionTmp" type="hidden" value="" />
    <input id="imoTmp" type="hidden" value="" />
    <input id="gross_weightTmp" type="hidden" value="" />
    <input id="volumeTmp" type="hidden" value="" />
    <table  border="4" cellspacing="2" style="width:809px;background-color:#CCFFFF;font-size:10px; border: 1PX solid #0000FF">
      <tr>
        <td align="center">Seleccionar</td>
        <td align="center">Marks and Nos.</td>
        <td align="center">Bulks</td>
        <td align="center">Type</td>
        <td align="center" >Cargo</td>
        <td align="center">Imo</td>
        <td align="center">Gross Weight</td>
        <td align="center">Measurement</td>
       </tr>
      <?
$i=99;
while ($rowA = mysql_fetch_array($resultA)) {
?>
      <tr>
        <? $car = str_replace('<br>','<br />',$rowA["cargo"]);
$car = str_replace('<br />','\n',$rowA["cargo"]);
?>
        
         <td align="center">
         <? if($rowA[update_edi_status]=='utilizado'){?>
         Aplicado
         <? }else{ ?>
         <input id="carga" type="checkbox" onclick="
         if(this.checked){
         document.getElementById('idActualizacionEsiTmp').value='<?=$rowA["id"]?>';
         document.getElementById('marksTmp').value=document.getElementById('markandnos<?=$i?>').innerHTML;
         document.getElementById('quantityTmp').value=document.getElementById('bulk<?=$i?>').innerHTML;
         document.getElementById('type_of_bulksTmp').value=document.getElementById('type<?=$i?>').innerHTML;
         document.getElementById('descriptionTmp').value=parent.document.getElementById('tratamiento_madera').value+' - <?=$car?>';
         document.getElementById('imoTmp').value=document.getElementById('imo<?=$i?>').innerHTML;
         document.getElementById('gross_weightTmp').value=document.getElementById('weight<?=$i?>').innerHTML;
         document.getElementById('volumeTmp').value=document.getElementById('measurement<?=$i?>').innerHTML;
         }else{
         document.getElementById('idActualizacionEsiTmp').value='';
         document.getElementById('marksTmp').value='';
         document.getElementById('quantityTmp').value='';
         document.getElementById('type_of_bulksTmp').value='';
         document.getElementById('descriptionTmp').value='';
         document.getElementById('imoTmp').value='';
         document.getElementById('gross_weightTmp').value='';
         document.getElementById('volumeTmp').value='';
         }"
         />
         <? } ?>
        </td>
        <td align="center" id="markandnos<?=$i?>"><?=$rowA["markandnos"]?></td>
        <td align="center" id="bulk<?=$i?>"><?=$rowA["bulk"]?></td>
        <td align="center" id="type<?=$i?>"><?=$rowA["type"]?></td>
        <td align="center" id="cargo<?=$i?>"><pre style="width:550px; overflow:scroll"><?=($rowA["cargo"])?>
        </pre></td>
        <td align="center" id="imo<?=$i?>"><?=$rowA["imo"]?></td>
        <td align="center" id="weight<?=$i?>"><?=$rowA["weight"]?></td>
        <td align="center" id="measurement<?=$i?>"><?=$rowA["measurement"]?></td>
        <!--<td align="center" id="measurement<?=$i?>" style="color:red">after update<br /><? //=strtoupper($rowA["comentarios"])?></td>-->
      </tr>
      <?
$i++;
   } 
   
  
?>
    </table>
    
  <table>
  
  <input type="hidden" class="aa" name="idHblexpint_actualizacionesTmp" id="idHblexpint_actualizacionesTmp" size="40" value="<?=$rs[id]?>"  />
  <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="<?=$rs[shipper]?>"  /></td>
  </tr>
  
  <tr>
    <td>ADDRESS</td>
    <td><input type="text" class="aa" name="shipper2" id="shipper2" size="40" value="<?=$rs[shipper2]?>" /></td>
  </tr>
  <tr>
    <td>PO BOX, CITY &amp; COUNTRY</td>
    <td><input type="text" class="aa" name="shipper3" id="shipper3" size="40" value="<?=$rs[shipper3]?>" /></td>
  </tr>
  <tr>
    <td>RFC</td>
    <td><input type="text" class="aa" name="shipper4" id="shipper4" size="40" value="<?=$rs[shipper4]?>" /></td>
  </tr>
  <tr>
    <td>CTC</td>
    <td><input type="text" class="aa" name="shipper5" id="shipper5" size="40" value="<?=$rs[shipper5]?>" /></td>
  </tr>
  <tr>
    <td>PHONE</td>
    <td><input type="text" class="aa" name="shipper6" id="shipper6" size="40" value="<?=$rs[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="<?=$rs[consignee]?>" /></td>
    </tr>
  <tr>
    <td>ADDRESS</td>
    <td><input type="text" class="aa" name="consignee2" id="consignee2" size="40" value="<?=$rs[consignee2]?>" /></td>
  </tr>
  <tr>
    <td>PO BOX, CITY &amp; COUNTRY</td>
    <td><input type="text" class="aa" name="consignee3" id="consignee3" size="40" value="<?=$rs[consignee3]?>" /></td>
  </tr>
  <tr>
    <td>RFC</td>
    <td><input type="text" class="aa" name="consignee4" id="consignee4" size="40"  value="<?=$rs[consignee4]?>"/></td>
  </tr>
  <tr>
    <td>CTC</td>
    <td><input type="text" class="aa" name="consignee5" id="consignee5" size="40" value="<?=$rs[consignee5]?>" /></td>
  </tr>
  <tr>
    <td width="226">PHONE</td>
    <td><input type="text" class="aa" name="consignee6" id="consignee6" size="40" value="<?=$rs[consignee6]?>" /></td>
  </tr>
   
  <tr>
    <td colspan="2" >&nbsp;</td>
  </tr>
  <tr>
    <td id="t_nombre"><b>NOTIFY </b>
    </td>
    <td>&nbsp;</td>
    </tr>
  <tr>
    <td>NAME</td>
    <td><input type="text" class="aa" name="notify1" id="notify1" size="40" value="<?=$rs[notify]?>" /></td>
    </tr>
  <tr>
    <td>ADDRESS</td>
    <td><input type="text" class="aa" name="notify2" id="notify2" size="40" value="<?=$rs[notify2]?>" /></td>
    </tr>
  <tr>
    <td>PO BOX, CITY &amp; COUNTRY</td>
    <td><input type="text" class="aa" name="notify3" id="notify3" size="40" value="<?=$rs[notify3]?>" /></td>
    </tr>
  <tr>
    <td>RFC</td>
    <td><input type="text" class="aa" name="notify4" id="notify4" size="40" value="<?=$rs[notify4]?>" /></td>
    </tr>
  <tr>
    <td>CTC</td>
    <td><input type="text" class="aa" name="notify5" id="notify5" size="40" value="<?=$rs[notify5]?>" /></td>
    </tr>
  <tr>
    <td>PHONE</td>
    <td><input type="text" class="aa" name="notify6" id="notify6" size="40" value="<?=$rs[notify6]?>" /></td>
    </tr>
</table>
 
 <? } 
}?>