View difference between Paste ID: fmPUHGpR and D7Tg9VtY
SHOW: | | - or go back to the newest paste.
1
<xsl:template name="validated">
2-
		<!-- error variable collect all errors finding in calendars -->
2+
	<!-- error variable collect all errors finding in calendars -->
3-
		<xsl:variable name="error">
3+
	<xsl:variable name="error">
4-
			<!-- loop consultant by consultant -->
4+
	<!-- loop consultant by consultant -->
5-
			<xsl:variable name="query" select="/workfile/query" />
5+
	<xsl:variable name="query" select="/workfile/query" />
6-
			<xsl:variable name="event" select="/workfile/calendar-list/calendar[@id=/workfile/query/consultant/@calendar-id]/items/event" />
6+
	<xsl:for-each select="/workfile/calendar-list/calendar[@id=/workfile/query/consultant/@calendar-id]">
7-
			<xsl:variable name="startdatetime" select="substring-before($event/start/datetime, 'T')" />
7+
		<xsl:variable name="calendar-id" select="@id" />
8-
			<xsl:for-each
8+
		<xsl:variable name="event" select="./items/event" />
9-
				select="/workfile/calendar-list/calendar[@id=/workfile/query/consultant/@calendar-id]">
9+
		<xsl:variable name="datesMois">
10-
				<xsl:variable name="calendar-id" select="@id" />
10+
			<xsl:call-template name="dayOfMonth">
11-
				<xsl:variable name="datesMois">
11+
				<xsl:with-param name="pDay" select="01" />
12-
					<xsl:call-template name="dayOfMonth">
12+
				<xsl:with-param name="pMonth" select="/workfile/query/@month" />
13-
						<xsl:with-param name="pDay" select="01" />
13+
				<xsl:with-param name="pYear" select="/workfile/query/@year" />			
14-
						<xsl:with-param name="pMonth" select="/workfile/query/@month" />
14+
			</xsl:call-template>
15-
						<xsl:with-param name="pYear" select="/workfile/query/@year" />			
15+
16-
					</xsl:call-template>
16+
		<xsl:for-each select="tokenize($datesMois,',')">
17-
				</xsl:variable>
17+
			<xsl:variable name="dateJour" select="." />
18-
				<xsl:for-each select="tokenize($datesMois,',')">
18+
			<xsl:if test="not ($dateJour=$query/bank-holiday/@date)">
19-
					<xsl:variable name="dateJour" select="." />
19+
				<xsl:choose>
20-
					<xsl:if test="not ($dateJour=$query/bank-holiday/@date)">
20+
					<xsl:when test="$event[substring-before(start/datetime, 'T')=$dateJour]">
21-
						<xsl:choose>
21+
						<xsl:for-each select="$event[substring-before(start/datetime, 'T')=$dateJour]">
22-
							<xsl:when test="$dateJour = $startdatetime">
22+
							<xsl:variable name="currentevent" select="." />
23-
								<xsl:for-each select="$event[substring-before(start/datetime, 'T')=$dateJour]">
23+
							<xsl:variable name="position" select="position()" />
24-
									<xsl:variable name="currentevent" select="." />
24+
							<xsl:variable name="currentcustomer" select="upper-case(summary)" />
25-
									<xsl:variable name="position" select="position()" />
25+
26-
									<xsl:variable name="currentcustomer" select="upper-case(summary)" />
26+
							<xsl:choose>
27
								<xsl:when test="(upper-case($currentcustomer)=/workfile/query/customer/task/@code) and not(upper-case($currentcustomer)=/workfile/query/customer/@id) or(/workfile/query/consultant[$calendar-id=@calendar-id]/@code=/workfile/query/customer[task/@code=$currentcustomer and @internal='false']/task[@code=$currentcustomer]/pricing/@consultant-code)
28-
									<xsl:choose>
