<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" version="1.0">
<xsl:import href="../../../appl/shared/default.xsl"/>
<!--<xsl:import href="uninu.xsl"/>-->
<xsl:variable name="Rev">
  <!-- Revision van deze cust.xsl -->
  <xsl:value-of select="substring(translate('$Revision$', '$ ', ''), 10)"/>
</xsl:variable>

  <xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'"/>
  <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
  <xsl:decimal-format name="euro" decimal-separator="," grouping-separator="."/>

  <xsl:variable name="PRJ_AFDELING_THEMA_KEY">82</xsl:variable>
  <xsl:variable name="PRJ_ONDERHANDEN_THEMA_KEY">26</xsl:variable>
  <xsl:variable name="PRJ_BEWONER_LABEL_KEY">-1</xsl:variable>
  <xsl:variable name="FacilitorRoot"><xsl:value-of select="//header/custId"/>.facilitorlabs.nl</xsl:variable>

  <xsl:template match="bezoeker" mode="badge">
    <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">
      <tr>
        <td colspan="2" style="text-align:center; font-size:30px; font-weight: bold; height:60px;"><xsl:value-of select="//lcl/BEZ/bezoeker"/></td>
      </tr>
      <tr>
        <td colspan="2" style="text-align:center; font-size:24px; font-weight: bold; height:30px;"><xsl:value-of select="naam"/></td>
      </tr>
      <xsl:if test="bedrijf!=''">
        <tr>
         <td colspan="2" style="text-align:center; font-size:16px; height:30px;"><xsl:value-of select="bedrijf"/></td>
        </tr>
      </xsl:if>
      <xsl:if test="pasnr!=''">
        <tr>
          <td colspan="2" style="text-align:center; font-size:24px; font-weight: bold; height:40px;"><xsl:value-of select="pasnr"/></td>
        </tr>
      </xsl:if>
      <tr>
        <td style="width: 50%;">&#160;</td>
        <td style="width: 50%; padding-top: 20px; text-align:right;">
          <xsl:element name="img">
            <xsl:attribute name="src">../../cust/<xsl:value-of select="//header/custId"/>/tmpl_logo.gif</xsl:attribute>
            <xsl:attribute name="style">width: 100%;</xsl:attribute>
          </xsl:element>
        </td>
      </tr>
    </TABLE>
  </xsl:template>

  <xsl:template match="melding" mode="evenement">
    <table border="0" width="100%" cellpadding="2">
        <tr>
            <td colspan="4" class="caption" style="padding-top:20px;padding-bottom:0px">
                <b>Werkbrief Evenementenbureau</b><br/><br/>
            </td>
        </tr>
        <tr>
            <td class="tekst">
                <b>Beteft:</b></td><td class="tekst">Reservering <xsl:value-of select="kenmerk[@naam='Reservering']/reservering/key"/></td>
        </tr>
        <tr>
            <td class="tekst">
                <b>Datum:</b></td><td class="tekst"><xsl:value-of select="datum_gepland/datum"/></td>
        </tr>
        <tr>
            <td class="tekst">
                <b>Naam bijeenkomst:</b></td><td class="tekst"><xsl:value-of select="kenmerk[@naam='Naam evenement']"/></td>
        </tr>
  			<tr>
  				<td class="tekst"><b>Contactpersoon:</b></td>
  				<td>
  					<xsl:value-of select="kenmerk[@naam='Contactpersoon']"/>
  				</td>
  			</tr>
  			<tr>
  				<td class="tekst"><b>Kenmerk klant:</b></td>
  				<td>
  					<xsl:value-of select="kenmerk[@naam='Referentie klant']"/>
  				</td>
  			</tr>
  			<tr>
  				<td class="tekst"><b>Factuuradres:</b></td>
  				<td>
  						<xsl:value-of select="kenmerk[@naam='Bedrijf']/bedrijf/naam"/>
  						<br/>T.a.v. <xsl:value-of select="kenmerk[@naam='Contactpersoon']"/><br/>
  						<xsl:value-of select="kenmerk[@naam='Bedrijf']/bedrijf/post_adres"/>
  						<br/>
  						<xsl:value-of select="kenmerk[@naam='Bedrijf']/bedrijf/post_postcode"/>,<xsl:text>&#xA0;</xsl:text>
  						<xsl:value-of select="kenmerk[@naam='Bedrijf']/bedrijf/post_plaats"/>
  						<xsl:text>&#xA0;</xsl:text>
  						<xsl:value-of select="kenmerk[@naam='Bedrijf']/bedrijf/post_land"/>
  				</td>
  			</tr>
        <tr>
            <td class="tekst">
                <b>Locatie:</b></td><td class="tekst"><xsl:for-each select="kenmerk[@naam='Reservering']/reservering/rsv_ruimte">
                    <xsl:if test="volgnr = 1">
                        <xsl:value-of select="res_ruimte/nr"/>
                    </xsl:if></xsl:for-each></td>
                    </tr>
                    <tr>
            <td class="tekst">
                <b>Subruimte:</b></td><td class="tekst">
                <xsl:for-each select="kenmerk[@naam='Reservering']/reservering/rsv_ruimte">
                    <xsl:sort select="volgnr"/>
                    <xsl:if test="volgnr != 1">
                        <xsl:if test="volgnr &gt; 2">/</xsl:if>
                        <xsl:value-of select="res_ruimte/nr"/>
                    </xsl:if>
                </xsl:for-each>
            </td>
        </tr>
        <tr>
          <td class="tekst"><b>Kostenplaats:</b></td><td class="tekst"><xsl:value-of select="kostenplaats/nr"/></td>
        </tr>
        <tr>
          <td class="tekst"><b>Opdrachtgever:</b></td><td class="tekst"><xsl:value-of select="voor/naam_full"/></td>
        </tr>
        <tr>
          <td class="tekst"><b>Telefoon:</b></td><td class="tekst"><xsl:value-of select="voor/telefoonnr"/></td>
        </tr>
        <tr>
            <td class="tekst">
                <b>Aantal personen:</b></td><td class="tekst"><xsl:value-of select="kenmerk[@naam='Reservering']/reservering/rsv_ruimte/bezoekers"/></td>
        </tr>
        <tr>
          <td class="tekst"><b>Totaalprijs:</b></td>
          <td class="tekst" style="text-align:left">
            <xsl:call-template name="europrijs">
              <xsl:with-param name="prijs" select="sum(kenmerk[@naam='Reservering']/reservering/rsv_ruimte/prijs[string(number(.))!='NaN'])+sum(kenmerk[@naam='Reservering']/reservering/rsv_ruimte/rsv_deel/prijs[string(number(.))!='NaN'])+sum(kenmerk[@naam='Reservering']/reservering/rsv_ruimte/rsv_artikel/prijs[string(number(.))!='NaN'])+sum(kenmerk[@naam='Reservering']/reservering/rsv_ruimte/melding/opdracht/kosten[string(number(.))!='NaN'])"/>
            </xsl:call-template>
          </td>
        </tr>
        <tr>
          <td class="tekst"><b>Programma:</b></td>
          <td class="tekst">
            <xsl:call-template name="linebreaks">
              <xsl:with-param name="string" select="kenmerk[@naam='Programmatijden']"/>
            </xsl:call-template>
          </td>
        </tr>
        <tr>
            <td colspan="4" height="10px">
            </td>
        </tr>
        <xsl:for-each select="kenmerk[@naam='Reservering']/reservering/rsv_ruimte">
        <xsl:sort select="volgnr" data-type="number"/>
                    <xsl:sort select="van/timestamp" data-type="number"/>
            <tr><td colspan="4"><hr/></td></tr>
                            <tr>
            <td colspan="3" class="caption">
                <b><xsl:value-of select="res_ruimte/nr"/></b>&#xA0;<xsl:value-of select="van/datum"/>&#xA0;<xsl:value-of select="van/tijd"/>-<xsl:value-of select="tot/tijd"/></td>
        </tr>
        <tr>
            <td colspan="3" class="tekst">
                <b>Opstelling:</b>&#xA0;<xsl:value-of select="res_ruimte/opstelling"/>&#xA0;<xsl:value-of select="bezoekers"/>&#xA0;personen</td>
                            <td class="tekst" style="text-align:right">
                <xsl:call-template name="europrijs">
                  <xsl:with-param name="prijs" select="prijs[string(number(.))!='NaN']"/>
      </xsl:call-template>
            </td>
        </tr>
        <tr>
            <td colspan="3" class="tekst">
                <b>Omschrijving:</b>&#xA0;<xsl:value-of select="omschrijving"/></td>
                            <td class="tekst" style="text-align:right">&#xA0;</td>
        </tr>
        <tr>
          <td colspan="4" class="tekst">
                    <xsl:call-template name="linebreaks">
                        <xsl:with-param name="string" select="opmerking"/>
                    </xsl:call-template>
            </td>
        </tr>
        <xsl:if test="sum(rsv_artikel/key) &gt; 0">
        <tr>
            <td colspan="4" class="tekst">
                <b>Catering Hutten(voor rekening gebruiker):</b>&#xA0;</td>
        </tr>
        <tr>
            <td colspan="4">
                <table>
                    <!-- rsv_artikel-lijst gesorteerd op van-tijd -->
                    <tr>
                        <th>Omschrijving</th>
                        <th>Aantal</th>
                        <th style="text-align:right">Prijs</th>
                        <th style="text-align:right">Tijdstip</th>
                        <th>Zaal</th>
                    </tr>
                    <xsl:for-each select="rsv_artikel">
                        <xsl:sort select="levering/tijd"/>
                        <tr>
                            <td class="result">
                                <xsl:value-of select="res_artikel/omschrijving"/>
                            </td>
                            <td class="result" style="text-align:right">
                                <xsl:value-of select="aantal"/>
                            </td>
                            <td class="result" style="text-align:right">
                                <xsl:call-template name="europrijs">
                                    <xsl:with-param name="prijs" select="prijs"/>
                                </xsl:call-template>
                            </td>

                            <!--<td class="result" style="text-align:right">
      <xsl:value-of select="levering/datum"/>
    </td>-->
                            <td class="result" style="text-align:right">
                                <xsl:value-of select="levering/tijd"/>
                            </td>
                            <td class="result">
                                <xsl:value-of select="../res_ruimte/nr"/>
                            </td>
                        </tr>
                    </xsl:for-each>
                </table>
            </td>
        </tr>
        <tr>
            <td colspan="3" class="tekst">
                Totaalprijs catering:
            </td>
            <td class="tekst" style="text-align:right">
                <xsl:call-template name="europrijs">
                  <xsl:with-param name="prijs" select="sum(rsv_deel/prijs[string(number(.))!='NaN'])+sum(rsv_artikel/prijs[string(number(.))!='NaN'])"/>
      </xsl:call-template>
            </td>
        </tr>
        </xsl:if>
        <tr>
            <td colspan="4" height="10px">
            </td>
        </tr>
        <xsl:if test="sum(rsv_deel/key) &gt; 0">
        <tr>
            <td colspan="4" class="tekst">
                <b>Standaard backoffice voorzieningen:</b>&#xA0;<xsl:if test="sum(rsv_deel/aantal[string(number(.))!='NaN'])"/></td>
        </tr>
        <tr>
            <td colspan="4">
                <table>
                    <!-- rsv_artikel-lijst gesorteerd op van-tijd -->
                    <tr>
                        <th>Omschrijving</th>
                        <th style="text-align:right">Prijs</th>
                        <th style="text-align:right">Begin</th>
                        <th style="text-align:right">Einde</th>
                        <th>Zaal</th>
                    </tr>
                    <xsl:for-each select="rsv_deel">
                        <xsl:sort select="van/tijd"/>
                        <tr>
                            <td class="result">
                                <xsl:if test="dirtlevel!='0'">
                                    <span class="fatal">
                                        <xsl:value-of select="//lcl/RES/ongeldig"/>
                                    </span>&#xA0;</xsl:if>
                                <xsl:value-of select="res_deel/deel/omschrijving"/>
                            </td>
                            <td class="result" style="text-align:right">
                                <xsl:call-template name="europrijs">
                                    <xsl:with-param name="prijs" select="prijs"/>
                                </xsl:call-template>
                            </td>
                            <!--<td class="result" style="text-align:right">
      <xsl:value-of select="van/datum"/>
    </td>-->
                            <td class="result" style="text-align:right">
                                <xsl:value-of select="van/tijd"/>
                            </td>
                            <td class="result" style="text-align:right">
                                <xsl:value-of select="tot/tijd"/>
                            </td>
                            <td class="result">
                                <xsl:value-of select="../res_ruimte/nr"/>
                            </td>
                        </tr>
                    </xsl:for-each>
                </table>
            </td>
        </tr>
        </xsl:if>

        <tr>
            <td colspan="4" class="tekst" style="font-size:13pt">
                <b>Meldingen:</b>&#xA0;
            </td>
        </tr>
        <xsl:for-each select="melding">
        <tr>
            <td colspan="4" class="tekst">
                <i><b>Melding: <xsl:value-of select="stdmelding/discipline/srtdiscipline/prefix"/><xsl:value-of select="key"/> - <xsl:value-of select="stdmelding/omschrijving"/></b></i>
            </td>
        </tr>
        <tr>
            <td colspan="4" class="tekst">
                Plaats: <xsl:value-of select="../res_ruimte/nr"/>
            </td>
        </tr>
            <xsl:if test="omschrijving">
                <tr>
                    <td colspan="4" class="tekst">Omschrijving:<br/>
                        <xsl:call-template name="linebreaks">
                            <xsl:with-param name="string" select="omschrijving"/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="opmerking">
                <tr>
                    <td colspan="4" class="tekst">Afhandeling:<br/>
                        <xsl:call-template name="linebreaks">
                            <xsl:with-param name="string" select="opmerking"/>
                        </xsl:call-template><br/>
                    </td>
                </tr>
            </xsl:if>
            <xsl:for-each select="kenmerk[@type!='L' and @type!='Q' and count(@xmlnode)=0]">
            <xsl:sort select="@volgnummer" data-type="number"/>
                <xsl:if test=".!='' and (../discipline/srtdiscipline/key != 4 or @volgnummer &lt; 101) and substring(@naam, 1, 9) != 'Actiepunt'">
                <tr>
                    <td align="right" colspan="4" class="tekst">
                        <xsl:value-of select="@naam"/>:&#xA0;<xsl:value-of select="."/>
                    </td>
                </tr>
                </xsl:if>
            </xsl:for-each>
            <tr>
                <td colspan="4" height="10px">
                </td>
            </tr>
        </xsl:for-each>

        <tr>
            <td colspan="4" height="10px">
            </td>
        </tr>
        <tr>
            <td colspan="4" class="tekst" style="font-size:13pt">
                <b>Opdrachten externe bedrijven:</b>&#xA0;
            </td>
        </tr>
        <xsl:for-each select="melding/opdracht">
        <tr>
            <td colspan="3" class="tekst">
                <i><b>Opdracht: <xsl:value-of select="../key"/>/<xsl:value-of select="bedrijfopdr_volgnr"/> aan <xsl:value-of select="uitvoerende/bedrijf/naam"/></b></i>
            </td>
            <td class="tekst" style="text-align:right">
                <xsl:call-template name="europrijs">
                    <xsl:with-param name="prijs" select="kosten"/>
                </xsl:call-template>
            </td>
        </tr>

            <xsl:if test="omschrijving">
                <tr>
                    <td colspan="4" class="tekst">Omschrijving:<br/>
                        <xsl:call-template name="linebreaks">
                            <xsl:with-param name="string" select="omschrijving"/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="opmerking">
                <tr>
                    <td colspan="4" class="tekst">Afhandeling:<br/>
                        <xsl:call-template name="linebreaks">
                            <xsl:with-param name="string" select="opmerking"/>
                        </xsl:call-template><br/>
                    </td>
                </tr>
            </xsl:if>
            <xsl:for-each select="kenmerk[@type!='L' and @type!='Q' and count(@xmlnode)=0]">
            <xsl:sort select="@volgnummer" data-type="number"/>
                <xsl:if test=".!='' and (../discipline/srtdiscipline/key != 4 or @volgnummer &lt; 101) and substring(@naam, 1, 9) != 'Actiepunt'">
                <tr>
                    <td align="right" colspan="4" class="tekst">
                        <xsl:value-of select="@naam"/>:&#xA0;<xsl:value-of select="."/>
                    </td>
                </tr>
                </xsl:if>
            </xsl:for-each>
        </xsl:for-each>
                    </xsl:for-each>
        <tr>
            <td colspan="4" height="30px">
            </td>
        </tr>
        <tr>
            <td colspan="3" class="tekst">
                <b>Totaalprijs evenement:</b>
            </td>
            <td class="tekst" style="text-align:right"><b>
                <xsl:call-template name="europrijs">
                  <xsl:with-param name="prijs" select="sum(kenmerk[@naam='Reservering']/reservering/rsv_ruimte/prijs[string(number(.))!='NaN'])+
                                                                             sum(kenmerk[@naam='Reservering']/reservering/rsv_ruimte/rsv_deel/prijs[string(number(.))!='NaN'])+
                                                                                                                 sum(kenmerk[@naam='Reservering']/reservering/rsv_ruimte/rsv_artikel/prijs[string(number(.))!='NaN'])+
                                                                                                                 sum(kenmerk[@naam='Reservering']/reservering/rsv_ruimte/melding/opdracht/kosten[string(number(.))!='NaN'])"/>
      </xsl:call-template>
            </b>
            </td>
        </tr>
    </table>
