<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--  $Id$  -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:dyn="http://exslt.org/dynamic" extension-element-prefixes="dyn">
    <xsl:output method="html" indent="no" doctype-system="" encoding="utf-8" />

    <xsl:include href="/app/tools/rps/templates/global.xsl" />

    <xsl:template name="pickLayout">
        <section class="Mapface MainBaseSection">
            <xsl:call-template name="successMessageGeneral">
                <xsl:with-param name="successMessage">All mapping exceptions approved for this file!</xsl:with-param>
            </xsl:call-template>
            <xsl:call-template name="newFiles" />
            <xsl:call-template name="needsReview" />
            <xsl:call-template name="hasErrors" />
            <xsl:call-template name="recentlyCompleted" />
        </section>
        <script type="text/javascript" src="/production/javascript/rps/mapface.js?v=5" />
    </xsl:template>

    <xsl:template name="newFiles">
        <fieldset id="newFilesFieldset" class="Form-fieldset">
            <h3>New Error Files</h3>
            <xsl:choose>
                <xsl:when test="count(NewFileList/MapFaceFile) &gt; 0">
                    <xsl:call-template name="newFilesList" />
                </xsl:when>
                <xsl:otherwise>
                    <p>There are no new error files at this time.</p>
                </xsl:otherwise>
            </xsl:choose>
        </fieldset>
    </xsl:template>

    <xsl:template name="newFilesList">
        <table class="Table" id="newFilesTable">
            <thead>
                <tr class="Table-row Table-row-header">
                    <th class="Table-col">Customer</th>
                    <th class="Table-col">Service</th>
                    <th class="Table-col">File Name</th>
                    <th class="Table-col">Received</th>
                    <th class="Table-col"># of Errors</th>
                    <th class="Table-col">Errors Mapped</th>
                    <th class="Table-col">Resolving User</th>
                </tr>
            </thead>
            <tbody>
                <xsl:for-each select="NewFileList/MapFaceFile">
                    <tr class="Table-row Table-row-data">
                        <xsl:if test="MapFaceFileID = /Root/Params/Highlight">
                            <xsl:attribute name="class">hi</xsl:attribute>
                        </xsl:if>
                        <td class="Table-col">
                            <xsl:value-of select="ClientName" />
                        </td>
                        <td class="Table-col">
                            <xsl:value-of select="ServiceName" />
                        </td>
                        <td class="Table-col">
                            <a href="https://{ClientNameClean}.royaltyshare.com/app/tracker?c=saveas&amp;file={FileID}" class="js-tooltip">
                                <xsl:if test="/Root/User/AccessLevel = 1 and VersionNum != 0">
                                    <xsl:attribute name="title">Importer Version: <xsl:value-of select="VersionNum" /></xsl:attribute>
                                </xsl:if>
                                <xsl:value-of select="OrigFileName" />
                            </a>
                        </td>
                        <td class="Table-col">
                            <xsl:value-of select="substring(DateCreated,0,11)" />
                        </td>
                        <td class="Table-col">
                            <xsl:value-of select="InitialErrors" />
                        </td>
                        <td class="Table-col">
                            <a href="https://{ClientNameClean}.royaltyshare.com/rps/mapface?c=map&amp;file={FileID}&amp;map=1">
                                <xsl:value-of select="InitialErrors - RemainingErrors" />
                            </a>
                        </td>
                        <td class="Table-col">
                            <xsl:choose>
                                <xsl:when test="normalize-space(ResolvingUserName)">
                                    <xsl:value-of select="ResolvingUserName" />
                                </xsl:when>
                                <xsl:otherwise>None</xsl:otherwise>
                            </xsl:choose>
                        </td>
                    </tr>
                </xsl:for-each>
            </tbody>
        </table>

        <xsl:call-template name="loadMore">
            <xsl:with-param name="id" select="'showMoreNew'"/>
        </xsl:call-template>

    </xsl:template>

    <xsl:template name="needsReview">
        <fieldset id="needsReviewFieldset" class="Form-fieldset">
            <h3>Needs Review</h3>
            <xsl:choose>
                <xsl:when test="count(ReviewFileList/MapFaceFile) &gt; 0">
                    <xsl:call-template name="needsReviewList" />
                </xsl:when>
                <xsl:otherwise>
                    <p>There are no files in need of review at this time.</p>
                </xsl:otherwise>
            </xsl:choose>
        </fieldset>
        <br class="superBreak" />
    </xsl:template>

    <xsl:template name="needsReviewList">
        <table class="textChart" id="needsReviewTable">
            <thead>
                <tr class="Table-row Table-row-header">
                    <th class="Table-col">Customer</th>
                    <th class="Table-col">Service</th>
                    <th class="Table-col">File Name</th>
                    <th class="Table-col">Received</th>
                    <th class="Table-col"># of Errors</th>
                    <th class="Table-col">Errors Mapped</th>
                    <th class="Table-col">Errors Approved</th>
                    <th class="Table-col">Resolving User</th>
                    <th class="Table-col">Approving User</th>
                </tr>
            </thead>
            <tbody>
                <xsl:for-each select="ReviewFileList/MapFaceFile">
                    <tr class="Table-row Table-row-data">
                        <xsl:if test="MapFaceFileID = /Root/Params/Highlight">
                            <xsl:attribute name="class">hi</xsl:attribute>
                        </xsl:if>
                        <td class="Table-col">
                            <xsl:value-of select="ClientName" />
                        </td>
                        <td class="Table-col">
                            <xsl:value-of select="ServiceName" />
                        </td>
                        <td class="Table-col">
                            <a href="https://{ClientNameClean}.royaltyshare.com/app/tracker?c=saveas&amp;file={FileID}" class="js-tooltip">
                                <xsl:if test="/Root/User/AccessLevel = 1 and VersionNum != 0">
                                    <xsl:attribute name="title">Importer Version: <xsl:value-of select="VersionNum" /></xsl:attribute>
                                </xsl:if>
                                <xsl:value-of select="OrigFileName" />
                            </a>
                        </td>
                        <td class="Table-col">
                            <xsl:value-of select="substring(DateCreated,0,11)" />
                        </td>
                        <td class="Table-col">
                            <xsl:value-of select="InitialErrors" />
                        </td>
                        <td class="Table-col">
                            <a href="https://{ClientNameClean}.royaltyshare.com/rps/mapface?c=map&amp;file={FileID}&amp;map=1">
                                <xsl:value-of select="InitialErrors - RemainingErrors" />
                            </a>
                        </td>
                        <td class="Table-col">
                            <a href="https://{ClientNameClean}.royaltyshare.com/rps/mapface?c=map&amp;file={FileID}&amp;approve=1">
                                <xsl:value-of select="ApprovedMappings" />
                            </a>
                        </td>
                        <td class="Table-col">
                            <xsl:choose>
                                <xsl:when test="normalize-space(ResolvingUserName)">
                                    <xsl:value-of select="ResolvingUserName" />
                                </xsl:when>
                                <xsl:otherwise>None</xsl:otherwise>
                            </xsl:choose>
                        </td>
                        <td class="Table-col">
                            <xsl:choose>
                                <xsl:when test="normalize-space(ApprovingUserName)">
                                    <xsl:value-of select="ApprovingUserName" />
                                </xsl:when>
                                <xsl:otherwise>None</xsl:otherwise>
                            </xsl:choose>
                        </td>
                    </tr>
                </xsl:for-each>
            </tbody>
        </table>
        <xsl:call-template name="loadMore">
            <xsl:with-param name="id" select="'showMoreReview'"/>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="hasErrors">
        <xsl:if test="count(ErrorFileList/MapFaceFile) &gt; 0">
            <fieldset id="hasErrorsFieldset" class="Form-fieldset">
                <h3>Cannot Process</h3>
                <xsl:call-template name="hasErrorsList" />
            </fieldset>
        </xsl:if>
    </xsl:template>

    <xsl:template name="hasErrorsList">
        <table class="Table" id="hasErrorsTable">
            <thead>
                <tr class="Table-row Table-row-header">
                    <th class="Table-col">Customer</th>
                    <th class="Table-col">Service</th>
                    <th class="Table-col">File Name</th>
                    <th class="Table-col">Received</th>
                    <th class="Table-col"># of Errors</th>
                    <th class="Table-col">Errors Mapped</th>
                    <th class="Table-col">Errors Approved</th>
                    <th class="Table-col">Resolving User</th>
                    <th class="Table-col">Approving User</th>
                </tr>
            </thead>
            <tbody>
                <xsl:for-each select="ErrorFileList/MapFaceFile">
                    <tr class="Table-row Table-row-data">
                        <xsl:if test="MapFaceFileID = /Root/Params/Highlight">
                            <xsl:attribute name="class">hi</xsl:attribute>
                        </xsl:if>
                        <td class="Table-col">
                            <xsl:value-of select="ClientName" />
                        </td>
                        <td class="Table-col">
                            <xsl:value-of select="ServiceName" />
                        </td>
                        <td class="Table-col">
                            <a href="https://{ClientNameClean}.royaltyshare.com/app/tracker?c=saveas&amp;file={FileID}" class="js-tooltip">
                                <xsl:if test="/Root/User/AccessLevel = 1 and VersionNum != 0">
                                    <xsl:attribute name="title">Importer Version: <xsl:value-of select="VersionNum" /></xsl:attribute>
                                </xsl:if>
                                <xsl:value-of select="OrigFileName" />
                            </a>
                        </td>
                        <td class="Table-col">
                            <xsl:value-of select="substring(DateCreated,0,11)" />
                        </td>
                        <td colspan="3">ERROR</td>
                        <td class="Table-col">
                            <xsl:choose>
                                <xsl:when test="normalize-space(ResolvingUserName)">
                                    <xsl:value-of select="ResolvingUserName" />
                                </xsl:when>
                                <xsl:otherwise>None</xsl:otherwise>
                            </xsl:choose>
                        </td>
                        <td class="Table-col">
                            <xsl:choose>
                                <xsl:when test="normalize-space(ApprovingUserName)">
                                    <xsl:value-of select="ApprovingUserName" />
                                </xsl:when>
                                <xsl:otherwise>None</xsl:otherwise>
                            </xsl:choose>
                        </td>
                    </tr>
                </xsl:for-each>
            </tbody>
        </table>
        <xsl:call-template name="loadMore">
            <xsl:with-param name="id" select="'showMoreErrors'"/>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="recentlyCompleted">
        <fieldset id="completedFieldset" class="Form-fieldset">
            <h3>Recently Completed</h3>
            <xsl:choose>
                <xsl:when test="count(CompletedFileList/MapFaceFile) &gt; 0">
                    <xsl:call-template name="completedList" />
                </xsl:when>
                <xsl:otherwise>
                    <p>There are no completed files at this time.</p>
                </xsl:otherwise>
            </xsl:choose>
        </fieldset>
    </xsl:template>

    <xsl:template name="completedList">
        <table class="Table" id="completedTable">
            <thead>
                <tr class="Table-row Table-row-header">
                    <th class="Table-col">Customer</th>
                    <th class="Table-col">Service</th>
                    <th class="Table-col">File Name</th>
                    <th class="Table-col">Received</th>
                    <th class="Table-col"># of Errors</th>
                    <th class="Table-col">Errors Mapped</th>
                    <th class="Table-col">Errors Approved</th>
                    <th class="Table-col">Resolving User</th>
                    <th class="Table-col">Approving User</th>
                </tr>
            </thead>
            <tbody>
                <xsl:for-each select="CompletedFileList/MapFaceFile">
                    <tr class="Table-row Table-row-data">
                        <xsl:if test="MapFaceFileID = /Root/Params/Highlight">
                            <xsl:attribute name="class">hi</xsl:attribute>
                        </xsl:if>
                        <td class="Table-col">
                            <xsl:value-of select="ClientName" />
                        </td>
                        <td class="Table-col">
                            <xsl:value-of select="ServiceName" />
                        </td>
                        <td class="Table-col">
                            <a href="https://{ClientNameClean}.royaltyshare.com/app/tracker?c=saveas&amp;file={FileID}" class="js-tooltip">
                                <xsl:if test="/Root/User/AccessLevel = 1 and VersionNum != 0">
                                    <xsl:attribute name="title">Importer Version: <xsl:value-of select="VersionNum" />
                                    </xsl:attribute>
                                </xsl:if>
                                <xsl:value-of select="OrigFileName" />
                            </a>
                        </td>
                        <td class="Table-col">
                            <xsl:value-of select="substring(DateCreated,0,11)" />
                        </td>
                        <td class="Table-col">
                            <xsl:value-of select="InitialErrors" />
                        </td>
                        <td class="Table-col">
                            <xsl:value-of select="InitialErrors - RemainingErrors" />
                        </td>
                        <td class="Table-col">
                            <xsl:value-of select="ApprovedMappings" />
                        </td>
                        <td class="Table-col">
                            <xsl:choose>
                                <xsl:when test="normalize-space(ResolvingUserName)">
                                    <xsl:value-of select="ResolvingUserName" />
                                </xsl:when>
                                <xsl:otherwise>None</xsl:otherwise>
                            </xsl:choose>
                        </td>
                        <td class="Table-col">
                            <xsl:choose>
                                <xsl:when test="normalize-space(ApprovingUserName)">
                                    <xsl:value-of select="ApprovingUserName" />
                                </xsl:when>
                                <xsl:otherwise>None</xsl:otherwise>
                            </xsl:choose>
                        </td>
                    </tr>
                </xsl:for-each>
            </tbody>
        </table>
    </xsl:template>

</xsl:stylesheet>
