<?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="opdracht" mode="include">
    <xsl:choose>
        <!-- "mld-opdrachten Inkoop-order (key=361)" -->
        <xsl:when test="opdrachttype/key='361'">
            <xsl:apply-templates select="." mode="include_inkooporder"/>
        </xsl:when>
        <!-- "alle andere mld-opdrachten" -->
        <xsl:otherwise>
          <xsl:apply-templates select="." mode="include_overig"/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template match="opdracht" mode="include_inkooporder">
    <table border="0" width="100%" cellpadding="2">
      <tr>
        <td colspan="4" class="caption" style="padding-top:20px;padding-bottom:20px">
          <b>
            <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 colspan="4" style="font-size:12px;">
          <b>Opdrachtnummer&#160;<xsl:value-of select="melding/stdmelding/discipline/srtdiscipline/prefix"/>
            <xsl:value-of select="melding/key"/>/<xsl:value-of select="bedrijfopdr_volgnr"/> verplicht vermelden op factuur</b>
        </td>
      </tr>            
      <tr>
        <td colspan="4" height="50px" valign="center"></td>
      </tr>
      <tr>
        <td align="right"><b>Afdeling:</b></td>
        <td align="left">Inkoop</td>
        <td colspan="2"/>
      </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 width="16%" align="right">
          <b><xsl:value-of select="//lcl/FAC/bedrijf"/>:</b>
        </td>
        <td width="34%">
          <xsl:value-of select="uitvoerende/bedrijf/naam"/>
        </td>
      </tr>
      <tr>
        <td align="right"><b>Telefoon:</b></td>
        <td align="left">(038) 498 1465</td>
         <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="2"/>
        <td align="right">
          <b><xsl:value-of select="//lcl/FAC/plaats"/>:</b>
        </td>
        <td>
            <xsl:value-of select="uitvoerende/bedrijf/post_postcode"/>&#160;<xsl:value-of select="uitvoerende/bedrijf/post_plaats"/>
        </td>
      </tr>
      <tr>
        <td width="16%"><b><u>Afleveradres:</u></b></td>
        <td width="34%"><xsl:value-of select="melding/aflever_adres/naam"/></td>
        <td colspan="2"/>
      </tr>
      <tr>
        <td width="16%"><b><xsl:value-of select="//lcl/FAC/adres"/>:</b></td>
        <td width="34%"><xsl:value-of select="melding/aflever_adres/bezoek_adres"/></td>
        <td colspan="2"/>
      </tr>
      <tr>
        <td width="16%"><b><xsl:value-of select="//lcl/FAC/plaats"/>:</b></td>
        <td width="34%"><xsl:value-of select="melding/aflever_adres/bezoek_postcode"/>&#160;<xsl:value-of select="melding/aflever_adres/bezoek_plaats"/></td>
        <td colspan="2"/>
      </tr>

      <tr>
        <td colspan="2"/>
        <td align="right">
          <b><xsl:value-of select="//lcl/FAC/kostenplaats"/>:</b>
        </td>
        <td align="left">
          <xsl:value-of select="kostenplaats/nr"/>
        </td>
      </tr>
      <tr/>
      <tr>
        <td width="16%"><b><u>Factuuradres:</u></b></td>
        <td width="34%"><xsl:value-of select="factuuradres/naam"/></td>
        <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 width="16%"></td>
        <td width="34%"></td>
        <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 width="16%"></td>
        <td width="34%"></td>
         <td colspan="2"/>
      </tr>
      <tr>
        <td colspan="4" height="50px" valign="center">
          <hr/>
        </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="4" height="50px" valign="center">
          <hr/>
        </td>
      </tr>


      <xsl:variable name="Kosten_1">
          <xsl:choose>
            <xsl:when test="string(number(kenmerk[@volgnummer = 24]))='NaN'">0</xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="kenmerk[@volgnummer = 24]"/>
            </xsl:otherwise>
          </xsl:choose>
      </xsl:variable>
      <xsl:variable name="Kosten_2">
          <xsl:choose>
            <xsl:when test="string(number(kenmerk[@volgnummer = 34]))='NaN'">0</xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="kenmerk[@volgnummer = 34]"/>
            </xsl:otherwise>
          </xsl:choose>
      </xsl:variable>
      <xsl:variable name="Kosten_3">
          <xsl:choose>
            <xsl:when test="string(number(kenmerk[@volgnummer = 44]))='NaN'">0</xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="kenmerk[@volgnummer = 44]"/>
            </xsl:otherwise>
          </xsl:choose>
      </xsl:variable>
      <xsl:variable name="Kosten_4">
          <xsl:choose>
            <xsl:when test="string(number(kenmerk[@volgnummer = 54]))='NaN'">0</xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="kenmerk[@volgnummer = 54]"/>
            </xsl:otherwise>
          </xsl:choose>
      </xsl:variable>
      <xsl:variable name="Kosten_5">
          <xsl:choose>
            <xsl:when test="string(number(kenmerk[@volgnummer = 64]))='NaN'">0</xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="kenmerk[@volgnummer = 64]"/>
            </xsl:otherwise>
          </xsl:choose>
      </xsl:variable>
      <xsl:variable name="Kosten_6">
          <xsl:choose>
            <xsl:when test="string(number(kenmerk[@volgnummer = 69]))='NaN'">0</xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="kenmerk[@volgnummer = 69]"/>
            </xsl:otherwise>
          </xsl:choose>
      </xsl:variable>
      <xsl:variable name="Kosten_7">
          <xsl:choose>
            <xsl:when test="string(number(kenmerk[@volgnummer = 74]))='NaN'">0</xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="kenmerk[@volgnummer = 74]"/>
            </xsl:otherwise>
          </xsl:choose>
      </xsl:variable>
      <xsl:variable name="Kosten_8">
          <xsl:choose>
            <xsl:when test="string(number(kenmerk[@volgnummer = 79]))='NaN'">0</xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="kenmerk[@volgnummer = 79]"/>
            </xsl:otherwise>
          </xsl:choose>
      </xsl:variable>   
      <xsl:variable name="Kosten_9">
          <xsl:choose>
            <xsl:when test="string(number(kenmerk[@volgnummer = 84]))='NaN'">0</xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="kenmerk[@volgnummer = 84]"/>
            </xsl:otherwise>
          </xsl:choose>
      </xsl:variable>
      <xsl:variable name="Kosten_10">
          <xsl:choose>
            <xsl:when test="string(number(kenmerk[@volgnummer = 89]))='NaN'">0</xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="kenmerk[@volgnummer = 89]"/>
            </xsl:otherwise>
          </xsl:choose>
      </xsl:variable>
      
      <xsl:variable name="Kosten_verzend">
          <xsl:choose>
            <xsl:when test="string(number(kenmerk[@volgnummer = 93]))='NaN'">0</xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="kenmerk[@volgnummer = 93]"/>
            </xsl:otherwise>
          </xsl:choose>
      </xsl:variable>     
            <xsl:variable name="Kosten_korting">
          <xsl:choose>
            <xsl:when test="string(number(kenmerk[@volgnummer = 94]))='NaN'">0</xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="kenmerk[@volgnummer = 94]"/>
            </xsl:otherwise>
          </xsl:choose>
      </xsl:variable>     
            <xsl:variable name="Kosten_overig">
          <xsl:choose>
            <xsl:when test="string(number(kenmerk[@volgnummer = 95]))='NaN'">0</xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="kenmerk[@volgnummer = 95]"/>
            </xsl:otherwise>
          </xsl:choose>
      </xsl:variable>                    

      <xsl:variable name="tot_kosten" select="$Kosten_1 + $Kosten_2 + $Kosten_3 + $Kosten_4 + $Kosten_5 + $Kosten_6 + $Kosten_7 + $Kosten_8 + $Kosten_9 + $Kosten_10 + $Kosten_verzend + $Kosten_overig - $Kosten_korting"/>



      <tr>
        <td align="left"><b><u>Aantal</u></b></td>
        <td align="right"><b><u>Artikel</u></b></td>
        <td align="right"><b><u>Artikelnummer</u></b></td>
        <td style="text-align:right"><b><u>Kosten totaal</u></b>
            <xsl:if test="kosten != $tot_kosten">
            <span style="font-size:8px; color:red"> (<xsl:value-of select="format-number($tot_kosten, '0,00', 'european')"/>) </span>
            </xsl:if>
       </td>
        <td></td>
      </tr>

      <xsl:if test="kenmerk[@volgnummer= 20] != '' and kenmerk[@volgnummer= 22] != '' and kenmerk[@volgnummer= 24] != ''">
          <tr>
            <td align="left"><xsl:value-of select="kenmerk[@volgnummer = 22]"/></td>
            <td align="right"><xsl:value-of select="kenmerk[@volgnummer = 20]"/></td>
            <td align="right"><xsl:value-of select="kenmerk[@volgnummer = 23]"/></td>            
            <td style="text-align:right">&#x20AC;&#xA0;<xsl:value-of select="format-number(kenmerk[@volgnummer = 24], '0,00', 'european')"/></td>
            <td></td>
          </tr>
      </xsl:if>

      <xsl:if test="kenmerk[@volgnummer= 30] != '' and kenmerk[@volgnummer= 32] != '' and kenmerk[@volgnummer= 34] != ''">
          <tr>
            <td align="left"><xsl:value-of select="kenmerk[@volgnummer = 32]"/></td>
            <td align="right"><xsl:value-of select="kenmerk[@volgnummer = 30]"/></td>
            <td align="right"><xsl:value-of select="kenmerk[@volgnummer = 33]"/></td>             
            <td style="text-align:right">&#x20AC;&#xA0;<xsl:value-of select="format-number(kenmerk[@volgnummer = 34], '0,00', 'european')"/></td>
            <td></td>
          </tr>
      </xsl:if>

      <xsl:if test="kenmerk[@volgnummer= 40] != '' and kenmerk[@volgnummer= 42] != '' and kenmerk[@volgnummer= 44] != ''">
          <tr>
            <td align="left"><xsl:value-of select="kenmerk[@volgnummer = 42]"/></td>
            <td align="right"><xsl:value-of select="kenmerk[@volgnummer = 40]"/></td>
            <td align="left"><xsl:value-of select="kenmerk[@volgnummer = 43]"/></td>            
            <td style="text-align:right">&#x20AC;&#xA0;<xsl:value-of select="format-number(kenmerk[@volgnummer = 44], '0,00', 'european')"/></td>
            <td></td>
          </tr>
      </xsl:if>

      <xsl:if test="kenmerk[@volgnummer= 50] != '' and kenmerk[@volgnummer= 52] != '' and kenmerk[@volgnummer= 54] != ''">
          <tr>
            <td align="left"><xsl:value-of select="kenmerk[@volgnummer = 52]"/></td>
            <td align="right"><xsl:value-of select="kenmerk[@volgnummer = 50]"/></td>
            <td align="left"><xsl:value-of select="kenmerk[@volgnummer = 53]"/></td>            
            <td style="text-align:right">&#x20AC;&#xA0;<xsl:value-of select="format-number(kenmerk[@volgnummer = 54], '0,00', 'european')"/></td>
            <td></td>
          </tr>
      </xsl:if>

      <xsl:if test="kenmerk[@volgnummer= 60] != '' and kenmerk[@volgnummer= 62] != '' and kenmerk[@volgnummer= 64] != ''">
          <tr>
            <td align="left"><xsl:value-of select="kenmerk[@volgnummer = 62]"/></td>
            <td align="right"><xsl:value-of select="kenmerk[@volgnummer = 60]"/></td>
            <td align="left"><xsl:value-of select="kenmerk[@volgnummer = 63]"/></td>            
            <td style="text-align:right">&#x20AC;&#xA0;<xsl:value-of select="format-number(kenmerk[@volgnummer = 64], '0,00', 'european')"/></td>
            <td></td>
          </tr>
      </xsl:if>
      
      <xsl:if test="kenmerk[@volgnummer= 66] != '' and kenmerk[@volgnummer= 67] != '' and kenmerk[@volgnummer= 69] != ''">
          <tr>
            <td align="left"><xsl:value-of select="kenmerk[@volgnummer = 67]"/></td>
            <td align="right"><xsl:value-of select="kenmerk[@volgnummer = 66]"/></td>
            <td align="right"><xsl:value-of select="kenmerk[@volgnummer = 68]"/></td>            
            <td style="text-align:right">&#x20AC;&#xA0;<xsl:value-of select="format-number(kenmerk[@volgnummer = 69], '0,00', 'european')"/></td>
            <td></td>
          </tr>
      </xsl:if>

      <xsl:if test="kenmerk[@volgnummer= 71] != '' and kenmerk[@volgnummer= 72] != '' and kenmerk[@volgnummer= 74] != ''">
          <tr>
            <td align="left"><xsl:value-of select="kenmerk[@volgnummer = 72]"/></td>
            <td align="right"><xsl:value-of select="kenmerk[@volgnummer = 71]"/></td>
            <td align="left"><xsl:value-of select="kenmerk[@volgnummer = 73]"/></td>            
            <td style="text-align:right">&#x20AC;&#xA0;<xsl:value-of select="format-number(kenmerk[@volgnummer = 74], '0,00', 'european')"/></td>
            <td></td>
          </tr>
      </xsl:if>
      
      <xsl:if test="kenmerk[@volgnummer= 76] != '' and kenmerk[@volgnummer= 77] != '' and kenmerk[@volgnummer= 79] != ''">
          <tr>
            <td align="left"><xsl:value-of select="kenmerk[@volgnummer = 77]"/></td>
            <td align="right"><xsl:value-of select="kenmerk[@volgnummer = 76]"/></td>
            <td align="right"><xsl:value-of select="kenmerk[@volgnummer = 78]"/></td>            
            <td style="text-align:right">&#x20AC;&#xA0;<xsl:value-of select="format-number(kenmerk[@volgnummer = 79], '0,00', 'european')"/></td>
            <td></td>
          </tr>
      </xsl:if>
      
      <xsl:if test="kenmerk[@volgnummer= 81] != '' and kenmerk[@volgnummer= 82] != '' and kenmerk[@volgnummer= 84] != ''">
          <tr>
            <td align="left"><xsl:value-of select="kenmerk[@volgnummer = 82]"/></td>
            <td align="right"><xsl:value-of select="kenmerk[@volgnummer = 81]"/></td>
            <td align="right"><xsl:value-of select="kenmerk[@volgnummer = 83]"/></td>            
            <td style="text-align:right">&#x20AC;&#xA0;<xsl:value-of select="format-number(kenmerk[@volgnummer = 84], '0,00', 'european')"/></td>
            <td></td>
          </tr>
      </xsl:if>
      
      <xsl:if test="kenmerk[@volgnummer= 86] != '' and kenmerk[@volgnummer= 87] != '' and kenmerk[@volgnummer= 89] != ''">
          <tr>
            <td align="left"><xsl:value-of select="kenmerk[@volgnummer = 87]"/></td>
            <td align="right"><xsl:value-of select="kenmerk[@volgnummer = 86]"/></td>
            <td align="right"><xsl:value-of select="kenmerk[@volgnummer = 88]"/></td>            
            <td style="text-align:right">&#x20AC;&#xA0;<xsl:value-of select="format-number(kenmerk[@volgnummer = 89], '0,00', 'european')"/></td>
            <td></td>
          </tr>
      </xsl:if>

      <xsl:if test="kenmerk[@volgnummer= 93] != '' or kenmerk[@volgnummer= 94] != '' or kenmerk[@volgnummer= 95] != ''">
          <tr>
              <td colspan="4" height="10px"/>
          </tr>    
      </xsl:if>      
      
      <xsl:if test="kenmerk[@volgnummer= 93] != ''">
          <tr>
            <td colspan="3" align="right"><xsl:value-of select="kenmerk[@volgnummer = 93]/@naam"/></td>
            <td style="text-align:right">&#x20AC;&#xA0;<xsl:value-of select="format-number(kenmerk[@volgnummer = 93], '0,00', 'european')"/></td>
            <td></td>
          </tr>
      </xsl:if>
      <xsl:if test="kenmerk[@volgnummer= 95] != ''">
          <tr>
            <td colspan="3" align="right"><xsl:value-of select="kenmerk[@volgnummer = 95]/@naam"/></td>
            <td style="text-align:right">&#x20AC;&#xA0;<xsl:value-of select="format-number(kenmerk[@volgnummer = 95], '0,00', 'european')"/></td>
            <td></td>
          </tr>
      </xsl:if>        
      <xsl:if test="kenmerk[@volgnummer= 94] != ''">
          <tr>
            <td colspan="3" align="right">Korting</td>
            <td style="text-align:right">&#x20AC;&#xA0;<xsl:value-of select="format-number(kenmerk[@volgnummer = 94], '0,00', 'european')"/></td>
            <td></td>
          </tr>
      </xsl:if>                                             

      <tr>
        <td colspan="4" height="20px" valign="center">
          <hr/>
        </td>
      </tr>


      <xsl:variable name="arbeid" select="uren*uurloon"/>
      <xsl:variable name="correctie0" select="$arbeid + materiaal"/>
      <xsl:variable name="correctie" select="kosten - $correctie0"/>
      <tr>
        <td/>
        <td style="text-align:right">
          <b><xsl:value-of select="//lcl/FAC/totaal"/> (excl. BTW):</b>
        </td>
        <td style="width:1in;text-align:right">
          <b>&#x20AC;&#xA0;<xsl:value-of select="format-number(kosten, '0,00', 'european')"/></b>
          <xsl:if test="kosten != $tot_kosten">
            <span style="font-size:8px; color:red"> (<xsl:value-of select="format-number($tot_kosten, '0,00', 'european')"/>) </span>
          </xsl:if>
        </td>
        <td/>
      </tr>
      <tr>
        <td colspan="4" height="100px" valign="center">
          <hr/>
        </td>
      </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 het NVZ 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="melding/stdmelding/discipline/srtdiscipline/prefix"/><xsl:value-of select="melding/key"/>/<xsl:value-of select="bedrijfopdr_volgnr"/>)
         worden niet in behandeling genomen.</td>
      </tr>
    </table>
  </xsl:template>


