Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <xsl:template name="validated">
- <!-- error variable collect all errors finding in calendars -->
- <xsl:variable name="error">
- <!-- loop consultant by consultant -->
- <xsl:variable name="query" select="/workfile/query" />
- <xsl:for-each select="/workfile/calendar-list/calendar[@id=/workfile/query/consultant/@calendar-id]">
- <xsl:variable name="calendar-id" select="@id" />
- <xsl:variable name="event" select="./items/event" />
- <xsl:variable name="datesMois">
- <xsl:call-template name="dayOfMonth">
- <xsl:with-param name="pDay" select="01" />
- <xsl:with-param name="pMonth" select="/workfile/query/@month" />
- <xsl:with-param name="pYear" select="/workfile/query/@year" />
- </xsl:call-template>
- </xsl:variable>
- <xsl:for-each select="tokenize($datesMois,',')">
- <xsl:variable name="dateJour" select="." />
- <xsl:if test="not ($dateJour=$query/bank-holiday/@date)">
- <xsl:choose>
- <xsl:when test="$event[substring-before(start/datetime, 'T')=$dateJour]">
- <xsl:for-each select="$event[substring-before(start/datetime, 'T')=$dateJour]">
- <xsl:variable name="currentevent" select="." />
- <xsl:variable name="position" select="position()" />
- <xsl:variable name="currentcustomer" select="upper-case(summary)" />
- <xsl:choose>
- <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)
- and not(upper-case($currentcustomer)=/workfile/query/customer[@internal='true']/task/@code)">
- <!-- If the summary equal one of the customer code, we check after the description -->
- <!-- If description is empty => error -->
- <xsl:variable name="description" select="description" />
- <xsl:if test="(not($description) or $description='') and not ($currentcustomer=/workfile/query/customer[@internal='true']/task/@code)">
- <!-- the description is not needed if the summary equal one of the internal codes -->
- <xsl:text>ERROR_EMPTY_DESC;</xsl:text>
- <xsl:value-of select="substring-before(start/datetime, 'T')" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="$currentcustomer" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="html-link" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="id" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="$calendar-id" />
- <xsl:text>;</xsl:text>
- </xsl:if>
- <!-- If description is not empty, we check if the amount of work hour is correct -->
- <xsl:variable name="current-event" select="." />
- <xsl:variable name="recurrence" select="recurrences/recurrence" />
- <xsl:variable name="startdate" select="substring-before(start/datetime, 'T')" />
- <xsl:variable name="enddate" select="substring-before(end/datetime, 'T')" />
- <xsl:variable name="prevdate" select="substring-before(/workfile/calendar-list/calendar[$calendar-id=@id]/items/event[number($position)-1]/start/datetime,'T')" />
- <xsl:variable name="startminute" select="minutes-from-dateTime(xs:dateTime(start/datetime))" />
- <xsl:variable name="endminute" select="minutes-from-dateTime(xs:dateTime(end/datetime))" />
- <xsl:if test="$startminute mod 15 or ($endminute mod 15)">
- <xsl:text>ERROR_EVENT_DURATION;</xsl:text>
- <xsl:value-of select="substring-before(start/datetime,'T')" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="$currentcustomer" />
- <xsl:text>;</xsl:text>
- <xsl:value-of
- select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="html-link" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="id" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="$calendar-id" />
- <xsl:text>;</xsl:text>
- </xsl:if>
- <!-- If the event start on a day and end the same day = OK -->
- <xsl:if test="not($startdate=$enddate)">
- <xsl:text>ERROR_EVENT_DATE_OVERFLOW;</xsl:text>
- <xsl:value-of select="substring-before(start/datetime,'T')" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="$currentcustomer" />
- <xsl:text>;</xsl:text>
- <xsl:value-of
- select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="html-link" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="id" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="$calendar-id" />
- <xsl:text>;</xsl:text>
- </xsl:if>
- <!-- If the event is not recurring = OK -->
- <xsl:if test="not(empty($recurrence))">
- <xsl:text>ERROR_EVENT_RECURRENCE;</xsl:text>
- <xsl:value-of select="substring-before(start/datetime,'T')" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="$currentcustomer" />
- <xsl:text>;</xsl:text>
- <xsl:value-of
- select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="html-link" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="id" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="$calendar-id" />
- <xsl:text>;</xsl:text>
- </xsl:if>
- <!-- If the event start on a day and end on another day => error -->
- <xsl:variable name="total">
- <xsl:if test="not($prevdate=$startdate)">
- <xsl:call-template name="sum">
- <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]" />
- </xsl:call-template>
- </xsl:if>
- </xsl:variable>
- <!-- we don't check if work hour is correct for the second, third, etc. event of the day -->
- <xsl:if test="not($prevdate=$startdate)">
- <!-- If amount of work hour is not correct => error -->
- <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) > number(/workfile/query/parameter[@name='work-hour-max']/@value) or number($total) < number(/workfile/query/parameter[@name='work-hour-min']/@value))">
- <xsl:text>ERROR_WORK_HOUR;</xsl:text>
- <xsl:value-of select="substring-before(start/datetime,'T')" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="$currentcustomer" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="html-link" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="id" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="$calendar-id" />
- <xsl:text>;</xsl:text>
- </xsl:if>
- </xsl:if>
- </xsl:when>
- <xsl:when test="$currentcustomer and $currentcustomer!=''">
- <xsl:text>ERROR_UNKNOWN_CODE;</xsl:text>
- <xsl:value-of select="substring-before(start/datetime,'T')" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="$currentcustomer" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="html-link" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="id" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="$calendar-id" />
- <xsl:text>;</xsl:text>
- </xsl:when>
- </xsl:choose>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>ERROR_EVENT_NOT_FOUND;</xsl:text>
- <xsl:value-of select="$dateJour" />
- <xsl:text>;</xsl:text>
- <xsl:text>no-customer;</xsl:text>
- <xsl:value-of select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
- <xsl:text>;</xsl:text>
- <xsl:text>no-link;</xsl:text>
- <xsl:value-of select="id" />
- <xsl:text>;</xsl:text>
- <xsl:value-of select="$calendar-id" />
- <xsl:text>;</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- </xsl:for-each>
- </xsl:for-each>
- </xsl:variable>
- <xsl:if test="$error">
- <xsl:value-of select="$error" />
- </xsl:if>
- </xsl:template>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement