<?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:param name="rooturl"/>
  <xsl:param name="custpath"/>

	<xsl:template name="stylesheet">
		<style>body {
       font-family: Verdana;
       background-color: rgb(255, 255, 255);
       margin-left:8;
       margin-top:8;
       cursor: auto;
    }

    table {
      border: 0;
    }

    table.details {
      background-color: "#31398C";
    }

    th {
      font-family: Verdana;
      font-size: 9pt;
      font-weight: normal;
      color: #ffffff;
      text-decoration: none;
      padding-left:  3px;
      padding-right: 3px;
      padding-top: 3px;
      padding-bottom: 3px;
      background-color: #31398C;
    }

    td {
      font-family: Verdana;
      font-style: normal;
      font-size: 8pt;
      font-weight: normal;
      color:  #000000;
      text-align: left;
      vertical-align: top;
    }

    td.result {
      text-decoration: none;
      padding-bottom: 2px;
      padding-top: 2px;
      padding-left: 2px;
      padding-right: 2px;
      background-color: #D6D8E8;
    }

    td.sec_heading {
      font-size: 9pt;
      text-decoration: none;
      padding-bottom: 2px;
      padding-top: 2px;
      padding-left: 2px;
      padding-right: 2px;
      text-align: left;
      background-color: #d0d0d0;
    }

    td.caption {
      font-size:   14pt;
      padding-bottom: 30px;
      padding-top: 40px;
    }

    td.subcaption {
      font-size: 10pt;
      font-weight: bold;
      text-decoration: underline;
    }

    td.label {
      font-size: 10pt;
    }

    td.value {
      font-style: italic;
      font-size: 10pt;
    }

    td.tekst {
      font-size: 10pt;
    }

    td.adres {
      font-size: 8pt;
      text-align: right;
    }

    td.tekstkop {
      font-weight: bold;
      font-size: 10pt;
    }

    td.tiny {
      font-size: 6pt;
      text-align: right;
    }</style>
	</xsl:template>

  <xsl:template name="pageheader2">
    <table border="0" width="100%">
      <tr>
        <td width="33%"></td>
        <td width="34%" class="tekst" style="font-size:12pt;text-align:center"><b>Inkooporder</b></td>
        <td width="33%" class="tekst" style="text-align:right">
          <xsl:choose>
            <xsl:when test="$mode='email'">
              <img src="cid:tmpl_logo.gif"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:element name="img"><xsl:attribute name="src"><xsl:value-of select="$custpath"/>/tmpl_logo.gif</xsl:attribute></xsl:element>
            </xsl:otherwise>
          </xsl:choose>
        </td>
      </tr>
    </table>
  </xsl:template>

  <xsl:template match="bestelling" mode="include">
    <table border="0" style="width:100%;border-collapse:collapse;" cellpadding="0" cellspacing="0">
            <tr><td colspan="2" class="tekst" style="width:100%;"><br/><br/></td></tr>
            <tr>
              <td colspan="2" class="tekst" style="width:100%;">
                <xsl:choose>
                  <xsl:when test="$srtnotificatiecode='BESAPI'">
Beste collega,<br/><br/>
U heeft een fiatteringsverzoek ontvangen, wilt u die in behandeling nemen.<br/><br/>
Indien u akkoord bent en de bestelling fiatteert zal de bestelling direct worden verzonden naar <xsl:choose><xsl:when test="bestelopdracht/bedrijf/naam!=''"><xsl:value-of select="bestelopdracht/bedrijf/naam"/></xsl:when><xsl:otherwise><xsl:value-of select="substring-before(concat(bestelitem/srtdeel/srtgroep/discipline/omschrijving, ' '), ' ')"/></xsl:otherwise></xsl:choose>.
                  </xsl:when>
                  <xsl:when test="$srtnotificatiecode='BESBES'">
Beste collega,<br/><br/>
Uw bestelaanvraag <xsl:if test="ismutatie=1">(WIJZIGING)</xsl:if><xsl:if test="isretour=1">(RETOUR)</xsl:if> is omgezet in onderstaande order en naar <xsl:choose><xsl:when test="bestelopdracht/bedrijf/naam!=''"><xsl:value-of select="bestelopdracht/bedrijf/naam"/></xsl:when><xsl:otherwise><xsl:value-of select="substring-before(concat(bestelitem/srtdeel/srtgroep/discipline/omschrijving, ' '), ' ')"/></xsl:otherwise></xsl:choose> verzonden.<br/><br/>
Voor eventuele vragen of opmerkingen graag een mail naar <a href="mailto:inkoop@svrz.nl"><nobr>inkoop@svrz.nl</nobr></a>.
                  </xsl:when>
                  <xsl:otherwise>
