<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" />
  <xsl:template match="/">
   <html>
    <head>

<title>BILL OF LADING</title>

<script>
<xsl:comment><![CDATA[
function hoy()
{
  var fechaActual = new Date();
  dia = fechaActual.getDate();
  mes = fechaActual.getMonth() +1;
  anno = fechaActual.getYear();
  if (dia <10) dia = "0" + dia;
  if (mes <10) mes = "0" + mes;
  var Hours;
  var Mins;
  var Time;
  Hours = fechaActual.getHours();
  if (Hours < 10) {
  Hours = "0" + Hours;
  }
  Mins = fechaActual.getMinutes();
  if (Mins < 10) {
  Mins = "0" + Mins;
  }
  fechaHoy = dia + "/" + mes + "/" + anno + " " + Hours + ":" + Mins;
  return fechaHoy;
}


]]></xsl:comment>
</script>

</head>
<body style="margin:0;" bgColor="#FFFFFF">
<br/>
<table align="center" border="0" width="100%" cellPadding="0" cellSpacing="0">
  <tr>  
    <td width="10%"><img src="../../src/img/logo_gobierno_chile_115x128.gif" height="70" width="60"> </img></td>
    <td width="30%">Gobierno de Chile <br/>Servicio Nacional de Aduanas</td>
    <td width="50%"><font face="arial" size="6"><b><center>BILL OF LADING</center></b></font></td>
    <td width="10%" align="right"><img src="../../src/img/logo_aduanas_chile_207x265.gif" height="70" width="60"> </img></td>
  </tr>
</table>
<br/>
<table align="center" rules="none" frame="box" width="100%" bordercolor="#000000" cellPadding="0" cellSpacing="0" bgcolor="#DDDDDD">
  <tr>
    <td width="50%"><font size="1"><b>Emisor: </b><xsl:for-each select="Documento/Participaciones/participacion"> <xsl:variable name="emisor" select="nombre"/> <xsl:if test="$emisor = 'EMI'"> <xsl:value-of select="nombres"/> </xsl:if> </xsl:for-each> </font></td>
    <td width="50%" align="right"><font size="1"><b>Tipo Documento: </b><xsl:variable name="tpoBl" select="Documento/OpTransporte/optransporte/sentido-operacion"/><xsl:if test="$tpoBl = 'S'">Salida</xsl:if><xsl:if test="$tpoBl = 'I'">Ingreso</xsl:if></font></td>
  </tr>