</xsl:template>

  <xsl:template match="melding" mode="full">
    <xsl:choose>
      <xsl:when test="$mode='summary'"></xsl:when>
    <xsl:otherwise>
    <html>
      <xsl:comment>================================ MELDINGEN ==============================</xsl:comment>
      <xsl:comment>FACILITOR 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:when test="stdmelding/key = '1241'">
            <p>Dienstrapport van <xsl:value-of select="melder/naam_full"/></p>
              <table cellspacing="2">
              <tr><td>Aanmaak rapport: </td><td><xsl:value-of select="begindatum/datum"/>&#160;<xsl:value-of select="begindatum/tijd"/></td></tr>
              <xsl:for-each select="tracking/track">
                 <xsl:if test="code='MLDAFM'">
                   <tr><td>Afsluiten rapport: </td><td><xsl:value-of select="datum/datum"/>&#160;<xsl:value-of select="datum/tijd"/></td></tr>
                 </xsl:if>
              </xsl:for-each>
              </table>
              <hr/>
              <table cellspacing="10">
              <xsl:for-each select="notes/note">
              <xsl:sort select="aanmaak"/>
                <tr>
                  <td><xsl:value-of select="aanmaak/tijd"/></td>
                  <td>
                    <xsl:call-template name="linebreaks">
                      <xsl:with-param name="string" select="omschrijving"/>
                    </xsl:call-template>
                  </td>
                </tr>
              </xsl:for-each>
              </table>
            </xsl:when>
            <xsl:when test="stdmelding/key = '1481'">
              <xsl:apply-templates select="." mode="evenement"/>
            </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:key name="jaar" match="//facilitor/rapport/rapport_data/data_row" use="FCLT_F_AANSCHAFJAAR"/>
   <xsl:key name="regel" match="//facilitor/rapport/rapport_data/data_row" use="HIDE_F_REGEL"/>

   <xsl:template match="rapport">

      <xsl:if test="@view='curs_v_rap_infobord' or @view='CURS_V_RAP_INFOBORD'">
         <html>
            <head>

               <style>th {
      border: 0px solid #c08080;
    }

    th.DefResultsetHeading {
      padding:  3px;
      background-color: #004F80;
      font-family: Verdana;
      font-size: 12pt;
      color: #FFF;
    }
    td.header {
      font-family: Verdana;
      padding:  3px;
      font-size: 16pt;
      font-weight: bold;
      color: #000;
      vertical-align: bottom;
    }
    td.content {
      font-family: Verdana;
      padding:  3px;
      font-size: 12pt;
     vertical-align: top;
      background-color: #fff;
      border-bottom-style: solid;
      border-bottom-width: 1px;
      border-bottom-color: #888;
    }
    body {
      margin-top:  3px;
      margin-bottom: 3px;
      margin-left:  15px;
      margin-right: 3px;
    }</style>

               <script language="javascript">var count=1;
