<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 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="melding" mode="IBA">
        <table border="0" width="100%" cellpadding="2">
        	<tr>
        		<td colspan="2" class="caption" style="padding-top:20px;padding-bottom:20px">
        			<b>Aanvraag&#160;<xsl:value-of select="discipline/srtdiscipline/prefix"/><xsl:value-of select="key"/></b>
        		</td>
        		<td colspan="2" class="caption" style="padding-top:20px;padding-bottom:20px">
        			<xsl:if test="spoed&lt;3">
        				<b><xsl:value-of select="//lcl/MLD/spoed"/></b>
        			</xsl:if>
        		</td>
        	</tr>
        	<tr>
        		<td align="right" width="16%">
        			<b>Aanvrager:</b>
        		</td>
        		<td align="left" width="34%">
        			<xsl:value-of select="melder/naam_full"/>
        		</td>
        		<td align="right" width="16%">
        			<b><xsl:value-of select="//lcl/FAC/telefoon"/>:</b>
        		</td>
        		<td align="left" width="34%">
        			<xsl:if test="melder/telefoonnr=''">-</xsl:if>
        			<xsl:value-of select="melder/telefoonnr"/>
        		</td>
        	</tr>
        	
        	
        	<tr>
        	  <td align="right">
        			<b>Datum:</b>
        		</td>
        		<td align="left">
        			<xsl:value-of select="gemeld/datum"/>&#xA0;
        			<xsl:value-of select="gemeld/tijd"/>u
        		</td>
        		<td align="right">
        			<b>Planning/Afleverdatum:</b>
        		</td>
        		<td align="left">
        			<xsl:value-of select="datum_gepland/datum"/>&#xA0;
        			<xsl:value-of select="datum_gepland/tijd"/>u
        		</td>	
        	</tr>
        	<tr height="10px">
        		<td colspan="4">
        			<hr/>
        		</td>
        	</tr>
        
        	<tr>
        		<td align="right">
        			<b>Categorie:</b>
        		</td>
        		<td align="left" colspan="3">>
        			<xsl:value-of select="discipline/omschrijving"/>&#160;<xsl:value-of select="stdmelding/omschrijving"/>
        		</td>        		
        	</tr>
        
        	
        	
        	<xsl:comment>als we binnen een opdracht zijn, tonen we de meldingtekst niet</xsl:comment>
        	<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 height="10px">
        		<td colspan="4">
        			<hr/>
        		</td>
        	</tr>
        	<xsl:for-each select="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>
        	<xsl:if test="count(deel)&gt;0">
        		<xsl:for-each select="deel">
        			<xsl:sort select="omschrijving"/>
        			<tr>
        				<xsl:choose>
        					<xsl:when test="position()=1">
        						<td align="right" valign="top">
        							<b><xsl:value-of select="//lcl/MLD/objecten"/>:</b>
        						</td>
        					</xsl:when>
        					<xsl:otherwise>
        						<td/>
        					</xsl:otherwise>
        				</xsl:choose>
        				<td align="left" valign="top">
        					<xsl:value-of select="omschrijving"/>
        				</td>
        				<td colspan="2" valign="top">
        					<xsl:comment>NADER TE DEFINIEREN</xsl:comment>
        				</td>
        			</tr>
        		</xsl:for-each>
        	</xsl:if>
        	<xsl:if test="opmerking!=''">
        		<tr>
        			<td align="right" valign="top">
        				<b><xsl:value-of select="//lcl/MLD/afhandeling"/>:</b>
        			</td>
        			<td colspan="3">
        				<xsl:call-template name="linebreaks">
        					<xsl:with-param name="string" select="opmerking"/>
        				</xsl:call-template>
        			</td>
        		</tr>
        	</xsl:if>
        	<tr height="10px">
        		<td colspan="4">
        			<hr/>
        		</td>
        	</tr>

          <tr>
        		<td align="right" valign="top">
        			<b>Afleveradres:</b>
        		</td>
        		<td align="right" valign="top">
        			<b><xsl:value-of select="aflever_adres/naam"/></b><br/>
        			<xsl:value-of select="aflever_adres/bezoek_adres"/><br/>
        			<xsl:value-of select="aflever_adres/bezoek_postcode"/>&#160;&#160;<xsl:value-of select="aflever_adres/bezoek_plaats"/>
        		</td>
        		<td align="right" valign="top">
        			<b>Factuuradres:</b>
        		</td>
        		<td align="right" valign="top">
        			<b><xsl:value-of select="../factuuradres/naam"/></b><br/>
        			<xsl:value-of select="../factuuradres/post_adres"/><br/>
        			<xsl:value-of select="../factuuradres/post_postcode"/>&#160;&#160;<xsl:value-of select="aflever_adres/post_plaats"/>
        		</td>
        	</tr>

        	
        </table>