<b><xsl:value-of select="//lcl/BES/bestelaanvraag"/>&#xA0;<xsl:value-of select="key"/><xsl:if test="ismutatie=1"> (WIJZIGING)</xsl:if><xsl:if test="isretour=1"> (RETOUR)</xsl:if></b>
                  </xsl:otherwise>
                </xsl:choose>
              </td>
            </tr>
            <tr><td colspan="2" class="tekst" style="width:100%;"><br/><br/></td></tr>
            <tr>
              <td class="label" style="width:20%;"><xsl:value-of select="//lcl/BES/bestelvoor"/>:</td>
              <td class="value" style="width:80%;"><xsl:value-of select="voor/naam_full"/></td>
            </tr>
            <xsl:if test="string(voor/email)!=''">
              <tr>
                <td class="label"><xsl:value-of select="//lcl/FAC/e-mail"/>:</td>
                <td class="value"><xsl:value-of select="voor/email"/></td>
              </tr>
            </xsl:if>
            <xsl:if test="voor/telefoonnr!=''">
              <tr>
                <td class="label"><xsl:value-of select="//lcl/FAC/telefoon"/>:</td>
                <td class="value"><xsl:value-of select="voor/telefoonnr"/></td>
              </tr>
            </xsl:if>
            <tr>
              <td class="label"><xsl:value-of select="//lcl/FAC/afdeling"/>:</td>
              <td class="value"><xsl:if test="voor/afdeling/omschrijving=''">-</xsl:if><xsl:value-of select="voor/afdeling/omschrijving"/></td>
            </tr>
            <tr><td height="20px"/></tr>
            <xsl:if test="string(voor/naam_full)!=string(aanvrager/naam_full)">
              <tr>
                <td class="label"><xsl:value-of select="//lcl/FAC/aanvrager"/>:</td>
                <td class="value"><xsl:value-of select="aanvrager/naam_full"/></td>
              </tr>
            </xsl:if>
            <tr>
              <td class="label"><xsl:value-of select="//lcl/FAC/kostenplaats"/>:</td>
              <td class="value"><xsl:if test="kostenplaats/nr=''">-</xsl:if><xsl:value-of select="kostenplaats/nr"/></td>
            </tr>
            <tr>
              <td class="label"><xsl:value-of select="//lcl/BES/aanvraagdatum"/>:</td>
              <td class="value"><xsl:value-of select="datum/datum"/>&#xA0;<xsl:value-of select="datum/tijd"/></td>
            </tr>
            <tr>
              <td class="label"><xsl:value-of select="//lcl/BES/gewenste_afleverdatum"/>:</td>
              <td class="value"><xsl:value-of select="leverdatum/datum"/></td>
            </tr>
            <tr>
              <td class="label"><xsl:value-of select="//lcl/BES/aanvraagstatus"/>:</td>
              <td class="value"><xsl:value-of select="status"/></td>
            </tr>
            <tr>
              <td class="label" style="vertical-align:top"><xsl:value-of select="//lcl/BES/afleveradres"/>:</td>
              <td class="value">
                <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>
            </tr>
            <tr><td height="20px"/></tr>
            <xsl:for-each select="kenmerk[count(@xmlnode)=0]">
              <xsl:if test="(@type!='L' and @type!='l' and @type!='Q')">
                <tr>
                  <td class="label"><xsl:value-of select="@naam"/>:</td>
                  <td class="value"><xsl:value-of select="."/></td>
                </tr>
              </xsl:if>
            </xsl:for-each>
            <tr><td height="20px"/></tr>
            <tr>
              <td colspan="2">
                <!--table cellpadding="0" cellspacing="0" border="1" bordercolor="#303030" width="100%"-->
                <table border="1" style="width:100%;border-collapse:collapse;" cellpadding="0" cellspacing="0">
                  <tr>
                    <th style="border:1px solid black;"><xsl:value-of select="//lcl/BES/artikelnr"/></th>
                    <th style="border:1px solid black;"><xsl:value-of select="//lcl/FAC/omschrijving"/></th>
                    <th style="border:1px solid black;"><xsl:value-of select="//lcl/FAC/opmerkingen"/></th>
                    <th style="text-align:right;border:1px solid black;"><xsl:value-of select="//lcl/FAC/aantal"/></th>
                    <th style="text-align:right;border:1px solid black;"><xsl:value-of select="//lcl/FAC/prijs"/></th>
                    <th style="text-align:right;border:1px solid black;"><xsl:value-of select="//lcl/FAC/totaal"/></th>
                  </tr>
                  <xsl:for-each select="bestelitem">
                    <tr>
                      <td class="result" style="text-align:left;">&#xA0;<xsl:value-of select="srtdeel/artikel_nummer"/></td>
                      <td class="result" style="text-align:left;"><xsl:value-of select="srtdeel/omschrijving"/></td>
                      <td class="result">
                        <xsl:for-each select="kenmerk[count(@xmlnode)=0]">
                          <xsl:if test="(@type!='L' and @type!='l' and @type!='Q')"><xsl:value-of select="@naam"/>: <xsl:value-of select="."/><br/></xsl:if>
                        </xsl:for-each>&#xA0;
                      </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(aantal*prijs, '0,00', 'european')"/></td>
                    </tr>
                  </xsl:for-each>
                  <tr><td height="6px" style="border-style:solid;border-width:0px;"/></tr>
                  <xsl:if test="/facilitor/bestelling/levkosten!='0'">
                    <tr>
                      <td class="tekst" style="text-align:right;border-style:solid;border-width:0px;" colspan="5"><xsl:value-of select="//lcl/BES/transportkosten"/>:</td>
                      <td class="tekst" style="text-align:right;border-style:solid;border-width:0px;"><xsl:value-of select="format-number(/facilitor/bestelling/levkosten, '0,00', 'european')"/></td>
                    </tr>
                  </xsl:if>
                  <tr>
                    <td class="tekstkop" style="text-align:right;border-style:solid;border-width:0px;" colspan="5"><xsl:value-of select="//lcl/FAC/totaal"/>:</td>
                    <td class="tekstkop" style="text-align:right;border-style:solid;border-width:0px;"><xsl:value-of select="format-number(sum(/facilitor/bestelling/bestelitem/totaal)+ /facilitor/bestelling/levkosten, '0,00', 'european')"/></td>
                  </tr>
                </table>
              </td>
            </tr>
    </table>
  </xsl:template>

  <xsl:template match="bestelopdracht" mode="include">
    <!--xsl:variable name="intern">
      <xsl:choose>
        <xsl:when test="bedrijf/key='21'">1</xsl:when>
        <xsl:otherwise>0</xsl:otherwise>
      </xsl:choose>
    </xsl:variable-->
    <!-- Define - "brute force" - variable to find/determine prefix -->
    <xsl:variable name="lev5">
      <xsl:value-of select="bestelling/voor/afdeling/parent/parent/parent/parent/naam"/>
    </xsl:variable>
    <xsl:variable name="lev4">
      <xsl:value-of select="bestelling/voor/afdeling/parent/parent/parent/naam"/>
    </xsl:variable>
    <xsl:variable name="lev3">
      <xsl:value-of select="bestelling/voor/afdeling/parent/parent/naam"/>
    </xsl:variable>
    <xsl:variable name="lev2">
      <xsl:value-of select="bestelling/voor/afdeling/parent/naam"/>
    </xsl:variable>
    <xsl:variable name="lev1">
      <xsl:value-of select="bestelling/voor/afdeling/naam"/>
    </xsl:variable>
    <xsl:variable name="prefix">
      <xsl:choose>
        <xsl:when test="$lev5!=''">
          <xsl:choose>
            <xsl:when test="substring(bestelling/voor/afdeling/parent/parent/parent/parent/naam, 1, 1) = '4'">230</xsl:when>
            <xsl:when test="substring(bestelling/voor/afdeling/parent/parent/parent/parent/naam, 1, 1) = '5'">245</xsl:when>
            <xsl:when test="substring(bestelling/voor/afdeling/parent/parent/parent/parent/naam, 1, 1) = '6'">260</xsl:when>
            <xsl:otherwise>215</xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:when test="$lev4!=''">
          <xsl:choose>
            <xsl:when test="substring(bestelling/voor/afdeling/parent/parent/parent/naam, 1, 1) = '4'">230</xsl:when>
            <xsl:when test="substring(bestelling/voor/afdeling/parent/parent/parent/naam, 1, 1) = '5'">245</xsl:when>
            <xsl:when test="substring(bestelling/voor/afdeling/parent/parent/parent/naam, 1, 1) = '6'">260</xsl:when>
            <xsl:otherwise>215</xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:when test="$lev3!=''">
          <xsl:choose>
            <xsl:when test="substring(bestelling/voor/afdeling/parent/parent/naam, 1, 1) = '4'">230</xsl:when>
            <xsl:when test="substring(bestelling/voor/afdeling/parent/parent/naam, 1, 1) = '5'">245</xsl:when>
            <xsl:when test="substring(bestelling/voor/afdeling/parent/parent/naam, 1, 1) = '6'">260</xsl:when>
            <xsl:otherwise>215</xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:when test="$lev2!=''">
          <xsl:choose>
            <xsl:when test="substring(bestelling/voor/afdeling/parent/naam, 1, 1) = '4'">230</xsl:when>
            <xsl:when test="substring(bestelling/voor/afdeling/parent/naam, 1, 1) = '5'">245</xsl:when>
            <xsl:when test="substring(bestelling/voor/afdeling/parent/naam, 1, 1) = '6'">260</xsl:when>
            <xsl:otherwise>215</xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:when test="$lev1!=''">
          <xsl:choose>
            <xsl:when test="substring(bestelling/voor/afdeling/naam, 1, 1) = '4'">230</xsl:when>
            <xsl:when test="substring(bestelling/voor/afdeling/naam, 1, 1) = '5'">245</xsl:when>
            <xsl:when test="substring(bestelling/voor/afdeling/naam, 1, 1) = '6'">260</xsl:when>
            <xsl:otherwise>215</xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:otherwise>999</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="digifact">
      <xsl:choose>
        <xsl:when test="$prefix = 215">factuur215@svrz.nl</xsl:when>
        <xsl:when test="$prefix = 230">factuur230@svrz.nl</xsl:when>
        <xsl:when test="$prefix = 245">factuur245@svrz.nl</xsl:when>
        <xsl:when test="$prefix = 260">factuur260@svrz.nl</xsl:when>
        <xsl:otherwise></xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="cp">
      <xsl:for-each select="bedrijf/contactpersoon">
        <xsl:sort select="naam"/>
        <xsl:if test="position()=1"><xsl:copy-of select="."/></xsl:if>
      </xsl:for-each>
    </xsl:variable>
    <xsl:variable name="voorl">
      <xsl:choose>
        <!-- Voorletters van alfabetisch eerste van contactpersonen (of leeg) -->
        <xsl:when test="msxml:node-set($cp)/contactpersoon/naam!=''"><xsl:value-of select="msxml:node-set($cp)/contactpersoon/voorletters"/></xsl:when>
        <!-- "Vaste" contactpersoon (of geen enkele contactpersoon) -->
        <xsl:otherwise></xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="anaam">
      <xsl:choose>
        <!-- Samengestelde achternaam van alfabetisch eerste van contactpersonen -->
        <xsl:when test="msxml:node-set($cp)/contactpersoon/naam!=''"><xsl:value-of select="msxml:node-set($cp)/contactpersoon/tussenv"/><xsl:text> </xsl:text><xsl:value-of select="msxml:node-set($cp)/contactpersoon/naam"/></xsl:when>
        <!-- "Vaste" contactpersoon (of leeg) -->
        <xsl:otherwise><xsl:value-of select="bedrijf/contact_persoon"/></xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="aanvraag">
      <xsl:value-of select="concat('000000', bestelling/key)"/>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="1=1">
        <table border="0" style="width:100%;border-collapse:collapse;" cellpadding="0" cellspacing="0">
          <tr>
            <td colspan="4" class="tekst" style="width:60%;">
              <br/><br/><br/>
              <xsl:value-of select="bedrijf/naam"/><br/>
              <xsl:if test="$anaam!=''">T.a.v. <xsl:value-of select="$voorl"/><xsl:text> </xsl:text><xsl:value-of select="$anaam"/><br/></xsl:if>
              <xsl:value-of select="bedrijf/post_adres"/><br/>
              <xsl:value-of select="bedrijf/post_postcode"/><xsl:text>  </xsl:text><xsl:value-of select="bedrijf/post_plaats"/><br/>
              <xsl:if test="bedrijf/post_land!='NL'"><xsl:value-of select="bedrijf/post_land"/></xsl:if><br/>
              <xsl:if test="not($anaam!='')"><br/></xsl:if>
              <br/><br/>
            </td>
            <td colspan="2" class="tekst" style="width:14%;"/>
            <td colspan="3" class="tekst">
              <br/><br/>
              <b>Factuuradres</b><br/>
              SVRZ<br/>
              <xsl:choose>
                <xsl:when test="substring-before(concat($digifact, '@'),'@')='factuur230'">F&amp;C Walcheren</xsl:when>
                <xsl:when test="substring-before(concat($digifact, '@'),'@')='factuur245'">F&amp;C Oosterschelde</xsl:when>
                <xsl:when test="substring-before(concat($digifact, '@'),'@')='factuur260'">F&amp;C Zeeuws-Vlaanderen</xsl:when>
                <xsl:otherwise>Concern-administratie</xsl:otherwise>
              </xsl:choose><br/>
              Postbus 100<br/>
              4330 AC<xsl:text>  </xsl:text>Middelburg<br/>
              <xsl:if test="$digifact!=''">of <xsl:value-of select="$digifact"/></xsl:if>
            </td>
          </tr>
          <tr>
            <td colspan="4" class="tekst" style="width:60%;border:1px solid black;padding:3px;">
              <table border="0" style="width:100%;border-collapse:collapse;" cellpadding="0" cellspacing="0">
                <tr>
                  <td colspan="2" class="tekst"><b>Inkoopordernr PUR-C1<xsl:value-of select="substring($aanvraag, string-length($aanvraag)-5)"/>-<xsl:value-of select="substring-after(id, '/')"/></b></td>
                </tr>
                <tr>
                  <td class="tekst" style="width:35%;">Besteld door:</td>
                  <td class="tekst"><xsl:if test="bestelling/voor/voorletters!=''"><xsl:value-of select="bestelling/voor/voorletters"/><xsl:text> </xsl:text></xsl:if><xsl:if test="bestelling/voor/tussenvoegsel!=''"><xsl:value-of select="bestelling/voor/tussenvoegsel"/><xsl:text> </xsl:text></xsl:if><xsl:value-of select="bestelling/voor/naam"/></td>
                </tr>
                <tr>
                  <td class="tekst"></td>
                  <td class="tekst">T: <xsl:value-of select="bestelling/voor/telefoonnr"/></td>
                </tr>
                <tr>
                  <td class="tekst"></td>
                  <td class="tekst">E: <xsl:value-of select="bestelling/voor/email"/></td>
                </tr>
                <!--tr>
                  <td class="tekst"></td>
                  <td class="tekst"></td>
                </tr-->
                <tr>
                  <td class="tekst"><br/>Middelburg,</td>
                  <td class="tekst"><br/><xsl:value-of select="//dateDay"/>-<xsl:value-of select="//dateMonth"/>-<xsl:value-of select="//dateYear"/></td>
                </tr>
              </table>
            </td>
            <td colspan="2" class="tekst" style="width:14%;"/>
            <td colspan="3" class="tekst">
              <b>Afleveradres</b><br/>
              <xsl:value-of select="substring-before(concat(afleveradres/naam, '-'),'-')"/><br/>
              <xsl:if test="bestelling/kenmerk[@naam='T.a.v.']!=''">T.a.v.: <xsl:value-of select="bestelling/kenmerk[@naam='T.a.v.']"/><br/></xsl:if>
              <xsl:value-of select="afleveradres/bezoek_adres"/><br/>
              <xsl:value-of select="afleveradres/bezoek_postcode"/><xsl:text> </xsl:text><xsl:value-of select="afleveradres/bezoek_plaats"/><br/><br/>
              <xsl:if test="bedrijf/kenmerk[@key='1020']!=''">SVRZ klantnummer: <xsl:value-of select="bedrijf/kenmerk[@key='1020']"/></xsl:if>
            </td>
          </tr>
          <tr>
            <td colspan="2" class="tekst"/>
            <td colspan="7" class="tekst">
              <!-- Ingevuld kenmerk anders leeg -->
              <xsl:if test="bestelling/kenmerk[@naam='Opmerking extern']!=''"><br/>Opmerking: <xsl:value-of select="bestelling/kenmerk[@naam='Opmerking extern']"/></xsl:if>
              <br/><br/><br/>
            </td>
          </tr>
          <xsl:for-each select="bestelopdrachtitem">
            <xsl:sort select="posnr" data-type="number"/>
            <xsl:variable name="btw" select="bestelitem/srtdeel/btw"/>
            <xsl:if test="position()=1">
              <tr>
                <td colspan="4" class="tekst" style="width:60%;font-size:8pt;border:1px solid black;padding:3px;">Artikelnummer/<br/>Omschrijving</td>
                <td class="tekst" style="width:8%;font-size:8pt;border:1px solid black;padding:3px;">Aantal/<br/>Eenh.</td>
                <td colspan="2" class="tekst" style="width:12%;font-size:8pt;border:1px solid black;padding:3px;">Nettoprijs<br/>excl. BTW</td>
                <td class="tekst" style="width:8%;font-size:8pt;border:1px solid black;padding:3px;">BTW</td>
                <td class="tekst" style="font-size:8pt;border:1px solid black;padding:3px;">Bedrag<br/>incl. BTW</td>
              </tr>
            </xsl:if>
            <tr>
              <td colspan="4" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                <xsl:choose>
                  <!-- Gebruik igv. Manutan (3981) het Opmerking-veld als - lange - artikelomschrijving! -->
                  <xsl:when test="bestelopdracht/bedrijf/key='3981'"><xsl:value-of select="bestelitem/srtdeel/artikel_nummer"/>/<br/><xsl:value-of select="bestelitem/srtdeel/opmerking"/></xsl:when>
                  <xsl:otherwise><xsl:value-of select="bestelitem/srtdeel/artikel_nummer"/>/<br/><xsl:value-of select="bestelitem/srtdeel/omschrijving"/></xsl:otherwise>
                </xsl:choose>
              </td>
              <td class="tekst" style="width:8%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                <xsl:value-of select="aantal"/><xsl:if test="bestelitem/srtdeel/eenheid!=''">/<br/><xsl:value-of select="bestelitem/srtdeel/eenheid"/></xsl:if>
              </td>
              <td colspan="2" class="tekst" style="width:12%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                € <xsl:value-of select="format-number(prijs, '0,00', 'european')"/>
              </td>
              <td class="tekst" style="width:8%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                <xsl:value-of select="format-number($btw, '0,0', 'european')"/>%
              </td>
              <td class="tekst" style="font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                € <xsl:value-of select="format-number(aantal * (round(prijs * (100 + $btw)) div 100), '0,00', 'european')"/>
              </td>
            </tr>
          </xsl:for-each>
          <tr>
            <td colspan="4" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
            <td class="tekst" style="width:8%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
            <td colspan="2" class="tekst" style="width:12%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
            <td class="tekst" style="width:8%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
            <td class="tekst" style="font-size:9pt;text-align:right;border-right:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
          </tr>
          <xsl:variable name="tmpinclbtw">
            <xsl:for-each select="bestelopdrachtitem">
              <xsl:variable name="btw" select="bestelitem/srtdeel/btw"/>
              <item><xsl:value-of select="aantal * (round(prijs * (100 + $btw)) div 100)"/></item>
            </xsl:for-each>
          </xsl:variable>
          <xsl:variable name="totinclbtw" select="sum(msxml:node-set($tmpinclbtw)/item)"/>
          <tr>
            <td colspan="4" class="tekst" style="font-size:9pt;">
              <table border="0" style="width:100%;border-collapse:collapse;" cellpadding="0" cellspacing="0">
                <tr>
                  <td class="tekst" style="width:35%;font-size:8pt;">
                    <br/>Levering op of rond:
                    <br/>Leveringscondities:
                    <br/>Betalingscondities:
                  </td>
                  <!-- Dynamisch? -->
                  <td class="tekst" style="font-size:8pt;">
                    <!--br/><xsl:choose><xsl:when test="bestelling/kenmerk[@naam='Levering in overleg']='Ja'">In overleg</xsl:when><xsl:otherwise><xsl:value-of select="bestelling/leverdatum/datum"/></xsl:otherwise></xsl:choose-->
                    <br/><xsl:value-of select="bestelling/leverdatum/datum"/>
                    <br/><xsl:value-of select="bedrijf/kenmerk[@key='1000']"/>
                    <br/><xsl:value-of select="bedrijf/kenmerk[@key='1001']"/>
                  </td>
                </tr>
              </table>
            </td>
            <td colspan="4" class="tekst" style="font-size:9pt;">
              <br/><b>Totaalbedrag in euro's:</b>
            </td>
            <td class="tekst" style="font-size:9pt;text-align:right;">
              <br/><b>€ <xsl:value-of select="format-number($totinclbtw, '0,00', 'european')"/></b>
            </td>
          </tr>
          <tr>
            <td colspan="9" class="tekst" style="font-size:8pt;">
              <br/>Op al onze transacties zijn de Algemene Inkoopvoorwaarden Gezondheidszorg, gedeponeerd bij de Rechtbank Den Haag te Den Haag, d.d. 26 augustus 2014 onder depotnummer 41/2014, van toepassing. BTW-nr.: NL823367095.B.02.
            </td>
          </tr>
        </table>
      </xsl:when>
      <xsl:otherwise>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

	<xsl:template match="bestelopdracht" mode="full">
	 <xsl:choose>
		<xsl:when test="$mode='summary'"></xsl:when>
		<xsl:otherwise>
		<html>
			<xsl:comment>================================ BESTELOPDRACHTEN ==============================</xsl:comment>
			<xsl:call-template name="htmlhead"/>
			<xsl:element name="body">
				<xsl:if test="$mode!='email'">
					<xsl:attribute name="onload">window.print();</xsl:attribute>
				</xsl:if>
				<xsl:call-template name="pageheader2"/>
				<xsl:apply-templates select="." mode="include"/>
			</xsl:element>
		</html>
		</xsl:otherwise>
	 </xsl:choose>
	</xsl:template>

	<xsl:template match="reservering" mode="include">
		<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">
			<TR>
				<TD WIDTH="40" ROWSPAN="30" ID="LINKERMARGE"/>
				<TD>
					<xsl:choose>
						<xsl:when test="not(boolean(rsv_ruimte))">
							<table>
								<tr>
									<td height="20"/>
								</tr>
								<tr>
									<td class="caption">Annulering</td>
								</tr>
								<tr>
									<td>
										<b>Op uw naam heeft een reservering<xsl:if test="key!=''"> onder nummer <xsl:value-of select="key"/></xsl:if> plaatsgevonden, die vervolgens direct weer is verwijderd.</b>
										<br/>
										<br/>Deze reservering wordt niet verder verwerkt.<br/><br/>
                  Wilt u toch een reservering aanmaken voeg dan een nieuwe reservering toe waarbij een zaal, voorziening of artikel gereserveerd is.</td>
								</tr>
							</table>
						</xsl:when>
						<xsl:otherwise>
							<!-- Bevestiging reservering -->

							<!-- De algemene gegevens van de deelreservering met het laagste volgnummer worden gebruikt als referentie gegevens! -->
							<xsl:variable name="min_volgnr">
								<xsl:value-of select="//reservering/rsv_ruimte/volgnr[not(. &gt; //reservering/rsv_ruimte/volgnr)]"/>
							</xsl:variable>

							<table border="0" bordercolor="#ffffff" width="100%">
								<tr>
									<td class="caption" valign="top" colspan="2">
										<xsl:choose>
											<xsl:when test="@content='complete'">Reservering <xsl:value-of select="key"/><br/></xsl:when>
											<xsl:otherwise>Deelreservering <xsl:value-of select="key"/> / <xsl:value-of select="$min_volgnr"/><br/></xsl:otherwise>
										</xsl:choose>
										<xsl:if test="string(rsv_ruimte[volgnr=$min_volgnr]/omschrijving)!=''">(<xsl:value-of select="rsv_ruimte[volgnr=$min_volgnr]/omschrijving"/>)</xsl:if>&#xA0;</td>
								</tr>
								<tr>
									<td width="20%" class="label">Aanvrager</td>
									<td width="80%" class="value">: <xsl:value-of select="rsv_ruimte[volgnr=$min_volgnr]/contact_user/naam_full"/></td>
								</tr>
								<tr>
									<td width="20%" class="label">E-mail adres</td>
									<td width="80%" class="value">: <xsl:value-of select="rsv_ruimte[volgnr=$min_volgnr]/contact_user/email"/></td>
								</tr>
								<tr>
									<td width="20%" class="label">Locatie</td>
									<td width="80%" class="value">: <xsl:value-of select="rsv_ruimte[volgnr=$min_volgnr]/contact_user/werkplek/plaats/regio/district/locatie/omschrijving"/></td>
								</tr>
								<tr>
									<td width="20%" class="label">Afdeling</td>
									<td width="80%" class="value">: <xsl:value-of select="rsv_ruimte[volgnr=$min_volgnr]/contact_user/afdeling/omschrijving"/></td>
								</tr>
								<tr>
									<td width="20%" class="label">Gastheer/-vrouw</td>
									<td width="80%" class="value">: <xsl:value-of select="rsv_ruimte[volgnr=$min_volgnr]/host_user/naam_full"/></td>
								</tr>
								<tr>
									<td width="20%" class="label">Kostenplaats</td>
									<td width="80%" class="value">: <xsl:value-of select="rsv_ruimte[volgnr=$min_volgnr]/kostenplaats/nr"/>&#xA0;
										<xsl:value-of select="rsv_ruimte[volgnr=$min_volgnr]/kostenplaats/omschrijving"/>
									</td>
								</tr>
								<xsl:if test="rsv_ruimte[volgnr=$min_volgnr]/contact_user/key!=ingevoerd_user/key">
									<tr>
										<td height="10px"/>
									</tr>
									<tr>
										<td width="20%" class="label">Behandeld door</td>
										<td width="80%" class="value">: <xsl:value-of select="ingevoerd_user/naam_full"/></td>
									</tr>
									<tr>
										<td width="20%" class="label">Datum</td>
										<td width="80%" class="value">: <xsl:value-of select="datum/datum"/></td>
									</tr>
								</xsl:if>
								<tr>
									<td height="5px"/>
								</tr>
								<tr>
									<td colspan="2" class="tekst">
										<xsl:choose>
											<xsl:when test="$srtnotificatiecode='RESNEW'"/>
											<xsl:when test="$srtnotificatiecode='RESDEL'">DE RESERVERING IS VERVALLEN</xsl:when>
											<xsl:otherwise>
												<xsl:call-template name="res_begintext"/>
											</xsl:otherwise>
										</xsl:choose>
									</td>
								</tr>
								<tr>
									<td height="5px"/>
								</tr>
								<tr>
									<td class="tekstkop" colspan="2" style="text-decoration:underline">Reserveringsgegevens</td>
								</tr>
								<tr>
									<td height="5px"/>
								</tr>
								<tr>
									<td colspan="2">
										<table cellpadding="0" cellspacing="0" border="1" bordercolor="#000000" frame="box">
											<!-- rsv_ruimte -->
											<xsl:for-each select="rsv_ruimte">
												<xsl:sort select="volgnr" data-type="number"/>
												<xsl:call-template name="rsv_ruimte">
													<xsl:with-param name="min_volgnr" select="$min_volgnr"/>
												</xsl:call-template>
											</xsl:for-each>
											<!-- totaal reservering -->
											<tr>
												<td height="10px" style="border-style:solid;border-width:0px;"/>
											</tr>
											<tr>
												<td class="tekstkop" align="right" colspan="2" style="border-style:solid;border-width:0px;">Totaalprijs reservering:</td>
												<td class="tekstkop" style="text-align:right;border-style:solid;border-width:0px;">
													<xsl:call-template name="europrijs">
														<xsl:with-param name="prijs"
														                select="sum(rsv_ruimte/prijs[string(number(.))!='NaN'])+sum(rsv_ruimte/rsv_deel/prijs[string(number(.))!='NaN'])+sum(rsv_ruimte/rsv_artikel/prijs[string(number(.))!='NaN'])"/>
													</xsl:call-template>
												</td>
											</tr>
										</table>
									</td>
								</tr>
								<xsl:call-template name="res_endtext">
									<xsl:with-param name="min_volgnr" select="$min_volgnr"/>
								</xsl:call-template>
							</table>
							<!-- Bevestiging reservering -->
						</xsl:otherwise>
					</xsl:choose>
				</TD>
				<TD WIDTH="30" ROWSPAN="30" ID="RECHTERMARGE"/>
			</TR>
		</TABLE>
	</xsl:template>

  <xsl:template match="opdracht" mode="include">
    <!--xsl:variable name="intern">
      <xsl:choose>
        <xsl:when test="bedrijf/key='21'">1</xsl:when>
        <xsl:otherwise>0</xsl:otherwise>
      </xsl:choose>
    </xsl:variable-->
    <!-- Define - "brute force" - variable to find/determine prefix -->
    <xsl:variable name="lev5">
      <xsl:value-of select="melding/voor/afdeling/parent/parent/parent/parent/naam"/>
    </xsl:variable>
    <xsl:variable name="lev4">
      <xsl:value-of select="melding/voor/afdeling/parent/parent/parent/naam"/>
    </xsl:variable>
    <xsl:variable name="lev3">
      <xsl:value-of select="melding/voor/afdeling/parent/parent/naam"/>
    </xsl:variable>
    <xsl:variable name="lev2">
      <xsl:value-of select="melding/voor/afdeling/parent/naam"/>
    </xsl:variable>
    <xsl:variable name="lev1">
      <xsl:value-of select="melding/voor/afdeling/naam"/>
    </xsl:variable>
    <xsl:variable name="prefix">
      <xsl:choose>
        <xsl:when test="$lev5!=''">
          <xsl:choose>
            <xsl:when test="substring(melding/voor/afdeling/parent/parent/parent/parent/naam, 1, 1) = '4'">230</xsl:when>
            <xsl:when test="substring(melding/voor/afdeling/parent/parent/parent/parent/naam, 1, 1) = '5'">245</xsl:when>
            <xsl:when test="substring(melding/voor/afdeling/parent/parent/parent/parent/naam, 1, 1) = '6'">260</xsl:when>
            <xsl:otherwise>215</xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:when test="$lev4!=''">
          <xsl:choose>
            <xsl:when test="substring(melding/voor/afdeling/parent/parent/parent/naam, 1, 1) = '4'">230</xsl:when>
            <xsl:when test="substring(melding/voor/afdeling/parent/parent/parent/naam, 1, 1) = '5'">245</xsl:when>
            <xsl:when test="substring(melding/voor/afdeling/parent/parent/parent/naam, 1, 1) = '6'">260</xsl:when>
            <xsl:otherwise>215</xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:when test="$lev3!=''">
          <xsl:choose>
            <xsl:when test="substring(melding/voor/afdeling/parent/parent/naam, 1, 1) = '4'">230</xsl:when>
            <xsl:when test="substring(melding/voor/afdeling/parent/parent/naam, 1, 1) = '5'">245</xsl:when>
            <xsl:when test="substring(melding/voor/afdeling/parent/parent/naam, 1, 1) = '6'">260</xsl:when>
            <xsl:otherwise>215</xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:when test="$lev2!=''">
          <xsl:choose>
            <xsl:when test="substring(melding/voor/afdeling/parent/naam, 1, 1) = '4'">230</xsl:when>
            <xsl:when test="substring(melding/voor/afdeling/parent/naam, 1, 1) = '5'">245</xsl:when>
            <xsl:when test="substring(melding/voor/afdeling/parent/naam, 1, 1) = '6'">260</xsl:when>
            <xsl:otherwise>215</xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:when test="$lev1!=''">
          <xsl:choose>
            <xsl:when test="substring(melding/voor/afdeling/naam, 1, 1) = '4'">230</xsl:when>
            <xsl:when test="substring(melding/voor/afdeling/naam, 1, 1) = '5'">245</xsl:when>
            <xsl:when test="substring(melding/voor/afdeling/naam, 1, 1) = '6'">260</xsl:when>
            <xsl:otherwise>215</xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:otherwise>999</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="digifact">
      <xsl:choose>
        <xsl:when test="$prefix = 215">factuur215@svrz.nl</xsl:when>
        <xsl:when test="$prefix = 230">factuur230@svrz.nl</xsl:when>
        <xsl:when test="$prefix = 245">factuur245@svrz.nl</xsl:when>
        <xsl:when test="$prefix = 260">factuur260@svrz.nl</xsl:when>
        <xsl:otherwise></xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="cp">
      <xsl:for-each select="uitvoerende/bedrijf/contactpersoon">
        <xsl:sort select="naam"/>
        <xsl:if test="position()=1"><xsl:copy-of select="."/></xsl:if>
      </xsl:for-each>
    </xsl:variable>
    <xsl:variable name="voorl">
      <xsl:choose>
        <!-- Voorletters van geselecteerde contactpersoon (of leeg) -->
        <xsl:when test="contactpersoon/naam!=''"><xsl:value-of select="contactpersoon/voorletters"/></xsl:when>
        <!-- Voorletters van alfabetisch eerste van contactpersonen (of leeg) -->
        <xsl:otherwise><xsl:value-of select="msxml:node-set($cp)/contactpersoon/voorletters"/></xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="anaam">
      <xsl:choose>
        <!-- Samengestelde achternaam van geselecteerde contactpersoon -->
        <xsl:when test="contactpersoon/naam!=''"><xsl:if test="contactpersoon/tussenv!=''"><xsl:value-of select="contactpersoon/tussenv"/><xsl:text> </xsl:text></xsl:if><xsl:value-of select="contactpersoon/naam"/></xsl:when>
        <!-- Samengestelde achternaam van alfabetisch eerste van contactpersonen -->
        <xsl:when test="msxml:node-set($cp)/contactpersoon/naam!=''"><xsl:if test="msxml:node-set($cp)/contactpersoon/tussenv!=''"><xsl:value-of select="msxml:node-set($cp)/contactpersoon/tussenv"/><xsl:text> </xsl:text></xsl:if><xsl:value-of select="msxml:node-set($cp)/contactpersoon/naam"/></xsl:when>
        <!-- Achternaam van "vaste" contactpersoon (of leeg) -->
        <xsl:otherwise><xsl:value-of select="uitvoerende/bedrijf/contact_persoon"/></xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="aanvraag">
      <xsl:value-of select="concat('000000', melding/key)"/>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="opdrachttype/key='5'">
        <table border="0" style="width:100%;border-collapse:collapse;" cellpadding="0" cellspacing="0">
          <tr>
            <td colspan="4" class="tekst" style="width:60%;">
              <br/><br/><br/>
              <xsl:value-of select="uitvoerende/bedrijf/naam"/><br/>
              <xsl:if test="$anaam!=''">T.a.v. <xsl:value-of select="$voorl"/><xsl:text> </xsl:text><xsl:value-of select="$anaam"/><br/></xsl:if>
              <xsl:value-of select="uitvoerende/bedrijf/post_adres"/><br/>
              <xsl:value-of select="uitvoerende/bedrijf/post_postcode"/><xsl:text>  </xsl:text><xsl:value-of select="uitvoerende/bedrijf/post_plaats"/><br/>
              <xsl:if test="uitvoerende/bedrijf/post_land!='NL'"><xsl:value-of select="uitvoerende/bedrijf/post_land"/></xsl:if><br/>
              <xsl:if test="not($anaam!='')"><br/></xsl:if>
              <br/><br/>
            </td>
            <td colspan="2" class="tekst" style="width:14%;"/>
            <td colspan="3" class="tekst">
              <br/><br/>
              <b>Factuuradres</b><br/>
              SVRZ<br/>
              <xsl:choose>
                <xsl:when test="substring-before(concat($digifact, '@'),'@')='factuur230'">F&amp;C Walcheren</xsl:when>
                <xsl:when test="substring-before(concat($digifact, '@'),'@')='factuur245'">F&amp;C Oosterschelde</xsl:when>
                <xsl:when test="substring-before(concat($digifact, '@'),'@')='factuur260'">F&amp;C Zeeuws-Vlaanderen</xsl:when>
                <xsl:otherwise>Concern-administratie</xsl:otherwise>
              </xsl:choose><br/>
              Postbus 100<br/>
              4330 AC<xsl:text>  </xsl:text>Middelburg<br/>
              <xsl:if test="$digifact!=''">of <xsl:value-of select="$digifact"/></xsl:if>
            </td>
          </tr>
          <tr>
            <td colspan="4" class="tekst" style="width:60%;border:1px solid black;padding:3px;">
              <table border="0" style="width:100%;border-collapse:collapse;" cellpadding="0" cellspacing="0">
                <tr>
                  <td colspan="2" class="tekst"><b>Inkoopordernr PUR-N1<xsl:value-of select="substring($aanvraag, string-length($aanvraag)-5)"/>-<xsl:value-of select="bedrijfopdr_volgnr"/></b></td>
                </tr>
                <tr>
                  <td class="tekst" style="width:35%;">Besteld door:</td>
                  <td class="tekst"><xsl:if test="melding/voor/voorletters!=''"><xsl:value-of select="melding/voor/voorletters"/><xsl:text> </xsl:text></xsl:if><xsl:if test="melding/voor/tussenvoegsel!=''"><xsl:value-of select="melding/voor/tussenvoegsel"/><xsl:text> </xsl:text></xsl:if><xsl:value-of select="melding/voor/naam"/></td>
                </tr>
                <tr>
                  <td class="tekst"></td>
                  <td class="tekst">T: <xsl:value-of select="melding/voor/telefoonnr"/></td>
                </tr>
                <tr>
                  <td class="tekst"></td>
                  <td class="tekst">E: <xsl:value-of select="melding/voor/email"/></td>
                </tr>
                <!--tr>
                  <td class="tekst"><xsl:if test="$anaam!=''">Contactpersoon leverancier:</xsl:if></td>
                  <td class="tekst"><xsl:if test="$anaam!=''"><xsl:value-of select="$voorl"/><xsl:text> </xsl:text><xsl:value-of select="$anaam"/></xsl:if></td>
                </tr-->
                <tr>
                  <td class="tekst"><br/>Middelburg,</td>
                  <td class="tekst"><br/><xsl:value-of select="//dateDay"/>-<xsl:value-of select="//dateMonth"/>-<xsl:value-of select="//dateYear"/></td>
                </tr>
              </table>
            </td>
            <td colspan="2" class="tekst" style="width:14%;"/>
            <td colspan="3" class="tekst">
              <b>Afleveradres</b><br/>
              <xsl:value-of select="substring-before(concat(melding/aflever_adres/naam, '-'),'-')"/><br/>
              <xsl:if test="kenmerk[@naam='T.a.v.']!=''">T.a.v.: <xsl:value-of select="kenmerk[@naam='T.a.v.']"/><br/></xsl:if>
              <xsl:value-of select="melding/aflever_adres/bezoek_adres"/><br/>
              <xsl:value-of select="melding/aflever_adres/bezoek_postcode"/><xsl:text> </xsl:text><xsl:value-of select="melding/aflever_adres/bezoek_plaats"/><br/><br/>
              <xsl:if test="uitvoerende/bedrijf/kenmerk[@key='1020']!=''">SVRZ klantnummer: <xsl:value-of select="uitvoerende/bedrijf/kenmerk[@key='1020']"/></xsl:if>
            </td>
          </tr>
          <tr>
            <td colspan="2" class="tekst"/>
            <td colspan="7" class="tekst">
              <!-- Ingevuld kenmerk anders leeg -->
              <xsl:if test="kenmerk[@naam='Opmerking extern']!=''"><br/>Opmerking: <xsl:value-of select="kenmerk[@naam='Opmerking extern']"/></xsl:if>
              <br/><br/><br/>
            </td>
          </tr>
          <xsl:variable name="tmpinclbtw1">
            <xsl:choose>
              <xsl:when test="kenmerk[@key='24']!=''"><xsl:value-of select="kenmerk[@key='23'] * (round(kenmerk[@key='24'] * (100 + substring-before(concat(kenmerk[@key='25'], '%'),'%'))) div 100)"/></xsl:when>
              <xsl:otherwise>0</xsl:otherwise>
            </xsl:choose>
          </xsl:variable>		
          <xsl:variable name="tmpinclbtw2">
            <xsl:choose>
              <xsl:when test="kenmerk[@key='29']!=''"><xsl:value-of select="kenmerk[@key='28'] * (round(kenmerk[@key='29'] * (100 + substring-before(concat(kenmerk[@key='30'], '%'),'%'))) div 100)"/></xsl:when>
              <xsl:otherwise>0</xsl:otherwise>
            </xsl:choose>
          </xsl:variable>		
          <xsl:variable name="tmpinclbtw3">
            <xsl:choose>
              <xsl:when test="kenmerk[@key='34']!=''"><xsl:value-of select="kenmerk[@key='33'] * (round(kenmerk[@key='34'] * (100 + substring-before(concat(kenmerk[@key='35'], '%'),'%'))) div 100)"/></xsl:when>
              <xsl:otherwise>0</xsl:otherwise>
            </xsl:choose>
          </xsl:variable>		
          <tr>
            <td colspan="4" class="tekst" style="width:60%;font-size:8pt;border:1px solid black;padding:3px;">Omschrijving</td>
            <td class="tekst" style="width:8%;font-size:8pt;border:1px solid black;padding:3px;">Aantal/<br/>Eenh.</td>
            <td colspan="2" class="tekst" style="width:12%;font-size:8pt;border:1px solid black;padding:3px;">Nettoprijs<br/>excl. BTW</td>
            <td class="tekst" style="width:8%;font-size:8pt;border:1px solid black;padding:3px;">BTW</td>
            <td class="tekst" style="font-size:8pt;border:1px solid black;padding:3px;">Bedrag<br/>incl. BTW</td>
          </tr>
          <tr>
            <td colspan="4" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
              <xsl:call-template name="linebreaks"><xsl:with-param name="string" select="kenmerk[@key='22']"/></xsl:call-template>
            </td>
            <td class="tekst" style="width:8%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
              <xsl:value-of select="kenmerk[@key='23']"/><xsl:if test="kenmerk[@key='51']!=''">/<br/><xsl:value-of select="kenmerk[@key='51']"/></xsl:if>
            </td>
            <td colspan="2" class="tekst" style="width:12%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
              € <xsl:value-of select="format-number(kenmerk[@key='24'], '0,00', 'european')"/>
            </td>
            <td class="tekst" style="width:8%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
              <xsl:value-of select="format-number(substring-before(concat(kenmerk[@key='25'], '%'),'%'), '0,0', 'european')"/>%
            </td>
            <td class="tekst" style="font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
              € <xsl:value-of select="format-number($tmpinclbtw1, '0,00', 'european')"/>
            </td>
          </tr>
          <xsl:if test="kenmerk[@key='27']!=''">
            <tr>
              <td colspan="4" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                <xsl:call-template name="linebreaks"><xsl:with-param name="string" select="kenmerk[@key='27']"/></xsl:call-template>
              </td>
              <td class="tekst" style="width:8%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                <xsl:value-of select="kenmerk[@key='28']"/><xsl:if test="kenmerk[@key='52']!=''">/<br/><xsl:value-of select="kenmerk[@key='52']"/></xsl:if>
              </td>
              <td colspan="2" class="tekst" style="width:12%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                € <xsl:value-of select="format-number(kenmerk[@key='29'], '0,00', 'european')"/>
              </td>
              <td class="tekst" style="width:8%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                <xsl:value-of select="format-number(substring-before(concat(kenmerk[@key='30'], '%'),'%'), '0,0', 'european')"/>%
              </td>
              <td class="tekst" style="font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                € <xsl:value-of select="format-number($tmpinclbtw2, '0,00', 'european')"/>
              </td>
            </tr>
          </xsl:if>
          <xsl:if test="kenmerk[@key='32']!=''">
            <tr>
              <td colspan="4" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                <xsl:call-template name="linebreaks"><xsl:with-param name="string" select="kenmerk[@key='32']"/></xsl:call-template>
              </td>
              <td class="tekst" style="width:8%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                <xsl:value-of select="kenmerk[@key='33']"/><xsl:if test="kenmerk[@key='53']!=''">/<br/><xsl:value-of select="kenmerk[@key='53']"/></xsl:if>
              </td>
              <td colspan="2" class="tekst" style="width:12%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                € <xsl:value-of select="format-number(kenmerk[@key='34'], '0,00', 'european')"/>
              </td>
              <td class="tekst" style="width:8%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                <xsl:value-of select="format-number(substring-before(concat(kenmerk[@key='35'], '%'),'%'), '0,0', 'european')"/>%
              </td>
              <td class="tekst" style="font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                € <xsl:value-of select="format-number($tmpinclbtw3, '0,00', 'european')"/>
              </td>
            </tr>
          </xsl:if>
          <tr>
            <td colspan="4" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
            <td class="tekst" style="width:8%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
            <td colspan="2" class="tekst" style="width:12%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
            <td class="tekst" style="width:8%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
            <td class="tekst" style="font-size:9pt;text-align:right;border-right:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
          </tr>
          <tr>
            <td colspan="4" class="tekst" style="font-size:9pt;">
              <table border="0" style="width:100%;border-collapse:collapse;" cellpadding="0" cellspacing="0">
                <tr>
                  <td class="tekst" style="width:35%;font-size:8pt;">
                    <br/>Levering op of rond:
                    <br/>Leveringscondities:
                    <br/>Betalingscondities:
                  </td>
                  <!-- Dynamisch? -->
                  <td class="tekst" style="font-size:8pt;">
                    <!--br/><xsl:value-of select="datumgereed/datum"/-->
                    <br/><xsl:choose><xsl:when test="kenmerk[@naam='Levering in overleg']='Ja'">In overleg</xsl:when><xsl:otherwise><xsl:value-of select="datumgereed/datum"/></xsl:otherwise></xsl:choose>
                    <br/><xsl:value-of select="uitvoerende/bedrijf/kenmerk[@key='1000']"/>
                    <br/><xsl:value-of select="uitvoerende/bedrijf/kenmerk[@key='1001']"/>
                  </td>
                </tr>
              </table>
            </td>
            <td colspan="4" class="tekst" style="font-size:9pt;">
              <br/><b>Totaalbedrag in euro's:</b>
            </td>
            <td class="tekst" style="font-size:9pt;text-align:right;">
              <br/><b>€ <xsl:value-of select="format-number($tmpinclbtw1 + $tmpinclbtw2 + $tmpinclbtw3, '0,00', 'european')"/></b>
            </td>
          </tr>
          <tr>
            <td colspan="9" class="tekst" style="font-size:8pt;">
              <br/>Op al onze transacties zijn de Algemene Inkoopvoorwaarden Gezondheidszorg, gedeponeerd bij de Rechtbank Den Haag te Den Haag, d.d. 26 augustus 2014 onder depotnummer 41/2014, van toepassing. BTW-nr.: NL823367095.B.02.
            </td>
          </tr>
        </table>
      </xsl:when>
      <xsl:when test="opdrachttype/key='21'">
        <table border="0" style="width:100%;border-collapse:collapse;" cellpadding="0" cellspacing="0">
          <tr>
            <td colspan="4" class="tekst" style="width:60%;">
              <br/><br/><br/>
              <xsl:value-of select="uitvoerende/bedrijf/naam"/><br/>
              <xsl:if test="$anaam!=''">T.a.v. <xsl:value-of select="$voorl"/><xsl:text> </xsl:text><xsl:value-of select="$anaam"/><br/></xsl:if>
              <xsl:value-of select="uitvoerende/bedrijf/post_adres"/><br/>
              <xsl:value-of select="uitvoerende/bedrijf/post_postcode"/><xsl:text>  </xsl:text><xsl:value-of select="uitvoerende/bedrijf/post_plaats"/><br/>
              <xsl:if test="uitvoerende/bedrijf/post_land!='NL'"><xsl:value-of select="uitvoerende/bedrijf/post_land"/></xsl:if><br/>
              <xsl:if test="not($anaam!='')"><br/></xsl:if>
              <br/><br/>
            </td>
            <td colspan="2" class="tekst" style="width:14%;"/>
            <td colspan="3" class="tekst">
              <br/><br/>
              <b>Factuuradres</b><br/>
              SVRZ<br/>
              <xsl:choose>
                <xsl:when test="substring-before(concat($digifact, '@'),'@')='factuur230'">F&amp;C Walcheren</xsl:when>
                <xsl:when test="substring-before(concat($digifact, '@'),'@')='factuur245'">F&amp;C Oosterschelde</xsl:when>
                <xsl:when test="substring-before(concat($digifact, '@'),'@')='factuur260'">F&amp;C Zeeuws-Vlaanderen</xsl:when>
                <xsl:otherwise>Concern-administratie</xsl:otherwise>
              </xsl:choose><br/>
              Postbus 100<br/>
              4330 AC<xsl:text>  </xsl:text>Middelburg<br/>
              <xsl:if test="$digifact!=''">of <xsl:value-of select="$digifact"/></xsl:if>
            </td>
          </tr>
          <tr>
            <td colspan="4" class="tekst" style="width:60%;border:1px solid black;padding:3px;">
              <table border="0" style="width:100%;border-collapse:collapse;" cellpadding="0" cellspacing="0">
                <tr>
                  <td colspan="2" class="tekst"><b>Inkoopordernr PUR-N1<xsl:value-of select="substring($aanvraag, string-length($aanvraag)-5)"/>-<xsl:value-of select="bedrijfopdr_volgnr"/></b></td>
                </tr>
                <tr>
                  <td class="tekst" style="width:35%;">Besteld door:</td>
                  <td class="tekst"><xsl:if test="melding/voor/voorletters!=''"><xsl:value-of select="melding/voor/voorletters"/><xsl:text> </xsl:text></xsl:if><xsl:if test="melding/voor/tussenvoegsel!=''"><xsl:value-of select="melding/voor/tussenvoegsel"/><xsl:text> </xsl:text></xsl:if><xsl:value-of select="melding/voor/naam"/></td>
                </tr>
                <tr>
                  <td class="tekst"></td>
                  <td class="tekst">T: <xsl:value-of select="melding/voor/telefoonnr"/></td>
                </tr>
                <tr>
                  <td class="tekst"></td>
                  <td class="tekst">E: <xsl:value-of select="melding/voor/email"/></td>
                </tr>
                <!--tr>
                  <td class="tekst"><xsl:if test="$anaam!=''">Contactpersoon leverancier:</xsl:if></td>
                  <td class="tekst"><xsl:if test="$anaam!=''"><xsl:value-of select="$voorl"/><xsl:text> </xsl:text><xsl:value-of select="$anaam"/></xsl:if></td>
                </tr-->
                <tr>
                  <td class="tekst"><br/>Middelburg,</td>
                  <td class="tekst"><br/><xsl:value-of select="//dateDay"/>-<xsl:value-of select="//dateMonth"/>-<xsl:value-of select="//dateYear"/></td>
                </tr>
              </table>
            </td>
            <td colspan="2" class="tekst" style="width:14%;"/>
            <td colspan="3" class="tekst">
              <b>Afleveradres</b><br/>
              <xsl:value-of select="substring-before(concat(melding/aflever_adres/naam, '-'),'-')"/><br/>
              <xsl:if test="kenmerk[@naam='T.a.v.']!=''">T.a.v.: <xsl:value-of select="kenmerk[@naam='T.a.v.']"/><br/></xsl:if>
              <xsl:value-of select="melding/aflever_adres/bezoek_adres"/><br/>
              <xsl:value-of select="melding/aflever_adres/bezoek_postcode"/><xsl:text> </xsl:text><xsl:value-of select="melding/aflever_adres/bezoek_plaats"/><br/><br/>
              <xsl:if test="uitvoerende/bedrijf/kenmerk[@key='1020']!=''">SVRZ klantnummer: <xsl:value-of select="uitvoerende/bedrijf/kenmerk[@key='1020']"/></xsl:if>
            </td>
          </tr>
          <tr>
            <td colspan="2" class="tekst"/>
            <td colspan="7" class="tekst">
              <!-- Ingevuld kenmerk anders leeg -->
              <xsl:if test="kenmerk[@naam='Opmerking extern']!=''"><br/>Opmerking: <xsl:value-of select="kenmerk[@naam='Opmerking extern']"/></xsl:if>
              <br/><br/><br/>
            </td>
          </tr>

          <!--xsl:variable name="tstregels">
            <xsl:for-each select="kenmerk[@key='42' or @key='43' or @key='44' or @key='46' or @key='47' or @key='48']">
              <xsl:sort select="@volgnummer" data-type="number"/>
              <xsl:if test=".!=''">
                <vnr>
                  <xsl:value-of select="@volgnummer"/>
                </vnr>
                <srt>
                  <xsl:choose>
                    <xsl:when test="@key&gt;45">Arbeid</xsl:when>
                    <xsl:otherwise>Mat.</xsl:otherwise>
                  </xsl:choose>
                </srt>
                <net>
                  <xsl:value-of select="."/>
                </net>
                <btw>
                  <xsl:choose>
                    <xsl:when test="@key=42 or @key=46">21</xsl:when>
                    <xsl:when test="@key=43 or @key=47">6</xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                  </xsl:choose>
                </btw>
              </xsl:if>
            </xsl:for-each>
          </xsl:variable>
          <tr>
            <td colspan="9" class="tekst" style="font-size:8pt;border:1px solid black;padding:3px;">TEST: <xsl:value-of select="$xxx"/></td>
          </tr-->

          <xsl:variable name="oms">
            <xsl:value-of select="omschrijving"/>
          </xsl:variable>
          <xsl:variable name="totcnt">
            <xsl:value-of select="count(kenmerk[@key='42' or @key='43' or @key='44' or @key='46' or @key='47' or @key='48'])"/>
          </xsl:variable>
          <xsl:variable name="arbcnt">
            <xsl:value-of select="count(kenmerk[@key='42' or @key='43' or @key='44'])"/>
          </xsl:variable>
          <xsl:variable name="matcnt">
            <xsl:value-of select="count(kenmerk[@key='46' or @key='47' or @key='48'])"/>
          </xsl:variable>

          <!--Header met of zonder Mat./Arbeid-kolom!-->
          <xsl:choose>
            <xsl:when test="$matcnt=0 or $arbcnt=0">
              <tr>
                <td colspan="5" class="tekst" style="width:60%;font-size:8pt;border:1px solid black;padding:3px;">Omschrijving</td>
                <td colspan="2" class="tekst" style="width:12%;font-size:8pt;border:1px solid black;padding:3px;">Nettoprijs<br/>excl. BTW</td>
                <td class="tekst" style="width:8%;font-size:8pt;border:1px solid black;padding:3px;">BTW</td>
                <td class="tekst" style="font-size:8pt;border:1px solid black;padding:3px;">Bedrag<br/>incl. BTW</td>
              </tr>
            </xsl:when>
            <xsl:otherwise>
              <tr>
                <td colspan="4" class="tekst" style="width:60%;font-size:8pt;border:1px solid black;padding:3px;">Omschrijving</td>
                <td class="tekst" style="width:8%;font-size:8pt;border:1px solid black;padding:3px;">Mat./<br/>Arbeid</td>
                <td colspan="2" class="tekst" style="width:12%;font-size:8pt;border:1px solid black;padding:3px;">Nettoprijs<br/>excl. BTW</td>
                <td class="tekst" style="width:8%;font-size:8pt;border:1px solid black;padding:3px;">BTW</td>
                <td class="tekst" style="font-size:8pt;border:1px solid black;padding:3px;">Bedrag<br/>incl. BTW</td>
              </tr>
            </xsl:otherwise>
          </xsl:choose>

          <!--Regels met of zonder Mat./Arbeid-kolom!-->
          <xsl:for-each select="kenmerk[@key='42' or @key='43' or @key='44' or @key='46' or @key='47' or @key='48']">
            <xsl:sort select="@volgnummer" data-type="number"/>
            <xsl:variable name="btw">
              <xsl:choose>
                <xsl:when test="@key=42 or @key=46">21</xsl:when>
                <xsl:when test="@key=43 or @key=47">6</xsl:when>
                <xsl:otherwise>0</xsl:otherwise>
              </xsl:choose>
            </xsl:variable>
            <xsl:choose>
              <xsl:when test="$matcnt=0 or $arbcnt=0">
                <tr>
                  <xsl:choose>
                    <xsl:when test="$totcnt=1">
                      <xsl:choose>
                        <xsl:when test="position()=1">
                          <td colspan="5" rowspan="1" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                            <xsl:call-template name="linebreaks"><xsl:with-param name="string" select="$oms"/></xsl:call-template>
                          </td>
                        </xsl:when>
                        <xsl:otherwise></xsl:otherwise>
                      </xsl:choose>
                    </xsl:when>
                    <xsl:when test="$totcnt=2">
                      <xsl:choose>
                        <xsl:when test="position()=1">
                          <td colspan="5" rowspan="2" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                            <xsl:call-template name="linebreaks"><xsl:with-param name="string" select="$oms"/></xsl:call-template>
                          </td>
                        </xsl:when>
                        <xsl:otherwise></xsl:otherwise>
                      </xsl:choose>
                    </xsl:when>
                    <xsl:when test="$totcnt=3">
                      <xsl:choose>
                        <xsl:when test="position()=1">
                          <td colspan="5" rowspan="3" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                            <xsl:call-template name="linebreaks"><xsl:with-param name="string" select="$oms"/></xsl:call-template>
                          </td>
                        </xsl:when>
                        <xsl:otherwise></xsl:otherwise>
                      </xsl:choose>
                    </xsl:when>
                    <!--xsl:when test="$totcnt=4">
                      <xsl:choose>
                        <xsl:when test="position()=1">
                          <td colspan="5" rowspan="4" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                            <xsl:call-template name="linebreaks"><xsl:with-param name="string" select="$oms"/></xsl:call-template>
                          </td>
                        </xsl:when>
                        <xsl:otherwise></xsl:otherwise>
                      </xsl:choose>
                    </xsl:when>
                    <xsl:when test="$totcnt=5">
                      <xsl:choose>
                        <xsl:when test="position()=1">
                          <td colspan="5" rowspan="5" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                            <xsl:call-template name="linebreaks"><xsl:with-param name="string" select="$oms"/></xsl:call-template>
                          </td>
                        </xsl:when>
                        <xsl:otherwise></xsl:otherwise>
                      </xsl:choose>
                    </xsl:when>
                    <xsl:when test="$totcnt=6">
                      <xsl:choose>
                        <xsl:when test="position()=1">
                          <td colspan="5" rowspan="6" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                            <xsl:call-template name="linebreaks"><xsl:with-param name="string" select="$oms"/></xsl:call-template>
                          </td>
                        </xsl:when>
                        <xsl:otherwise></xsl:otherwise>
                      </xsl:choose>
                    </xsl:when-->
                    <xsl:otherwise></xsl:otherwise>
                  </xsl:choose>
                  <td colspan="2" class="tekst" style="width:12%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                    € <xsl:value-of select="format-number(., '0,00', 'european')"/>
                  </td>
                  <td class="tekst" style="width:8%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                    <xsl:value-of select="format-number($btw, '0,0', 'european')"/>%
                  </td>
                  <td class="tekst" style="font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                    € <xsl:value-of select="format-number(round(. * (100 + $btw)) div 100, '0,00', 'european')"/>
                  </td>
                </tr>
              </xsl:when>
              <xsl:otherwise>
                <tr>
                  <xsl:choose>
                    <xsl:when test="$totcnt=1">
                      <xsl:choose>
                        <xsl:when test="position()=1">
                          <td colspan="4" rowspan="1" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                            <xsl:call-template name="linebreaks"><xsl:with-param name="string" select="$oms"/></xsl:call-template>
                          </td>
                        </xsl:when>
                        <xsl:otherwise></xsl:otherwise>
                      </xsl:choose>
                    </xsl:when>
                    <xsl:when test="$totcnt=2">
                      <xsl:choose>
                        <xsl:when test="position()=1">
                          <td colspan="4" rowspan="2" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                            <xsl:call-template name="linebreaks"><xsl:with-param name="string" select="$oms"/></xsl:call-template>
                          </td>
                        </xsl:when>
                        <xsl:otherwise></xsl:otherwise>
                      </xsl:choose>
                    </xsl:when>
                    <xsl:when test="$totcnt=3">
                      <xsl:choose>
                        <xsl:when test="position()=1">
                          <td colspan="4" rowspan="3" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                            <xsl:call-template name="linebreaks"><xsl:with-param name="string" select="$oms"/></xsl:call-template>
                          </td>
                        </xsl:when>
                        <xsl:otherwise></xsl:otherwise>
                      </xsl:choose>
                    </xsl:when>
                    <xsl:when test="$totcnt=4">
                      <xsl:choose>
                        <xsl:when test="position()=1">
                          <td colspan="4" rowspan="4" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                            <xsl:call-template name="linebreaks"><xsl:with-param name="string" select="$oms"/></xsl:call-template>
                          </td>
                        </xsl:when>
                        <xsl:otherwise></xsl:otherwise>
                      </xsl:choose>
                    </xsl:when>
                    <xsl:when test="$totcnt=5">
                      <xsl:choose>
                        <xsl:when test="position()=1">
                          <td colspan="4" rowspan="5" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                            <xsl:call-template name="linebreaks"><xsl:with-param name="string" select="$oms"/></xsl:call-template>
                          </td>
                        </xsl:when>
                        <xsl:otherwise></xsl:otherwise>
                      </xsl:choose>
                    </xsl:when>
                    <xsl:when test="$totcnt=6">
                      <xsl:choose>
                        <xsl:when test="position()=1">
                          <td colspan="4" rowspan="6" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                            <xsl:call-template name="linebreaks"><xsl:with-param name="string" select="$oms"/></xsl:call-template>
                          </td>
                        </xsl:when>
                        <xsl:otherwise></xsl:otherwise>
                      </xsl:choose>
                    </xsl:when>
                    <xsl:otherwise></xsl:otherwise>
                  </xsl:choose>
                  <td class="tekst" style="width:8%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                    <xsl:choose>
                      <xsl:when test="@key&gt;45">Mat.</xsl:when>
                      <xsl:otherwise>Arbeid</xsl:otherwise>
                    </xsl:choose>
                  </td>
                  <td colspan="2" class="tekst" style="width:12%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                    € <xsl:value-of select="format-number(., '0,00', 'european')"/>
                  </td>
                  <td class="tekst" style="width:8%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                    <xsl:value-of select="format-number($btw, '0,0', 'european')"/>%
                  </td>
                  <td class="tekst" style="font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;padding:3px;">
                    € <xsl:value-of select="format-number(round(. * (100 + $btw)) div 100, '0,00', 'european')"/>
                  </td>
                </tr>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:for-each>

          <!--Lege regel met of zonder Mat./Arbeid-kolom!-->
          <xsl:choose>
            <xsl:when test="$matcnt=0 or $arbcnt=0">
              <tr>
                <td colspan="5" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
                <td colspan="2" class="tekst" style="width:12%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
                <td class="tekst" style="width:8%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
                <td class="tekst" style="font-size:9pt;text-align:right;border-right:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
              </tr>
            </xsl:when>
            <xsl:otherwise>
              <tr>
                <td colspan="4" class="tekst" style="width:60%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
                <td class="tekst" style="width:8%;font-size:9pt;border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
                <td colspan="2" class="tekst" style="width:12%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
                <td class="tekst" style="width:8%;font-size:9pt;text-align:right;border-left:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
                <td class="tekst" style="font-size:9pt;text-align:right;border-right:1px solid black;border-right:1px solid black;border-bottom:1px solid black;padding:3px;">&#xA0;</td>
              </tr>
            </xsl:otherwise>
          </xsl:choose>

          <!--Condities/Totaal!-->
          <xsl:variable name="tmpinclbtw">
            <xsl:for-each select="kenmerk[@key='42' or @key='43' or @key='44' or @key='46' or @key='47' or @key='48']">
              <xsl:variable name="btw">
                <xsl:choose>
                  <xsl:when test="@key=42 or @key=46">21</xsl:when>
                  <xsl:when test="@key=43 or @key=47">6</xsl:when>
                  <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
              </xsl:variable>
              <item><xsl:value-of select="round(. * (100 + $btw)) div 100"/></item>
            </xsl:for-each>
          </xsl:variable>
          <xsl:variable name="totinclbtw" select="sum(msxml:node-set($tmpinclbtw)/item)"/>
          <tr>
            <td colspan="4" class="tekst" style="font-size:9pt;">
              <table border="0" style="width:100%;border-collapse:collapse;" cellpadding="0" cellspacing="0">
                <tr>
                  <td class="tekst" style="width:35%;font-size:8pt;">
                    <br/>Levering op of rond:
                    <br/>Leveringscondities:
                    <br/>Betalingscondities:
                  </td>
                  <!-- Dynamisch? -->
                  <td class="tekst" style="font-size:8pt;">
                    <!--br/><xsl:value-of select="datumgereed/datum"/-->
                    <br/><xsl:choose><xsl:when test="kenmerk[@naam='Levering in overleg']='Ja'">In overleg</xsl:when><xsl:otherwise><xsl:value-of select="datumgereed/datum"/></xsl:otherwise></xsl:choose>
                    <br/><xsl:value-of select="uitvoerende/bedrijf/kenmerk[@key='1000']"/>
                    <br/><xsl:value-of select="uitvoerende/bedrijf/kenmerk[@key='1001']"/>
                  </td>
                </tr>
              </table>
            </td>
            <td colspan="4" class="tekst" style="font-size:9pt;">
              <br/><b>Totaalbedrag in euro's:</b>
            </td>
            <td class="tekst" style="font-size:9pt;text-align:right;">
              <br/><b>€ <xsl:value-of select="format-number($totinclbtw, '0,00', 'european')"/></b>
            </td>
          </tr>

          <!--Disclaimer!-->
          <tr>
            <td colspan="9" class="tekst" style="font-size:8pt;">
              <br/>Op al onze transacties zijn de Algemene Inkoopvoorwaarden Gezondheidszorg, gedeponeerd bij de Rechtbank Den Haag te Den Haag, d.d. 26 augustus 2014 onder depotnummer 41/2014, van toepassing. BTW-nr.: NL823367095.B.02.
            </td>
          </tr>
        </table>
      </xsl:when>
      <xsl:otherwise>
    <table border="0" width="100%" cellpadding="2">
      <tr>
        <td colspan="4" class="caption" style="padding-top:20px;padding-bottom:20px">
          <b>
            <xsl:choose>
              <xsl:when test="statusopdr_key = 10 and statusopdr_key_refiat &gt; 0">
                <xsl:value-of select="//lcl/MLD/hergoedkeuring"/>:&#xA0;
              </xsl:when>
              <xsl:when test="(statusopdr_key = 3 or statusopdr_key = 4) and statusopdr_key_refiat &gt; 0">
                <xsl:value-of select="//lcl/MLD/herfiattering"/>:&#xA0;
              </xsl:when>
            </xsl:choose>
            <xsl:value-of select="opdrachttype/omschrijving"/>&#160;
            <xsl:value-of select="melding/stdmelding/discipline/srtdiscipline/prefix"/>
            <xsl:value-of select="melding/key"/>/<xsl:value-of select="bedrijfopdr_volgnr"/></b>
        </td>
      </tr>
      <tr>
        <td width="16%"/>
        <td width="17%"/>
        <td width="17%"/>
        <td width="16%" align="right">
          <b><xsl:value-of select="//lcl/FAC/bedrijf"/>:</b>
        </td>
        <td width="17%">
          <xsl:value-of select="uitvoerende/bedrijf/naam"/>
        </td>
        <td width="17%">
        </td>
      </tr>
      <tr>
        <td colspan="3"/>
        <td align="right">
          <b><xsl:value-of select="//lcl/FAC/contactpersoon"/>:</b>
        </td>
        <td>
          <xsl:value-of select="contactpersoon/naam_full"/>
        </td>
      </tr>
      <tr>
        <td colspan="3"/>
        <td align="right">
          <b><xsl:value-of select="//lcl/FAC/telefoon"/>:</b>
        </td>
        <td>
          <xsl:value-of select="contactpersoon/telefoon1"/>
        </td>
      </tr>
      <tr>
        <td colspan="3"/>
        <td align="right">
          <b><xsl:value-of select="//lcl/FAC/adres"/>:</b>
        </td>
        <td>
          <xsl:value-of select="uitvoerende/bedrijf/post_adres"/>
        </td>
      </tr>
      <tr>
        <td colspan="3"/>
        <td align="right">
          <b><xsl:value-of select="//lcl/FAC/plaats"/>:</b>
        </td>
        <td>
          <xsl:value-of select="uitvoerende/bedrijf/post_plaats"/>
        </td>
      </tr>
      <tr>
        <td align="right">
          <b><xsl:value-of select="//lcl/FAC/contactpersoon"/>:</b>
        </td>
        <td align="left">
          <xsl:value-of select="backoffice_contact/naam_full"/>
        </td>
        <td colspan="3"/>
      </tr>
      <tr>
        <td align="right">
          <b><xsl:value-of select="//lcl/FAC/telefoon"/>:</b>
        </td>
        <td align="left">
          <xsl:value-of select="backoffice_contact/telefoonnr"/>
        </td>
        <td align="left">
        </td>
        <td align="right">
          <b><xsl:value-of select="//lcl/FAC/kostenplaats"/>:</b>
        </td>
        <td align="left">
          <xsl:value-of select="kostenplaats/nr"/>
        </td>
      </tr>
      <xsl:if test="melding/kenmerk[@naam='Ordernr']!=''">
        <tr>
          <td colspan="3"/>
          <td align="right">
            <b><xsl:value-of select="//lcl/MLD/ordernr"/>:</b>
          </td>
          <td align="left">
            <xsl:value-of select="melding/kenmerk[@naam='Ordernr']"/>
          </td>
        </tr>
      </xsl:if>
      <tr>
        <td colspan="3"/>
        <td align="right">
          <b><xsl:value-of select="//lcl/MLD/datum_gereed"/>:</b>
        </td>
        <td align="left">
          <xsl:value-of select="datumgereed/datum"/>
        </td>
      </tr>
      <tr>
        <td colspan="3"/>
        <td align="right">
          <b><xsl:value-of select="//lcl/MLD/datum_verzonden"/>:</b>
        </td>
        <td align="left">
          <xsl:value-of select="datumverzonden/datum"/>
        </td>
      </tr>
      <tr>
        <td colspan="3"/>
        <td align="right">
          <b><xsl:value-of select="//lcl/MLD/status"/>:</b>
        </td>
        <td align="left">
          <xsl:value-of select="status"/>
        </td>
      </tr>
      <tr>
        <td align="right" valign="top">
          <b><xsl:value-of select="//lcl/FAC/omschrijving"/>:</b>
        </td>
        <td align="left" colspan="3">
          <xsl:call-template name="linebreaks">
            <xsl:with-param name="string" select="omschrijving"/>
          </xsl:call-template>
        </td>
      </tr>
      <tr>
        <td colspan="6">
          <hr/>
        </td>
      </tr>
      <tr>
        <td colspan="6" align="center">
          <table width="100%" style="background-color:#EEEEEE;border: 1px solid blue">
            <tr>
              <td>
                <xsl:apply-templates select="melding" mode="include"/>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td colspan="6" height="30px" valign="center">
          <hr/>
        </td>
      </tr>
      <xsl:variable name="arbeid" select="uren*uurloon"/>
      <xsl:variable name="arbeid_refiat" select="uren_refiat*uurloon_refiat"/>
      <tr>
        <td align="right">
          <b><xsl:value-of select="//lcl/MLD/uren"/>:</b>
        </td>
        <td>
          <xsl:value-of select="format-number(uren, '0,00', 'european')"/>
          <b>&#xA0;à&#xA0;</b>&#x20AC;&#xA0;<xsl:value-of select="format-number(uurloon, '0,00', 'european')"/></td>
        <td style="width:2in;text-align:left">
          <xsl:if test="statusopdr_key_refiat &gt; 0">
            (<xsl:value-of select="//lcl/MLD/was"/>&#xA0;<xsl:value-of select="format-number(uren, '0,00', 'european')"/>
            <b>&#xA0;à&#xA0;</b>&#x20AC;&#xA0;<xsl:value-of select="format-number(uurloon, '0,00', 'european')"/>)
          </xsl:if>
        </td>
        <td align="right">
          <b><xsl:value-of select="//lcl/MLD/arbeid"/>:</b>
        </td>
        <td style="width:1in;text-align:right">&#x20AC;&#xA0;<xsl:value-of select="format-number($arbeid, '0,00', 'european')"/></td>
        <td style="width:1in;text-align:right">
          <xsl:if test="statusopdr_key_refiat &gt; 0">
            (<xsl:value-of select="//lcl/MLD/was"/> &#x20AC;&#xA0;<xsl:value-of select="format-number($arbeid_refiat, '0,00', 'european')"/>)
          </xsl:if>
        </td>
      </tr>
      <tr>
        <td colspan="3"/>
        <td align="right">
          <b><xsl:value-of select="//lcl/MLD/materiaal"/>:</b>
        </td>
        <td style="width:1in;text-align:right">&#x20AC;&#xA0;<xsl:value-of select="format-number(materiaal, '0,00', 'european')"/></td>
        <td style="width:1in;text-align:right">
          <xsl:if test="statusopdr_key_refiat &gt; 0">
            (<xsl:value-of select="//lcl/MLD/was"/> &#x20AC;&#xA0;<xsl:value-of select="format-number(materiaal_refiat, '0,00', 'european')"/>)
          </xsl:if>
        </td>
      </tr>
      <xsl:variable name="correctie0" select="$arbeid + materiaal"/>
      <xsl:variable name="correctie" select="kosten - $correctie0"/>
      <xsl:variable name="correctie0_refiat" select="$arbeid_refiat + materiaal_refiat"/>
      <xsl:variable name="correctie_refiat" select="kosten_refiat - $correctie0_refiat"/>
      <xsl:if test="$correctie!=0">
      <tr>
        <td colspan="3"/>
        <td align="right">
          <b><xsl:value-of select="//lcl/MLD/correctie"/>:</b>
        </td>
        <td style="width:1in;text-align:right">&#x20AC;&#xA0;<xsl:value-of select="format-number($correctie, '0,00', 'european')"/></td>
        <td style="width:1in;text-align:right">
          <xsl:if test="statusopdr_key_refiat &gt; 0">
            (<xsl:value-of select="//lcl/MLD/was"/> &#x20AC;&#xA0;<xsl:value-of select="format-number($correctie_refiat, '0,00', 'european')"/>)
          </xsl:if>
        </td>
      </tr>
      </xsl:if>
      <tr>
        <td colspan="3"/>
        <td align="right">
          <b><xsl:value-of select="//lcl/FAC/totaal"/>:</b>
        </td>
        <td style="width:1in;text-align:right">
          <b>&#x20AC;&#xA0;<xsl:value-of select="format-number(kosten, '0,00', 'european')"/></b>
        </td>
        <td style="width:1in;text-align:right">
          <xsl:if test="statusopdr_key_refiat &gt; 0">
            (<xsl:value-of select="//lcl/MLD/was"/> &#x20AC;&#xA0;<xsl:value-of select="format-number(kosten_refiat, '0,00', 'european')"/>)
          </xsl:if>
        </td>
      </tr>
    </table>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

	<xsl:template match="opdracht" mode="full">
	 <xsl:choose>
		<xsl:when test="$mode='summary'"></xsl:when>
		<xsl:otherwise>
		<html>
			<xsl:comment>================================ OPDRACHTEN ==============================</xsl:comment>
			<xsl:call-template name="htmlhead"/>
			<xsl:element name="body">
				<xsl:if test="$mode!='email'">
					<xsl:attribute name="onload">window.print();</xsl:attribute>
				</xsl:if>
				<xsl:call-template name="pageheader2"/>
				<xsl:apply-templates select="." mode="include"/>
			</xsl:element>
		</html>
		</xsl:otherwise>
	 </xsl:choose>
	</xsl:template>

</xsl:stylesheet>