function startAutoRefreshTim() {
  // verwijder scrollbar
  parent.document.body.style.overflow="hidden";
  return;
}</script>
            </head>

            <xsl:variable name="gebouw">
               <xsl:if test="contains(where,'gebouw')">
                  <xsl:for-each select="rapport_data/data_row">
                     <xsl:if test="position()=1">
                        <xsl:value-of select="GEBOUW_OMSCHRIJVING"/>
                     </xsl:if>
                  </xsl:for-each>
               </xsl:if>
            </xsl:variable>

            <body onLoad="startAutoRefreshTim();parent.Activate();">
               <table width="90%" style="margin: 50px 5% 0 5%">
                  <tr>
                     <td class="header" width="100%">Reserveringen en Bezoekers<xsl:value-of select="$gebouw"/></td>
                     <td>
                        <xsl:element name="img">
                           <xsl:attribute name="src">../../cust/<xsl:value-of select="//header/custId"/>/tmpl_logo.gif</xsl:attribute>
                        </xsl:element>
                     </td>
                  </tr>
               </table>

               <xsl:variable name="ruimten">
                  <xsl:for-each select="rapport_data/data_row">
                     <xsl:sort select="RUIMTE"/>
                     <xsl:sort select="TIJD_VAN"/>
                     <xsl:sort select="ITEM_KEY"/>
                     <xsl:if test="OFFSET &lt; 3000 or AKTIEF='active'">
                        <xsl:if test="ITEM_TYPE='RES'">
                           <xsl:copy-of select="."/>
                        </xsl:if>
                     </xsl:if>
                  </xsl:for-each>
               </xsl:variable>

               <xsl:variable name="ruimte_bezoekers">
                  <xsl:for-each select="rapport_data/data_row">
                     <xsl:sort select="ITEM_KEY"/>
                     <xsl:if test="OFFSET &gt; -480 and OFFSET &lt; 480 and BEZOEK_STATUS='expected'">
                        <xsl:if test="ITEM_TYPE='RES'">
                           <xsl:copy-of select="."/>
                        </xsl:if>
                     </xsl:if>
                  </xsl:for-each>
               </xsl:variable>

               <xsl:variable name="bezoekers">
                  <xsl:for-each select="rapport_data/data_row">
                     <xsl:sort select="TIJD_VAN"/>
                     <xsl:sort select="ITEM_KEY"/>
                     <xsl:if test="OFFSET &gt; -480 and OFFSET &lt; 480 and BEZOEK_STATUS='expected'">
                        <xsl:if test="ITEM_TYPE='BEZ'">
                           <xsl:copy-of select="."/>
                        </xsl:if>
                     </xsl:if>
                  </xsl:for-each>
               </xsl:variable>

               <xsl:variable name="bezoekers_bezoekers">
                  <xsl:for-each select="rapport_data/data_row">
                     <xsl:sort select="ITEM_KEY"/>
                     <xsl:if test="OFFSET &lt; 3000 or AKTIEF='active'">
                        <xsl:if test="ITEM_TYPE='BEZ'">
                           <xsl:copy-of select="."/>
                        </xsl:if>
                     </xsl:if>
                  </xsl:for-each>
               </xsl:variable>
               <table width="90%" style="margin: 0 5%" cellpadding="0" cellspacing="0">
                  <tr>
                     <th class="DefResultsetHeading" style="text-align:left">Ruimte</th>
                     <th class="DefResultsetHeading" style="text-align:left">Gastheer/-vrouw</th>
                     <th class="DefResultsetHeading" style="text-align:left">Van</th>
                     <th class="DefResultsetHeading" style="text-align:left">Tot</th>
                     <th class="DefResultsetHeading" style="text-align:left">Bezoeker</th>
                  </tr>

                  <xsl:for-each select="msxml:node-set($ruimten)/data_row">
                     <xsl:variable name="prev_ruimte">
                        <xsl:choose>
                           <xsl:when test="position()=1">Quqelequ</xsl:when>
                           <xsl:otherwise>
                              <xsl:value-of select="preceding-sibling::data_row[1]/RUIMTE"/>
                           </xsl:otherwise>
                        </xsl:choose>
                     </xsl:variable>

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

                     <xsl:variable name="rsv_ruimte">
                        <xsl:value-of select="ITEM_KEY"/>
                     </xsl:variable>

                     <xsl:choose>
                        <xsl:when test="ITEM_KEY = $prev_rsv_ruimte">
                        </xsl:when>
                        <xsl:otherwise>
                           <xsl:if test="RUIMTE != $prev_ruimte and position() != '1'">
                              <tr>
                                 <td height="2"></td>
                              </tr>
                           </xsl:if>
                           <tr>
                              <td class="content">
                                 <xsl:if test="RUIMTE != $prev_ruimte">
                                    <b>
                                       <xsl:value-of select="RUIMTE"/>
                                    </b>
                                 </xsl:if>&#xA0;</td>
                              <td class="content">
                                 <xsl:value-of select="GASTHEER"/>
                              </td>
                              <td class="content">
                                 <xsl:value-of select="TIJD_VAN"/>
                              </td>
                              <td class="content">
                                 <xsl:value-of select="TIJD_TOT"/>
                              </td>
                              <td class="content">
                                 <xsl:for-each select="msxml:node-set($ruimte_bezoekers)/data_row">
                                    <xsl:variable name="prev_rsv_ruimte2">
                                       <xsl:choose>
                                          <xsl:when test="position()=1">Quqelequ</xsl:when>
                                          <xsl:otherwise>
                                             <xsl:value-of select="preceding-sibling::data_row[1]/ITEM_KEY"/>
                                          </xsl:otherwise>
                                       </xsl:choose>
                                    </xsl:variable>
                                    <xsl:if test="ITEM_KEY = $rsv_ruimte">
                                       <xsl:if test="ITEM_KEY = $prev_rsv_ruimte2">
                                          <br/>
                                       </xsl:if>

                                       <xsl:value-of select="BEZOEKER"/>
                                       <xsl:if test="BEDRIJF!=''">&#xA0;(<xsl:value-of select="BEDRIJF"/>)</xsl:if>
                                    </xsl:if>
                                 </xsl:for-each>&#xA0;</td>
                           </tr>
                        </xsl:otherwise>
                     </xsl:choose>
                  </xsl:for-each>

                  <xsl:for-each select="msxml:node-set($bezoekers)/data_row">
                     <xsl:variable name="afspraak">
                        <xsl:value-of select="ITEM_KEY"/>
                     </xsl:variable>
                     <xsl:variable name="prev_afspraak">
                        <xsl:choose>
                           <xsl:when test="position()=1">Quqelequ</xsl:when>
                           <xsl:otherwise>
                              <xsl:value-of select="preceding-sibling::data_row[1]/ITEM_KEY"/>
                           </xsl:otherwise>
                        </xsl:choose>
                     </xsl:variable>
                     <xsl:if test="position()=1">
                        <tr>
                           <td height="50" class="header" colspan="5" width="100%">Overige bezoekers<xsl:value-of select="$gebouw"/></td>
                        </tr>
                        <tr>
                           <th class="DefResultsetHeading" style="text-align:left">Bezoeker</th>
                           <th class="DefResultsetHeading" style="text-align:left">Gastheer/-vrouw</th>
                           <th class="DefResultsetHeading" style="text-align:left">Van</th>
                           <th class="DefResultsetHeading" style="text-align:left">Tot</th>
                           <th class="DefResultsetHeading" style="text-align:left">&#xA0;</th>
                        </tr>
                     </xsl:if>
                     <xsl:if test="$prev_afspraak != $afspraak">
                        <xsl:if test="position() != '1'">
                           <tr>
                              <td height="2"></td>
                           </tr>
                        </xsl:if>
                        <tr>
                           <td class="content">
                              <xsl:for-each select="msxml:node-set($bezoekers_bezoekers)/data_row">
                                 <xsl:variable name="prev_afspraak2">
                                    <xsl:choose>
                                       <xsl:when test="position()=1">Quqelequ</xsl:when>
                                       <xsl:otherwise>
                                          <xsl:value-of select="preceding-sibling::data_row[1]/ITEM_KEY"/>
                                       </xsl:otherwise>
                                    </xsl:choose>
                                 </xsl:variable>
                                 <xsl:if test="ITEM_KEY = $afspraak">
                                    <xsl:if test="ITEM_KEY = $prev_afspraak2">
                                       <br/>
                                    </xsl:if>

                                    <xsl:value-of select="BEZOEKER"/>
                                    <xsl:if test="BEDRIJF!=''">&#xA0;(<xsl:value-of select="BEDRIJF"/>)</xsl:if>
                                 </xsl:if>
                              </xsl:for-each>&#xA0;</td>
                           <td class="content">
                              <xsl:value-of select="GASTHEER"/>
                           </td>
                           <td class="content">
                              <xsl:value-of select="TIJD_VAN"/>
                           </td>
                           <td class="content">
                              <xsl:value-of select="TIJD_TOT"/>
                           </td>
                           <td class="content">
                              <xsl:value-of select="OMSCHRIJVING"/>&#xA0;</td>

                        </tr>
                     </xsl:if>
                  </xsl:for-each>
               </table>
               <input type="hidden" name="timeID2" value="-1"/>
            </body>
         </html>
      </xsl:if>

      <xsl:if test="@view='curs_v_info_loc_overzicht' or @view='CURS_V_INFO_LOC_OVERZICHT'">
         <html>
            <head>

               <style>th {
      border: 0px solid #c08080;
    }

    th.DefResultsetHeading {
      padding:  3px;
      background-color: #004f80;
      font-family: Verdana;
      font-size: 12pt;
      color: #fff;
    }
    td {
      font-family: Verdana;
      padding:  3px;
      font-size: 12pt;
      border-bottom-style: solid;
      border-bottom-width: 1px;
      border-bottom-color: #c0c0c0;
    }
    body {
      margin-top:  3px;
      margin-bottom: 3px;
      margin-left:  15px;
      margin-right: 3px;
    }</style>

               <script language="javascript">var count=1;