</xsl:template>


	<xsl:template match="opdracht" mode="include">
    <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>
        <xsl:choose>        
            <xsl:when test="melding/aflever_adres/naam != ''">
                <td width="25%"><b><u>Afleveradres</u></b></td>
            </xsl:when>
            <xsl:otherwise>
                <td width="25%"/>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:choose>        
            <xsl:when test="factuuradres/naam != ''">
                <td width="25%"><b><u>Factuuradres</u></b></td>
            </xsl:when>
            <xsl:otherwise>
                <td width="25%"/>
            </xsl:otherwise>
        </xsl:choose>
        
        <td width="25%" align="right">
          <b><xsl:value-of select="//lcl/FAC/bedrijf"/>:</b>
        </td>
        <td width="25%">
          <xsl:value-of select="uitvoerende/bedrijf/naam"/>
        </td>
      </tr>
      <tr>
        <td>
            <xsl:value-of select="melding/aflever_adres/naam"/>
        </td>
        <td>
          <xsl:value-of select="factuuradres/naam"/>
        </td>
        <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>
            <xsl:value-of select="melding/aflever_adres/bezoek_adres"/>
        </td>
        <td>
          <xsl:value-of select="factuuradres/post_adres"/>
        </td>
        <td align="right">
          <b><xsl:value-of select="//lcl/FAC/telefoon"/>:</b>
        </td>
        <td>
          <xsl:value-of select="contactpersoon/telefoon1"/>
        </td>
      </tr>
      <tr>
        <td>
            <xsl:value-of select="melding/aflever_adres/bezoek_postcode"/>&#160;&#160;<xsl:value-of select="melding/aflever_adres/bezoek_plaats"/>
        </td>
        <td>
          <xsl:value-of select="factuuradres/post_postcode"/>&#160;&#160;<xsl:value-of select="factuuradres/post_plaats"/>
        </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_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='Projectnummer']!=''">
        <tr>
          <td colspan="2"/>
          <td align="right">
            <b>Projectnummer:</b>
          </td>
          <td align="left">
            <xsl:value-of select="melding/kenmerk[@naam='Projectnummer']"/>
          </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/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="IBA"/>
              </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>
    <table border="0" width="100%">
    <tr style="line-height:0; border:0; font-size:0px">
    <div id="cxml" style="display:none">
        <span id="hiddenfields">yes</span>
        <span id="order_ID"><xsl:value-of select="melding/stdmelding/discipline/srtdiscipline/prefix"/><xsl:value-of select="melding/key"/>/<xsl:value-of select="bedrijfopdr_volgnr"/></span>
        <xsl:choose>
            <xsl:when test="melding/aflever_adres/key = 161">
                <span id="ShipTo_Name"></span>
                <span id="ShipTo_Address"></span>
                <span id="ShipTo_PostalCode"></span>
                <span id="ShipTo_City"></span>            
            </xsl:when>
            <xsl:otherwise>
                <span id="ShipTo_Name"><xsl:value-of select="melding/aflever_adres/naam"/></span>
                <span id="ShipTo_Address"><xsl:value-of select="melding/aflever_adres/bezoek_adres"/></span>
                <span id="ShipTo_PostalCode"><xsl:value-of select="melding/aflever_adres/bezoek_postcode"/></span>
                <span id="ShipTo_City"><xsl:value-of select="melding/aflever_adres/bezoek_plaats"/></span>
            </xsl:otherwise>
        </xsl:choose>            
        <span id="BillTo_Name"><xsl:value-of select="factuuradres/naam"/></span>
        <span id="BillTo_Address"><xsl:value-of select="factuuradres/post_adres"/></span>
        <span id="BillTo_PostalCode"><xsl:value-of select="factuuradres/post_postcode"/></span>
        <span id="BillTo_City"><xsl:value-of select="factuuradres/post_plaats"/></span>
        <span id="requestedDeliveryDate"><xsl:value-of select="melding/datum_gepland/datum"/></span>
        <span id="Extinsic_ContactPerson"><xsl:value-of select="backoffice_contact/naam_full"/></span>
        <span id="Extinsic_Projectnr"><xsl:value-of select="melding/kenmerk[@naam='Projectnummer']"/></span>
    </div>
    </tr>
    </table>

  </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:comment>FACILITOR default XSL template for opdracht</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="pageheader"/>
				<xsl:apply-templates select="." mode="include"/>
				<xsl:call-template name="pagefooter"/>
			</xsl:element>
		</html>
       </xsl:otherwise>
      </xsl:choose>
	</xsl:template>





</xsl:stylesheet>