</table>
<br/>
<table align="center" border="1" width="100%" cellPadding="0" cellSpacing="0" bordercolor="#000000">
  <tr>
      <td rowspan="2" valign="top"><font size="1"><b>EMB: Embarcador </b><br/><xsl:for-each select="Documento/Participaciones/participacion"> <xsl:variable name="emb" select="nombre"/> <xsl:if test="$emb = 'EMB'"> <xsl:value-of select="nombres"/><br/>[<xsl:value-of select="tipo-id"/>] : <xsl:value-of select="valor-id"/> </xsl:if> </xsl:for-each></font></td><td bgcolor="#AAAAAA"><font size="1"><b>#BL </b><br/><xsl:value-of select="Documento/numero-referencia"/></font></td><td bgcolor="#AAAAAA"><font size="1"><b>Tipo Servicio </b><br/><xsl:variable name="tipServicio" select="Documento/tipo-servicio"/>
        [<xsl:value-of select="Documento/tipo-servicio"/>]
        <xsl:if test="$tipServicio='EMPTY'">Empty</xsl:if>
        <xsl:if test="$tipServicio='FCL/FCL'">Full Container Load</xsl:if>
        <xsl:if test="$tipServicio='LCL/LCL'">Less than Container Load</xsl:if>
        <xsl:if test="$tipServicio='BB'">Break Bulk</xsl:if>
        <xsl:if test="$tipServicio='FCL/LCL'">Full Container Load &amp; Less than Container Load</xsl:if>
        <xsl:if test="$tipServicio='FCL/BB'">Full Container Load &amp; Break Bulk</xsl:if>
        <xsl:if test="$tipServicio='LCL/BB'">Less than Container Load &amp; Break Bulk</xsl:if>
        <xsl:if test="$tipServicio='FCL/LCL/BB'">Full Container Load, Less than Container Load &amp; Break Bulk</xsl:if>
        <xsl:if test="$tipServicio='CY/CY'">Container Yard to Container Yard</xsl:if>
        <xsl:if test="$tipServicio='CFS/CFS'">Container Freight Station to Container Freight Station</xsl:if>
        </font></td>
  </tr>
  <tr>
      <td><font size="1"><b>Condición de Transporte </b><br/><xsl:variable name="condTransp" select="Documento/cond-transporte"/>
        [<xsl:value-of select="Documento/cond-transporte"/>]
        <xsl:if test="$condTransp='HH'">House/House</xsl:if>
        <xsl:if test="$condTransp='HP'">House/Pier</xsl:if>
        <xsl:if test="$condTransp='PP'">Pier/Pier</xsl:if>
        <xsl:if test="$condTransp='PH'">Pier/House</xsl:if></font></td><td><font size="1"><b>Sentido de la Operación </b><br/><xsl:variable name="sentidoOp" select="Documento/OpTransporte/optransporte/sentido-operacion"/>[<xsl:value-of select="Documento/OpTransporte/optransporte/sentido-operacion"/>] <xsl:if test="$sentidoOp = 'S'">Salida</xsl:if><xsl:if test="$sentidoOp = 'I'">Ingreso</xsl:if></font></td>
  </tr>
  <tr>
      <td rowspan="2" valign="top"><font size="1"><b>CONS: Consignatario </b><br/><xsl:for-each select="Documento/Participaciones/participacion"> <xsl:variable name="cons" select="nombre"/> <xsl:if test="$cons = 'CONS'"> <xsl:value-of select="nombres"/><br/><xsl:variable name="tipID" select="tipo-id"/> <xsl:if test="$tipID!=''">[<xsl:value-of select="tipo-id"/>] : <xsl:value-of select="valor-id"/></xsl:if> </xsl:if> </xsl:for-each></font></td><td><font size="1"><b>Nave </b><br/><xsl:value-of select="Documento/OpTransporte/optransporte/nombre-nave"/></font></td><td><font size="1"><b>Servicio </b><br/><xsl:value-of select="Documento/service"/></font></td>
  </tr>
  <tr>
      <td><font size="1"><b>Bandera </b><br/></font></td><td><font size="1"><b>Viaje </b><br/></font></td>
  </tr>
  <tr>
      <td>
          <font size="1" valign="top"><b>NOTI: Notificar a </b><br/>
                <xsl:for-each select="Documento/Participaciones/participacion"> 
                              <xsl:variable name="noti" select="nombre"/> 
                              <xsl:if test="$noti = 'NOTI'"> <xsl:value-of select="nombres"/><br/>
                                      <xsl:variable name="tipIDNoti" select="tipo-id"/> 
                                      <xsl:if test="$tipIDNoti!=''">[<xsl:value-of select="tipo-id"/>] : <xsl:value-of select="valor-id"/>
                                      </xsl:if> 
                              </xsl:if> 
                </xsl:for-each>
          </font>
      </td>
      <td rowspan="2" colspan="2">
          <font size="1"><b>Puerto Embarque de la Mercancía :  </b>
          <xsl:for-each select="Documento/Locaciones/locacion">
                        <xsl:variable name="pemb" select="nombre"/>
                        <xsl:if test="$pemb = 'PE'"> [<xsl:value-of select="codigo"/>] - <xsl:value-of select="descripcion"/>
                        </xsl:if>
          </xsl:for-each>
          <br/> <b>Puerto Desembarque de la Mercancía : </b>
          <xsl:for-each select="Documento/Locaciones/locacion">
                        <xsl:variable name="pdemb" select="nombre"/>
                        <xsl:if test="$pdemb = 'PD'"> [<xsl:value-of select="codigo"/>] - <xsl:value-of select="descripcion"/>
                        </xsl:if>
          </xsl:for-each></font></td>
  </tr>
  <tr>
      <td><font size="1" valign="top"><b>ALM: Almacenista </b><br/><xsl:for-each select="Documento/Participaciones/participacion"> <xsl:variable name="alm" select="nombre"/> <xsl:if test="$alm = 'ALM'"> <xsl:value-of select="nombres"/><br/><xsl:variable name="tipIDAlm" select="tipo-id"/> <xsl:if test="$tipIDAlm!=''">[<xsl:value-of select="tipo-id"/>] : <xsl:value-of select="valor-id"/></xsl:if> </xsl:if> </xsl:for-each></font></td>
  </tr>
