<?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:output method="xml" indent="yes" encoding="utf-8"/>

	<xsl:decimal-format name="european" decimal-separator="," grouping-separator="."/>

	<xsl:param name="mode"/>
	<xsl:param name="srtnotificatiecode"/>

    <xsl:variable name="xsrtnotificatiecode">MLDACP</xsl:variable>

	<xsl:variable name="Rev">
		<!-- Revision van deze yahu2sys.xsl -->
		<xsl:value-of select="substring(translate('$Revision$', '$ ', ''), 10)"/>
	</xsl:variable>

	<xsl:template match="melding">
		<facilitor>
			<xsl:choose>
				<xsl:when test="voor/oslogin = '_KPMG_KOPPELING'">
					<xsl:element name="meldingstatus">
						<xsl:attribute name="key">
							<xsl:value-of select="externnr"/>
						</xsl:attribute>
						<xsl:choose>
							<xsl:when test="$srtnotificatiecode='MLDACP'">
								<status>ACCEPT</status>
								<timestamp>
									<xsl:value-of select="tracking/track[@code='MLDACP']/datum/jaar"/>-<xsl:value-of select="tracking/track[@code='MLDACP']/datum/maand"/>-<xsl:value-of select="tracking/track[@code='MLDACP']/datum/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="tracking/track[@code='MLDACP']/datum/tijd"/>:00</timestamp>
								<xsl:if test="opmerking!=''">
									<afhandeling>
										<xsl:value-of select="opmerking"/>
									</afhandeling>
								</xsl:if>
								<oplosdatum>
									<xsl:value-of select="datum_gepland/jaar"/>-<xsl:value-of select="datum_gepland/maand"/>-<xsl:value-of select="datum_gepland/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="datum_gepland/tijd"/>:00</oplosdatum>
							</xsl:when>
							<xsl:when test="$srtnotificatiecode='MLDAFM'">
								<timestamp>
									<xsl:value-of select="tracking/track[@code='MLDAFM']/datum/jaar"/>-<xsl:value-of select="tracking/track[@code='MLDAFM']/datum/maand"/>-<xsl:value-of select="tracking/track[@code='MLDAFM']/datum/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="tracking/track[@code='MLDAFM']/datum/tijd"/>:00</timestamp>
								<status>CLOSE</status>
								<xsl:if test="opmerking!=''">
									<afhandeling>
										<xsl:value-of select="opmerking"/>
									</afhandeling>
								</xsl:if>
								<oplosdatum>
									<xsl:value-of select="datum_gepland/jaar"/>-<xsl:value-of select="datum_gepland/maand"/>-<xsl:value-of select="datum_gepland/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="datum_gepland/tijd"/>:00</oplosdatum>
							</xsl:when>
							<xsl:when test="$srtnotificatiecode='MLDAFR'">
								<timestamp>
									<xsl:value-of select="tracking/track[@code='MLDAFR']/datum/jaar"/>-<xsl:value-of select="tracking/track[@code='MLDAFR']/datum/maand"/>-<xsl:value-of select="tracking/track[@code='MLDAFR']/datum/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="tracking/track[@code='MLDAFR']/datum/tijd"/>:00</timestamp>
								<status>FINCLOSE</status>
								<kosten>
									<xsl:value-of select="kenmerk[@naam='Kosten']"/>
								</kosten>
							</xsl:when>
							<xsl:when test="$srtnotificatiecode='MLDREJ' or status_key='1'">
								<timestamp>
									<xsl:value-of select="tracking/track[@code='MLDREJ']/datum/jaar"/>-<xsl:value-of select="tracking/track[@code='MLDREJ']/datum/maand"/>-<xsl:value-of select="tracking/track[@code='MLDREJ']/datum/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="tracking/track[@code='MLDREJ']/datum/tijd"/>:00</timestamp>
								<status>REJECT</status>
								<afhandeling>Afgewezen.<xsl:if test="opmerking!=''">
										<xsl:value-of select="opmerking"/></xsl:if></afhandeling>
								<oplosdatum>
									<xsl:value-of select="datum_gepland/jaar"/>-<xsl:value-of select="datum_gepland/maand"/>-<xsl:value-of select="datum_gepland/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="datum_gepland/tijd"/>:00</oplosdatum>
								<kosten>
									<xsl:value-of select="format-number(sum(opdracht/kosten), '0,00', 'european')"/>
								</kosten>
							</xsl:when>
							<xsl:otherwise>
								<xsl:variable name="maxtrack">
									<xsl:for-each select="tracking/track[@code='MLDUPD']/datum">
										<xsl:sort select="timestamp" data-type="number" order="descending"/>
										<xsl:if test="position()=1">
											<xsl:copy-of select="."/>
										</xsl:if>
									</xsl:for-each>
								</xsl:variable>
								<timestamp>
									<xsl:value-of select="msxml:node-set($maxtrack)/datum/jaar"/>-<xsl:value-of select="msxml:node-set($maxtrack)/datum/maand"/>-<xsl:value-of select="msxml:node-set($maxtrack)/datum/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="msxml:node-set($maxtrack)/datum/tijd"/>:00</timestamp>
								<xsl:if test="opmerking!=''">
									<afhandeling>
										<xsl:value-of select="opmerking"/>
									</afhandeling>
								</xsl:if>
								<oplosdatum>
									<xsl:value-of select="datum_gepland/jaar"/>-<xsl:value-of select="datum_gepland/maand"/>-<xsl:value-of select="datum_gepland/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="datum_gepland/tijd"/>:00</oplosdatum>
							</xsl:otherwise>
						</xsl:choose>
						<xsl:for-each select="kenmerk">
							<xsl:sort select="@volgnummer" data-type="number"/>
							<xsl:if test="@type != 'M'">
							<xsl:element name="kenmerk">
								<xsl:attribute name="naam">
									<xsl:value-of select="@naam"/>
								</xsl:attribute>
								<xsl:attribute name="volgnummer">
									<xsl:value-of select="@volgnummer"/>
								</xsl:attribute>
								<xsl:attribute name="type">
									<xsl:value-of select="@type"/>
								</xsl:attribute>
								<xsl:value-of select="."/>
							</xsl:element>
							</xsl:if>
						</xsl:for-each>
						<xsl:element name="kenmerk">
							<xsl:attribute name="naam">Bijlagen</xsl:attribute>
							<xsl:attribute name="volgnummer">300</xsl:attribute>
							<xsl:attribute name="type">M</xsl:attribute>
							<xsl:element name="FCLTmeldingattachment">
								<xsl:attribute name="meldingkey">
									<xsl:value-of select="key"/>
								</xsl:attribute>
								<xsl:attribute name="kenmerkkey">
									<xsl:choose>
										<xsl:when test="discipline/srtdiscipline/prefix = 'A'">81</xsl:when>
										<xsl:when test="discipline/srtdiscipline/prefix = 'K'">82</xsl:when>
										<xsl:when test="discipline/srtdiscipline/prefix = 'M'">83</xsl:when>
									</xsl:choose>
								</xsl:attribute>
								<xsl:attribute name="nodename">bijlage</xsl:attribute>
							</xsl:element>
						</xsl:element>
					</xsl:element>
				</xsl:when>
				<xsl:otherwise>
					<xsl:element name="opdracht">
						<xsl:attribute name="key">
							<xsl:value-of select="externnr"/>
						</xsl:attribute>
						<xsl:attribute name="type">update</xsl:attribute>
						<xsl:choose>
							<xsl:when test="$srtnotificatiecode='MLDACP'">
								<mut_datum>
									<xsl:value-of select="tracking/track[@code='MLDACP']/datum/jaar"/>-<xsl:value-of select="tracking/track[@code='MLDACP']/datum/maand"/>-<xsl:value-of select="tracking/track[@code='MLDACP']/datum/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="tracking/track[@code='MLDACP']/datum/tijd"/>:00</mut_datum>
								<xsl:if test="opmerking!=''">
									<opmerking>
										<xsl:value-of select="opmerking"/>
									</opmerking>
								</xsl:if>
								<datumgereed>
									<xsl:value-of select="datum_gepland/jaar"/>-<xsl:value-of select="datum_gepland/maand"/>-<xsl:value-of select="datum_gepland/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="datum_gepland/tijd"/>:00</datumgereed>
							</xsl:when>
							<xsl:when test="$srtnotificatiecode='MLDAFM'">
								<mut_datum>
									<xsl:value-of select="tracking/track[@code='MLDAFM']/datum/jaar"/>-<xsl:value-of select="tracking/track[@code='MLDAFM']/datum/maand"/>-<xsl:value-of select="tracking/track[@code='MLDAFM']/datum/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="tracking/track[@code='MLDAFM']/datum/tijd"/>:00</mut_datum>
								<status>ORDAFM</status>
								<xsl:if test="opmerking!=''">
									<opmerking>
										<xsl:value-of select="opmerking"/>
									</opmerking>
								</xsl:if>
								<datumgereed>
									<xsl:value-of select="datum_gepland/jaar"/>-<xsl:value-of select="datum_gepland/maand"/>-<xsl:value-of select="datum_gepland/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="datum_gepland/tijd"/>:00</datumgereed>
							</xsl:when>
							<xsl:when test="$srtnotificatiecode='MLDAFR'">
								<mut_datum>
									<xsl:value-of select="tracking/track[@code='MLDAFR']/datum/jaar"/>-<xsl:value-of select="tracking/track[@code='MLDAFR']/datum/maand"/>-<xsl:value-of select="tracking/track[@code='MLDAFR']/datum/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="tracking/track[@code='MLDAFR']/datum/tijd"/>:00</mut_datum>
								<status>ORDAFR</status>
								<kosten>
									<xsl:value-of select="kenmerk[@naam='Kosten']"/>
								</kosten>
							</xsl:when>
							<xsl:when test="$srtnotificatiecode='MLDREJ' or status_key='1'">
								<mut_datum>
									<xsl:value-of select="tracking/track[@code='MLDREJ']/datum/jaar"/>-<xsl:value-of select="tracking/track[@code='MLDREJ']/datum/maand"/>-<xsl:value-of select="tracking/track[@code='MLDREJ']/datum/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="tracking/track[@code='MLDREJ']/datum/tijd"/>:00</mut_datum>
								<status>ORDAFM</status>
								<opmerking>Afgewezen.<xsl:if test="opmerking!=''">
										<xsl:value-of select="opmerking"/></xsl:if></opmerking>
								<datumgereed>
									<xsl:value-of select="datum_gepland/jaar"/>-<xsl:value-of select="datum_gepland/maand"/>-<xsl:value-of select="datum_gepland/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="datum_gepland/tijd"/>:00</datumgereed>
								<kosten>
									<xsl:value-of select="format-number(sum(opdracht/kosten), '0,00', 'european')"/>
								</kosten>
							</xsl:when>
							<xsl:otherwise>
								<xsl:variable name="maxtrack">
									<xsl:for-each select="tracking/track[@code='MLDUPD']/datum">
										<xsl:sort select="timestamp" data-type="number" order="descending"/>
										<xsl:if test="position()=1">
											<xsl:copy-of select="."/>
										</xsl:if>
									</xsl:for-each>
								</xsl:variable>
								<mut_datum>
									<xsl:value-of select="msxml:node-set($maxtrack)/datum/jaar"/>-<xsl:value-of select="msxml:node-set($maxtrack)/datum/maand"/>-<xsl:value-of select="msxml:node-set($maxtrack)/datum/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="msxml:node-set($maxtrack)/datum/tijd"/>:00</mut_datum>
								<xsl:if test="opmerking!=''">
									<opmerking>
										<xsl:value-of select="opmerking"/>
									</opmerking>
								</xsl:if>
								<datumgereed>
									<xsl:value-of select="datum_gepland/jaar"/>-<xsl:value-of select="datum_gepland/maand"/>-<xsl:value-of select="datum_gepland/dag"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="datum_gepland/tijd"/>:00</datumgereed>
							</xsl:otherwise>
						</xsl:choose>
						<xsl:for-each select="kenmerk">
							<xsl:sort select="@volgnummer" data-type="number"/>
							<xsl:element name="kenmerk">
								<xsl:attribute name="naam">
									<xsl:value-of select="@naam"/>
								</xsl:attribute>
								<xsl:attribute name="volgnummer">
									<xsl:value-of select="@volgnummer"/>
								</xsl:attribute>
								<xsl:attribute name="type">
									<xsl:value-of select="@type"/>
								</xsl:attribute>
								<xsl:value-of select="."/>
							</xsl:element>
						</xsl:for-each>
						<xsl:element name="kenmerk">
							<xsl:attribute name="naam">Bijlage</xsl:attribute>
							<xsl:attribute name="volgnummer">300</xsl:attribute>
							<xsl:attribute name="type">M</xsl:attribute>
							<xsl:element name="FCLTmeldingattachment">
								<xsl:attribute name="meldingkey">
									<xsl:value-of select="key"/>
								</xsl:attribute>
								<xsl:attribute name="kenmerkkey">
									<xsl:choose>
										<xsl:when test="discipline/srtdiscipline/prefix = 'A'">81</xsl:when>
										<xsl:when test="discipline/srtdiscipline/prefix = 'K'">82</xsl:when>
										<xsl:when test="discipline/srtdiscipline/prefix = 'M'">83</xsl:when>
									</xsl:choose>
								</xsl:attribute>
								<xsl:attribute name="nodename">bijlage</xsl:attribute>
							</xsl:element>
						</xsl:element>
					</xsl:element>
				</xsl:otherwise>
			</xsl:choose>
		</facilitor>
	</xsl:template>

	<xsl:template match="facilitor">
		<xsl:apply-templates select="melding"/>
	</xsl:template>

	<!-- Root -->
	<xsl:template match="/">
		<xsl:apply-templates select="facilitor"/>
	</xsl:template>

	<xsl:template match="melder">
	</xsl:template>
</xsl:stylesheet><!-- Stylesheet edited using Stylus Studio - (c) 2004-2007. Progress Software Corporation. All rights reserved. -->