<?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="full">
    <xsl:choose>
        <xsl:when test="$srtnotificatiecode = 'CUST02'"><xsl:apply-templates select="." mode="mld_sms"/></xsl:when>
        <xsl:when test="$mode='summary'"></xsl:when>
        <xsl:otherwise>
        		<html>
        			<xsl:comment>================================ MELDINGEN ==============================</xsl:comment>
        			<xsl:comment>FACILITOR 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:call-template name="pageheader"/>
        				<xsl:choose>
        		         <xsl:when test="$srtnotificatiecode = 'MLDKTO'">
        			         <xsl:apply-templates select="." mode="kto"/>
        		         </xsl:when>
        			      <xsl:otherwise>
              		      <xsl:apply-templates select="." mode="include"/>
              		   </xsl:otherwise>
                    </xsl:choose>
              		<xsl:call-template name="pagefooter"/>
        			</xsl:element>
        		</html>
       </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<xsl:template match="melding" mode="include">
    <xsl:choose>
        <xsl:when test="./stdmelding/discipline/srtdiscipline/key = 1 or ./stdmelding/discipline/srtdiscipline/key = 21 or ./stdmelding/discipline/srtdiscipline/key = 22">
            <xsl:comment>Dit is een klacht van exposant of organisator of bezoeker, dus die gaat op een andere manier...</xsl:comment>
            <xsl:apply-templates select="." mode="klacht_exp_org_bez"/>
        </xsl:when>
        <xsl:otherwise>
            <xsl:comment>Alle andere meldingtypen...</xsl:comment>
            <xsl:apply-templates select="." mode="default"/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>


<xsl:template match="melding" mode="mld_sms">
    <xsl:choose>
        <xsl:when test="count(tracking/track[@code='MLDAFM'])=0"><xsl:apply-templates select="." mode="mld_sms_new"/></xsl:when>
        <xsl:otherwise><xsl:apply-templates select="." mode="mld_sms_afm"/></xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template match="melding" mode="mld_sms_new">
<xsl:if test="./stdmelding/discipline/srtdiscipline/key = 1">Uw melding staat geregistreerd in het RAI meldingensysteem onder nummer <xsl:value-of select="key"/>.
Voor eventuele vragen kunt u terecht bij uw contactpersoon <xsl:value-of select="voor/voornaam"/>&#160;<xsl:value-of select="voor/tussenvoegsel"/>&#160;<xsl:value-of select="voor/naam"/>.
Telefoonnummer: <xsl:value-of select="voor/telefoonnr"/>.
Als uw melding is opgelost, ontvangt u hiervan eveneens automatisch bericht.
Met vriendelijke groet,
Amsterdam RAI
</xsl:if>
</xsl:template>

<xsl:template match="melding" mode="mld_sms_afm">
<xsl:if test="./stdmelding/discipline/srtdiscipline/key = 1">Uw melding met nummer <xsl:value-of select="key"/> is op <xsl:value-of select="tracking/track[@code='MLDAFM']/datum/datum"/> om <xsl:value-of select="tracking/track[@code='MLDAFM']/datum/tijd"/>u afgemeld.
Met vriendelijke groet,
Amsterdam RAI
</xsl:if>
</xsl:template>


<xsl:template match="melding" mode="klacht_exp_org_bez">
		<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="//lcl/MLD/melding"/>&#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>Registered by:</b>
				</td>
				<td align="left" width="34%">
					<xsl:value-of select="voor/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="voor/telefoonnr=''">-</xsl:if>
					<xsl:value-of select="voor/telefoonnr"/>
				</td>
			</tr>

			<tr>
			  <td align="right">
					<b><xsl:value-of select="//lcl/MLD/melddatum"/>:</b>
				</td>
				<td align="left">
					<xsl:value-of select="gemeld/datum"/>&#xA0;
					<xsl:value-of select="gemeld/tijd"/>u
				</td>
				<td align="right">
					<b><xsl:value-of select="//lcl/MLD/uitvoertijd"/>:</b>
				</td>
				<td align="left">
					<xsl:value-of select="datum_gepland/datum"/>&#xA0;
					<xsl:value-of select="datum_gepland/tijd"/>u
				</td>
			</tr>

			<tr>
				<td align="right">
					<b><xsl:value-of select="//lcl/MLD/status"/>:</b>
				</td>
				<td align="left">
					<xsl:value-of select="status"/>
				</td>
			</tr>

			<tr height="10px">
				<td colspan="4">
					<hr/>
				</td>
			</tr>

			<tr>
				<td align="right">
					<b><xsl:value-of select="//lcl/MLD/vakgroep"/>:</b>
				</td>
				<td align="left">
					<xsl:if test="discipline/omschrijving=''">-</xsl:if>
					<xsl:value-of select="discipline/omschrijving"/>
				</td>
					<td align="right">
					<b><xsl:value-of select="//lcl/MLD/stdmelding"/>:</b>
				</td>
				<td align="left">
					<xsl:if test="stdmelding/omschrijving=''">-</xsl:if>
					<xsl:value-of select="stdmelding/omschrijving"/>
				</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 height="20px">
				<td colspan="4">
				</td>
			</tr>
		  <tr height="10px">
				<td colspan="4">
					<hr/>
				</td>
			</tr>

    <xsl:choose>
        <xsl:when test="./stdmelding/discipline/srtdiscipline/key = 1">
            <xsl:comment>Dit is een klacht van exposant, die is net ietsjes anders dan klacht van organisator</xsl:comment>
            <tr>
                <td colspan="2" style="padding-top:20px;padding-bottom:10px;font-size:12pt">
                	<b><u>Exhibitor</u></b>
                </td>
            </tr>
            <xsl:apply-templates select="kenmerk[@key=181]" mode="ebms"/>
        </xsl:when>
        <xsl:when test="./stdmelding/discipline/srtdiscipline/key = 22">
            <xsl:comment>Dit is een klacht van bezoeker, die is net ietsjes anders dan de andere 2 klachten</xsl:comment>
            <tr>
                <td colspan="2" style="padding-top:20px;padding-bottom:10px;font-size:12pt">
                	<b><u>Visitor</u></b>
                </td>
            </tr>
        </xsl:when>
        <xsl:otherwise>
            <xsl:comment>Dit is een klacht van organisator, die is net ietsjes anders dan klacht van organisator</xsl:comment>
            <tr>
                <td colspan="2" style="padding-top:10px;padding-bottom:10px;font-size:12pt">
                	<b><u>Plaats:</u></b>
                </td>
         				<xsl:if test="$mode!='email'">
            			<xsl:if test="plaats/regio/district/locatie/gebouw/verdieping/ruimte/key">
                    <td rowspan='11' colspan='2'>
                          <xsl:element name="img">
                                      <xsl:attribute name="src">
                                                  ../../appl/CAD/mySlnk2IMG.asp?mode=0&amp;vKey=<xsl:value-of select="plaats/regio/district/locatie/gebouw/verdieping/key"/>&amp;scenario_key=0&amp;paperWidth=120&amp;paperHeight=50&amp;forPrint=1&amp;discs=61&amp;thema=<xsl:value-of select="$PRJ_AFDELING_THEMA_KEY"/>&amp;highlight=<xsl:value-of select="plaats/regio/district/locatie/gebouw/verdieping/ruimte/key"/></xsl:attribute>
                                      <xsl:attribute name="style">height:80mm; width:160mm</xsl:attribute>
                                      <xsl:attribute name="border">0</xsl:attribute>
                                      <xsl:attribute name="galleryimg">false</xsl:attribute>
                          </xsl:element>
                    </td>
            			</xsl:if>
            	  </xsl:if>
            </tr>
            <tr>
        				<td align="right">
        					<b><xsl:value-of select="//lcl/FAC/locatie"/>:</b>
        				</td>
        				<td align="left" colspan="1">
        					<xsl:value-of select="plaats/regio/district/locatie/code"/>&#xA0;
        					<xsl:if test="plaats/regio/district/locatie/omschrijving!=''">(<xsl:value-of select="plaats/regio/district/locatie/omschrijving"/>)</xsl:if>
        				</td>
        		</tr>
        		<tr>
        		    <xsl:choose>
        					<xsl:when test="plaats/@type='T'">
        						<td align="right">
        							<b><xsl:value-of select="//lcl/FAC/terrein"/>:</b>
        						</td>
        						<td align="left" colspan="1">
        							<xsl:value-of select="plaats/regio/district/locatie/terrein/code"/>-<xsl:value-of select="plaats/regio/district/locatie/terrein/naam"/></td>
        					</xsl:when>
        					<xsl:otherwise>
        						<td align="right">
        							<b><xsl:value-of select="//lcl/FAC/gebouw"/>:</b>
        						</td>
        						<td align="left" colspan="1">
        							<xsl:value-of select="plaats/regio/district/locatie/gebouw/code"/>-<xsl:value-of select="plaats/regio/district/locatie/gebouw/naam"/></td>
        					</xsl:otherwise>
        				</xsl:choose>
        		</tr>
        		<tr>
        				<xsl:if test="plaats/@type!='T' and plaats/@type!='G'">
        					<td align="right">
        						<b><xsl:value-of select="//lcl/FAC/bouwlaag"/>:</b>
        					</td>
        					<td align="left" colspan="1">
        						<xsl:value-of select="plaats/regio/district/locatie/gebouw/verdieping/code"/>&#xA0;
        						<xsl:if test="plaats/regio/district/locatie/gebouw/verdieping/omschrijving!=''">(<xsl:value-of select="plaats/regio/district/locatie/gebouw/verdieping/omschrijving"/>)</xsl:if>
        					</td>
        				</xsl:if>
        		</tr>
        		<tr>
        				<xsl:if test="plaats/@type='R'">
        					<td align="right" valign="top">
        						<b><xsl:value-of select="//lcl/FAC/ruimte"/>:</b>
        					</td>
        					<td align="left" colspan="1">
        						<xsl:value-of select="plaats/regio/district/locatie/gebouw/verdieping/ruimte/nr"/>&#xA0;
        						<xsl:if test="plaats/regio/district/locatie/gebouw/verdieping/ruimte/omschrijving!=''">(<xsl:value-of select="plaats/regio/district/locatie/gebouw/verdieping/ruimte/omschrijving"/>)</xsl:if>
        					</td>
        				</xsl:if>
        		</tr>

            <tr>
                <td colspan="2" style="padding-top:50px;padding-bottom:10px;font-size:12pt">
                	<b><u>Organisation</u></b>
                </td>
            </tr>
            <xsl:apply-templates select="kenmerk[@key=503]" mode="ebms_event"/>


        </xsl:otherwise>
    </xsl:choose>



			<xsl:for-each select="kenmerk[@type!='L' and @type!='Q' and count(@xmlnode)=0 and @key!=181 and @key!=503]">
				<xsl:sort select="@volgnummer" data-type="number"/>
			  <xsl:apply-templates select="." mode="default"/>
			  </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>

		</table>
	</xsl:template>



<xsl:template match="kenmerk" mode="default">
    <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:template>

<xsl:template match="kenmerk" mode="ebms">
    <xsl:if test=".!=''">
    	<tr>
    		<td align="right">
    			<b>Event:</b>
    		</td>
    		<td colspan="3">
    			<xsl:value-of select="substring-before(substring-after(.,'|'),'|')"/>
    		</td>
    	</tr>
    	<tr>
    		<td align="right">
    			<b>Company:</b>
    		</td>
    		<td colspan="3">
    			<xsl:value-of select="substring-before(substring-after(substring-after(.,'|'),'|'),'|')"/>
    		</td>
    	</tr>
    	<tr>
    		<td align="right">
    			<b>Standnumber:</b>
    		</td>
    		<td colspan="3">
    			<xsl:value-of select="substring-after(substring-after(substring-after(.,'|'),'|'),'|')"/>
    		</td>
    	</tr>
    	<tr>
    		<td align="right">
    			<b>Ordernumber:</b>
    		</td>
    		<td colspan="3">
    			<xsl:value-of select="substring-before(.,'|')"/>
    		</td>
    	</tr>
    </xsl:if>
</xsl:template>

<xsl:template match="kenmerk" mode="ebms_event">
    <xsl:if test=".!=''">
      <tr>
    		<td align="right">
    			<b>Event:</b>
    		</td>
    		<td colspan="3">
    			<xsl:value-of select="substring-before(.,'|')"/>
    		</td>
    	</tr>
    	<tr>
    		<td align="right">
    			<b>Company:</b>
    		</td>
    		<td colspan="3">
    			<xsl:value-of select="substring-after(.,'|')"/>
    		</td>
    	</tr>
    </xsl:if>
</xsl:template>

<xsl:template match="kenmerk" mode="ebms_sms">
    <xsl:if test=".!=''">
        Beurs/event: <xsl:value-of select="substring-before(substring-after(.,'|'),'|')"/>
        Bedrijf Exhibitor: <xsl:value-of select="substring-before(substring-after(substring-after(.,'|'),'|'),'|')"/>
    		Standnummer: <xsl:value-of select="substring-after(substring-after(substring-after(.,'|'),'|'),'|')"/>
    		Ordernummer: <xsl:value-of select="substring-before(.,'|')"/>
    </xsl:if>
</xsl:template>



<xsl:template match="melding" mode="default">
		<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="//lcl/MLD/melding"/>&#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><xsl:value-of select="//lcl/FAC/aanvrager"/>:</b>
				</td>
				<td align="left" width="34%">
					<xsl:value-of select="voor/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="voor/telefoonnr=''">-</xsl:if>
					<xsl:value-of select="voor/telefoonnr"/>
				</td>
			</tr>
			<xsl:if test="string(voor/naam_full)!=string(voor/naam_full)">
													<tr>
								<td align="right" width="16%"><b><xsl:value-of select="//lcl/MLD/meldingvoor"/>:</b></td>
								<td align="left" width="34%"><xsl:value-of select="voor/naam_full"/></td>
							</tr>
						</xsl:if>
			<tr>
				<td align="right">
					<b><xsl:value-of select="//lcl/FAC/locatie"/>:</b>
				</td>
				<td align="left">
					<xsl:value-of select="voor/werkplek/plaats/regio/district/locatie/code"/>&#xA0;
					<xsl:if test="voor/werkplek/plaats/regio/district/locatie/omschrijving!=''">(<xsl:value-of select="voor/werkplek/plaats/regio/district/locatie/omschrijving"/>)</xsl:if>
				</td>
				<td align="right" valign="top">
					<b><xsl:value-of select="//lcl/FAC/afdeling"/>:</b>
				</td>
				<td align="left">
					<xsl:value-of select="voor/afdeling/omschrijving"/>
				</td>
			</tr>
			<tr>
				<td align="right" valign="top">
					<b><xsl:value-of select="//lcl/FAC/werkplek"/>:</b>
				</td>
				<td align="left">
					<xsl:value-of select="voor/werkplek/plaats/regio/district/locatie/gebouw/code"/>-<xsl:value-of select="voor/werkplek/plaats/regio/district/locatie/gebouw/naam"/><br/>
					<xsl:value-of select="voor/werkplek/plaats/regio/district/locatie/gebouw/verdieping/code"/>.<xsl:value-of select="voor/werkplek/plaats/regio/district/locatie/gebouw/verdieping/ruimte/nr"/>&#xA0;
					<xsl:if test="voor/werkplek/plaats/regio/district/locatie/gebouw/verdieping/ruimte/omschrijving!=''">(<xsl:value-of select="voor/werkplek/plaats/regio/district/locatie/gebouw/verdieping/ruimte/omschrijving"/>)</xsl:if>
				</td>
				<td colspan="2"/>
			</tr>
			<tr height="40px">
				<td colspan="4">
					<hr/>
				</td>
			</tr>
			<tr>
				<td align="right">
					<b><xsl:value-of select="//lcl/FAC/locatie"/>:</b>
				</td>
				<td align="left">
					<xsl:value-of select="plaats/regio/district/locatie/code"/>&#xA0;
					<xsl:if test="plaats/regio/district/locatie/omschrijving!=''">(<xsl:value-of select="plaats/regio/district/locatie/omschrijving"/>)</xsl:if>
				</td>
				<td align="right">
					<b><xsl:value-of select="//lcl/MLD/melddatum"/>:</b>
				</td>
				<td align="left">
					<xsl:value-of select="gemeld/datum"/>&#xA0;
					<xsl:value-of select="gemeld/tijd"/>
				</td>
			</tr>
			<tr>
				<xsl:choose>
					<xsl:when test="plaats/@type='T'">
						<td align="right">
							<b><xsl:value-of select="//lcl/FAC/terrein"/>:</b>
						</td>
						<td align="left">
							<xsl:value-of select="plaats/regio/district/locatie/terrein/code"/>-<xsl:value-of select="plaats/regio/district/locatie/terrein/naam"/></td>
					</xsl:when>
					<xsl:otherwise>
						<td align="right">
							<b><xsl:value-of select="//lcl/FAC/gebouw"/>:</b>
						</td>
						<td align="left">
							<xsl:value-of select="plaats/regio/district/locatie/gebouw/code"/>-<xsl:value-of select="plaats/regio/district/locatie/gebouw/naam"/></td>
					</xsl:otherwise>
				</xsl:choose>

			</tr>
			<tr>
				<xsl:if test="plaats/@type='T' or plaats/@type='G'">
					<td colspan="2"/>
				</xsl:if>
				<xsl:if test="plaats/@type!='T' and plaats/@type!='G'">
					<td align="right">
						<b><xsl:value-of select="//lcl/FAC/bouwlaag"/>:</b>
					</td>
					<td align="left">
						<xsl:value-of select="plaats/regio/district/locatie/gebouw/verdieping/code"/>&#xA0;
						<xsl:if test="plaats/regio/district/locatie/gebouw/verdieping/omschrijving!=''">(<xsl:value-of select="plaats/regio/district/locatie/gebouw/verdieping/omschrijving"/>)</xsl:if>
					</td>
				</xsl:if>
				<td align="right">
					<b><xsl:value-of select="//lcl/MLD/uitvoertijd"/>:</b>
				</td>
				<td align="left">
					<xsl:value-of select="uitvoertijd"/>
					<xsl:choose>
					    <xsl:when test="uitvoertijd[@eenheid='U']">&#160;<xsl:value-of select="//lcl/MLD/uren"/>
					    </xsl:when>
					    <xsl:otherwise>&#160;<xsl:value-of select="//lcl/FAC/dagen"/>
					    </xsl:otherwise>
                    </xsl:choose>
                </td>
			</tr>
			<tr>
				<xsl:if test="plaats/@type='R'">
					<td align="right" valign="top">
						<b><xsl:value-of select="//lcl/FAC/ruimte"/>:</b>
					</td>
					<td align="left">
						<xsl:value-of select="plaats/regio/district/locatie/gebouw/verdieping/ruimte/nr"/>&#xA0;
						<xsl:if test="plaats/regio/district/locatie/gebouw/verdieping/ruimte/omschrijving!=''">(<xsl:value-of select="plaats/regio/district/locatie/gebouw/verdieping/ruimte/omschrijving"/>)</xsl:if>
					</td>
				</xsl:if>
				<xsl:if test="plaats/@type!='R'">
					<td colspan="2"/>
				</xsl:if>
				<td align="right">
					<b><xsl:value-of select="//lcl/MLD/status"/>:</b>
				</td>
				<td align="left">
					<xsl:value-of select="status"/>
				</td>
			</tr>
			<tr height="30px">
				<td colspan="4"/>
			</tr>
			<tr>
				<td align="right">
					<b><xsl:value-of select="//lcl/MLD/stdmelding"/>:</b>
				</td>
				<td align="left">
					<xsl:if test="stdmelding/omschrijving=''">-</xsl:if>
					<xsl:value-of select="stdmelding/omschrijving"/>
				</td>
				<td align="right">
					<b><xsl:value-of select="//lcl/MLD/vakgroep"/>:</b>
				</td>
				<td align="left">
					<xsl:if test="discipline/omschrijving=''">-</xsl:if>
					<xsl:value-of select="discipline/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>
			<xsl:for-each select="kenmerk[@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>
		</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:0px">
					<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>
				<td width="16%" align="right">
					<b><xsl:value-of select="//lcl/FAC/bedrijf"/>:</b>
				</td>
				<td width="34%">
					<xsl:value-of select="uitvoerende/bedrijf/naam"/>
				</td>
				<td width="16%" align="right">
					<b><xsl:value-of select="//lcl/FAC/contactpersoon"/>:</b>
				</td>
				<td width="34%">
					<xsl:value-of select="contactpersoon/naam_full"/>
				</td>
			</tr>
			<tr>
				<td align="right">
					<b><xsl:value-of select="//lcl/FAC/adres"/>:</b>
				</td>
				<td>
					<xsl:value-of select="uitvoerende/bedrijf/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 align="right">
					<b><xsl:value-of select="//lcl/FAC/plaats"/>:</b>
				</td>
				<td>
					<xsl:value-of select="uitvoerende/bedrijf/post_plaats"/>
				</td>
				<td colspan="2"/>
			</tr>
			<tr height="20px">
				<td colspan="4">
				</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="include"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td colspan="4" height="20px" valign="center">
					<hr/>
				</td>
			</tr>
			<xsl:variable name="arbeid" select="uren*uurloon"/>
			<tr>
			    <xsl:if test="$mode!='email'">
        			<xsl:if test="melding/plaats/regio/district/locatie/gebouw/verdieping/ruimte/key">
            			<xsl:if test="melding/stdmelding/discipline/srtdiscipline/key != 1 and melding/stdmelding/discipline/srtdiscipline/key != 21">
                    <td rowspan='5' colspan='2'>Plattegrond:<br/>
                          <xsl:element name="img">
                                      <xsl:attribute name="src">
                                                  ../../appl/CAD/mySlnk2IMG.asp?mode=0&amp;vKey=<xsl:value-of select="melding/plaats/regio/district/locatie/gebouw/verdieping/key"/>&amp;scenario_key=0&amp;paperWidth=120&amp;paperHeight=50&amp;forPrint=1&amp;discs=61&amp;thema=<xsl:value-of select="$PRJ_AFDELING_THEMA_KEY"/>&amp;highlight=<xsl:value-of select="melding/plaats/regio/district/locatie/gebouw/verdieping/ruimte/key"/></xsl:attribute>
                                      <xsl:attribute name="style">height:50mm; width:100mm</xsl:attribute>
                                      <xsl:attribute name="border">1</xsl:attribute>
                                      <xsl:attribute name="galleryimg">false</xsl:attribute>
                          </xsl:element>
                    </td>
            			</xsl:if>
            </xsl:if>
        	</xsl:if>

				<td align="right">
					<b><xsl:value-of select="//lcl/MLD/uren"/>:</b>
				</td>
				<td style="width:1in;text-align:right">
					<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>

			</tr>
			<tr>
				<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 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 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 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>
	</xsl:template>





    <!-- ******************************************************************************************************************  -->

    <!--                                        Hier komen de USER-rapportage functies                                       -->

    <!-- ******************************************************************************************************************  -->


