<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:import href="./environment.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">
	
	
    <table border="0" width="100%" cellpadding="2">
      
  
      
      <tr>
        <td colspan="2" class="caption" style="padding-top:20px;padding-bottom:20px">
          <b>
            <xsl:value-of select="opdrachttype/omschrijving"/>&#160;
            <xsl:element name="a">
            	<xsl:attribute name="href"><xsl:value-of select="$FacilitorRoot"/>/?<xsl:value-of select="../bookmarks/opdracht"/><xsl:value-of select="key"/></xsl:attribute>
		            <xsl:value-of select="melding/stdmelding/discipline/srtdiscipline/prefix"/>
		            <xsl:value-of select="melding/key"/>/<xsl:value-of select="bedrijfopdr_volgnr"/>
            </xsl:element> 
          </b>            
        </td>        
      </tr>
      
      <tr>
        <td colspan="4" height="10px" valign="center">
          <hr/>
        </td>
      </tr>
      
      <tr>      	
      	<td colspan="4" style="font-size:20px"><b><xsl:value-of select="melding/voor/afdeling/bedrijf/naam"/></b></td>
      </tr>
      
      <tr>
      	<td><b>Post<xsl:value-of select="//lcl/FAC/adres"/>: </b></td>
      	<td><xsl:value-of select="melding/voor/afdeling/bedrijf/post_adres"/></td>
        <td><b>Bezoek<xsl:value-of select="//lcl/FAC/adres"/>: </b></td>
      	<td><xsl:value-of select="melding/voor/afdeling/bedrijf/bezoek_adres"/></td>
      </tr>
      
      <tr>
      	<td/>
      	<td><xsl:value-of select="melding/voor/afdeling/bedrijf/post_postcode"/>&#160;&#160;<xsl:value-of select="melding/voor/afdeling/bedrijf/post_plaats"/></td>
        <td/>
        <td><xsl:value-of select="melding/voor/afdeling/bedrijf/bezoek_postcode"/>&#160;&#160;<xsl:value-of select="melding/voor/afdeling/bedrijf/bezoek_plaats"/></td>
      </tr>
      
      <tr>
      	<td><b><xsl:value-of select="//lcl/FAC/telefoon"/>: </b></td>
      	<td><xsl:value-of select="melding/voor/afdeling/bedrijf/telefoon"/></td>
        <td><b>Fax: </b></td>
      	<td><xsl:value-of select="melding/voor/afdeling/bedrijf/fax"/></td>
      </tr>
      <tr>
      	<td><b><xsl:value-of select="//lcl/FAC/e-mail"/>: </b></td>
      	<td><xsl:value-of select="melding/voor/afdeling/bedrijf/email"/></td>
        <td colspan="2"/>
      </tr>

      <tr>
        <td colspan="4" height="10px" valign="center">
          <hr/>
        </td>
      </tr>
      
      
      <tr>
      	<td colspan="4" style="font-size:20px"><b><xsl:value-of select="uitvoerende/bedrijf/naam"/></b>&#160;&#160;&#160;&#160;<span style="font-size:9px">(<b>GLN</b>: <xsl:value-of select="uitvoerende/bedrijf/leverancier_nr"/>)</span></td>
      </tr>
     
      <tr>
      	<td><b>Post<xsl:value-of select="//lcl/FAC/adres"/>: </b></td>
      	<td><xsl:value-of select="uitvoerende/bedrijf/post_adres"/></td>
        <td><b>Bezoek<xsl:value-of select="//lcl/FAC/adres"/>: </b></td>
      	<td><xsl:value-of select="uitvoerende/bedrijf/bezoek_adres"/></td>
      </tr>
      
      <tr>
      	<td/>
      	<td><xsl:value-of select="uitvoerende/bedrijf/post_postcode"/>&#160;&#160;<xsl:value-of select="uitvoerende/bedrijf/post_plaats"/></td>
        <td/>
        <td><xsl:value-of select="uitvoerende/bedrijf/bezoek_postcode"/>&#160;&#160;<xsl:value-of select="uitvoerende/bedrijf/bezoek_plaats"/></td>
      </tr>
      
      <tr>
      	<td><b><xsl:value-of select="//lcl/FAC/telefoon"/>: </b></td>
      	<td><xsl:value-of select="uitvoerende/bedrijf/telefoon"/></td>
        <td><b>Fax: </b></td>
      	<td><xsl:value-of select="uitvoerende/bedrijf/fax"/></td>
      </tr>
      <tr>
      	<td><b><xsl:value-of select="//lcl/FAC/e-mail"/>: </b></td>
      	<td><xsl:value-of select="uitvoerende/bedrijf/email"/></td>
        <td colspan="2"/>
      </tr>

      <tr>
        <td colspan="4" height="10px" valign="center">
          <hr/>
        </td>
      </tr>
      
      <tr>
      	<td colspan="4" style="font-size:20px"><b>Opdrachtgegevens</b></td>
      </tr>
     
      <tr>
      	<td colspan="2" style="font-size:14px"><b>MAREON NUMMER: </b>
            <xsl:value-of select="melding/stdmelding/discipline/srtdiscipline/prefix"/>
            <xsl:value-of select="melding/key"/>/<xsl:value-of select="bedrijfopdr_volgnr"/></td>
				<td colspan="2" style="font-size:14px"><b>TOBIAS NUMMER: </b> <xsl:value-of select="opdr_id"/></td>
      </tr>
      
      
      <tr>
      	<td><b>Status: </b></td>
      	<td><xsl:value-of select="status"/></td>
        <td colspan="2"/>
      </tr>
      <tr>
      	<td><b>Opdrachtdatum: </b></td>
      	<td><xsl:value-of select="datumbegin/datum"/></td>
        <td><b>Uitvoeren voor: </b></td>
      	<td><xsl:value-of select="einddatum/datum"/></td>
      </tr>
      <tr>
      	<td><b>Plandatum / tijd: </b></td>
      	<td><xsl:value-of select="plandatum/datum"/>&#160;<xsl:value-of select="plandatum/tijd"/></td>
        <td colspan="2"/>
      </tr>
           
      <tr>
        <td colspan="4" height="10px" valign="center">
        </td>
      </tr>
			
			<xsl:for-each select="melding/kenmerk[@type!='L' and @type!='l' and @type!='Q' and count(@xmlnode)=0]">
        <xsl:sort select="@volgnummer" data-type="number"/>
        <xsl:if test=".!=''">
          <tr>
            <td align="right">
              <b>
                <xsl:value-of select="@naam"/>:</b>
            </td>
            <td colspan="3">
              <xsl:value-of select="."/>
            </td>
          </tr>
        </xsl:if>
      </xsl:for-each>
			      
      <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 align="right" valign="top">
          <b><xsl:value-of select="//lcl/FAC/opmerking"/>:</b>
        </td>
        <td align="left" colspan="3">
          <xsl:call-template name="linebreaks">
            <xsl:with-param name="string" select="opmerking"/>
          </xsl:call-template>
        </td>
      </tr>
      
      <tr>
        <td colspan="4" height="10px" 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>          
        </td>
        <td/>
      </tr>
      <tr>
        <td colspan="4" height="10px" valign="center">
          <hr/>
        </td>
      </tr>
      <tr>
        <td colspan="5" style="text-align:left; font-size:9px; color:red">
        <xsl:call-template name="escape_marnr_tobiasnr"><xsl:with-param name="string" select="melding/voor/afdeling/bedrijf/opmerking2"/></xsl:call-template>
				</td>
      </tr>
      <tr>
			    <td colspan="5" style="text-align:left; font-size:9px">
			    <xsl:value-of select="melding/voor/afdeling/bedrijf/opmerking"/>
			    </td>
			</tr>
			
    </table>
  </xsl:template>
	
	<xsl:template name="escape_marnr_tobiasnr">
		<xsl:param name="string"/>
		<xsl:variable name="l_marnr" select="'MAR###'"/>
		<xsl:variable name="l_tobiasnr" select="'TOBIAS###'"/>
		<xsl:choose>
			<xsl:when test="contains($string, $l_marnr)">
				<xsl:value-of select="substring-before($string, $l_marnr)"/>
				<xsl:value-of select="melding/stdmelding/discipline/srtdiscipline/prefix"/><xsl:value-of select="melding/key"/>/<xsl:value-of select="bedrijfopdr_volgnr"/>
				<xsl:call-template name="escape_marnr_tobiasnr">
						<xsl:with-param name="string" select="substring-after($string, $l_marnr)"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="contains($string, $l_tobiasnr)">
				<xsl:value-of select="substring-before($string, $l_tobiasnr)"/>
				<xsl:value-of select="opdr_id"/>
				<xsl:call-template name="escape_marnr_tobiasnr">
					<xsl:with-param name="string" select="substring-after($string, $l_tobiasnr)"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise><xsl:value-of select="$string"/></xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	
	
	
</xsl:stylesheet>
