<?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:template match="melding" mode="full">
		<xsl:choose>
			<xsl:when test="$mode='summary'"></xsl:when>
			<xsl:otherwise>
				<html>
					<xsl:comment>================================ MELDINGEN ==============================</xsl:comment>
					<xsl:comment>Facilitor new style default XSL template for melding</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:choose>
							<xsl:when test="stdmelding/key = '2'">
								<xsl:call-template name="pageheader"/>
								<p>Dienstrapport van <xsl:value-of select="melder/naam_full"/></p>
								<table cellspacing="2">
									<tr>
										<td>Aanmaak rapport:</td>
										<td>
											<xsl:value-of select="begindatum/datum"/>&#xA0;<xsl:value-of select="begindatum/tijd"/></td>
									</tr>
									<xsl:for-each select="tracking/track">
										<xsl:if test="code='MLDAFM'">
											<tr>
												<td>Afsluiten rapport:</td>
												<td>
													<xsl:value-of select="datum/datum"/>&#xA0;<xsl:value-of select="datum/tijd"/></td>
											</tr>
										</xsl:if>
									</xsl:for-each>
								</table>
								<hr/>
								<table cellspacing="10">
									<xsl:for-each select="notes/note">
										<tr>
											<td>
												<xsl:call-template name="linebreaks">
													<xsl:with-param name="string" select="omschrijving"/>
												</xsl:call-template>
											</td>
										</tr>
									</xsl:for-each>
								</table>
								<xsl:call-template name="pagefooter"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:call-template name="pageheader"/>
								<xsl:apply-templates select="." mode="include"/>
								<xsl:call-template name="pagefooter"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:element>
				</html>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>



	<xsl:template match="rapport">
		<xsl:if test="@view='gdfs_v_rap_dienstrapport' or @view='GDFS_V_RAP_DIENSTRAPPORT'">
			<html>
				<head>

					<style>tdx {
      font-family: Verdana;
      padding:  3px;
      font-size: 12pt;
      font-weight: normal;
      color: #DE0072;
    }</style>
				</head>

				<body>

					<table width="100%" class="DefResultsetTable" border="1" cellpadding="0" cellspacing="0">
						<xsl:if test="position() = 1">
							<tr>
								<th class="DefResultsetHeading" style="text-align:left">Datum</th>
								<th class="DefResultsetHeading" style="text-align:left">Dienstrapport</th>
								<th class="DefResultsetHeading" style="text-align:left">Persoon</th>
								<th class="DefResultsetHeading" style="text-align:left">Print</th>
							</tr>
						</xsl:if>
						<xsl:for-each select="rapport_data/data_row">
							<tr>
								<td class="DRR" style="text-align:left">
									<xsl:value-of select="FCLT_D_DATUM"/>
									<xsl:if test="$mode != 'excel'">&#xA0;</xsl:if>
								</td>
								<td class="DRR" style="text-align:left">
									<xsl:value-of select="DIENSTRAPPORT"/>
									<xsl:if test="$mode != 'excel'">&#xA0;</xsl:if>
								</td>
								<td class="DRR" style="text-align:left">
									<xsl:value-of select="PERSOON"/>
									<xsl:if test="$mode != 'excel'">&#xA0;</xsl:if>
								</td>
								<xsl:element name="td">
									<xsl:attribute name="class">DRR</xsl:attribute>
									<xsl:attribute name="title">Print dienstrapport</xsl:attribute>
									<xsl:attribute name="style">{ cursor: hand; border:none; text-align:right; }</xsl:attribute>
									<xsl:attribute name="onclick">window.open('/appl/mld/mld_opdr_xml.asp?mld_key=<xsl:value-of select="DIENSTRAPPORT"/>','pr_rep','resizable=1,scrollbars=1,menubar=1,toolbar=1'); wnd.focus();</xsl:attribute>
									<u>Print dienstrapport <xsl:value-of select="DIENSTRAPPORT"/></u>
								</xsl:element>
							</tr>
						</xsl:for-each>
					</table>
				</body>
			</html>
		</xsl:if>
		<xsl:if test="@view='gdfs_v_rap_auto_registratie' or @view='GDFS_V_RAP_AUTO_REGISTRATIE'">
			<html>
				<head>

					<style>tdx {
      font-family: Verdana;
      padding:  3px;
      font-size: 12pt;
      font-weight: normal;
      color: #DE0072;
    }</style>
				</head>

				<xsl:variable name="distinct">
					<xsl:for-each select="rapport_data/data_row">
						<xsl:sort select="AUTO"/>
						<xsl:copy-of select="."/>
					</xsl:for-each>
				</xsl:variable>
				<xsl:variable name="sorted">
					<xsl:for-each select="rapport_data/data_row">
						<xsl:sort select="AUTO"/>
						<xsl:sort select="TIMESTAMP"/>
						<xsl:copy-of select="."/>
					</xsl:for-each>
				</xsl:variable>

				<body>

					<xsl:for-each select="msxml:node-set($distinct)/data_row">
						<xsl:variable name="auto">
							<xsl:value-of select="AUTO"/>
						</xsl:variable>

						<xsl:variable name="prev_auto">
							<xsl:choose>
								<xsl:when test="position()=1">Quqelequ</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="preceding-sibling::data_row[1]/AUTO"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>
						<xsl:if test="$prev_auto != $auto">

							<xsl:if test="position() != 1">
								<div style="page-break-before:always">&#xA0;</div>
							</xsl:if>
							<table width="100%" class="DefResultsetTable" border="1" cellpadding="0" cellspacing="0">
							<xsl:for-each select="msxml:node-set($sorted)/data_row[AUTO=$auto]">
								<xsl:if test="position() = 1">
								  <xsl:variable name="km_start">
										<xsl:value-of select="km_uitgifte"/>
									</xsl:variable>
									<tr>
										<th class="DefResultsetHeading" colspan="11" style="text-align:center">ENGIE E&amp;P Nederland B.V. - DEN HELDER</th>
									</tr>
									<tr>
										<th class="DefResultsetHeading" colspan="5" style="text-align:center">Month of: <xsl:value-of select="MAAND"/></th>
										<th class="DefResultsetHeading" colspan="6" style="text-align:center">Drive list - <xsl:value-of select="AUTO"/></th>
									</tr>
									<tr>
										<th class="DefResultsetHeading" style="text-align:left">Name Driver</th>
										<th class="DefResultsetHeading" style="text-align:left">Date Required</th>
										<th class="DefResultsetHeading" style="text-align:left">At hours</th>
										<th class="DefResultsetHeading" style="text-align:left">Date of Return</th>
										<th class="DefResultsetHeading" style="text-align:left">At hours</th>
										<th class="DefResultsetHeading" style="text-align:left">Reason</th>
										<th class="DefResultsetHeading" style="text-align:left">From</th>
										<th class="DefResultsetHeading" style="text-align:left">To</th>
										<th class="DefResultsetHeading" style="text-align:left">KM Out</th>
										<th class="DefResultsetHeading" style="text-align:left">KM In</th>
										<th class="DefResultsetHeading" style="text-align:left">KM Driven</th>
									</tr>
								</xsl:if>
								
									<tr>
										<td class="DRR" style="text-align:left">
											<xsl:value-of select="BESTUURDER"/>
											<xsl:if test="$mode != 'excel'">&#xA0;</xsl:if>
										</td>
										<td class="DRR" style="text-align:left">
											<xsl:value-of select="UITGIFTE_DATUM"/>
											<xsl:if test="$mode != 'excel'">&#xA0;</xsl:if>
										</td>
										<td class="DRR" style="text-align:left">
											<xsl:value-of select="UITGIFTE_TIJD"/>
											<xsl:if test="$mode != 'excel'">&#xA0;</xsl:if>
										</td>
										<td class="DRR" style="text-align:left">
											<xsl:value-of select="INNAME_DATUM"/>
											<xsl:if test="$mode != 'excel'">&#xA0;</xsl:if>
										</td>
										<td class="DRR" style="text-align:left">
											<xsl:value-of select="INNAME_TIJD"/>
											<xsl:if test="$mode != 'excel'">&#xA0;</xsl:if>
										</td>
										<td class="DRR" style="text-align:left">
											<xsl:value-of select="REDEN"/>
											<xsl:if test="$mode != 'excel'">&#xA0;</xsl:if>
										</td>
										<td class="DRR" style="text-align:left">
											<xsl:value-of select="VAN"/>
											<xsl:if test="$mode != 'excel'">&#xA0;</xsl:if>
										</td>
										<td class="DRR" style="text-align:left">
											<xsl:value-of select="NAAR"/>
											<xsl:if test="$mode != 'excel'">&#xA0;</xsl:if>
										</td>
										<td class="DRR" style="text-align:left">
											<xsl:value-of select="KM_UITGIFTE"/>
											<xsl:if test="$mode != 'excel'">&#xA0;</xsl:if>
										</td>
										<td class="DRR" style="text-align:left">
											<xsl:value-of select="KM_INNAME"/>
											<xsl:if test="$mode != 'excel'">&#xA0;</xsl:if>
										</td>
										<td class="DRR" style="text-align:right">
											<xsl:value-of select="KM_VERSCHIL"/>
											<xsl:if test="$mode != 'excel'">&#xA0;</xsl:if>
										</td>
									</tr>
								</xsl:for-each>
								<xsl:variable name="km">
 <values>
 <xsl:for-each select="msxml:node-set($sorted)/data_row[AUTO=$auto]//child::KM_VERSCHIL">
 <value><xsl:value-of select="."/></value>
 </xsl:for-each>
 </values>
 </xsl:variable>
								<tr>
								<td colspan="10"></td>
								<td class="DRR" style="text-align:right">
								<xsl:value-of select="sum(msxml:node-set($km)/values/value)"/>
								<xsl:if test="$mode != 'excel'">&#xA0;</xsl:if>
								</td>
								</tr>
							</table>
						</xsl:if>
					</xsl:for-each>
				</body>
			</html>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>