<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" version="1.0">
	<xsl:import href="../../../appl/shared/default.xsl"/>
	<xsl:variable name="Rev">
		<!-- Revision van deze cust.xsl -->
		<xsl:value-of select="substring(translate('$Revision$', '$ ', ''), 10)"/>
	</xsl:variable>
	
	
	<xsl:template match="bestelopdracht" mode="include">
    <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">
      <TR>
        <TD WIDTH="40" ROWSPAN="30" ID="LINKERMARGE"></TD>
        <TD>
          <!-- Bestelopdracht -->
          <table border="0" bordercolor="#ffffff" width="100%">
            <tr>
              <td colspan="5" class="caption" style="text-align:center">
                <b><xsl:value-of select="//lcl/BES/inkooporder"/>&#xA0;<u><xsl:value-of select="id"/></u></b>
              </td>
            </tr>
            <tr>
              <td colspan="5" style="height:30"/>
            </tr>
            <tr>
              <td colspan="2" style="width:47%">
                <b><xsl:value-of select="//lcl/BES/factuur_aan"/>:</b>
              </td>
              <td style="width:6%"></td>
              <td colspan="2" style="width:47%">
                <b><xsl:value-of select="//lcl/BES/leverancier"/>:</b>
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <xsl:value-of select="factuuradres/naam"/>
                <br/>
                <xsl:value-of select="factuuradres/post_adres"/>
                <br/>
                <xsl:value-of select="factuuradres/post_postcode"/>&#xA0;
                <xsl:value-of select="factuuradres/post_plaats"/>
                <br/>
                <xsl:value-of select="factuuradres/post_land"/>
              </td>
              <td/>
              <td colspan="2">
                <xsl:value-of select="bedrijf/naam"/>
                <br/>
                <xsl:value-of select="bedrijf/post_adres"/>
                <br/>
                <xsl:value-of select="bedrijf/post_postcode"/>&#xA0;
                <xsl:value-of select="bedrijf/post_plaats"/>
                <br/>
                <xsl:value-of select="bedrijf/post_land"/>
              </td>
            </tr>
            <tr>
              <td colspan="5" style="height:20"/>
            </tr>
            <tr>
              <td colspan="2">
                <b><xsl:value-of select="//lcl/FAC/contactgegevens"/>:</b>
              </td>
              <td/>
              <td colspan="2">
                <b/>
              </td>
            </tr>
            <tr>
              <td colspan="2" style="vertical-align:top">
                <b><xsl:value-of select="//lcl/BES/besteller"/>: </b>
                <xsl:value-of select="bestelling/aanvrager/naam_full"/>
                <br/>
                <b><xsl:value-of select="//lcl/FAC/e-mail"/>: </b>
                <xsl:value-of select="bestelling/aanvrager/email"/>
                <br/>
                <b><xsl:value-of select="//lcl/FAC/telefoon"/>: </b>
                <xsl:value-of select="bestelling/aanvrager/telefoonnr"/>
                <br/>
                <b><xsl:value-of select="//lcl/FAC/kostenplaats"/>: </b>
                <xsl:value-of select="bestelling/kostenplaats/nr"/>
                <br/>
                <b><xsl:value-of select="//lcl/FAC/werkplek"/>: </b>
                <xsl:value-of select="bestelling/plaats"/>
                <br/>
                <br/>
                <b><xsl:value-of select="//lcl/BES/gewenste_afleverdatum"/>: </b>
                <xsl:value-of select="bestelling/leverdatum/datum"/>
              </td>
              <td/>
              <td colspan="2" style="vertical-align:top">
                <b><xsl:value-of select="//lcl/BES/aanvraagnummers"/>: </b>
                <xsl:value-of select="bestelling/key"/>
                <br/>
                <b><xsl:value-of select="//lcl/BES/opdrachtnummer"/>: </b>
                <xsl:value-of select="id"/>
                <br/>
                <b><xsl:value-of select="//lcl/BES/orderdatum"/>: </b>
                <xsl:value-of select="datum/datum"/>
              </td>
            </tr>
            <tr>
              <td colspan="5" style="height:20"/>
            </tr>
            <tr>
              <td colspan="2">
                <b><xsl:value-of select="//lcl/BES/afleveradres"/>:</b>
              </td>
              <td/>
              <td colspan="2">
                <b/>
              </td>
            </tr>
            
            
            
            
            <tr>
                <xsl:choose>
                    <!-- "extern afleveradres, en anders intern (HAYG) kantoor afleveradres -->
                    <xsl:when test="bestelling/kenmerk[@key=10] != ''">
                        <!-- straat + huisnummer is ingevuld, dus extern -->
                        <xsl:apply-templates select="." mode="extern_adres"/>
                    </xsl:when>
                    <!-- "alle andere mld-opdrachten" -->
                    <xsl:otherwise>
                      <xsl:apply-templates select="." mode="intern_adres"/>
                    </xsl:otherwise>
                </xsl:choose>
                <td/>
                <td colspan="2" style="vertical-align:top">
                <!-- de externe afleveradressen zijn flexprops (key 5, 8, ,9 10) en die worden hier overgeslagen.-->
                <xsl:for-each select="bestelling/kenmerk[@type!='L' and @type!='l' and @type!='Q' and @key!=5 and @key!=8 and @key!=9 and @key!=10]">
                  <b>
                    <xsl:value-of select="@naam"/>: </b>
                  <xsl:value-of select="."/>
                  <br/>
                </xsl:for-each>&#xA0;</td>
            </tr>
            <tr>
              <td colspan="5" style="height:20"/>
            </tr>
            <TR>
              <TD colspan="5">
                <TABLE cellpadding="0" cellspacing="0" border="1" bordercolor="#303030" width="100%">
                  <tr>
                    <th style="width:20"><xsl:value-of select="//lcl/BES/regel"/></th>
                    <th style="width:20"><xsl:value-of select="//lcl/BES/artikelnr"/></th>
                    <th style="width:200"><xsl:value-of select="//lcl/FAC/omschrijving"/></th>
                    <th style="width:20"><xsl:value-of select="//lcl/FAC/eenheid"/></th>
                    <th style="width:20; text-align:right"><xsl:value-of select="//lcl/FAC/aantal"/></th>
                    <th style="width:20; text-align:right"><xsl:value-of select="//lcl/FAC/prijs"/></th>
                    <th style="width:20; text-align:right"><xsl:value-of select="//lcl/FAC/totaal"/></th>
                  </tr>
                  <xsl:for-each select="bestelopdrachtitem">
                    <xsl:sort select="srtdeel/omschrijving"/>
                    <xsl:sort select="posnr" data-type="number"/>
                    <tr>
                      <td class="result">
                        <xsl:value-of select="posnr"/>
                      </td>
                      <td class="result">
                        <xsl:value-of select="bestelitem/srtdeel/artikel_nummer"/>
                      </td>
                      <td class="result">
                        <xsl:value-of select="bestelitem/srtdeel/omschrijving"/>&#xA0;
                        <xsl:for-each select="bestelitem/kenmerk">
                          <br/>
                          <xsl:value-of select="@naam"/>: <xsl:value-of select="."/></xsl:for-each>
                      </td>
                      <td class="result">
                        <xsl:value-of select="bestelitem/srtdeel/eenheid"/>
                      </td>
                      <td class="result" style="text-align:right">
                        <xsl:value-of select="aantal"/>
                      </td>
                      <td class="result" style="text-align:right">
                        <xsl:value-of select="format-number(prijs, '0,00', 'european')"/>
                      </td>
                      <td class="result" style="text-align:right">
                        <xsl:value-of select="format-number(totaal, '0,00', 'european')"/>
                      </td>
                    </tr>
                  </xsl:for-each>
                  <tr>
                    <td colspan="6"/>
                    <td style="text-align:right">
                      <b>
                        <xsl:value-of select="format-number(sum(bestelopdrachtitem/totaal), '0,00', 'european')"/>
                      </b>
                    </td>
                  </tr>
                </TABLE>
              </TD>
            </TR>
            <tr>
              <td colspan="5" style="height:40"/>
            </tr>
            <tr>
              <td colspan="5" style="text-align:center; font-size:9px">Op leveringen die gedaan zijn op basis van dit formulier zijn de algemene inkoopvoorwaarden van HayGroup van toepassing. Indien sprake is van een mantelovereenkomst geschiedt deze order onder de bepalingen uit de mantelovereenkomst. Facturen zonder vermelding van het opdrachtnummer (<xsl:value-of select="id"/>)<xsl:value-of select="//lcl/BES/order_disclaimer2"/></td>
            </tr>
          </table>
        </TD>
        <TD WIDTH="30" ROWSPAN="30" ID="RECHTERMARGE"/>
      </TR>
    </TABLE>
  </xsl:template>
	
	
	<xsl:template match="bestelopdracht" mode="intern_adres">
      <td colspan="2" style="vertical-align:top">
        <xsl:comment>Bestemd voor</xsl:comment>
        <xsl:value-of select="bestelling/kenmerk[@key=5]"/>
        <br/>
        <xsl:value-of select="afleveradres/naam"/>
        <br/>
        <xsl:value-of select="afleveradres/bezoek_adres"/>
        <br/>
        <xsl:value-of select="afleveradres/bezoek_postcode"/>&#xA0;
        <xsl:value-of select="afleveradres/bezoek_plaats"/>
        <br/>
        <xsl:value-of select="afleveradres/bezoek_land"/>
      </td>
	</xsl:template>
	
	<xsl:template match="bestelopdracht" mode="extern_adres">
      <td colspan="2" style="vertical-align:top">
        <xsl:comment>Bestemd voor</xsl:comment>
        <xsl:value-of select="bestelling/kenmerk[@key=5]"/>
        <br/>
        <xsl:comment>Straat+huisnr</xsl:comment>
        <xsl:value-of select="bestelling/kenmerk[@key=10]"/>
        <br/>
        <xsl:comment>Postcode+Plaats</xsl:comment>
        <xsl:value-of select="bestelling/kenmerk[@key=9]"/>&#xA0;<xsl:value-of select="bestelling/kenmerk[@key=8]"/>
      </td>
	</xsl:template>
	
	
	
	
</xsl:stylesheet>