</table>
<br/>


<table align="center" border="1" width="100%" cellPadding="0" cellSpacing="0" bordercolor="#000000">
  <tr bgcolor="#AAAAAA">
    <td width="5%" align="center"><font size="1"><b>#</b></font></td>
    <td width="5%" align="center"><font size="1"><b>Nro Bultos</b></font></td>
    <td width="45%" align="center"><font size="1"><b>Tipo de bulto; Descripción<br/>Descripción de la Mercancía</b></font></td>
    <td width="20%" align="center"><font size="1"><b>Marcas y Números</b></font></td>
    <td width="5%" align="center"><font size="1"><b>Peso</b></font></td>
    <td width="5%" align="center"><font size="1"><b>Volumen</b></font></td>
    <td width="15%" align="center"><font size="1"><b>Observaciones</b></font></td>
  </tr>
  <xsl:for-each select="Documento/Items/item">
  <tr>
    <td width="5%" valign="top"><font size="1"><xsl:value-of select="numero-item"/></font></td>
    <td width="5%" valign="top"><font size="1"><xsl:value-of select="cantidad"/></font></td>
    <td width="45%" valign="top"><font size="1">[<xsl:value-of select="tipo-bulto"/>]<br/><br/><xsl:value-of select="descripcion"/></font></td>
    <td width="20%" valign="top"><font size="1"><xsl:value-of select="marcas"/><br/><br/>
        <xsl:for-each select="Contenedores/contenedor">
          <b>Contenedor</b><br/>
          <b>SN : </b><xsl:value-of select="sigla"/>&#160;<xsl:value-of select="numero"/>-<xsl:value-of select="digito"/><br/>
          <b>Peso : </b><xsl:value-of select="peso"/><br/>
          <b>Status : </b><xsl:value-of select="status"/><br/>
          <b>SELLO : </b><xsl:for-each select="Sellos/sello"><xsl:value-of select="numero"/>&#160;-&#160;<xsl:value-of select="codigo"/>&#160;<xsl:value-of select="emisor"/></xsl:for-each>
        </xsl:for-each></font>
    </td>
    <td width="5%" valign="top"><font size="1"><xsl:value-of select="peso-bruto"/>&#160;<xsl:value-of select="unidad-peso"/></font></td>
    <td width="5%" valign="top"><font size="1"><xsl:value-of select="volumen"/>&#160;<xsl:value-of select="unidad-volumen"/></font></td>
    <td width="15%" valign="top"><font size="1"><xsl:value-of select="observaciones"/>&#160;</font></td>
  </tr>
  </xsl:for-each>
</table>

<br/>

