<?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:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'"/>
	<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
	<xsl:decimal-format name="euro" decimal-separator="," grouping-separator="."/>

   <xsl:key name="jaar" match="//facilitor/rapport/rapport_data/data_row" use="FCLT_F_JAAR"/>
   <xsl:key name="regel" match="//facilitor/rapport/rapport_data/data_row" use="HIDE_F_REGEL"/>

	<xsl:template match="rapport" mode="default">
		<html>
			<xsl:choose>

				<xsl:when test="translate(@view, $smallcase, $uppercase)='ASFC_V_RAP_TAAKLIJST' or
				                translate(@view, $smallcase, $uppercase)='ASFC_V_RAP_TAAKLIJST_PLUS1' or
												translate(@view, $smallcase, $uppercase)='ASFC_V_RAP_TAAKLIJST_PLUS2' or
												translate(@view, $smallcase, $uppercase)='ASFC_V_RAP_TAAKLIJST_LF'">

               <table width="100%" class="DefResultsetTable" border="1" cellpadding="0" cellspacing="0">
                
                	<xsl:if test=" count(rapport_data/data_row) = 0">
					        <tr>
						<td>
							<center>
								<b>Geen gegevens gevonden</b>
							</center>
						</td>
					</tr>
									</xsl:if>

				<xsl:variable name="sorted">
						<xsl:for-each select="rapport_data/data_row">
							<xsl:sort select="VOLGORDE"/>
							<xsl:sort select="FCLT_F_TAAK"/>
							<xsl:sort select="LOCATIEEENHEID"/>
							<xsl:sort select="IDENTIFICATIE"/>
								<xsl:copy-of select="."/>
						</xsl:for-each>
				</xsl:variable>

				<xsl:for-each select="msxml:node-set($sorted)/data_row">

					<xsl:variable name="prev_taak">
						<xsl:choose>
							<xsl:when test="position()=1">Quqelequ</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="preceding-sibling::data_row[1]/FCLT_F_TAAK"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:variable>

					<xsl:variable name="prev_datum">
						<xsl:choose>
							<xsl:when test="position()=1">Quqelequ</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="preceding-sibling::data_row[1]/INSPECTIEDATUM"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:variable>

				<xsl:if test="$prev_taak != FCLT_F_TAAK or $prev_datum != INSPECTIEDATUM">

							<xsl:if test="position() != 1">
								<xsl:text disable-output-escaping="yes">&lt;/table&gt;</xsl:text>
								<div style="page-break-before:always">&#xA0;</div>
								<xsl:text disable-output-escaping="yes">&lt;table width="100%" class="DefResultsetTable" border="1" cellspacing="0" cellpadding="0"&gt;</xsl:text>
							</xsl:if>

                  <thead>
									                    <tr>
                        <th style="text-align: left" colspan="4">Taak: <xsl:value-of select="FCLT_F_TAAK"/></th>
												<th style="text-align: right" colspan="3">Datum: <xsl:value-of select="INSPECTIEDATUM"/></th>
                     </tr>
                     <tr>
                        <th style="text-align: left">Onderdeel</th>
                        <th style="text-align: left">Identificatie</th>
												<th style="text-align: left">Ruimtenr vlgns bestek</th>
												<th style="text-align: left">Werkzaamheden</th>
												<th style="text-align: left">Opmerking</th>
												<th style="text-align: left">o</th>
												<th style="text-align: left">m</th>
                     </tr>
                  </thead>
				</xsl:if>
                  <tbody>
         
                           <tr>
                              <td>
                                 <xsl:value-of select="LOCATIEEENHEID"/>
                              </td>
                              <td>
                                 <xsl:value-of select="IDENTIFICATIE"/>
                              </td>
															<td>
                                 <xsl:value-of select="RUIMTENR_BESTEK"/>
                              </td>
															<td>
                                 <xsl:value-of select="WERKZAAMHEDEN"/>
                              </td>
															<td>
                                 &#xA0;
                              </td>
															<td>
                                 &#xA0;
                              </td>
															<td>
                                 &#xA0;
                              </td>
 										</tr>
                  </tbody>
									</xsl:for-each>
               </table>

				</xsl:when>

				<xsl:otherwise>
					<xsl:comment>================================ RAPPORT ==============================</xsl:comment>
					<xsl:comment>FACILITOR default XSL template for rapport</xsl:comment>
					<xsl:call-template name="htmlhead"/>
					<body>
						<table>
							<xsl:for-each select="rapport_data/data_row">
								<xsl:sort select="."/>
								<tr>
									<td>
										<xsl:value-of select="current()"/>
									</td>
								</tr>
							</xsl:for-each>
						</table>
					</body>
				</xsl:otherwise>
			</xsl:choose>
		</html>
	</xsl:template>

</xsl:stylesheet>