<xsl:template match="opdracht" mode="include_overig">
      <table border="0" width="100%" cellpadding="2">
      <tr>
        <td colspan="4" class="caption" style="padding-top:20px;padding-bottom:20px">
          <b>
            <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="34%"/>
        <td width="16%" align="right">
          <b><xsl:value-of select="//lcl/FAC/bedrijf"/>:</b>
        </td>
        <td width="34%">
          <xsl:value-of select="uitvoerende/bedrijf/naam"/>
        </td>
      </tr>
      <tr>
        <td colspan="2"/>
        <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="2"/>
        <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="2"/>
        <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="2"/>
        <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="2"/>
      </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="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="2"/>
          <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="2"/>
        <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="2"/>
        <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="2"/>
        <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="4">
          <hr/>
        </td>
      </tr>
      <tr>
        <td colspan="4" 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="4" height="30px" valign="center">
          <hr/>
        </td>
      </tr>
      <xsl:variable name="arbeid" select="uren*uurloon"/>
      <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 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>
      </tr>
      <tr>
        <td colspan="2"/>
        <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>
      </tr>
      <xsl:variable name="correctie0" select="$arbeid + materiaal"/>
      <xsl:variable name="correctie" select="kosten - $correctie0"/>
      <xsl:if test="$correctie!=0">
        <tr>
          <td colspan="2"/>
          <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>
        </tr>
      </xsl:if>
      <tr>
        <td colspan="2"/>
        <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>
      </tr>
    </table>
  </xsl:template>


  <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"/></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"/>
              </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"/>
                <br/>
                <b><xsl:value-of select="//lcl/BES/gewenste_afleverdatum"/>: </b>
				<xsl:value-of select="bestelling/leverdatum/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>
              <td colspan="2" style="vertical-align:top">
                <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>
              <td/>
              <td colspan="2" style="vertical-align:top">
                <xsl:for-each select="bestelling/kenmerk[@type!='L' and @type!='l' and @type!='Q']">
                  <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>

                  <xsl:if test="bestelling/levkosten != '0'">
                  <tr>
                    <td class="label" style="text-align:right;border-style:solid;border-width:0px;" colspan="6">
                      <xsl:value-of select="//lcl/BES/transportkosten"/>:
                    </td>
                    <td class="label" style="text-align:right;border-style:solid;border-width:0px;">
                      <xsl:value-of select="format-number(bestelling/levkosten, '0,00', 'european')"/>
                    </td>
                  </tr>
                  </xsl:if>

                  <tr>
                    <td class="label" style="text-align:right;border-style:solid;border-width:0px;" colspan="6">
                      <b>
                        <xsl:value-of select="//lcl/FAC/totaal"/>:
                      </b>
                    </td>
                    <td style="text-align:right">
                      <b>
                        <xsl:value-of select="format-number(sum(bestelopdrachtitem/totaal) + bestelling/levkosten, '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 het NVZ 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>


    <!-- ******************************************************************************************************************  -->

    <!--                                        Hier komen de USER-rapportage functies                                       -->

    <!-- ******************************************************************************************************************  -->