<table align="center" border="1" width="100%" cellPadding="0" cellSpacing="0" bordercolor="#000000">
  <tr>
    <td colspan="7" align="left"><font size="1"><b>Totales</b></font></td>
  </tr>
  <tr>
    <td width="5%" valign="top"><font size="1"><xsl:value-of select="Documento/total-item"/></font></td>
    <td width="5%" valign="top"><font size="1"><xsl:value-of select="Documento/total-bultos"/></font></td>
    <td width="45%" valign="top"><font size="1">&#160;</font></td>
    <td width="20%" valign="top"><font size="1">&#160;</font></td>
    <td width="5%" valign="top"><font size="1"><xsl:value-of select="Documento/total-peso"/>&#160;<xsl:value-of select="Documento/unidad-peso"/></font></td>
    <td width="5%" valign="top"><font size="1"><xsl:value-of select="Documento/total-volumen"/>&#160;<xsl:value-of select="Documento/unidad-volumen"/></font></td>
    <td width="15%" valign="top"><font size="1">&#160;</font></td>
  </tr>
  <tr>
    <td colspan="7" align="left"><font size="1"><b>Observaciones</b><br/>
        <xsl:for-each select="Documento/Observaciones/observacion">
                      <xsl:value-of select="nombre"/>&#160;-&#160;<xsl:value-of select="contenido"/>
        </xsl:for-each>
    </font></td>
  </tr>
</table>
<br/>
<table align="center" border="1" width="100%" cellPadding="0" cellSpacing="0" bordercolor="#000000">
       <tr>
           <td width="50%" valign="top"><font size="1"><b>REP: Representante</b><br/><xsl:for-each select="Documento/Participaciones/participacion"> <xsl:variable name="rep" select="nombre"/> <xsl:if test="$rep = 'REP'"> <xsl:value-of select="nombres"/><br/>[<xsl:value-of select="tipo-id"/>] : <xsl:value-of select="valor-id"/> </xsl:if> </xsl:for-each></font></td>
           <td width="50%" valign="top"><font size="1"><b>MFTO<br/>Nro Aceptación </b><xsl:for-each select="Documento/Referencias/referencia"> <xsl:variable name="refMfto" select="tipo-referencia"/> <xsl:if test="$refMfto = 'REF'"> <xsl:value-of select="numero"/><br/><b>Fecha Emisión </b><xsl:value-of select="fecha"/><br/><b>Emisor </b>[<xsl:value-of select="tipo-id-emisor"/>]&#160;<xsl:value-of select="valor-id-emisor"/>&#160;[<xsl:value-of select="nac-id-emisor"/>]&#160;</xsl:if> </xsl:for-each></font></td>
       </tr>
       <tr>
           <td width="50%" valign="top"><font size="1"><b>Emisor BL</b><br/><xsl:for-each select="Documento/Participaciones/participacion"> <xsl:variable name="emido" select="nombre"/> <xsl:if test="$emido = 'EMIDO'"> <xsl:value-of select="nombres"/><br/>[<xsl:value-of select="tipo-id"/>] : <xsl:value-of select="valor-id"/></xsl:if> </xsl:for-each></font></td>
           <td width="50%" valign="top"><font size="1"><b>BL MADRE<br/>Nro Aceptación </b><xsl:for-each select="Documento/Referencias/referencia"> <xsl:variable name="refBl" select="tipo-referencia"/> <xsl:if test="$refBl = 'MADRE'"> <xsl:value-of select="numero"/><br/><b>Fecha Emisión </b><xsl:value-of select="fecha"/><br/><b>Emisor </b>[<xsl:value-of select="tipo-id-emisor"/>]&#160;<xsl:value-of select="valor-id-emisor"/>&#160;[<xsl:value-of select="nac-id-emisor"/>]&#160;</xsl:if> </xsl:for-each></font></td>
       </tr>
</table>
<br/>
<table align="center" border="1" width="100%" cellPadding="0" cellSpacing="0" bordercolor="#000000">
       <tr><td align="right"><font size="1"><b>Fecha de generación del documento: </b><script>document.write(hoy())</script>&#160;</font></td></tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