28+
and not(upper-case($currentcustomer)=/workfile/query/customer[@internal='true']/task/@code)">
29-
										<xsl:when test="(upper-case($currentcustomer)=$query/customer/task/@code) and not(upper-case($currentcustomer)=$query/customer/@id)
29+
30-
											or($query/consultant[$calendar-id=@calendar-id]/@code=
30+
<!-- If the summary equal one of the customer code, we check after the description -->	
31-
																	$query/customer[task/@code=$currentcustomer and @internal='false']
31+
<!-- If description is empty => error -->
32-
																	/task[@code=$currentcustomer]/pricing/@consultant-code)
32+
									<xsl:variable name="description" select="description" />
33-
															and not(upper-case($currentcustomer)=$query/customer[@internal='true']/task/@code)">
33+
									<xsl:if test="(not($description) or $description='') and not ($currentcustomer=/workfile/query/customer[@internal='true']/task/@code)">
34-
										<!-- If the summary equal one of the customer code, we check after the 
34+
<!-- the description is not needed if the summary equal one of the internal codes -->
35-
											description -->	
35+
										<xsl:text>ERROR_EMPTY_DESC;</xsl:text>
36
										<xsl:value-of select="substring-before(start/datetime, 'T')" />
37-
										<!-- If description is empty => error -->
37+
										<xsl:text>;</xsl:text>
38-
										<xsl:variable name="description" select="description" />
38+
										<xsl:value-of select="$currentcustomer" />
39-
										<xsl:if test="(not($description) or $description='')
39+
										<xsl:text>;</xsl:text>
40-
											and not ($currentcustomer=/workfile/query/customer[@internal='true']/task/@code)">
40+
										<xsl:value-of select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
41-
											<!-- the description is not needed if the summary equal one of the internal codes -->
41+
										<xsl:text>;</xsl:text>
42-
											<xsl:text>ERROR_EMPTY_DESC;</xsl:text>
42+
										<xsl:value-of select="html-link" />
43-
											<xsl:value-of select="substring-before(start/datetime, 'T')" />
43+
										<xsl:text>;</xsl:text>
44
										<xsl:value-of select="id" />
45
										<xsl:text>;</xsl:text>
46
										<xsl:value-of select="$calendar-id" />
47-
											<xsl:value-of
47+
										<xsl:text>;</xsl:text>
48-
												select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
48+
									</xsl:if>
49
										
50
<!-- If description is not empty, we check if the amount of work hour is correct -->
51
									<xsl:variable name="current-event" select="." />
52-
													<xsl:value-of select="id" />
52+
									<xsl:variable name="recurrence" select="recurrences/recurrence" />
53-
													<xsl:text>;</xsl:text>
53+
									<xsl:variable name="startdate" select="substring-before(start/datetime, 'T')" />
54
									<xsl:variable name="enddate" select="substring-before(end/datetime, 'T')" />
55
									<xsl:variable name="prevdate" select="substring-before(/workfile/calendar-list/calendar[$calendar-id=@id]/items/event[number($position)-1]/start/datetime,'T')" />
56
									<xsl:variable name="startminute" select="minutes-from-dateTime(xs:dateTime(start/datetime))" />
57
									<xsl:variable name="endminute" select="minutes-from-dateTime(xs:dateTime(end/datetime))" />
58
									<xsl:if test="$startminute mod 15 or ($endminute mod 15)">
59-
											<!-- If description is not empty, we check if the amount of work hour 
59+
										<xsl:text>ERROR_EVENT_DURATION;</xsl:text>
60-
												is correct -->
60+
										<xsl:value-of select="substring-before(start/datetime,'T')" />
61-
											<xsl:variable name="current-event" select="." />
61+
										<xsl:text>;</xsl:text>
62-
											<xsl:variable name="recurrence" select="recurrences/recurrence" />
62+
										<xsl:value-of select="$currentcustomer" />
63-
											<xsl:variable name="startdate" select="substring-before(start/datetime, 'T')" />