<xsl:key name="GROUP_BY_datum" match="//facilitor/rapport/rapport_data/data_row" use="TRUNC_INS_CONTROLE_DATUM"/>
<xsl:key name="GROUP_BY_gebouw_key" match="//facilitor/rapport/rapport_data/data_row" use="FCLT_KEY"/>
<xsl:key name="GROUP_BY_afgeronde_tijd" match="//facilitor/rapport/rapport_data/data_row" use="AFGERONDE_TIJD"/>
<xsl:key name="GROUP_BY_RTM_ruimtegroep" match="//facilitor/rapport/rapport_data/data_row" use="RUIMTEGROEP"/>

    <xsl:template match="rapport">

        <xsl:if test="@view = 'arai_v_rap_kpi_all'">
            <script>
                <xsl:text disable-output-escaping="yes">
                function alg_show_rapport_details (p_title, p_rapport_naam, p_filtervalue) {
                    var url = "appl/fac/fac_report.asp?mode=list&amp;rap_name=" + p_rapport_naam;
                    if (p_filtervalue != ''){
                        url = url + "&amp;fclt_key=" + p_filtervalue;
                    }
                    FcltMgr.openDetail(url, p_title, { });
                }
                function alg_show_rapport_manual (p_title, p_rapport_naam, p_filtervalue) {
                    var url = "appl/fac/fac_report.asp?mode=list&amp;rap_name=" + p_rapport_naam;
                    if (p_filtervalue != ''){
                        url = url + "&amp;fclt_key=" + p_filtervalue;
                    }
                    FcltMgr.openDetail(url, p_title, { });
                }
                </xsl:text>
            </script>


            <table border="0" width="100%" cellpadding="2">
                <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">
                <xsl:sort select="KPI_NAAM"/>
                    <xsl:if test="position() = 1">
                        <tr height="100px"/>
                    </xsl:if>
                    <td width="33%" style="text-align:center">
                      <xsl:call-template name="kpi_overall_image">
                            <xsl:with-param name="p_kpi_naam" select="KPI_NAAM"/>
                            <xsl:with-param name="p_kpi_status" select="KPI_STATUS"/>
                            <xsl:with-param name="p_rapport_naam" select="FCLT_URL"/>
                            <xsl:with-param name="p_rapport_details" select="USR_RAP_ALL_DETAILS"/>
                        </xsl:call-template>
                    </td>
                    <xsl:if test="position() mod 2 = 0">
                        <tr height="150px"/>
                    </xsl:if>
                </xsl:for-each>
            </table>
        </xsl:if>


        <xsl:if test="@view = 'arai_v_rap_kpi_temp_per_ruimte'">
            <script>
                <xsl:text disable-output-escaping="yes">
                function alg_show_ruimte_details (p_roomkey) {
                    var url = "appl/alg/alg_ruimte.asp?key=" + p_roomkey
                    FcltMgr.openDetail(url, "Ruimte gegevens", { });
                }
                <!-- mbmb: usrgraph_key=21 is the key van de grafiek voor de dag-meting van temperatuur als lijn-grafiek-->
                function alg_show_kpi_temp_vandaag_lijngrafiek (p_title, p_roomkey) {
                    var url = "../../appl/fac/fac_usrgraph.asp?usrgraph_key=21&amp;fclt_key=" + p_roomkey
                    FcltMgr.openModalDetail(url, p_title, { xheight: 300, width: 800});
                }

                <!-- mbmb: usrgraph_key=22 is the key van de grafiek voor de dag-meting van temperatuur als bar-chart-->
                function alg_show_kpi_temp_vandaag_barchart (p_title, p_roomkey) {
                    var url = "../../appl/fac/fac_usrgraph.asp?usrgraph_key=22&amp;fclt_key=" + p_roomkey
                    FcltMgr.openModalDetail(url, p_title, { xheight: 300, width: 800});
                }
                <!-- mbmb: label=21 is the key of cad_label -->
                function alg_show_kpi_temp_cad (p_title, p_verdiepingkey) {
                    var url = "../../appl/CAD/mySlnk2IMG.asp?labelPos=1&amp;vKey=" + p_verdiepingkey + "&amp;scenario_key=0&amp;thema=-1&amp;label=21&amp;werkplek=0&amp;mode=0&amp;contmode=0&amp;discs=121,61&amp;paperColor=15395820"
                    FcltMgr.openModalDetail(url, p_title, { height: 600, width: 800 });
                }

                </xsl:text>
            </script>
            <xsl:variable name="p_rows" select="5"/>
            <xsl:variable name="p_cols" select="4"/>


            <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[JOIN_KPI=2 or JOIN_KPI=3]">
            <xsl:sort select="ALG_GEBOUW_CODE"/>
            <xsl:sort select="ALG_RUIMTE_OMSCHRIJVING"/>

               <xsl:if test="position() mod ($p_rows * $p_cols) = 0">
                    <div style="page-break-before:always">&#160;</div>
                    <xsl:comment>=== Na elke 20 records (5x4 passen op 1 A4) =====</xsl:comment>
				            <xsl:call-template name="kpi_temp_ins_new_page">
				                <xsl:with-param name="p_page" select="floor(position() div ($p_rows * $p_cols))"/>
				                <xsl:with-param name="p_rows" select="$p_rows"/>
				                <xsl:with-param name="p_cols" select="$p_cols"/>
				            </xsl:call-template>
			         </xsl:if>
			         <xsl:if test="position() = last() and position() mod ($p_rows * $p_cols) != 0 ">
                    <div style="page-break-before:always">&#160;</div>
                    <xsl:comment>=== De laatste paar, zijn minder dan 20 =====</xsl:comment>
				            <xsl:call-template name="kpi_temp_ins_new_page">
				                <xsl:with-param name="p_page" select="floor((position() div ($p_rows * $p_cols))+1)"/>
				                <xsl:with-param name="p_rows" select="$p_rows"/>
				                <xsl:with-param name="p_cols" select="$p_cols"/>
				            </xsl:call-template>
			         </xsl:if>
            </xsl:for-each>
        </xsl:if>



        <xsl:if test="@view = 'arai_v_rap_kpi_ict_mitel'">
            <script>
                function alg_show_rapport_details (p_title, p_rapport_naam, p_filtervalue) {
                    var url = "appl/fac/fac_report.asp?mode=list&amp;rap_name=" + p_rapport_naam;
                    if (p_filtervalue != ''){
                        url = url + "&amp;fclt_key=" + p_filtervalue;
                    }
                    FcltMgr.openDetail(url, p_title, { });
                }
                <xsl:text disable-output-escaping="yes">
                function ins_show_deel_details (p_deelkey) {
                    var url = "appl/ins/ins_deel.asp?urole=bo&amp;ins_key=" + p_deelkey
                    FcltMgr.openDetail(url, "Object gegevens", { });
                }

                <!-- mbmb: usrgraph_key=41 is the key van de grafiek voor de dag-meting van ict-mitel als lijn-grafiek-->
                function alg_show_kpi_ict_mitel_vandaag_lijngrafiek (p_title, p_deelkey) {
                    var url = "../../appl/fac/fac_usrgraph.asp?usrgraph_key=41&amp;fclt_key=" + p_deelkey
                    FcltMgr.openModalDetail(url, p_title, { xheight: 300, width: 800});
                }

                <!-- mbmb: usrgraph_key=42 is the key van de grafiek voor de dag-meting van ict-mitel als bar-chart-->
                function alg_show_kpi_ict_mitel_vandaag_barchart (p_title, p_deelkey) {
                    var url = "../../appl/fac/fac_usrgraph.asp?usrgraph_key=42&amp;fclt_key=" + p_deelkey
                    FcltMgr.openModalDetail(url, p_title, { xheight: 300, width: 800});
                }
                </xsl:text>
            </script>
            <xsl:variable name="p_rows" select="2"/>
            <xsl:variable name="p_cols" select="2"/>


            <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">
            <xsl:sort select="INS_SRTDEEL_OMSCHRIJVING"/>
            <xsl:sort select="INS_DEEL_OMSCHRIJVING"/>

               <xsl:if test="position() mod ($p_rows * $p_cols) = 0">
                    <div style="page-break-before:always">&#160;</div>
                    <xsl:comment>=== Na elke 20 records (5x4 passen op 1 A4) =====</xsl:comment>
				            <xsl:call-template name="kpi_ict_mitel_ins_new_page">
				                <xsl:with-param name="p_page" select="floor(position() div ($p_rows * $p_cols))"/>
				                <xsl:with-param name="p_rows" select="$p_rows"/>
				                <xsl:with-param name="p_cols" select="$p_cols"/>
				            </xsl:call-template>
			         </xsl:if>
			         <xsl:if test="position() = last() and position() mod ($p_rows * $p_cols) != 0 ">
                    <div style="page-break-before:always">&#160;</div>
                    <xsl:comment>=== De laatste paar, zijn minder dan 20 =====</xsl:comment>
				            <xsl:call-template name="kpi_ict_mitel_ins_new_page">
				                <xsl:with-param name="p_page" select="floor((position() div ($p_rows * $p_cols))+1)"/>
				                <xsl:with-param name="p_rows" select="$p_rows"/>
				                <xsl:with-param name="p_cols" select="$p_cols"/>
				            </xsl:call-template>
			         </xsl:if>
            </xsl:for-each>
        </xsl:if>


        <xsl:if test="@view = 'arai_v_kpi_toilet_gebouw'">
            <script>
                <xsl:text disable-output-escaping="yes">
                function alg_show_rapport_details (p_title, p_rapport_naam, p_filtervalue) {
                    var url = "appl/fac/fac_report.asp?mode=list&amp;rap_name=" + p_rapport_naam;
                    if (p_filtervalue != ''){
                        url = url + "&amp;fclt_key=" + p_filtervalue;
                    }
                    FcltMgr.openDetail(url, p_title, { });
                }
                <!-- mbmb: usrgraph_key=21 is the key van de grafiek voor de dag-meting van schone toiletten als lijn-grafiek-->
                function alg_show_kpi_toilet_vandaag_lijngrafiek (p_title, p_roomkey) {
                    var url = "../../appl/fac/fac_usrgraph.asp?usrgraph_key=43&amp;fclt_key=" + p_roomkey
                    FcltMgr.openModalDetail(url, p_title, { xheight: 300, width: 800});
                }

                <!-- mbmb: usrgraph_key=22 is the key van de grafiek voor de dag-meting van schone toiletten als bar-chart-->
                function alg_show_kpi_toilet_vandaag_barchart (p_title, p_roomkey) {
                    var url = "../../appl/fac/fac_usrgraph.asp?usrgraph_key=44&amp;fclt_key=" + p_roomkey
                    FcltMgr.openModalDetail(url, p_title, { xheight: 300, width: 800});
                }
                </xsl:text>
            </script>
            <xsl:variable name="p_rows" select="5"/>
            <xsl:variable name="p_cols" select="4"/>


            <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">
            <xsl:sort select="ALG_GEBOUW_CODE"/>
            <xsl:sort select="ALG_RUIMTE_NR"/>

               <xsl:if test="position() mod ($p_rows * $p_cols) = 0">
                    <div style="page-break-before:always">&#160;</div>
                    <xsl:comment>=== Na elke 20 records (5x4 passen op 1 A4) =====</xsl:comment>
				            <xsl:call-template name="kpi_toilet_ins_new_page">
				                <xsl:with-param name="p_page" select="floor(position() div ($p_rows * $p_cols))"/>
				                <xsl:with-param name="p_rows" select="$p_rows"/>
				                <xsl:with-param name="p_cols" select="$p_cols"/>
				            </xsl:call-template>
			         </xsl:if>
			         <xsl:if test="position() = last() and position() mod ($p_rows * $p_cols) != 0 ">
                    <div style="page-break-before:always">&#160;</div>
                    <xsl:comment>=== De laatste paar, zijn minder dan 20 =====</xsl:comment>
				            <xsl:call-template name="kpi_toilet_ins_new_page">
				                <xsl:with-param name="p_page" select="floor((position() div ($p_rows * $p_cols))+1)"/>
				                <xsl:with-param name="p_rows" select="$p_rows"/>
				                <xsl:with-param name="p_cols" select="$p_cols"/>
				            </xsl:call-template>
			         </xsl:if>
            </xsl:for-each>
        </xsl:if>




        <xsl:if test="@view = 'arai_v_rap_kpi_standschoon'">
            <script>
                <xsl:text disable-output-escaping="yes">
                function alg_show_rapport_details (p_title, p_rapport_naam, p_filtervalue) {
                    var url = "appl/fac/fac_report.asp?mode=list&amp;rap_name=" + p_rapport_naam;
                    if (p_filtervalue != ''){
                        url = url + "&amp;fclt_key=" + p_filtervalue;
                    }
                    FcltMgr.openDetail(url, p_title, { });
                }
                <!-- mbmb: usrgraph_key=61 is the key van de grafiek voor de dag-meting van schone STANDS als lijn-grafiek-->
                function alg_show_kpi_schonestands_vandaag_lijngrafiek (p_title) {
                    var url = "../../appl/fac/fac_usrgraph.asp?usrgraph_key=61"
                    FcltMgr.openModalDetail(url, p_title, { height: 300, width: 800});
                }

                <!-- mbmb: usrgraph_key=62 is the key van de grafiek voor de dag-meting van schone STANDS als bar-chart-->
                function alg_show_kpi_schonestands_vandaag_barchart (p_title) {
                    var url = "../../appl/fac/fac_usrgraph.asp?usrgraph_key=62"
                    FcltMgr.openModalDetail(url, p_title, { height: 300, width: 800});
                }
                </xsl:text>
            </script>
            <xsl:variable name="p_rows" select="5"/>
            <xsl:variable name="p_cols" select="4"/>


            <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">


               <xsl:if test="position() mod ($p_rows * $p_cols) = 0">
                    <div style="page-break-before:always">&#160;</div>
                    <xsl:comment>=== Na elke 20 records (5x4 passen op 1 A4) =====</xsl:comment>
				            <xsl:call-template name="kpi_schonestands_ins_new_page">
				                <xsl:with-param name="p_page" select="floor(position() div ($p_rows * $p_cols))"/>
				                <xsl:with-param name="p_rows" select="$p_rows"/>
				                <xsl:with-param name="p_cols" select="$p_cols"/>
				            </xsl:call-template>
			         </xsl:if>
			         <xsl:if test="position() = last() and position() mod ($p_rows * $p_cols) != 0 ">
                    <div style="page-break-before:always">&#160;</div>
                    <xsl:comment>=== De laatste paar, zijn minder dan 20 =====</xsl:comment>
				            <xsl:call-template name="kpi_schonestands_ins_new_page">
				                <xsl:with-param name="p_page" select="floor((position() div ($p_rows * $p_cols))+1)"/>
				                <xsl:with-param name="p_rows" select="$p_rows"/>
				                <xsl:with-param name="p_cols" select="$p_cols"/>
				            </xsl:call-template>
			         </xsl:if>
            </xsl:for-each>
        </xsl:if>



        <xsl:comment>----      Overige RAPPORTEN          ---- </xsl:comment>
        <xsl:comment>----      Overige RAPPORTEN          ---- </xsl:comment>
        <xsl:comment>----      Overige RAPPORTEN          ---- </xsl:comment>


        <xsl:if test="@view = 'arai_v_rap_temp_per_ruimte'">
            <table border="0" width="100%" cellpadding="2">
                <tr>
                    <td><b>Datum</b></td>
                    <td><b>Tijd</b></td>
                    <td><b>Gebouw</b></td>
                    <td><b>Ruimte</b></td>
                    <td><b>Temperatuur</b></td>
                </tr>
                <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">

                    <xsl:sort select="FCLT_X_JAAR" order="descending" />
                    <xsl:sort select="FCLT_X_MAAND" order="descending" />
                    <xsl:sort select="FCLT_X_DAG" order="descending" />
                    <xsl:sort select="FCLT_X_UUR" order="descending"/>
                    <xsl:sort select="FCLT_X_MINUUT" order="descending"/>
                    <xsl:sort select="FCLT_F_GEBOUW" order="descending" />
                    <xsl:sort select="FCLT_F_RUIMTE" order="descending" />

                    <tr>
                        <td><xsl:value-of select="FCLT_X_DAG"/>-<xsl:value-of select="FCLT_X_MAAND"/>-<xsl:value-of select="FCLT_X_JAAR"/></td>
                        <td><xsl:value-of select="FCLT_X_UUR"/>:<xsl:value-of select="FCLT_X_MINUUT"/>u</td>
                        <td><xsl:value-of select="FCLT_F_GEBOUW"/></td>
                        <td><xsl:value-of select="FCLT_F_RUIMTE"/></td>
                        <xsl:call-template name="td_red_orange_green">
                            <xsl:with-param name="p_value" select="RUIMTETEMPERATUUR"/>
                            <xsl:with-param name="p_value_prefix"></xsl:with-param>
                            <xsl:with-param name="p_value_postfix" select="''"/>
                            <xsl:with-param name="p_kpi_color" select="KPI_TEMP"/>
                            <xsl:with-param name="p_kpi_value_orange" select="''"/>
                            <xsl:with-param name="p_kpi_value_red" select="''"/>
                            <xsl:with-param name="p_kpi_sortmethod" select="0"/>
                        </xsl:call-template>

                    </tr>
                </xsl:for-each>
            </table>
        </xsl:if>


        <xsl:if test="@view = 'arai_v_rap_kpi_ict_all'">
            <table border="0" width="100%" cellpadding="2">
                <tr>
                    <td><b>Datum</b></td>
                    <td><b>Tijd</b></td>
                    <td><b>Gemiddelde wachttijd (in sec)</b></td>
                </tr>
                <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">
                <xsl:sort select="FCLT_F_DATUM" order="descending" />
                <xsl:sort select="TIJD" order="descending"/>
                    <tr>
                        <td><xsl:value-of select="FCLT_F_DATUM"/></td>
                        <td><xsl:value-of select="TIJD"/></td>
                        <xsl:call-template name="td_red_orange_green">
                            <xsl:with-param name="p_value" select="WACHTTIJD"/>
                            <xsl:with-param name="p_value_prefix"></xsl:with-param>
                            <xsl:with-param name="p_value_postfix" select="''"/>
                            <xsl:with-param name="p_kpi_color" select="KPI_ICT_MITEL"/>
                            <xsl:with-param name="p_kpi_value_orange" select="''"/>
                            <xsl:with-param name="p_kpi_value_red" select="''"/>
                            <xsl:with-param name="p_kpi_sortmethod" select="0"/>
                        </xsl:call-template>
                    </tr>
                </xsl:for-each>
            </table>
        </xsl:if>

        <xsl:if test="@view = 'arai_v_rap_kpi_toilet_all'">
            <table border="0" width="100%" cellpadding="2">
                <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[generate-id(.)=generate-id(key('GROUP_BY_datum',TRUNC_INS_CONTROLE_DATUM)[1])]">
                <xsl:sort select="FCLT_X_DATUM"/>
                    <xsl:call-template name="controle_toiletten_lijst_perdatum"><xsl:with-param name="p_datum" select="TRUNC_INS_CONTROLE_DATUM"/></xsl:call-template>
                </xsl:for-each>
            </table>
        </xsl:if>


        <xsl:if test="@view = 'arai_v_rap_kpi_toilet'">
            <table border="0" width="100%" cellpadding="2">

                <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[generate-id(.)=generate-id(key('GROUP_BY_gebouw_key',FCLT_KEY)[1])]">
                <xsl:sort select="ALG_GEBOUW_CODE"/>
                    <xsl:call-template name="controle_toiletten_lijst_pergebouw">
                        <xsl:with-param name="p_gebouw_key" select="FCLT_KEY"/>
                        <xsl:with-param name="p_datum" select="TRUNC_INS_CONTROLE_DATUM"/>
                    </xsl:call-template>
                </xsl:for-each>
            </table>
        </xsl:if>

        <xsl:if test="@view = 'arai_v_rap_mld_klachten' or @view ='arai_v_rap_mld_org_klachten' or @view ='arai_v_rap_standschoon_lopend' or @view ='arai_v_rap_standschoonmaak_all'">
            <script>
                <xsl:text disable-output-escaping="yes">
                function mld_show_melding_details (p_mldkey) {
                    var url = "appl/mld/mld_melding.asp?urole=bo&amp;mld_key=" + p_mldkey
                    FcltMgr.openDetail(url, "Melding details", { });
                }

                </xsl:text>
            </script>

            <table border="0" width="100%" cellpadding="2">
                <tr>
                    <td colspan='8' width='100%'  bgcolor='#00A4E3' valign="top"><b>Aantal items: </b><xsl:value-of select="count(//facilitor/rapport/rapport_data/data_row/FCLT_F_MELDINGNR)"/> </td>
                </tr>

                <xsl:choose>
                    <xsl:when test="//facilitor/header/language = 'NL'">
                        <tr>
                            <td width='5%'  bgcolor='#C0C0C0' valign="top"><b>Nr</b></td>
                            <td width='10%' bgcolor='#C0C0C0' valign="top"><b>Evenement</b></td>
                            <td width='15%' bgcolor='#C0C0C0' valign="top"><b>Bedrijf<br/>Lokatie</b></td>
                            <td width='10%' bgcolor='#C0C0C0' valign="top"><b>Contactpersoon<br/>Mailadres<br/>Telefoon</b></td>
                            <td width='20%' bgcolor='#C0C0C0' valign="top"><b>Melding<br/>Omschrijving</b></td>
                            <td width='20%' bgcolor='#C0C0C0' valign="top"><b>Leverancier<br/>Status<br/>Afhandeling</b></td>
                            <td width='10%' bgcolor='#C0C0C0' valign="top"><b>Ingevoerd<br/>Door<br/>Looptijd</b></td>
                            <td width='10%' bgcolor='#C0C0C0' valign="top"><b>Afgemeld<br/>Door</b></td>
                        </tr>
                     </xsl:when>
                    <xsl:otherwise>
							          <tr>
                            <td width='5%'  bgcolor='#C0C0C0' valign="top"><b>Nr</b></td>
                            <td width='10%' bgcolor='#C0C0C0' valign="top"><b>Event</b></td>
                            <td width='15%' bgcolor='#C0C0C0' valign="top"><b>Company<br/>Location</b></td>
                            <td width='10%' bgcolor='#C0C0C0' valign="top"><b>Contactperson<br/>Email<br/>Telephonenumber</b></td>
                            <td width='20%' bgcolor='#C0C0C0' valign="top"><b>Call<br/>Description</b></td>
                            <td width='20%' bgcolor='#C0C0C0' valign="top"><b>Supplier<br/>Status<br/>Completion remark</b></td>
                            <td width='10%' bgcolor='#C0C0C0' valign="top"><b>Creation Date<br/>Issued by<br/>Progress Time</b></td>
                            <td width='10%' bgcolor='#C0C0C0' valign="top"><b>Closing Date On<br/>Closed By</b></td>
                        </tr>
    						    </xsl:otherwise>
    				    </xsl:choose>





                <tr height="20px">
            				<td colspan="8">
            					<hr/>
            				</td>
            		</tr>


                <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">
                <xsl:sort select="FCLT_F_MELDINGNR"/>

                <tr>
                    <td valign="top">
                        <xsl:element name="span">
                            <xsl:attribute name="onclick">mld_show_melding_details(<xsl:value-of select="FCLT_F_MELDINGNR"/>)</xsl:attribute>
                            <xsl:attribute name="style">cursor: pointer;</xsl:attribute>
                                <u><xsl:value-of select="FCLT_F_MELDINGNR"/></u>
                        </xsl:element>
                    </td>


                    <td valign="top"><xsl:value-of select="FCLT_F_EVENEMENT"/></td>
                    <td valign="top"><b><xsl:value-of select="FCLT_F_COMPANY"/></b><br/><xsl:value-of select="FCLT_F_LOKATIE"/></td>

                    <td valign="top"><b><xsl:value-of select="COMPANY_CONTACTPERSOON"/></b><br/><xsl:value-of select="COMPANY_MAILADRES"/><br/><xsl:value-of select="COMPANY_TELEFOON"/></td>

                    <td valign="top"><b><xsl:value-of select="FCLT_F_MELDING"/></b><br/>
                        <xsl:call-template name="linebreaks">
                            <xsl:with-param name="string" select="MLD_MELDING_OMSCHRIJVING"/>
                        </xsl:call-template>
                    </td>
                    <td valign="top"><b>
                        <xsl:value-of select="FCLT_F_LEVERANCIER"/><br/>
                        <xsl:element name="span">
                            <xsl:attribute name="style">
                                <xsl:choose>
                        						<xsl:when test="MLD_OPERATIONEEL_TE_LAAT = '1'">
                        							    color:#ff0000
                        						</xsl:when>
                        						<xsl:otherwise>
                    							        color:#00c000;
                    						    </xsl:otherwise>
                    				    </xsl:choose>
                						</xsl:attribute>
                            <xsl:value-of select="FCLT_F_STATUS"/>
                        </xsl:element>


                        </b><br/>
                        <xsl:call-template name="linebreaks">
                            <xsl:with-param name="string" select="MLD_MELDING_OPMERKING"/>
                        </xsl:call-template>
                    </td>
                    <td valign="top"><xsl:value-of select="INVOER_DATUM_TIME"/><br/><xsl:value-of select="INGEVOERD_DOOR"/><br/><xsl:value-of select="MLD_OPERATIONEEL_DAGENUURMIN"/></td>

                    <td valign="top"><xsl:value-of select="AFMELD_DATUM_TIME"/><br/><xsl:value-of select="AFGEMELD_DOOR"/></td>

                </tr>
                <tr height="10px">
            				<td colspan="8">
            					<hr/>
            				</td>
            		</tr>

                </xsl:for-each>
            </table>
        </xsl:if>

        <xsl:if test="@view = 'arai_v_rap_mld_klachten_2' or @view ='arai_v_rap_mld_org_klachten_2' or @view ='arai_v_rap_mld_tot_klachten_2'">
            <script>
                <xsl:text disable-output-escaping="yes">
                function mld_show_melding_details (p_mldkey) {
                    var url = "appl/mld/mld_melding.asp?urole=bo&amp;mld_key=" + p_mldkey
                    FcltMgr.openDetail(url, "Melding details", { });
                }
                </xsl:text>
            </script>

            <table border="0" width="100%" cellpadding="2">
              <xsl:if test="$mode !='excel'">
                <tr>
                    <td colspan='30' width='100%'  bgcolor='#00A4E3' valign="top"><b>Aantal items: </b><xsl:value-of select="count(//facilitor/rapport/rapport_data/data_row/FCLT_F_MELDINGNR)"/> </td>
                </tr>
              </xsl:if>
                <xsl:choose>
                    <xsl:when test="//facilitor/header/language = 'NL'">
                        <tr>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Nr</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Evenement</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Bedrijf</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Lokatie</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Contactpersoon</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Mailadres</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Telefoon</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Klacht</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Vakgroep</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Melding</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Omschrijving</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Leverancier</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Status</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>TeLaat</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Afhandeling</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Ingevoerd</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>IJaar</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>IKwartaal</b></td>                                                         
                            <td  bgcolor='#C0C0C0' valign="top"><b>IDatum</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>ITijd</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Door</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Looptijd</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>LDag</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>LUur</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>LMin</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Afgemeld</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>ADatum</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>ATijd</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Door</b></td>
                        </tr>
                    </xsl:when>
                    <xsl:otherwise>
							        <tr>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Nr</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Event</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Company</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Location</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Contactperson</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Email</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Telephonenumber</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Complaint</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Category</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Call</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Description</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Supplier</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Status</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Too Late</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Completion remark</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Creation Timestamp</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Creation Year</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Creation Quarter</b></td>                             
                            <td  bgcolor='#C0C0C0' valign="top"><b>Creation Date</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Creation Time</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Issued by</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Progress</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Progress (Days)</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Progress (Hours)</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Progress (Minutes)</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Closing Timestamp</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Closing Date</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Closing Time</b></td>
                            <td  bgcolor='#C0C0C0' valign="top"><b>Closed by</b></td>
                      </tr>
    						    </xsl:otherwise>
    				    </xsl:choose>

                <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">
                <xsl:sort select="FCLT_F_MELDINGNR"/>
                    <tr>
                        <td valign="top">
                            <xsl:element name="span">
                                <xsl:attribute name="onclick">mld_show_melding_details(<xsl:value-of select="FCLT_F_MELDINGNR"/>)</xsl:attribute>
                                <xsl:attribute name="style">cursor: pointer;</xsl:attribute>
                                    <u><xsl:value-of select="FCLT_F_MELDINGNR"/></u>
                            </xsl:element>
                        </td>
                        <td valign="top"><xsl:value-of select="FCLT_F_EVENEMENT"/></td>
                        <td valign="top"><xsl:value-of select="FCLT_F_COMPANY"/></td>
                        <td valign="top"><xsl:value-of select="FCLT_F_LOKATIE"/></td>
                        <td valign="top"><xsl:value-of select="COMPANY_CONTACTPERSOON"/></td>
                        <td valign="top"><xsl:value-of select="COMPANY_MAILADRES"/></td>
                        <td valign="top"><xsl:value-of select="COMPANY_TELEFOON"/></td>
                        <td valign="top"><xsl:value-of select="FCLT_F_TYPE"/></td>
                        <td valign="top"><xsl:value-of select="FCLT_F_VAKGROEP"/></td>
                        <td valign="top"><xsl:value-of select="FCLT_F_MELDING"/></td>
                        <td valign="top">
                        <xsl:choose>
                          <xsl:when test="$mode='excel'">
                            <xsl:value-of select="MLD_MELDING_OMSCHRIJVING"/>
                          </xsl:when>
                          <xsl:otherwise>
                            <xsl:call-template name="linebreaks">
                              <xsl:with-param name="string" select="MLD_MELDING_OMSCHRIJVING"/>
                             </xsl:call-template>                          
                          </xsl:otherwise>
                        </xsl:choose>                         
                        </td>
                        <td valign="top"><xsl:value-of select="FCLT_F_LEVERANCIER"/></td>
                        <td valign="top">
                            <xsl:element name="span">
                                <xsl:attribute name="style">
                                    <xsl:choose>
                            						<xsl:when test="MLD_OPERATIONEEL_TE_LAAT = '1'">
                            							    color:#ff0000
                            						</xsl:when>
                            						<xsl:otherwise>
                        							        color:#00c000;
                        						    </xsl:otherwise>
                        				    </xsl:choose>
                    						</xsl:attribute>
                                <xsl:value-of select="FCLT_F_STATUS"/>
                            </xsl:element>
                        </td>
                        <td valign="top"><xsl:value-of select="MLD_OPERATIONEEL_TE_LAAT"/></td>
                        <td valign="top">
                        <xsl:choose>
                          <xsl:when test="$mode='excel'">
                            <xsl:value-of select="MLD_MELDING_OPMERKING"/>
                          </xsl:when>
                          <xsl:otherwise>
                            <xsl:call-template name="linebreaks">
                              <xsl:with-param name="string" select="MLD_MELDING_OPMERKING"/>
                             </xsl:call-template>                          
                          </xsl:otherwise>
                        </xsl:choose>                            
                        </td>
                        <td valign="top"><xsl:value-of select="INVOER_DATUM_TIME"/></td>                        
                        <td valign="top"><xsl:value-of select="FCLT_F_JAAR"/></td>
                        <td valign="top"><xsl:value-of select="FCLT_F_KWARTAAL"/></td>
                        <td valign="top"><xsl:value-of select="substring-before(INVOER_DATUM_TIME,' ')"/></td>
                        <td valign="top"><xsl:value-of select="substring-after(INVOER_DATUM_TIME,' ')"/></td>


                        <td valign="top"><xsl:value-of select="INGEVOERD_DOOR"/></td>
                        <td valign="top"><xsl:value-of select="MLD_OPERATIONEEL_DAGENUURMIN"/></td>
                        <td valign="top"><xsl:value-of select="substring-before(MLD_OPERATIONEEL_DAGENUURMIN,'d')"/></td>
                        <td valign="top"><xsl:value-of select="substring-before(substring-after(MLD_OPERATIONEEL_DAGENUURMIN,'d'),'u')"/></td>
                        <td valign="top"><xsl:value-of select="substring-before(substring-after(substring-after(MLD_OPERATIONEEL_DAGENUURMIN,'d'),'u'),'m')"/></td>

                        <td valign="top"><xsl:value-of select="AFMELD_DATUM_TIME"/></td>
                        <td valign="top"><xsl:value-of select="substring-before(AFMELD_DATUM_TIME,' ')"/></td>
                        <td valign="top"><xsl:value-of select="substring-after(AFMELD_DATUM_TIME,' ')"/></td>

                        <td valign="top"><xsl:value-of select="AFGEMELD_DOOR"/></td>
                    </tr>


                </xsl:for-each>
            </table>
        </xsl:if>

        <xsl:comment>De generatie van QR-codes voor toiletschoonmaak</xsl:comment>
        <xsl:if test="@view = 'arai_v_ins_qrc_toilet'">
            <xsl:variable name="p_rows" select="3"/>
            <xsl:variable name="p_cols" select="2"/>

            <table border="0" width="100%" cellpadding="2">
                <tr height="200"><td align="center"><span style="font-size:24pt;color:#000000">QR Code</span></td></tr>
                <tr height="200"><td align="center"><span style="font-size:24pt;color:#000000">Generator</span></td></tr>
                <tr height="200"><td align="center"><span style="font-size:24pt;color:#000000">Toiletschoonmaak</span></td></tr>
            </table>

            <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">
            <xsl:sort select="FCLT_F_GEBOUW"/>
            <xsl:sort select="PLAATS"/>
               <xsl:if test="position() mod ($p_rows * $p_cols) = 0">
                    <div style="page-break-before:always">&#160;</div>
                    <xsl:comment>=== Na elke 2 records (2x1 passen op 1 A4) =====</xsl:comment>
				            <xsl:call-template name="qrc_ins_new_page">
				                <xsl:with-param name="p_page" select="floor(position() div ($p_rows * $p_cols))"/>
				                <xsl:with-param name="p_rows" select="$p_rows"/>
				                <xsl:with-param name="p_cols" select="$p_cols"/>
				            </xsl:call-template>
			         </xsl:if>
			         <xsl:if test="position() = last() and position() mod ($p_rows * $p_cols) != 0 ">
                    <div style="page-break-before:always">&#160;</div>
                    <xsl:comment>=== De laatste paar, zijn minder dan 2 =====</xsl:comment>
				            <xsl:call-template name="qrc_ins_new_page">
				                <xsl:with-param name="p_page" select="floor((position() div ($p_rows * $p_cols))+1)"/>
				                <xsl:with-param name="p_rows" select="$p_rows"/>
				                <xsl:with-param name="p_cols" select="$p_cols"/>
				            </xsl:call-template>
			         </xsl:if>
            </xsl:for-each>
        </xsl:if>


        <xsl:if test="@view = 'arai_v_hall_bezetting'">
        <script>
            <xsl:text disable-output-escaping="yes">
                function alg_show_ruimte_cad (p_title, p_verdiepingkey, p_ruimtekey) {
                    var url = "../../appl/CAD/mySlnk2IMG.asp?labelPos=1&amp;vKey=" + p_verdiepingkey + "&amp;highlight=" + p_ruimtekey + "&amp;scenario_key=0&amp;thema=-1&amp;label=21&amp;werkplek=0&amp;mode=0&amp;contmode=0&amp;discs=121,61&amp;paperColor=15395820"
                    FcltMgr.openModalDetail(url, p_title, { height: 600, width: 800 });
                }
            </xsl:text>
        </script>
            <!-- max_aantal_cols is het grootste aantal ruimten bij een ruimtegroep, primair tbv de telliong td's (dat die netjes uitkomt) -->
            <!-- max_aantal_cols gaan we secundair gebruiken voor een alert-error: indien gelijk aan 0, dan ligt de verbinding met Coneco eruit.  -->
            <xsl:variable name="max_aantal_cols">
                <xsl:call-template name="MaxRuimteCols">
            				<xsl:with-param name="p_groepnr" select="1"/>
            				<xsl:with-param name="p_maxgroepnr" select="count(//facilitor/rapport/rapport_data/data_row[generate-id(.)=generate-id(key('GROUP_BY_RTM_ruimtegroep',RUIMTEGROEP)[1])])"/>
            				<xsl:with-param name="p_result" select="0"/>
        		    </xsl:call-template>
        		</xsl:variable>

            <table>
            <tr height='5px'/>
            <tr height='10px'>
                <td width='1%' align='left'><span style='font-size:10pt'>&#160;</span></td>
                <td width='1%' style='border-left: 2px solid #9C0006; border-right: 2px solid #9C0006 ; border-top: 2px solid #9C0006; border-bottom: 2px solid #9C0006' align='left' bgcolor='#FFC7CE'><span style="font-size:10pt;color:#9C0006">&#160;</span></td>
                <td width='5%' align='left'><span style="font-size:10pt;color:#9C0006"><b>In gebruik</b></span></td>
                <td width='2%' align='left'><span style='font-size:10pt'>&#160;</span></td>
                <td width='1%' style='border-left: 2px solid #006100; border-right: 2px solid #006100 ; border-top: 2px solid #006100; border-bottom: 2px solid #006100' align='left' bgcolor='#C6EFCE'><span style="font-size:10pt;color:#006100">&#160;</span></td>
                <td width='5%' align='left'><span style="font-size:10pt;color:#006100"><b>Vrij</b></span></td>
                <td width='80%'></td>
            </tr>
            <tr height='5px'/>
            </table>

            <table border="1" width="99%">
                <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[generate-id(.)=generate-id(key('GROUP_BY_RTM_ruimtegroep',RUIMTEGROEP)[1])]">
                <xsl:sort select="RUIMTEGROEP"/>
                    <xsl:call-template name="ruimte_bezet_per_groep">
                        <xsl:with-param name="p_ruimtegroep" select="RUIMTEGROEP"/>
                        <xsl:with-param name="p_max_aantal_cols" select="$max_aantal_cols"/>
                    </xsl:call-template>
                </xsl:for-each>
            </table>
            <xsl:if test="$max_aantal_cols = 0">
                Geen connectie
            </xsl:if>
            <xsl:value-of select="//facilitor/rapport/rapport_data/data_row/INS_KENMERKDEEL_AANMAAK[1]"/>
        </xsl:if>
		</xsl:template>


    <xsl:template name="MaxRuimteCols">
        <xsl:param name="p_groepnr"/>
        <xsl:param name="p_maxgroepnr"/>
        <xsl:param name="p_result"/>
        <xsl:choose>
            <xsl:when test="$p_groepnr &lt;= $p_maxgroepnr">
                <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[generate-id(.)=generate-id(key('GROUP_BY_RTM_ruimtegroep',RUIMTEGROEP)[1])]">
                <xsl:sort select="RUIMTEGROEP"/>
                    <xsl:variable name="l_ruimtegroep" select="RUIMTEGROEP"/>
                    <xsl:if test="position() = $p_groepnr">
                        <xsl:variable name="l_ruimtegroep_cols" select="count(//facilitor/rapport/rapport_data/data_row[RUIMTEGROEP=$l_ruimtegroep])"/>
                        <xsl:choose>
                            <xsl:when test="$l_ruimtegroep_cols &gt; $p_result">
                                <xsl:call-template name="MaxRuimteCols">
                            				<xsl:with-param name="p_groepnr" select="$p_groepnr + 1"/>
                            				<xsl:with-param name="p_maxgroepnr" select="$p_maxgroepnr"/>
                            				<xsl:with-param name="p_result" select="$l_ruimtegroep_cols"/>
                        		    </xsl:call-template>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:call-template name="MaxRuimteCols">
                            				<xsl:with-param name="p_groepnr" select="$p_groepnr + 1"/>
                            				<xsl:with-param name="p_maxgroepnr" select="$p_maxgroepnr"/>
                            				<xsl:with-param name="p_result" select="$p_result"/>
                        		    </xsl:call-template>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:if>
                </xsl:for-each>
            </xsl:when>
            <xsl:otherwise>
               <xsl:value-of select="$p_result"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <xsl:template name="ruimte_bezet_per_groep">
        <xsl:param name="p_ruimtegroep"/>
        <xsl:param name="p_max_aantal_cols"/>
        <tr>
        <td width='6%' style='padding-left:5px;border-left: 1px solid #000000; border-right: 1px solid #000000' align='left'>
            <span style='font-size:16pt;'>
                <xsl:call-template name="print_ruimte_groep">
                    <xsl:with-param name="p_ruimtegroep" select="$p_ruimtegroep"/>
                </xsl:call-template>
            </span>
        </td>
        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[RUIMTEGROEP=$p_ruimtegroep]">
        <xsl:sort select="ALG_RUIMTE_OMSCHRIJVING"/>
            <xsl:choose>
                <xsl:when test="INS_KENMERKDEEL_WAARDE = '0'">
                    <td  width='5%' style='padding-left:5px;border-right: 1px solid #000000;cursor: pointer' align='left' bgcolor='#C6EFCE'>
                        <xsl:element name="span">
                            <xsl:attribute name="style">font-size:12pt;color:#006100</xsl:attribute>
                            <xsl:attribute name="onclick">alg_show_ruimte_cad ('', <xsl:value-of select="ALG_VERDIEPING_KEY"/>, <xsl:value-of select="ALG_RUIMTE_KEY"/>)</xsl:attribute>
                                <xsl:value-of select="ALG_RUIMTE_OMSCHRIJVING"/>
                        </xsl:element>
                    </td>
                </xsl:when>
                <xsl:otherwise>
                    <td width='5%' style='padding-left:5px;border-left: 2px solid #9C0006; border-right: 2px solid #9C0006 ; border-top: 2px solid #9C0006; border-bottom: 2px solid #9C0006;cursor: pointer' align='left' bgcolor='#FFC7CE'>
                    <xsl:element name="span">
                            <xsl:attribute name="style">font-size:12pt;color:#9C0006</xsl:attribute>
                            <xsl:attribute name="onclick">alg_show_ruimte_cad ('', <xsl:value-of select="ALG_VERDIEPING_KEY"/>, <xsl:value-of select="ALG_RUIMTE_KEY"/>)</xsl:attribute>
                                <xsl:value-of select="ALG_RUIMTE_OMSCHRIJVING"/>
                        </xsl:element>
                    </td>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:if test="position() = last()">
                <xsl:call-template name="fill_missing_cells">
                    <xsl:with-param name="p_positie" select="position()"/>
                    <xsl:with-param name="p_max_aantal_cols" select="$p_max_aantal_cols"/>
                </xsl:call-template>
            </xsl:if>
        </xsl:for-each>
        </tr>
    </xsl:template>

    <xsl:template name="print_ruimte_groep">
    <xsl:param name="p_ruimtegroep"/>
         <xsl:choose>
            <xsl:when test="contains($p_ruimtegroep, '-')">
                <xsl:value-of select="substring-after($p_ruimtegroep,'-')"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$p_ruimtegroep"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="fill_missing_cells">
        <xsl:param name="p_positie"/>
        <xsl:param name="p_max_aantal_cols"/>
        <xsl:if test="$p_positie &lt; $p_max_aantal_cols">
            <td  width='5%' style='border-right: 1px solid #000000' align='left'><span>&#160;</span></td>
            <xsl:call-template name="fill_missing_cells">
                    <xsl:with-param name="p_positie" select="$p_positie + 1"/>
                    <xsl:with-param name="p_max_aantal_cols" select="$p_max_aantal_cols"/>
             </xsl:call-template>
        </xsl:if>
    </xsl:template>


    <xsl:template name="kpi_overall_image">
        <xsl:param name="p_kpi_naam"/>
        <xsl:param name="p_kpi_status"/>
        <xsl:param name="p_rapport_naam"/>
        <xsl:param name="p_rapport_details"/>

        <xsl:element name="img">
        <xsl:attribute name="height">125</xsl:attribute>
        <xsl:if test="$p_rapport_naam != ''">
            <xsl:attribute name="onclick">alg_show_rapport_details('<xsl:value-of select="$p_kpi_naam"/>','<xsl:value-of select="$p_rapport_naam"/>','','')</xsl:attribute>
            <xsl:attribute name="style">cursor: pointer;</xsl:attribute>
        </xsl:if>
        <xsl:attribute name="src">
            <xsl:choose>
    						<xsl:when test="$p_kpi_status = '2'">
    							    ../../cust/arai/images/kpi_error.gif
    						</xsl:when>
    						<xsl:when test="$p_kpi_status = '1'">
    							    ../../cust/arai/images/kpi_orange.gif
    						</xsl:when>
    						<xsl:when test="$p_kpi_status = '0'">
    							    ../../cust/arai/images/kpi_okee.png
    						</xsl:when>
    						<xsl:otherwise>
        						  ../../cust/arai/images/kpi_dontcare.png
    						</xsl:otherwise>
    				</xsl:choose>
        </xsl:attribute>
        </xsl:element>

        <br/>


        <xsl:element name="span">
            <xsl:attribute name="style">
                <xsl:if test="$p_rapport_details != ''">cursor: pointer;</xsl:if>
                font-size:14pt;
								<xsl:choose>
        						<xsl:when test="$p_kpi_status = '2'">
        							    color:#ff0000
        						</xsl:when>
        						<xsl:when test="$p_kpi_status = '1'">
        							    color:#ff8800
        						</xsl:when>
        						<xsl:when test="$p_kpi_status = '0'">
        							    color:#00c000;
        						</xsl:when>
    						    <xsl:otherwise>
    							        color:#c0c0c0
    						    </xsl:otherwise>
    				    </xsl:choose>
						</xsl:attribute>
						<xsl:if test="$p_rapport_details != ''">
                <xsl:attribute name="onclick">alg_show_rapport_manual('Details <xsl:value-of select="$p_kpi_naam"/>','<xsl:value-of select="$p_rapport_details"/>','')</xsl:attribute>
            </xsl:if>
            <b><xsl:value-of select="$p_kpi_naam"/></b>
        </xsl:element>
        <br/>
    </xsl:template>



    <xsl:template name="kpi_temp_ins_new_page">
        <xsl:param name="p_page"/>
        <xsl:param name="p_rows"/>
        <xsl:param name="p_cols"/>


        <table border="0" width="100%" cellpadding="2">

        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[JOIN_KPI=2 or JOIN_KPI=3]">
        <xsl:sort select="ALG_GEBOUW_CODE"/>
        <xsl:sort select="ALG_RUIMTE_OMSCHRIJVING"/>
            <xsl:if test="position() &gt;= (($p_page - 1)*($p_rows*$p_cols)+1) and position() &lt;= ($p_page*($p_rows*$p_cols))">
                <xsl:if test="(position() mod $p_cols) = 0">
                    <xsl:comment>=== Na elke 4 records (1x4 passen op 1 regel) =====</xsl:comment>
                    <xsl:call-template name="kpi_temp_ins_new_tr">
                        <xsl:with-param name="p_pos" select="position() - $p_cols + 1"/>
                        <xsl:with-param name="p_cols" select="$p_cols"/>
                    </xsl:call-template>
                </xsl:if>
                <xsl:if test="(position() = last()) and (position() mod $p_cols) != 0">
                    <xsl:comment>=== Na elke 4 records (1x4 passen op 1 regel) =====</xsl:comment>
                    <xsl:call-template name="kpi_temp_ins_new_tr">
                        <xsl:with-param name="p_pos" select="floor(position() div $p_cols) * $p_cols + 1"/>
                        <xsl:with-param name="p_cols" select="$p_cols"/>
                    </xsl:call-template>
                </xsl:if>
            </xsl:if>
        </xsl:for-each>
        </table>
    </xsl:template>


    <xsl:template name="kpi_temp_ins_new_tr">
        <xsl:param name="p_pos"/>
        <xsl:param name="p_cols"/>
        <tr height="250px">
        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[JOIN_KPI=2 or JOIN_KPI=3]">
        <xsl:sort select="ALG_GEBOUW_CODE"/>
        <xsl:sort select="ALG_RUIMTE_OMSCHRIJVING"/>
            <xsl:if test="position() &gt;= $p_pos and position() &lt;= $p_pos + $p_cols - 1">
                <td width="25%" style="text-align:center">
                    <xsl:element name="img">
                        <xsl:attribute name="height">25</xsl:attribute>
                        <xsl:attribute name="onclick">alg_show_kpi_temp_vandaag_barchart('Temperatuur van <xsl:value-of select="ALG_GEBOUW_NAAM"/>' ,<xsl:value-of select="ALG_RUIMTE_KEY"/>)</xsl:attribute>
                        <xsl:attribute name="style">cursor: pointer;</xsl:attribute>
                        <xsl:attribute name="src">../../cust/arai/images/kpi_barchart.png</xsl:attribute>
                    </xsl:element>

                    <xsl:element name="span">
                        <xsl:attribute name="onclick">alg_show_ruimte_details(<xsl:value-of select="ALG_RUIMTE_KEY"/>)</xsl:attribute>
                        <xsl:attribute name="style">cursor: pointer;font-size:14pt</xsl:attribute>
                            <b><u><xsl:value-of select="ALG_GEBOUW_NAAM"/>&#160;</u></b>
                    </xsl:element>
                    <xsl:element name="img">
                        <xsl:attribute name="height">25</xsl:attribute>
                        <xsl:attribute name="onclick">alg_show_kpi_temp_vandaag_lijngrafiek('Temperatuur van <xsl:value-of select="ALG_GEBOUW_NAAM"/>' ,<xsl:value-of select="ALG_RUIMTE_KEY"/>)</xsl:attribute>
                        <xsl:attribute name="style">cursor: pointer;</xsl:attribute>
                        <xsl:attribute name="src">../../cust/arai/images/kpi_lijngrafiek.png</xsl:attribute>
                    </xsl:element>

                    <br/>
                    <xsl:element name="span">
                        <xsl:attribute name="onclick">alg_show_ruimte_details(<xsl:value-of select="ALG_RUIMTE_KEY"/>)</xsl:attribute>
                        <xsl:attribute name="style">cursor: pointer;font-size:10pt</xsl:attribute>
                            <i><xsl:value-of select="ALG_RUIMTE_OMSCHRIJVING"/>&#160;</i>
                    </xsl:element>



                    <br/>
                    <xsl:call-template name="kpi_display_image">
                        <xsl:with-param name="p_rapport_naam" select="'CAD'"/>
                        <xsl:with-param name="p_rapport_filter_value" select="''"/>
                        <xsl:with-param name="p_value" select="AVG_TEMP"/>
                        <xsl:with-param name="p_eenheid" select="' °C'"/>
                        <xsl:with-param name="p_min_oranje" select="MIN_WAARDE_ORANJE"/>
                        <xsl:with-param name="p_max_oranje" select="MAX_WAARDE_ORANJE"/>
                        <xsl:with-param name="p_min_rood" select="MIN_WAARDE"/>
                        <xsl:with-param name="p_max_rood" select="MAX_WAARDE"/>
                        <xsl:with-param name="p_join_kpi" select="JOIN_KPI"/>
                        <xsl:with-param name="p_kpi_status" select="''"/>
                    </xsl:call-template>
                </td>
            </xsl:if>
        </xsl:for-each>
        </tr>
    </xsl:template>




    <xsl:template name="kpi_ict_mitel_ins_new_page">
        <xsl:param name="p_page"/>
        <xsl:param name="p_rows"/>
        <xsl:param name="p_cols"/>


        <table border="0" width="100%" cellpadding="2">

        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">
            <xsl:sort select="INS_SRTDEEL_OMSCHRIJVING"/>
            <xsl:sort select="INS_DEEL_OMSCHRIJVING"/>
            <xsl:if test="position() &gt;= (($p_page - 1)*($p_rows*$p_cols)+1) and position() &lt;= ($p_page*($p_rows*$p_cols))">
                <xsl:if test="(position() mod $p_cols) = 0">
                    <xsl:comment>=== Na elke 4 records (1x4 passen op 1 regel) =====</xsl:comment>
                    <xsl:call-template name="kpi_ict_mitel_ins_new_tr">
                        <xsl:with-param name="p_pos" select="position() - $p_cols + 1"/>
                        <xsl:with-param name="p_cols" select="$p_cols"/>
                    </xsl:call-template>
                </xsl:if>
                <xsl:if test="(position() = last()) and (position() mod $p_cols) != 0">
                    <xsl:comment>=== Na elke 4 records (1x4 passen op 1 regel) =====</xsl:comment>
                    <xsl:call-template name="kpi_ict_mitel_ins_new_tr">
                        <xsl:with-param name="p_pos" select="floor(position() div $p_cols) * $p_cols + 1"/>
                        <xsl:with-param name="p_cols" select="$p_cols"/>
                    </xsl:call-template>
                </xsl:if>
            </xsl:if>
        </xsl:for-each>
        </table>
    </xsl:template>


    <xsl:template name="kpi_ict_mitel_ins_new_tr">
        <xsl:param name="p_pos"/>
        <xsl:param name="p_cols"/>
        <tr height="250px">
        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">
            <xsl:sort select="INS_SRTDEEL_OMSCHRIJVING"/>
            <xsl:sort select="INS_DEEL_OMSCHRIJVING"/>
            <xsl:if test="position() &gt;= $p_pos and position() &lt;= $p_pos + $p_cols - 1">
                <td width="25%" style="text-align:center">

                    <xsl:element name="img">
                        <xsl:attribute name="height">25</xsl:attribute>
                        <xsl:attribute name="onclick">alg_show_kpi_ict_mitel_vandaag_barchart('Wachttijd in seconden van <xsl:value-of select="INS_SRTDEEL_OMSCHRIJVING"/>' ,<xsl:value-of select="INS_DEEL_KEY"/>)</xsl:attribute>
                        <xsl:attribute name="style">cursor: pointer;</xsl:attribute>
                        <xsl:attribute name="src">../../cust/arai/images/kpi_barchart.png</xsl:attribute>
                    </xsl:element>
                    <xsl:element name="span">
                        <xsl:attribute name="onclick">ins_show_deel_details(<xsl:value-of select="INS_DEEL_KEY"/>)</xsl:attribute>
                        <xsl:attribute name="style">cursor: pointer;font-size:14pt;</xsl:attribute>
                            <b><u><xsl:value-of select="INS_SRTDEEL_OMSCHRIJVING"/>&#160;</u></b>
                    </xsl:element>

                    <xsl:element name="img">
                        <xsl:attribute name="height">25</xsl:attribute>
                        <xsl:attribute name="onclick">alg_show_kpi_ict_mitel_vandaag_lijngrafiek('Wachttijd in seconden van <xsl:value-of select="INS_SRTDEEL_OMSCHRIJVING"/>' ,<xsl:value-of select="INS_DEEL_KEY"/>)</xsl:attribute>
                        <xsl:attribute name="style">cursor: pointer;</xsl:attribute>
                        <xsl:attribute name="src">../../cust/arai/images/kpi_lijngrafiek.png</xsl:attribute>
                    </xsl:element>
                    <br/>
                    <xsl:element name="span">
                        <xsl:attribute name="onclick">ins_show_deel_details(<xsl:value-of select="INS_DEEL_KEY"/>)</xsl:attribute>
                        <xsl:attribute name="style">cursor: pointer;font-size:10pt</xsl:attribute>
                            <b><u>(<xsl:value-of select="INS_DEEL_OMSCHRIJVING"/>)</u></b>
                    </xsl:element>
                    <br/>
                    <xsl:call-template name="kpi_display_image">
                        <xsl:with-param name="p_rapport_naam" select="''"/>
                        <xsl:with-param name="p_rapport_filter_value" select="'1'"/>
                        <xsl:with-param name="p_value" select="INS_KENMERKDEEL_WAARDE"/>
                        <xsl:with-param name="p_eenheid" select="' sec. wachttijd'"/>
                        <xsl:with-param name="p_min_oranje" select="0"/>
                        <xsl:with-param name="p_max_oranje" select="WAARDE_ORANJE"/>
                        <xsl:with-param name="p_min_rood" select="0"/>
                        <xsl:with-param name="p_max_rood" select="WAARDE_ROOD"/>
                        <xsl:with-param name="p_join_kpi" select="JOIN_KPI"/>
                        <xsl:with-param name="p_kpi_status" select="KPI_COLOR_OVERRULE"/>
                    </xsl:call-template>
                </td>
            </xsl:if>
        </xsl:for-each>
        </tr>
    </xsl:template>

    <xsl:template name="kpi_toilet_ins_new_tr">
        <xsl:param name="p_pos"/>
        <xsl:param name="p_cols"/>
        <tr height="200px">
        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">
        <xsl:sort select="ALG_GEBOUW_CODE"/>
        <xsl:sort select="ALG_RUIMTE_NR"/>
            <xsl:if test="position() &gt;= $p_pos and position() &lt;= $p_pos + $p_cols - 1">
                <td width="25%" style="text-align:center">
                    <xsl:element name="img">
                        <xsl:attribute name="height">25</xsl:attribute>
                        <xsl:attribute name="onclick">alg_show_kpi_toilet_vandaag_barchart('Toiletschoonmaak van <xsl:value-of select="ALG_GEBOUW_NAAM"/>' ,<xsl:value-of select="ALG_GEBOUW_KEY"/>)</xsl:attribute>
                        <xsl:attribute name="style">cursor: pointer;</xsl:attribute>
                        <xsl:attribute name="src">../../cust/arai/images/kpi_barchart.png</xsl:attribute>
                    </xsl:element>
                    <xsl:element name="span">
                        <xsl:attribute name="style">font-size:13pt</xsl:attribute>
                            <b><u><xsl:value-of select="ALG_GEBOUW_NAAM"/>&#160;</u></b>
                    </xsl:element>
                    <xsl:element name="img">
                        <xsl:attribute name="height">25</xsl:attribute>
                        <xsl:attribute name="onclick">alg_show_kpi_toilet_vandaag_lijngrafiek('Toiletschoonmaak van <xsl:value-of select="ALG_GEBOUW_NAAM"/>' ,<xsl:value-of select="ALG_GEBOUW_KEY"/>)</xsl:attribute>
                        <xsl:attribute name="style">cursor: pointer;</xsl:attribute>
                        <xsl:attribute name="src">../../cust/arai/images/kpi_lijngrafiek.png</xsl:attribute>
                    </xsl:element>
                    <br/>
                    <xsl:call-template name="kpi_display_image">
                        <xsl:with-param name="p_rapport_naam" select="'arai_v_rap_kpi_toilet'"/>
                        <xsl:with-param name="p_rapport_filter_value" select="ALG_GEBOUW_KEY"/>
                        <xsl:with-param name="p_value" select="GOED"/>
                        <xsl:with-param name="p_eenheid" select="' %'"/>
                        <xsl:with-param name="p_min_oranje" select="''"/>
                        <xsl:with-param name="p_max_oranje" select="''"/>
                        <xsl:with-param name="p_min_rood" select="''"/>
                        <xsl:with-param name="p_max_rood" select="''"/>
                        <xsl:with-param name="p_join_kpi" select="JOIN_KPI"/>
                        <xsl:with-param name="p_kpi_status" select="KPI_STATUS"/>
                    </xsl:call-template>
                </td>
            </xsl:if>
        </xsl:for-each>
        </tr>
    </xsl:template>


    <xsl:template name="kpi_toilet_ins_new_page">
        <xsl:param name="p_page"/>
        <xsl:param name="p_rows"/>
        <xsl:param name="p_cols"/>


        <table border="0" width="100%" cellpadding="2">

        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">
        <xsl:sort select="ALG_GEBOUW_CODE"/>
        <xsl:sort select="ALG_RUIMTE_NR"/>
            <xsl:if test="position() &gt;= (($p_page - 1)*($p_rows*$p_cols)+1) and position() &lt;= ($p_page*($p_rows*$p_cols))">
                <xsl:if test="(position() mod $p_cols) = 0">
                    <xsl:comment>=== Na elke 4 records (1x4 passen op 1 regel) =====</xsl:comment>
                    <xsl:call-template name="kpi_toilet_ins_new_tr">
                        <xsl:with-param name="p_pos" select="position() - $p_cols + 1"/>
                        <xsl:with-param name="p_cols" select="$p_cols"/>
                    </xsl:call-template>
                </xsl:if>
                <xsl:if test="(position() = last()) and (position() mod $p_cols) != 0">
                    <xsl:comment>=== Na elke 4 records (1x4 passen op 1 regel) =====</xsl:comment>
                    <xsl:call-template name="kpi_toilet_ins_new_tr">
                        <xsl:with-param name="p_pos" select="floor(position() div $p_cols) * $p_cols + 1"/>
                        <xsl:with-param name="p_cols" select="$p_cols"/>
                    </xsl:call-template>
                </xsl:if>
            </xsl:if>
        </xsl:for-each>
        </table>
    </xsl:template>



    <xsl:template name="kpi_schonestands_ins_new_tr">
        <xsl:param name="p_pos"/>
        <xsl:param name="p_cols"/>
        <tr height="200px">
        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">

            <xsl:if test="position() &gt;= $p_pos and position() &lt;= $p_pos + $p_cols - 1">
                <td width="25%" style="text-align:center">
                     <xsl:element name="img">
                        <xsl:attribute name="height">25</xsl:attribute>
                        <xsl:attribute name="onclick">alg_show_kpi_schonestands_vandaag_barchart('Percentage te late afhandeling standschoonmaak')</xsl:attribute>
                        <xsl:attribute name="style">cursor: pointer;</xsl:attribute>
                        <xsl:attribute name="src">../../cust/arai/images/kpi_barchart.png</xsl:attribute>
                    </xsl:element>
                    <xsl:element name="span">
                        <xsl:attribute name="style">font-size:13pt</xsl:attribute>
                            <b><u><xsl:value-of select="FCLT_XAS_TIJD"/>&#160;</u></b>
                    </xsl:element>

                    <xsl:element name="img">
                        <xsl:attribute name="height">25</xsl:attribute>
                        <xsl:attribute name="onclick">alg_show_kpi_schonestands_vandaag_lijngrafiek('Percentage te late afhandeling standschoonmaak')</xsl:attribute>
                        <xsl:attribute name="style">cursor: pointer;</xsl:attribute>
                        <xsl:attribute name="src">../../cust/arai/images/kpi_lijngrafiek.png</xsl:attribute>
                    </xsl:element>
                    <br/>
                    <xsl:call-template name="kpi_display_image">
                        <xsl:with-param name="p_rapport_naam" select="'arai_v_rap_standschoon_lopend'"/>
                        <xsl:with-param name="p_rapport_filter_value" select="'1'"/>
                        <xsl:with-param name="p_value" select="FOUT"/>
                        <xsl:with-param name="p_eenheid" select="' % te laat'"/>
                        <xsl:with-param name="p_min_oranje" select="''"/>
                        <xsl:with-param name="p_max_oranje" select="''"/>
                        <xsl:with-param name="p_min_rood" select="''"/>
                        <xsl:with-param name="p_max_rood" select="''"/>
                        <xsl:with-param name="p_join_kpi" select="JOIN_KPI"/>
                        <xsl:with-param name="p_kpi_status" select="KPI_STATUS"/>
                    </xsl:call-template>
                </td>
            </xsl:if>
        </xsl:for-each>
        </tr>
    </xsl:template>


    <xsl:template name="kpi_schonestands_ins_new_page">
        <xsl:param name="p_page"/>
        <xsl:param name="p_rows"/>
        <xsl:param name="p_cols"/>


        <table border="0" width="100%" cellpadding="2">

        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">

            <xsl:if test="position() &gt;= (($p_page - 1)*($p_rows*$p_cols)+1) and position() &lt;= ($p_page*($p_rows*$p_cols))">
                <xsl:if test="(position() mod $p_cols) = 0">
                    <xsl:comment>=== Na elke 4 records (1x4 passen op 1 regel) =====</xsl:comment>
                    <xsl:call-template name="kpi_schonestands_ins_new_tr">
                        <xsl:with-param name="p_pos" select="position() - $p_cols + 1"/>
                        <xsl:with-param name="p_cols" select="$p_cols"/>
                    </xsl:call-template>
                </xsl:if>
                <xsl:if test="(position() = last()) and (position() mod $p_cols) != 0">
                    <xsl:comment>=== Na elke 4 records (1x4 passen op 1 regel) =====</xsl:comment>
                    <xsl:call-template name="kpi_schonestands_ins_new_tr">
                        <xsl:with-param name="p_pos" select="floor(position() div $p_cols) * $p_cols + 1"/>
                        <xsl:with-param name="p_cols" select="$p_cols"/>
                    </xsl:call-template>
                </xsl:if>
            </xsl:if>
        </xsl:for-each>
        </table>
    </xsl:template>



    <xsl:template name="kpi_display_image">
        <xsl:param name="p_rapport_naam"/>
        <xsl:param name="p_rapport_filter_value"/>
        <xsl:param name="p_value"/>
        <xsl:param name="p_eenheid"/>
        <xsl:param name="p_min_oranje"/>
        <xsl:param name="p_max_oranje"/>
        <xsl:param name="p_min_rood"/>
        <xsl:param name="p_max_rood"/>
        <xsl:param name="p_join_kpi"/>
        <xsl:param name="p_kpi_status"/>


        <xsl:element name="img">
        <xsl:attribute name="height">100</xsl:attribute>

        <xsl:if test="$p_rapport_naam = 'CAD'">
            <xsl:attribute name="onclick">alg_show_kpi_temp_cad('Plattegrond van <xsl:value-of select="ALG_GEBOUW_NAAM"/>' , <xsl:value-of select="ALG_VERDIEPING_KEY"/>)</xsl:attribute>
            <xsl:attribute name="style">cursor: pointer;</xsl:attribute>
        </xsl:if>
        <xsl:if test="$p_rapport_naam != 'CAD' and $p_rapport_naam != ''">
            <xsl:attribute name="onclick">alg_show_rapport_details('Details','<xsl:value-of select="$p_rapport_naam"/>','<xsl:value-of select="$p_rapport_filter_value"/>')</xsl:attribute>
            <xsl:attribute name="style">cursor: pointer;</xsl:attribute>
        </xsl:if>



        <xsl:attribute name="src">
            <xsl:choose>
    						<xsl:when test="$p_kpi_status = '-1'">
    							    ../../cust/arai/images/kpi_dontcare.png
    						</xsl:when>
    						<xsl:when test="$p_kpi_status = '0'">
    							    ../../cust/arai/images/kpi_okee.png
    						</xsl:when>
    						<xsl:when test="$p_kpi_status = '1'">
    							    ../../cust/arai/images/kpi_orange.png
    						</xsl:when>
    						<xsl:when test="$p_kpi_status = '2'">
    							    ../../cust/arai/images/kpi_error.png
    						</xsl:when>
    		        <xsl:when test="$p_join_kpi != '3'">
    							    ../../cust/arai/images/kpi_dontcare.png
    						</xsl:when>
    						<xsl:otherwise>
        						<xsl:choose>
            						<xsl:when test="($p_value &gt;= $p_min_oranje) and ($p_value &lt;= $p_max_oranje)">
            							    ../../cust/arai/images/kpi_okee.png
            						</xsl:when>
            						<xsl:when test="($p_value &lt; $p_min_rood) or ($p_value &gt; $p_max_rood)">
            							    ../../cust/arai/images/kpi_error.png
            						</xsl:when>
        						    <xsl:otherwise>
        							        ../../cust/arai/images/kpi_orange.png
        						    </xsl:otherwise>
        				    </xsl:choose>
    						</xsl:otherwise>
    				</xsl:choose>
        </xsl:attribute>
        </xsl:element>

        <br/>


        <xsl:element name="span">
            <xsl:attribute name="style">
             font-size:14pt;
								<xsl:choose>
								    <xsl:when test="($p_join_kpi != '3') or ($p_kpi_status = '-1')">
								        color:#c0c0c0
								    </xsl:when>
        						<xsl:when test="$p_kpi_status = '0'">
        							  color:#00c000
        						</xsl:when>
        						<xsl:when test="$p_kpi_status = '1'">
        							   color:#ff8800;
        						</xsl:when>
        						<xsl:when test="$p_kpi_status = '2'">
        							   color:#ff0000
        						</xsl:when>
        		        <xsl:otherwise>
            						<xsl:choose>
                						<xsl:when test="(($p_value &gt;= $p_min_oranje) and ($p_value &lt;= $p_max_oranje))">
                							  color:#00c000
                						</xsl:when>
                						<xsl:when test="(($p_value &lt; $p_min_rood) or ($p_value &gt; $p_max_rood))">
                							  color:#ff0000
                						</xsl:when>
            						    <xsl:otherwise>
            							      color:#ff8800;
            						    </xsl:otherwise>
            				    </xsl:choose>
        						</xsl:otherwise>
    				    </xsl:choose>
						</xsl:attribute>
            <b><xsl:value-of select="$p_value"/><xsl:value-of select="$p_eenheid"/></b>
        </xsl:element>

        <xsl:comment>
        <xsl:if test="$p_join_kpi = '3'">
            <br/>
            <table border="0" width="50%" cellpadding="2">
                <tr>
                <td height='10px' style="background-color:red"> </td><td style="background-color:orange"> </td><td style="background-color:green"> </td><td style="background-color:orange"> </td> <td style="background-color:red"> </td>
                </tr>
            </table>
    		</xsl:if>
    		<xsl:if test="$p_join_kpi != '3'">
            <br/>
            <table border="0" width="50%" cellpadding="2">
                <tr>
                <td height='10px' style="background-color:#C0C0C0"> </td><td style="background-color:gray"> </td><td style="background-color:#6D6969"> </td>
                </tr>
            </table>
    		</xsl:if>
    		</xsl:comment>

    		<br/>
        <xsl:if test="$p_join_kpi = '3'">
            <span style="font-size:7pt;color:#ff0000">■■ <b><xsl:value-of select="$p_min_rood"/></b></span>
            <span style="font-size:7pt;color:#ff8800"> ■■ </span>
            <span style="font-size:7pt;color:#00c000"><b><xsl:value-of select="$p_min_oranje"/></b> ■■■ <b><xsl:value-of select="$p_max_oranje"/></b></span>
            <span style="font-size:7pt;color:#ff8800"> ■■ </span>
            <span style="font-size:7pt;color:#ff0000"> <b><xsl:value-of select="$p_max_rood"/></b> ■■</span>
        </xsl:if>
    		<xsl:if test="$p_join_kpi != '3'">
            <span style="font-size:7pt;color:#c0c0c0">■■ <b><xsl:value-of select="$p_min_rood"/></b></span>
            <span style="font-size:7pt;color:#c0c0c0"> ■■ </span>
            <span style="font-size:7pt;color:#c0c0c0"><b><xsl:value-of select="$p_min_oranje"/></b> ■■■ <b><xsl:value-of select="$p_max_oranje"/></b></span>
            <span style="font-size:7pt;color:#c0c0c0"> ■■ </span>
            <span style="font-size:7pt;color:#c0c0c0"> <b><xsl:value-of select="$p_max_rood"/></b> ■■</span>
    		</xsl:if>
    </xsl:template>


    <xsl:template name="controle_toiletten_lijst_perdatum">
        <xsl:param name="p_datum"/>

        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[generate-id(.)=generate-id(key('GROUP_BY_gebouw_key',FCLT_KEY)[1])]">
        <xsl:sort select="ALG_GEBOUW_CODE"/>
            <xsl:call-template name="controle_toiletten_lijst_pergebouw">
                <xsl:with-param name="p_gebouw_key" select="FCLT_KEY"/>
                <xsl:with-param name="p_datum" select="$p_datum"/>
            </xsl:call-template>
        </xsl:for-each>
    </xsl:template>

    <xsl:template name="controle_toiletten_lijst_pergebouw">
        <xsl:param name="p_gebouw_key"/>
        <xsl:param name="p_datum"/>
        <xsl:variable name="l_gebouw_naam" select="ALG_GEBOUW_NAAM"/>
        <xsl:if test="count(//facilitor/rapport/rapport_data/data_row[TRUNC_INS_CONTROLE_DATUM=$p_datum and FCLT_KEY=$p_gebouw_key]) &gt; 0">
            <tr height='30'>
                <td bgcolor='#009BE0' align='center' colspan='10'><span style="font-size:14pt;">Toiletcontrole van <b><xsl:value-of select="$l_gebouw_naam"/></b> op <xsl:value-of select="$p_datum"/></span></td>
            </tr>
        </xsl:if>
        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[generate-id(.)=generate-id(key('GROUP_BY_afgeronde_tijd',AFGERONDE_TIJD)[1])]">
            <xsl:sort select="AFGERONDE_TIJD"/>

            <xsl:call-template name="controle_toiletten_lijst_tijd">
                    <xsl:with-param name="p_gebouw_key" select="$p_gebouw_key"/>
                    <xsl:with-param name="p_afgeronde_tijd" select="AFGERONDE_TIJD"/>
                    <xsl:with-param name="p_datum" select="$p_datum"/>
            </xsl:call-template>
        </xsl:for-each>
    </xsl:template>

    <xsl:template name="controle_toiletten_lijst_tijd">
        <xsl:param name="p_gebouw_key"/>
        <xsl:param name="p_afgeronde_tijd"/>
        <xsl:param name="p_datum"/>

        <xsl:if test="count(//facilitor/rapport/rapport_data/data_row[TRUNC_INS_CONTROLE_DATUM=$p_datum and FCLT_KEY=$p_gebouw_key and AFGERONDE_TIJD=$p_afgeronde_tijd]) &gt; 0">


            <tr>
            	    <td bgcolor='#C0C0C0'><b>Tijd</b></td>
            	    <td bgcolor='#C0C0C0'><b>Verdieping</b></td>
        	        <td bgcolor='#C0C0C0'><b>Ruimte</b></td>
        	        <td bgcolor='#C0C0C0'><b>Beoordeling</b></td>
        	        <td bgcolor='#C0C0C0'><b>Opmerking</b></td>
            </tr>
        </xsl:if>

        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[TRUNC_INS_CONTROLE_DATUM=$p_datum and FCLT_KEY=$p_gebouw_key and AFGERONDE_TIJD=$p_afgeronde_tijd]">

                <xsl:sort select="TIJD"/>
                <xsl:sort select="ALG_VERDIEPING_VOLGNR" data-type="number"/>
                <xsl:sort select="ALG_RUIMTE_NR"/>

                <tr>
                	    <td><xsl:value-of select="TIJD"/></td>
                	    <td><xsl:value-of select="ALG_VERDIEPING_VOLGNR"/></td>
            	        <td><xsl:value-of select="ALG_RUIMTE_NR"/>-<xsl:value-of select="ALG_RUIMTE_OMSCHRIJVING"/></td>


            	        <td>
            	            <xsl:if test="FOUT = '0'"><xsl:value-of select="INS_CONTROLEMODE_OMS"/></xsl:if>
            	            <xsl:if test="FOUT = '1'"><span style="color:red"><b><xsl:value-of select="INS_CONTROLEMODE_OMS"/></b></span></xsl:if>
            	        </td>
            	        <td><xsl:call-template name="linebreaks"><xsl:with-param name="string" select="INS_DEELSRTCONTROLE_OPMERKING"/></xsl:call-template></td>




                </tr>
        </xsl:for-each>
        <xsl:if test="count(//facilitor/rapport/rapport_data/data_row[TRUNC_INS_CONTROLE_DATUM=$p_datum and FCLT_KEY=$p_gebouw_key and AFGERONDE_TIJD=$p_afgeronde_tijd]) &gt; 0">
            <tr height='10'>
            <xsl:call-template name="td_red_orange_green">
                <xsl:with-param name="p_value" select="//facilitor/rapport/rapport_data/data_row[TRUNC_INS_CONTROLE_DATUM=$p_datum and FCLT_KEY=$p_gebouw_key and AFGERONDE_TIJD=$p_afgeronde_tijd]/KPI_TOILET_PERGEBOUW[1]"/>
                <xsl:with-param name="p_value_prefix"><xsl:value-of select="$p_afgeronde_tijd"/>u: </xsl:with-param>
                <xsl:with-param name="p_value_postfix" select="'%'"/>
                <xsl:with-param name="p_kpi_color" select="''"/>
                <xsl:with-param name="p_kpi_value_orange" select="//facilitor/rapport/rapport_data/data_row[TRUNC_INS_CONTROLE_DATUM=$p_datum and FCLT_KEY=$p_gebouw_key and AFGERONDE_TIJD=$p_afgeronde_tijd]/WAARDE_ORANJE[1]"/>
                <xsl:with-param name="p_kpi_value_red" select="//facilitor/rapport/rapport_data/data_row[TRUNC_INS_CONTROLE_DATUM=$p_datum and FCLT_KEY=$p_gebouw_key and AFGERONDE_TIJD=$p_afgeronde_tijd]/WAARDE_ROOD[1]"/>
                <xsl:with-param name="p_kpi_sortmethod" select="1"/>

            </xsl:call-template>



            </tr>
        </xsl:if>

    </xsl:template>





    <xsl:template name="qrc_ins_new_page">
        <xsl:param name="p_page"/>
        <xsl:param name="p_rows"/>
        <xsl:param name="p_cols"/>


        <table>

        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">
        <xsl:sort select="FCLT_F_GEBOUW"/>
        <xsl:sort select="PLAATS"/>
            <xsl:if test="position() &gt;= (($p_page - 1)*($p_rows*$p_cols)+1) and position() &lt;= ($p_page*($p_rows*$p_cols))">
                <xsl:if test="(position() mod $p_cols) = 0">
                    <xsl:comment>=== Na elke 1 records (1x1 passen op 1 regel) =====</xsl:comment>
                    <xsl:call-template name="qrc_ins_new_tr">
                        <xsl:with-param name="p_pos" select="position() - $p_cols + 1"/>
                        <xsl:with-param name="p_cols" select="$p_cols"/>
                    </xsl:call-template>
                </xsl:if>
                <xsl:if test="(position() = last()) and (position() mod $p_cols) != 0">
                    <xsl:comment>=== Na elke 1 records (1x1 passen op 1 regel) =====</xsl:comment>
                    <xsl:call-template name="qrc_ins_new_tr">
                        <xsl:with-param name="p_pos" select="floor(position() div $p_cols) * $p_cols + 1"/>
                        <xsl:with-param name="p_cols" select="$p_cols"/>
                    </xsl:call-template>
                </xsl:if>
            </xsl:if>
        </xsl:for-each>
        </table>
    </xsl:template>


    <xsl:template name="qrc_ins_new_tr">
        <xsl:param name="p_pos"/>
        <xsl:param name="p_cols"/>

        <tr height="80px">
        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">
        <xsl:sort select="FCLT_F_GEBOUW"/>
        <xsl:sort select="PLAATS"/>
            <xsl:if test="position() &gt;= $p_pos and position() &lt;= $p_pos + $p_cols - 1">
                <td width="25%" style="text-align:center">
                    <xsl:element name="img">
                        <xsl:attribute name="style">height: 5cm</xsl:attribute>
                        <xsl:attribute name="src">
                         ../../appl/shared/qrcode.asp?size=16&amp;text=%3Fu%3D<xsl:value-of select="HIDE_F_BOOKMARK_ID"/>%26ins_key%3D<xsl:value-of select="INS_DEEL_KEY"/>
                        </xsl:attribute>
                    </xsl:element><br/>
                    <xsl:comment><span style="font-size:7px"><xsl:value-of select="INS_DEEL_UPPER"/></span><br/></xsl:comment>
                    <xsl:comment><span style="font-size:7px"><xsl:value-of select="INS_DEEL_KEY"/></span></xsl:comment>
                </td>
            </xsl:if>
        </xsl:for-each>
        </tr>
        <tr height="80px">
        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row">
        <xsl:sort select="FCLT_F_GEBOUW"/>
        <xsl:sort select="PLAATS"/>
            <xsl:if test="position() &gt;= $p_pos and position() &lt;= $p_pos + $p_cols - 1">
                <td width="25%" style="text-align:center">
                    <xsl:value-of select="FCLT_F_GEBOUW"/><br/>
                    <xsl:value-of select="PLAATS"/><br/>
                    <xsl:value-of select="SOORTRUIMTE"/><br/>
                </td>
            </xsl:if>
        </xsl:for-each>


        </tr>
    </xsl:template>

    <!-- Als kpi_color is meegegeven, dan bepaalt dit de kleur, en anders kijkt die naar value_orange en value_red -->
    <!-- p_kpi_sortmethod bepaalt de wijze van vergelijken: 0 betekent dat lage waarden goed zijn (groen-oranje-rood), 1 betekent dat hoge waarden goed zijn (rood-oranje-groen)-->
    <xsl:template name="td_red_orange_green">
        <xsl:param name="p_value"/>
        <xsl:param name="p_value_prefix"/>
        <xsl:param name="p_value_postfix"/>
        <xsl:param name="p_kpi_color"/>
        <xsl:param name="p_kpi_value_orange"/>
        <xsl:param name="p_kpi_value_red"/>
        <xsl:param name="p_kpi_sortmethod"/>
            <xsl:element name="td">
                <xsl:attribute name="align">left</xsl:attribute>
                <xsl:attribute name="colspan">1</xsl:attribute>
                <xsl:attribute name="bgcolor">
                		<xsl:choose>
                		    <xsl:when test="$p_kpi_color=-1">#c0c0c0</xsl:when>
                		    <xsl:when test="$p_kpi_color=0">#00c000</xsl:when>
                		    <xsl:when test="$p_kpi_color=1">#ff8800</xsl:when>
                		    <xsl:when test="$p_kpi_color=2">#ff0000</xsl:when>
                		    <xsl:otherwise>
                		        <xsl:choose>
                		            <xsl:when test="$p_kpi_sortmethod=0">
                		                <xsl:choose>
                    		                <xsl:when test="$p_value &lt;= $p_kpi_value_orange">#00c000</xsl:when>
                    		                <xsl:when test="$p_value &lt;= $p_kpi_value_red">#ff8800</xsl:when>
                    		                <xsl:otherwise>#ff0000</xsl:otherwise>
                		                </xsl:choose>
                		            </xsl:when>
                		            <xsl:otherwise>
                		                <xsl:choose>
                    		                <xsl:when test="$p_value &gt;= $p_kpi_value_orange">#00c000</xsl:when>
                    		                <xsl:when test="$p_value &gt;= $p_kpi_value_red">#ff8800</xsl:when>
                    		                <xsl:otherwise>#ff0000</xsl:otherwise>
                		                </xsl:choose>
                		            </xsl:otherwise>
                		        </xsl:choose>
                		    </xsl:otherwise>
        				    </xsl:choose>
        				</xsl:attribute>
    				    <span style="font-size:10pt;"><xsl:value-of select="$p_value_prefix"/><xsl:value-of select="$p_value"/><xsl:value-of select="$p_value_postfix"/></span>
             </xsl:element>
    </xsl:template>

</xsl:stylesheet>