<xsl:key name="GROUP_BY_alg_ruimte_key" match="//facilitor/rapport/rapport_data/data_row" use="ALG_RUIMTE_KEY"/>

<xsl:template match="rapport">

    <xsl:if test="@view = 'vgld_v_rap_res_infobord'">


        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[generate-id(.)=generate-id(key('GROUP_BY_alg_ruimte_key',ALG_RUIMTE_KEY)[1])]">
        <xsl:sort select="FCLT_F_RUIMTE"/>
            <xsl:call-template name="dagoverzicht_per_ruimte">
                <xsl:with-param name="p_ruimte_key" select="ALG_RUIMTE_KEY"/>
            </xsl:call-template>
            <xsl:if test="position()!=last()">
                <div style="page-break-before:always">&#160;</div>
            </xsl:if>
        </xsl:for-each>


    </xsl:if>

</xsl:template>



 <xsl:template name="dagoverzicht_per_ruimte">
        <xsl:param name="p_ruimte_key"/>

        <table border="0" width="100%" cellpadding="2">

        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[ALG_RUIMTE_KEY=$p_ruimte_key]">
        <xsl:sort select="OFFSET" data-type="number" order="descending"/>
            <xsl:if test="position() = 1">
                <tr height="10px">
                    <td colspan='5'></td>
                </tr>
                <tr height="50px">
                    <td></td>
                    <td colspan='4'><b><span style='font-family:arial;font-size:36pt'><xsl:value-of select="FCLT_F_RUIMTE"/></span></b></td>
                </tr>
                <tr height="20px">
                    <td></td>
                    <td width='10%'><span style='font-family:arial;font-size:12pt'>Datum</span></td>
                    <td colspan='3' width='10%'><span style='font-family:arial;font-size:12pt'><xsl:value-of select="DAG"/></span></td>
                </tr>
                <tr height="25px">
    				        <td colspan='5'>
    					        <hr/>
    				        </td>
                </tr>
            </xsl:if>

            <tr height="20px">
                <td colspan='3'></td>
                <td width='20%'><b><span style='font-family:arial;font-size:14pt'>In gebruik door:</span></b></td>
                <td width='40%'><b><span style='font-family:arial;font-size:14pt'><xsl:value-of select="GASTHEER"/></span></b></td>
            </tr>
            <tr height="20px">
                <td width='15%'><b><span style='font-family:arial;font-size:18pt'>Aanvang:</span></b></td>
                <td width='10%'><b><span style='font-family:arial;font-size:18pt'><xsl:value-of select="TIJD_VAN"/></span></b></td>
                <td width='10%'><b><span style='font-family:arial;font-size:18pt'>uur</span></b></td>
                <td colspan='2'><i><span style='font-family:arial;font-size:14pt'><xsl:value-of select="OMSCHRIJVING"/></span></i></td>

            </tr>
            <tr height="20px">
                <td width='15%'><b><span style='font-family:arial;font-size:18pt'>Einde:</span></b></td>
                <td width='10%'><b><span style='font-family:arial;font-size:18pt'><xsl:value-of select="TIJD_TOT"/></span></b></td>
                <td width='10%'><b><span style='font-family:arial;font-size:18pt'>uur</span></b></td>
                <td colspan='2'></td>
            </tr>


            <tr height="25px">
				        <td colspan='5'>
					        <hr/>
				        </td>
            </tr>

        </xsl:for-each>
        </table>
    </xsl:template>

</xsl:stylesheet>
<!-- Stylus Studio meta-information - (c) 2004-2007. Progress Software Corporation. All rights reserved.
<metaInformation>
<scenarios ><scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" url="..\..\..\TEMP\VGLD_files\bestelopdr245_20140320163140.xml" htmlbaseurl="" outputurl="" processortype="internal" useresolver="yes" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator=""/></scenarios><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/><MapperBlockPosition></MapperBlockPosition><TemplateContext></TemplateContext><MapperFilter side="source"></MapperFilter></MapperMetaTag>
</metaInformation>
-->