63+
										<xsl:text>;</xsl:text>
64-
											<xsl:variable name="enddate" select="substring-before(end/datetime, 'T')" />
64+
										<xsl:value-of
65-
											<xsl:variable name="prevdate"
65+
select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
66-
												select="substring-before(/workfile/calendar-list/calendar[$calendar-id=@id]
66+
										<xsl:text>;</xsl:text>
67-
																						/items/event[number($position)-1]/start/datetime,'T')" />
67+
										<xsl:value-of select="html-link" />
68-
											<xsl:variable name="startminute"
68+
										<xsl:text>;</xsl:text>
69-
												select="minutes-from-dateTime(xs:dateTime(start/datetime))" />
69+
										<xsl:value-of select="id" />
70-
											<xsl:variable name="endminute"
70+
										<xsl:text>;</xsl:text>
71-
												select="minutes-from-dateTime(xs:dateTime(end/datetime))" />
71+
										<xsl:value-of select="$calendar-id" />
72-
											<xsl:if
72+
										<xsl:text>;</xsl:text>
73-
												test="$startminute mod 15
73+
									</xsl:if>
74-
																	or ($endminute mod 15)">
74+
<!-- If the event start on a day and end the same day = OK -->
75
									<xsl:if test="not($startdate=$enddate)">
76-
												<xsl:text>ERROR_EVENT_DURATION;</xsl:text>
76+
										<xsl:text>ERROR_EVENT_DATE_OVERFLOW;</xsl:text>
77-
												<xsl:value-of select="substring-before(start/datetime,'T')" />
77+
										<xsl:value-of select="substring-before(start/datetime,'T')" />
78-
												<xsl:text>;</xsl:text>
78+
										<xsl:text>;</xsl:text>
79-
												<xsl:value-of select="$currentcustomer" />
79+
										<xsl:value-of select="$currentcustomer" />
80-
												<xsl:text>;</xsl:text>
80+
										<xsl:text>;</xsl:text>
81-
												<xsl:value-of
81+
										<xsl:value-of
82-
													select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
82+
select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
83-
												<xsl:text>;</xsl:text>
83+
										<xsl:text>;</xsl:text>
84-
												<xsl:value-of select="html-link" />
84+
										<xsl:value-of select="html-link" />
85-
												<xsl:text>;</xsl:text>
85+
										<xsl:text>;</xsl:text>
86-
														<xsl:value-of select="id" />
86+
										<xsl:value-of select="id" />
87-
														<xsl:text>;</xsl:text>
87+
										<xsl:text>;</xsl:text>
88-
												<xsl:value-of select="$calendar-id" />
88+
										<xsl:value-of select="$calendar-id" />
89-
												<xsl:text>;</xsl:text>
89+
										<xsl:text>;</xsl:text>
90
									</xsl:if>
91-
											</xsl:if>
91+
<!-- If the event is not recurring = OK -->
92-
											<!-- If the event start on a day and end the same day = OK -->
92+
									<xsl:if test="not(empty($recurrence))">
93-
											<xsl:if test="not($startdate=$enddate)">
93+
										<xsl:text>ERROR_EVENT_RECURRENCE;</xsl:text>
94-
												<xsl:text>ERROR_EVENT_DATE_OVERFLOW;</xsl:text>
94+
										<xsl:value-of select="substring-before(start/datetime,'T')" />
95-
												<xsl:value-of select="substring-before(start/datetime,'T')" />
95+
										<xsl:text>;</xsl:text>
96-
												<xsl:text>;</xsl:text>
96+
										<xsl:value-of select="$currentcustomer" />
97-
												<xsl:value-of select="$currentcustomer" />
97+
										<xsl:text>;</xsl:text>
98-
												<xsl:text>;</xsl:text>
98+
										<xsl:value-of
99-
												<xsl:value-of
99+
select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
100-
													select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
100+
										<xsl:text>;</xsl:text>
101-
												<xsl:text>;</xsl:text>
101+
										<xsl:value-of select="html-link" />
102-
												<xsl:value-of select="html-link" />
102+
										<xsl:text>;</xsl:text>
103-
												<xsl:text>;</xsl:text>
103+
										<xsl:value-of select="id" />
104-
														<xsl:value-of select="id" />
104+
										<xsl:text>;</xsl:text>
105-
														<xsl:text>;</xsl:text>
105+
										<xsl:value-of select="$calendar-id" />
106-
												<xsl:value-of select="$calendar-id" />
106+
										<xsl:text>;</xsl:text>
107-
												<xsl:text>;</xsl:text>
107+
									</xsl:if>
108-
											</xsl:if>
108+
<!-- If the event start on a day and end on another day => error -->
109-
											<!-- If the event is not recurring = OK -->
109+
									<xsl:variable name="total">
110-
											<xsl:if test="not(empty($recurrence))">
110+
										<xsl:if test="not($prevdate=$startdate)">
111-
												<xsl:text>ERROR_EVENT_RECURRENCE;</xsl:text>
111+
											<xsl:call-template name="sum">
112-
												<xsl:value-of select="substring-before(start/datetime,'T')" />
112+
												<xsl:with-param name="events" select="/workfile/calendar-list/calendar[@id=$calendar-id]/items/event[substring-before(start/datetime,'T')=$startdate and substring-before(start/datetime,'T')=substring-before(end/datetime,'T') and upper-case(summary)=/workfile/query/customer/task/@code]" />
113-
												<xsl:text>;</xsl:text>
113+
											</xsl:call-template>
114-
												<xsl:value-of select="$currentcustomer" />
114+
115-
												<xsl:text>;</xsl:text>
115+
									</xsl:variable>
116-
												<xsl:value-of
116+
117-
													select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
117+
<!-- we don't check if work hour is correct for the second, third, etc. event of the day -->
118-
												<xsl:text>;</xsl:text>
118+
									<xsl:if test="not($prevdate=$startdate)">
119-
												<xsl:value-of select="html-link" />
119+
<!-- If amount of work hour is not correct => error -->
120-
												<xsl:text>;</xsl:text>
120+
										<xsl:if test="not($current-event/custom-elements/day-of-week/@index-day-of-week='5') and not($current-event/custom-elements/day-of-week/@index-day-of-week='6') and not($startdate=/workfile/query/bank-holiday/@date) and (number($total) &gt; number(/workfile/query/parameter[@name='work-hour-max']/@value) or number($total) &lt; number(/workfile/query/parameter[@name='work-hour-min']/@value))">
121-
														<xsl:value-of select="id" />
121+
											<xsl:text>ERROR_WORK_HOUR;</xsl:text>
122-
														<xsl:text>;</xsl:text>
122+
											<xsl:value-of select="substring-before(start/datetime,'T')" />
123-
												<xsl:value-of select="$calendar-id" />
123+
124-
												<xsl:text>;</xsl:text>
124+
125-
											</xsl:if>
125+
126-
											<!-- If the event start on a day and end on another day => error -->
126+
											<xsl:value-of select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
127-
											<xsl:variable name="total">
127+
128-
												<xsl:if test="not($prevdate=$startdate)">
128+
129-
													<xsl:call-template name="sum">
129+
130-
														<xsl:with-param name="events"
130+
131-
															select="/workfile/calendar-list/calendar[@id=$calendar-id]
131+
132-
																												/items/event[substring-before(start/datetime,'T')=$startdate
132+
133-
																												and substring-before(start/datetime,'T')=substring-before(end/datetime,'T') 
133+
134-
																												and upper-case(summary)=/workfile/query/customer/task/@code]" />
134+
135-
													</xsl:call-template>
135+
									</xsl:if>
136-
												</xsl:if>
136+
								</xsl:when>
137-
											</xsl:variable>
137+
								<xsl:when test="$currentcustomer and $currentcustomer!=''">										