function startAutoRefreshTim() {
  // verwijder scrollbar
  parent.document.body.style.overflow="hidden";
  return;
}</script>
            </head>
            <body onLoad="startAutoRefreshTim();parent.Activate();">
               <br/>
               <xsl:element name="img">
                  <xsl:attribute name="src">../../cust/<xsl:value-of select="//header/custId"/>/tmpl_logo.gif</xsl:attribute>
               </xsl:element>
               <br/>
               <br/>
               <table width="100%" cellpadding="0" cellspacing="0">
                  <tr>
                     <th class="DefResultsetHeading" style="text-align:left">Reserveringsstatus</th>
                     <th class="DefResultsetHeading" style="text-align:left">Aanvang</th>
                     <th class="DefResultsetHeading" style="text-align:left">Einde</th>
                     <th class="DefResultsetHeading" style="text-align:left">Zaal</th>
                     <th class="DefResultsetHeading" style="text-align:left">Omschrijving</th>
                  </tr>

                  <xsl:variable name="sorted">
                     <xsl:for-each select="rapport_data/data_row">
                        <xsl:sort select="TIJD_VAN"/>
                        <xsl:sort select="TIJD_TOT"/>
                        <xsl:sort select="RUIMTE"/>
                        <xsl:if test="OFFSET &lt; 30 or AKTIEF='active'">
                        <xsl:copy-of select="."/>
                        </xsl:if>
                     </xsl:for-each>
                  </xsl:variable>


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

                        <xsl:element name="tr">
                           <xsl:attribute name="id">tr<xsl:value-of select="position()"/></xsl:attribute>
                           <td>
                              <xsl:choose>
                                 <xsl:when test="AKTIEF='active'">Begonnen</xsl:when>
                                 <xsl:when test="AKTIEF='passed'">Afgelopen</xsl:when>
                                 <xsl:when test="AKTIEF='expected'">
                                    <xsl:if test="BOARDING=1">Zaal betreden</xsl:if>
                                    <xsl:if test="BOARDING=0">Bijna begonnen</xsl:if>
                                 </xsl:when>
                              </xsl:choose>
                           </td>
                           <td>
                              <xsl:value-of select="TIJD_VAN"/>
                           </td>
                           <td>
                              <xsl:value-of select="TIJD_TOT"/>
                           </td>
                           <td>
                              <xsl:value-of select="RUIMTE"/>
                           </td>
                           <td>
                              <xsl:value-of select="OMSCHRIJVING"/>&#xA0;</td>
                        </xsl:element>

                  </xsl:for-each>
               </table>
               <input type="hidden" name="timeID2" value="-1"/>
            </body>
         </html>
      </xsl:if>

      <xsl:if test="@view='demo_v_rap_it_inventaris_jaar'">
         <table width="100%" class="DefResultsetTable" cellpadding="0" cellspacing="0">
            <thead>
               <tr>
                  <th style="text-align: left">Onderdeel</th>
                  <th style="text-align: left">Rubriek</th>
                  <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[generate-id(.)=generate-id(key('jaar',FCLT_F_AANSCHAFJAAR)[1])]">
                     <xsl:sort select="FCLT_F_AANSCHAFJAAR"/>
                     <th style="text-align: right">
                        <xsl:value-of select="FCLT_F_AANSCHAFJAAR"/>
                     </th>
                  </xsl:for-each>
                  <th style="text-align: right">Totaal</th>
               </tr>
            </thead>
            <tbody>
               <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[generate-id(.)=generate-id(key('regel',HIDE_F_REGEL)[1])]">
                  <xsl:sort select="HIDE_F_REGEL"/>
                  <xsl:variable name="regelaantal">
                     <xsl:value-of select="sum(key('regel', HIDE_F_REGEL)/AANTAL)"/>
                  </xsl:variable>
                  <xsl:if test="$regelaantal!=0">
                     <tr>
                        <td>
                           <xsl:value-of select="FCLT_F_ORGANISATIE"/>
                        </td>
                        <td>
                           <xsl:value-of select="FCLT_F_CATEGORIE"/>
                        </td>
                        <xsl:for-each select="key('regel', HIDE_F_REGEL)">
                           <xsl:sort select="FCLT_F_AANSCHAFJAAR"/>
                           <td style="text-align: right">
                              <xsl:if test="AANTAL!=0">
                                 <xsl:value-of select="AANTAL"/>
                              </xsl:if>
                           </td>
                        </xsl:for-each>
                        <!--td style="text-align: right"><xsl:value-of select="sum(key('regel', HIDE_F_REGEL)/AANTAL)"/></td-->
                        <td style="text-align: right"><xsl:value-of select="$regelaantal"/></td>
                     </tr>
                  </xsl:if>
               </xsl:for-each>
            </tbody>
            <tfoot>
               <tr>
                  <th colspan="2" style="text-align: left">Totaal</th>
                  <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[generate-id(.)=generate-id(key('jaar',FCLT_F_AANSCHAFJAAR)[1])]">
                     <xsl:sort select="FCLT_F_AANSCHAFJAAR"/>
                     <th style="text-align: right">
                        <xsl:value-of select="sum(key('jaar', FCLT_F_AANSCHAFJAAR)/AANTAL)"/>
                     </th>
                  </xsl:for-each>
                  <th style="text-align: right"><xsl:value-of select="sum(//AANTAL)"/></th>
               </tr>
            </tfoot>
         </table>
      </xsl:if>

      <xsl:if test="translate(@view, $smallcase, $uppercase)='DEMO_V_RAP_MJB_GRID'">

               <table width="100%" class="DefResultsetTable" cellpadding="0" cellspacing="0">
                  <thead>
                     <tr>
                        <th style="text-align: left">Locatie</th>
                        <th style="text-align: left">Categorie</th>
                        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[generate-id(.)=generate-id(key('jaar',FCLT_F_AANSCHAFJAAR)[1])]">
                           <xsl:sort select="FCLT_F_AANSCHAFJAAR"/>
                           <th style="text-align: right">
                              <xsl:value-of select="FCLT_F_AANSCHAFJAAR"/>
                           </th>
                        </xsl:for-each>
                        <th style="text-align: right">Totaal</th>
                     </tr>
                  </thead>
                  <tbody>
                     <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[generate-id(.)=generate-id(key('regel',HIDE_F_REGEL)[1])]">
                        <xsl:sort select="HIDE_F_REGEL"/>
                        <xsl:variable name="regelbedrag">
                           <xsl:value-of select="sum(key('regel', HIDE_F_REGEL)/BEDRAG)"/>
                        </xsl:variable>
                        <xsl:if test="$regelbedrag!=0">
                           <tr>
                              <td>
                                 <xsl:value-of select="FCLT_F_LOCATIE"/>
                              </td>
                              <td>
                                 <xsl:value-of select="FCLT_F_CATEGORIE"/>
                              </td>
                              <xsl:for-each select="key('regel', HIDE_F_REGEL)">
                                 <xsl:sort select="FCLT_F_AANSCHAFJAAR"/>
                                 <td style="text-align: right">
                                    <xsl:if test="BEDRAG!=0">
                                       <xsl:value-of select="format-number(BEDRAG, '#,#', 'euro')"/>
                                    </xsl:if>
                                 </td>
                              </xsl:for-each>
                              <!--td style="text-align: right"><xsl:value-of select="sum(key('regel', HIDE_F_REGEL)/BEDRAG)"/></td-->
                              <td style="text-align: right"><xsl:value-of select="format-number($regelbedrag, '#.###,#', 'euro')"/></td>
                           </tr>
                        </xsl:if>
                     </xsl:for-each>
                  </tbody>
                  <tfoot>
                     <tr>
                        <th colspan="2" style="text-align: left">Totaal</th>
                        <xsl:for-each select="//facilitor/rapport/rapport_data/data_row[generate-id(.)=generate-id(key('jaar',FCLT_F_AANSCHAFJAAR)[1])]">
                           <xsl:sort select="FCLT_F_AANSCHAFJAAR"/>
                           <th style="text-align: right">
                              <xsl:value-of select="format-number(sum(key('jaar', FCLT_F_AANSCHAFJAAR)/BEDRAG), '#.###,#', 'euro')"/>
                           </th>
                        </xsl:for-each>
                        <th style="text-align: right"><xsl:value-of select="format-number(sum(//BEDRAG), '#.###,#', 'euro')"/></th>
                     </tr>
                  </tfoot>
               </table>

      </xsl:if>

      <xsl:if test="translate(@view, $smallcase, $uppercase)='DEMO_V_RAP_BEZ_OPROEP'">
        <style>
          .oproep-table {
            width: 90%;
            margin: 2em auto 2em auto;
            text-align: center;
            font-size: 3em;
          }
          .oproep-table th {
            padding: 0.2em;
          }
          .oproep-table td {
            border-bottom: 1px solid #ccc;
            padding: 1em;
          }
          .oproep-table td.oproep-nr {
            font-weight: bold;
          }
          .oproep-table td.new {
            font-weight: bold;
            background-color: #f1f1f1;
          }
        </style>
        <table class="oproep-table">
  		  	<tr>
  		  		<th>Nummer</th>
  		  		<th>Naar</th>
  		  	</tr>
  		  	<xsl:for-each select="rapport_data/data_row">
  		  		<xsl:sort select="HIDE_F_OPROEPTIJD" order="descending"/>
        		<tr>
        			<td class="oproep-nr"><xsl:value-of select="OPROEPNR"/></td>
        			<td class="oproep-ruimte"><xsl:value-of select="FCLT_F_RUIMTENR"/></td>
        		</tr>
  		  	</xsl:for-each>
        </table>
      </xsl:if>

   </xsl:template>

</xsl:stylesheet>