﻿<ViewDefinitions xmlns="http://www.windex.nl/schemas/viewdefinition/2007">
	<Views>
		<View Name="WebPartPage_OrganizationView" HiddenColumnIds="0;7;8;9;10;11" ColumnWidths="65px;125px;auto;auto;auto;auto"
			  DefaultOrderColumn="3">
			<Columns>
				<XsltColumn HeaderText="Lidmaatschappen" Ordinal="2">
					<Transform>
						<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
							<xsl:param name="date"/>
							<xsl:output method="html" indent="yes"/>
							<xsl:template match="/Row">
								<xsl:variable name="id" select="translate(concat(Column[@index='0']/., '_', Column[@name='ProductNames']/@index), '{-}', '')" />

								<div>
									<xsl:attribute name="onMouseLeave">
										<xsl:text>javascript:document.getElementById('</xsl:text>
										<xsl:value-of select="$id"/>
										<xsl:text>').style.display = 'none'</xsl:text>
									</xsl:attribute>
									<xsl:attribute name="onMouseEnter">
										<xsl:text>javascript:document.getElementById('</xsl:text>
										<xsl:value-of select="$id"/>
										<xsl:text>').style.display = ''</xsl:text>
									</xsl:attribute>

									<xsl:if test="Column[@name='ProductShortNames']/results/result">

										<!-- Actuele lidmaatschappen -->

										<xsl:call-template name="Icons">
											<xsl:with-param name="membershipEquals" select="'Algemeen'"/>
											<xsl:with-param name="transienceFilter" select="'wcc_Transience_Current'"/>
										</xsl:call-template>

										<xsl:call-template name="Icons">
											<xsl:with-param name="membershipEquals" select="'Aspirant'"/>
											<xsl:with-param name="transienceFilter" select="'wcc_Transience_Current'"/>
										</xsl:call-template>

										<xsl:call-template name="Icons">
											<xsl:with-param name="membershipStartsWith" select="'Lid_'"/>
											<xsl:with-param name="transienceFilter" select="'wcc_Transience_Current'"/>
										</xsl:call-template>
										
										<!-- Beëindigde lidmaatschappen -->

										<xsl:call-template name="Icons">
											<xsl:with-param name="membershipEquals" select="'Algemeen'"/>
											<xsl:with-param name="transienceFilter" select="'wcc_Transience_NotCurrent'"/>
										</xsl:call-template>

										<xsl:call-template name="Icons">
											<xsl:with-param name="membershipEquals" select="'Aspirant'"/>
											<xsl:with-param name="transienceFilter" select="'wcc_Transience_NotCurrent'"/>
										</xsl:call-template>

										<xsl:call-template name="Icons">
											<xsl:with-param name="membershipStartsWith" select="'Lid_'"/>
											<xsl:with-param name="transienceFilter" select="'wcc_Transience_NotCurrent'"/>
										</xsl:call-template>

									</xsl:if>
									
								</div>
								<div style="margin-top: 6px; position: absolute; padding: 5px; display: none; border-color: #777777; background-color: #EFEFEF; z-index: 999" class="wccButtonBar">
									<xsl:attribute name="id">
										<xsl:value-of select="$id"/>
									</xsl:attribute>

									<div style="padding-top: 3px;">
										<div style="display: inline-block; line-height: 20px; height: 20px; width: 22px;">
											<span></span>
										</div>
										<div style="display: inline-block; line-height: 20px; height: 20px; width: 200px;">
											<span style="color: gray">Lidmaatschap</span>
										</div>
										<div style="display: inline-block; line-height: 20px; height: 20px; width: 85px;">
											<span style="color: gray">Begindatum</span>
										</div>
										<div style="display: inline-block; line-height: 20px; height: 20px; width: 85px;">
											<span style="color: gray">Einddatum</span>
										</div>
									</div>

									<!-- Actuele lidmaatschappen -->

									<xsl:call-template name="PopupItems">
										<xsl:with-param name="membershipEquals" select="'Algemeen'"/>
										<xsl:with-param name="transienceFilter" select="'wcc_Transience_Current'"/>
									</xsl:call-template>

									<xsl:call-template name="PopupItems">
										<xsl:with-param name="membershipEquals" select="'Aspirant'"/>
										<xsl:with-param name="transienceFilter" select="'wcc_Transience_Current'"/>
									</xsl:call-template>

									<xsl:call-template name="PopupItems">
										<xsl:with-param name="membershipStartsWith" select="'Lid_'"/>
										<xsl:with-param name="transienceFilter" select="'wcc_Transience_Current'"/>
									</xsl:call-template>

									<!-- Beëindigde lidmaatschappen -->

									<xsl:call-template name="PopupItems">
										<xsl:with-param name="membershipEquals" select="'Algemeen'"/>
										<xsl:with-param name="transienceFilter" select="'wcc_Transience_NotCurrent'"/>
									</xsl:call-template>

									<xsl:call-template name="PopupItems">
										<xsl:with-param name="membershipEquals" select="'Aspirant'"/>
										<xsl:with-param name="transienceFilter" select="'wcc_Transience_NotCurrent'"/>
									</xsl:call-template>

									<xsl:call-template name="PopupItems">
										<xsl:with-param name="membershipStartsWith" select="'Lid_'"/>
										<xsl:with-param name="transienceFilter" select="'wcc_Transience_NotCurrent'"/>
									</xsl:call-template>
								
								</div>

							</xsl:template>

							<xsl:template name="Icons">
								<xsl:param name="membershipEquals"/>
								<xsl:param name="membershipStartsWith"/>
								<xsl:param name="transienceFilter"/>
								<xsl:for-each select="Column[@name='ProductShortNames']/results/result">

									<xsl:if test="($membershipEquals != '' and value/. = $membershipEquals) or ($membershipStartsWith != '' and starts-with(value/., $membershipStartsWith))">

										<xsl:variable name="pos">
											<xsl:value-of select="number(position())"/>
										</xsl:variable>
										<xsl:variable name="endDate">
											<xsl:value-of select="../../../Column[@name='MembershipEndDates']/results/result[position()=$pos]/value/."/>
										</xsl:variable>
										<xsl:variable name="transience">
											<xsl:call-template name="Transience">
												<xsl:with-param name="endDate" select="$endDate"/>
											</xsl:call-template>
										</xsl:variable>

										<xsl:if test="$transience = $transienceFilter">
											<img>
												<xsl:attribute name="src">
													<xsl:value-of select="concat('/intranet/Afbeeldingen/BusinessObjectView/', value/., '.png')"/>
												</xsl:attribute>
												<xsl:attribute name="alt">
													<xsl:value-of select="value/."/>
												</xsl:attribute>

												<xsl:choose>
													<xsl:when test="$transience = 'wcc_Transience_NotCurrent'">
														<xsl:attribute name="style">
															<xsl:text>
															height: 16px; padding-left: 5px;;
															opacity: 0.5; 
															-webkit-filter: grayscale(100%); -moz-filter: grayscale(100%); -o-filter: grayscale(100%); -ms-filter: grayscale(100%); filter: grayscale(100%);
														</xsl:text>
														</xsl:attribute>
													</xsl:when>
													<xsl:otherwise>
														<xsl:attribute name="style">
															<xsl:text>height: 16px; padding-left: 5px;</xsl:text>
														</xsl:attribute>
													</xsl:otherwise>
												</xsl:choose>
											</img>
										</xsl:if>

									</xsl:if>
									
								</xsl:for-each>
								
							</xsl:template>

							<xsl:template name="PopupItems">
								<xsl:param name="membershipEquals"/>
								<xsl:param name="membershipStartsWith"/>
								<xsl:param name="transienceFilter"/>
								<xsl:for-each select="Column[@name='ProductShortNames']/results/result">

									<xsl:if test="($membershipEquals != '' and value/. = $membershipEquals) or ($membershipStartsWith != '' and starts-with(value/., $membershipStartsWith))">
							
										<xsl:variable name="pos">
											<xsl:value-of select="number(position())"/>
										</xsl:variable>
										<xsl:variable name="membershipTypeName">
											<xsl:value-of select="../../../Column[@name='ProductNames']/results/result[position()=$pos]/value/."/>
										</xsl:variable>
										<xsl:variable name="startDate">
											<xsl:value-of select="../../../Column[@name='MembershipStartDates']/results/result[position()=$pos]/value/."/>
										</xsl:variable>
										<xsl:variable name="endDate">
											<xsl:value-of select="../../../Column[@name='MembershipEndDates']/results/result[position()=$pos]/value/."/>
										</xsl:variable>

										<xsl:variable name="transience">
											<xsl:call-template name="Transience">
												<xsl:with-param name="endDate" select="$endDate"/>
											</xsl:call-template>
										</xsl:variable>

										<xsl:if test="$transience = $transienceFilter">

											<div>

												<div style="display: inline-block; width: 22px;">
													<img>
														<xsl:attribute name="src">
															<xsl:value-of select="concat('/intranet/Afbeeldingen/BusinessObjectView/', value/., '.png')"/>
														</xsl:attribute>
														<xsl:attribute name="alt">
															<xsl:value-of select="value/."/>
														</xsl:attribute>
														<xsl:choose>
															<xsl:when test="$transience = 'wcc_Transience_NotCurrent'">
																<xsl:attribute name="style">
																	<xsl:text>
																		display: inline-block; height: 16px; padding-left: 5px;
																		opacity: 0.5; 
																		-webkit-filter: grayscale(100%); -moz-filter: grayscale(100%); -o-filter: grayscale(100%); -ms-filter: grayscale(100%); filter: grayscale(100%);
																	</xsl:text>
																</xsl:attribute>
															</xsl:when>
															<xsl:otherwise>
																<xsl:attribute name="style">
																	<xsl:text>display: inline-block; height: 16px; padding-left: 5px;</xsl:text>
																</xsl:attribute>
															</xsl:otherwise>
														</xsl:choose>
													</img>
												</div>

												<div style="display: inline-block; line-height: 20px; height: 20px; width: 200px;">
													<xsl:attribute name="class">
														<xsl:value-of select="$transience"/>
													</xsl:attribute>
													<xsl:value-of select="$membershipTypeName"/>
												</div>

												<div style="display: inline-block; line-height: 20px; height: 20px; width: 85px;">
													<xsl:attribute name="class">
														<xsl:value-of select="$transience"/>
													</xsl:attribute>
													<!-- Begindatum transformeren van 2021-01-27T12:34:56 naar 27-01-2021 -->
													<xsl:if test="$startDate != ''">
														<xsl:variable name="day">
															<xsl:value-of select="substring-before(substring-after(substring-after($startDate, '-'), '-'), 'T')"/>
														</xsl:variable>
														<xsl:variable name="month">
															<xsl:value-of select="substring-before(substring-after($startDate, '-'), '-')"/>
														</xsl:variable>
														<xsl:variable name="year">
															<xsl:value-of select="substring-before($startDate, '-')"/>
														</xsl:variable>
														<xsl:value-of select="concat($day, '-', $month, '-', $year)"/>
													</xsl:if>
												</div>

												<div style="display: inline-block; line-height: 20px; height: 20px; width: 85px;">
													<xsl:attribute name="class">
														<xsl:value-of select="$transience"/>
													</xsl:attribute>
													<!-- Einddatum transformeren van 2021-01-27T12:34:56 naar 27-01-2021 -->
													<xsl:if test="$endDate != ''">
														<xsl:variable name="day">
															<xsl:value-of select="substring-before(substring-after(substring-after($endDate, '-'), '-'), 'T')"/>
														</xsl:variable>
														<xsl:variable name="month">
															<xsl:value-of select="substring-before(substring-after($endDate, '-'), '-')"/>
														</xsl:variable>
														<xsl:variable name="year">
															<xsl:value-of select="substring-before($endDate, '-')"/>
														</xsl:variable>
														<xsl:value-of select="concat($day, '-', $month, '-', $year)"/>
													</xsl:if>
												</div>

											</div>

										</xsl:if>

									</xsl:if>

								</xsl:for-each>
							</xsl:template>

							<xsl:template name="Transience">
								<xsl:param name="endDate"/>
								<xsl:choose>
									<xsl:when test="$endDate != ''">
										<xsl:variable name="membershipEndDate" select="number(translate(translate(translate($endDate, '-', ''), 'T', ''), ':', '')) div 1000000"/>
										<xsl:variable name="currentDate" select="number(translate(translate(translate($date, '-', ''), 'T', ''), ':', '')) div 1000000"/>
										<xsl:choose>
											<xsl:when test="$membershipEndDate &lt; $currentDate">
												<xsl:text>wcc_Transience_NotCurrent</xsl:text>
											</xsl:when>
											<xsl:otherwise>
												<xsl:text>wcc_Transience_Current</xsl:text>
											</xsl:otherwise>
										</xsl:choose>
									</xsl:when>
									<xsl:otherwise>
										<xsl:text>wcc_Transience_Current</xsl:text>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:template>
						</xsl:stylesheet>
					</Transform>
				</XsltColumn>

				<AddressColumn HeaderText="Bezoekadres" Ordinal="4" CommunicationChannel="Bezoekadres" AddressElements="Straatnaam;Huisnummer;Toevoeging"/>
				<AddressColumn HeaderText="Vestigingsplaats" Ordinal="5" CommunicationChannel="Bezoekadres" AddressElement="Plaats"/>

				<XsltColumn HeaderText="Dossier" Ordinal="6">
					<Transform>
						<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
							<xsl:output method="html" indent="yes"/>
							<xsl:template match="/Row">

								<xsl:if test="Column[@name='Dossier']/.!=''">
									<a target="_blank">
										<xsl:attribute name="href">
											<xsl:value-of select="Column[@name='Dossier']/."/>
										</xsl:attribute>
										Klik hier
									</a>
								</xsl:if>

							</xsl:template>
						</xsl:stylesheet>
					</Transform>
				</XsltColumn>
			</Columns>
		</View>
	</Views>
</ViewDefinitions>