138
									<xsl:text>ERROR_UNKNOWN_CODE;</xsl:text>
139-
											<!-- we don't check if work hour is correct for the second, third, etc. 
139+
									<xsl:value-of select="substring-before(start/datetime,'T')" />
140-
												event of the day -->
140+
141-
											<xsl:if test="not($prevdate=$startdate)">
141+
									<xsl:value-of select="$currentcustomer" />
142-
												<!-- If amount of work hour is not correct => error -->
142+
143-
												<xsl:if
143+
									<xsl:value-of select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
144-
													test="not($current-event/custom-elements/day-of-week/@index-day-of-week='5') 
144+
145-
																					and not($current-event/custom-elements/day-of-week/@index-day-of-week='6')
145+
									<xsl:value-of select="html-link" />
146-
																					and not($startdate=/workfile/query/bank-holiday/@date) 
146+
147-
																					and (number($total) &gt; number(/workfile/query/parameter[@name='work-hour-max']/@value)
147+
									<xsl:value-of select="id" />
148-
																					or number($total) &lt; number(/workfile/query/parameter[@name='work-hour-min']/@value))">
148+
149-
													<xsl:text>ERROR_WORK_HOUR;</xsl:text>
149+
150-
													<xsl:value-of select="substring-before(start/datetime,'T')" />
150+
151-
													<xsl:text>;</xsl:text>
151+
								</xsl:when>
152-
													<xsl:value-of select="$currentcustomer" />
152+
							</xsl:choose>
153-
													<xsl:text>;</xsl:text>
153+
													
154-
													<xsl:value-of
154+
						</xsl:for-each>
155-
														select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
155+
					</xsl:when>
156-
													<xsl:text>;</xsl:text>
156+
					<xsl:otherwise>
157-
													<xsl:value-of select="html-link" />
157+
						<xsl:text>ERROR_EVENT_NOT_FOUND;</xsl:text>
158-
													<xsl:text>;</xsl:text>
158+
						<xsl:value-of select="$dateJour" />
159-
														<xsl:value-of select="id" />
159+
						<xsl:text>;</xsl:text>
160-
														<xsl:text>;</xsl:text>
160+
						<xsl:text>no-customer;</xsl:text>
161-
													<xsl:value-of select="$calendar-id" />
161+
						<xsl:value-of select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
162-
													<xsl:text>;</xsl:text>
162+
						<xsl:text>;</xsl:text>
163-
												</xsl:if>
163+
						<xsl:text>no-link;</xsl:text>
164-
											</xsl:if>
164+
						<xsl:value-of select="id" />
165-
										</xsl:when>
165+
						<xsl:text>;</xsl:text>
166-
										<xsl:when test="$currentcustomer and $currentcustomer!=''">										
166+
						<xsl:value-of select="$calendar-id" />
167-
											<xsl:text>ERROR_UNKNOWN_CODE;</xsl:text>
167+
						<xsl:text>;</xsl:text>
168-
												<xsl:value-of select="substring-before(start/datetime,'T')" />
168+
					</xsl:otherwise>
169-
												<xsl:text>;</xsl:text>
169+
				</xsl:choose>  				
170-
												<xsl:value-of select="$currentcustomer" />
170+
			</xsl:if>
171-
												<xsl:text>;</xsl:text>
171+
		</xsl:for-each>
172-
												<xsl:value-of
172+
	</xsl:for-each>
173-
													select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
173+
</xsl:variable>
174-
												<xsl:text>;</xsl:text>
174+
175-
												<xsl:value-of select="html-link" />
175+
<xsl:if test="$error">
176-
												<xsl:text>;</xsl:text>
176+
	<xsl:value-of select="$error" />
177-
														<xsl:value-of select="id" />
177+
</xsl:if>
178-
														<xsl:text>;</xsl:text>
178+
179-
												<xsl:value-of select="$calendar-id" />
179+
</xsl:template>