<!--                                                                  -->
<!--  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="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 4.01//EN" encoding="utf-8" />

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

	<xsl:template name="pickLayout">
		<link href="/production/css/rps/mapface.css?v=2" media="screen" rel="stylesheet" type="text/css" />
		<div class="section" id="mapface">
            <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" />
		</div>
		<script type="text/javascript" src="/production/javascript/rps/mapface.js?v=5" />
	</xsl:template>

	<xsl:template name="newFiles">
    	<fieldset id="newFilesFieldset">
      		<legend>New Error Files</legend>
      		<xsl:choose>
      			<xsl:when test="count(NewFileList/MapFaceFile) &gt; 0">
					<xsl:call-template name="newFilesList" />
        		</xsl:when>
        		<xsl:otherwise>
        			<p class="emptyMessage">There are no new error files at this time.</p>
        		</xsl:otherwise>
        	</xsl:choose>
        </fieldset>
        <br class="superBreak" />
	</xsl:template>
	
	<xsl:template name="newFilesList">
  		<table class="textChart" id="newFilesTable">
    		<tr>
    			<th>Customer</th>
    			<th>Service</th>
    			<th>File Name</th>
    			<th>Received</th>
    			<th># of Errors</th>
    			<th>Errors Mapped</th>
    			<th>Resolving User</th>	
    		</tr>
    		<xsl:for-each select="NewFileList/MapFaceFile">
        		<tr class="row{position() mod 2}">
		  	       	<xsl:if test="MapFaceFileID = /Root/Params/Highlight">
			            <xsl:attribute name="class">hi</xsl:attribute>
			        </xsl:if>	        		
        			<td><xsl:value-of select="ClientName" /></td>
        			<td><xsl:value-of select="ServiceName" /></td>       
        			<td>
        				<a href="https://{ClientNameClean}.royaltyshare.com/app/tracker?c=saveas&amp;file={FileID}">
                            <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><xsl:value-of select="substring(DateCreated,0,11)" /></td>  
        			<td><xsl:value-of select="InitialErrors" /></td>
        			<td>
        				<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>
        				<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>
    	</table>	
    	<div id="showMoreNew" class="showMore"><a href="javascript:showMoreNew()">More...</a></div>
	</xsl:template>

	<xsl:template name="needsReview">
    	<fieldset id="needsReviewFieldset">
      		<legend>Needs Review</legend>
      		<xsl:choose>
      			<xsl:when test="count(ReviewFileList/MapFaceFile) &gt; 0">
					<xsl:call-template name="needsReviewList" />
        		</xsl:when>
        		<xsl:otherwise>
        			<p class="emptyMessage">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">
    		<tr>
    			<th>Customer</th>
    			<th>Service</th>
    			<th>File Name</th>
    			<th>Received</th>
    			<th># of Errors</th>
    			<th>Errors Mapped</th>
    			<th>Errors Approved</th>
    			<th>Resolving User</th>	
    			<th>Approving User</th>	
    		</tr>
    		<xsl:for-each select="ReviewFileList/MapFaceFile">
        		<tr class="row{position() mod 2}">
		  	       	<xsl:if test="MapFaceFileID = /Root/Params/Highlight">
			            <xsl:attribute name="class">hi</xsl:attribute>
			        </xsl:if>	        		
        			<td><xsl:value-of select="ClientName" /></td>
        			<td><xsl:value-of select="ServiceName" /></td>       
        			<td>
        				<a href="https://{ClientNameClean}.royaltyshare.com/app/tracker?c=saveas&amp;file={FileID}">
                            <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><xsl:value-of select="substring(DateCreated,0,11)" /></td>  
        			<td><xsl:value-of select="InitialErrors" /></td>
        			<td>
        				<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>
        				<a href="https://{ClientNameClean}.royaltyshare.com/rps/mapface?c=map&amp;file={FileID}&amp;approve=1"><xsl:value-of select="ApprovedMappings" /></a>
        			</td>  
        			<td>
        				<xsl:choose>
        					<xsl:when test="normalize-space(ResolvingUserName)">
        						<xsl:value-of select="ResolvingUserName" />
        					</xsl:when>
        					<xsl:otherwise>None</xsl:otherwise>
        				</xsl:choose>
        			</td>     
        			<td>
        				<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>
    	</table>	
    	<div id="showMoreReview" class="showMore"><a href="javascript:showMoreReview()">More...</a></div>
	</xsl:template>

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

	<xsl:template name="hasErrorsList">
  		<table class="textChart" id="hasErrorsTable">
    		<tr>
    			<th>Customer</th>
    			<th>Service</th>
    			<th>File Name</th>
    			<th>Received</th>
    			<th># of Errors</th>
    			<th>Errors Mapped</th>
    			<th>Errors Approved</th> 			
    			<th>Resolving User</th>	
    			<th>Approving User</th>	
    		</tr>
    		<xsl:for-each select="ErrorFileList/MapFaceFile">
        		<tr class="row{position() mod 2}">
		  	       	<xsl:if test="MapFaceFileID = /Root/Params/Highlight">
			            <xsl:attribute name="class">hi</xsl:attribute>
			        </xsl:if>	        		
        			<td><xsl:value-of select="ClientName" /></td>
        			<td><xsl:value-of select="ServiceName" /></td>       
        			<td>
        				<a href="https://{ClientNameClean}.royaltyshare.com/app/tracker?c=saveas&amp;file={FileID}">
                            <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><xsl:value-of select="substring(DateCreated,0,11)" /></td>  
        			<td colspan="3">ERROR</td>          			
        			<td>
        				<xsl:choose>
        					<xsl:when test="normalize-space(ResolvingUserName)">
        						<xsl:value-of select="ResolvingUserName" />
        					</xsl:when>
        					<xsl:otherwise>None</xsl:otherwise>
        				</xsl:choose>
        			</td>     
        			<td>
        				<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>
    	</table>	
    	<div id="showMoreErrors" class="showMore"><a href="javascript:showMoreErrors()">More...</a></div>
	</xsl:template>

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

	<xsl:template name="completedList">
  		<table class="textChart" id="completedTable">
    		<tr>
    			<th>Customer</th>
    			<th>Service</th>
    			<th>File Name</th>
    			<th>Received</th>
    			<th># of Errors</th>
    			<th>Errors Mapped</th>
    			<th>Errors Approved</th>
    			<th>Resolving User</th>	
    			<th>Approving User</th>	
    		</tr>
    		<xsl:for-each select="CompletedFileList/MapFaceFile">
        		<tr class="row{position() mod 2}">
		  	       	<xsl:if test="MapFaceFileID = /Root/Params/Highlight">
			            <xsl:attribute name="class">hi</xsl:attribute>
			        </xsl:if>	        		
        			<td><xsl:value-of select="ClientName" /></td>
        			<td><xsl:value-of select="ServiceName" /></td>       
                    <td>
                        <a href="https://{ClientNameClean}.royaltyshare.com/app/tracker?c=saveas&amp;file={FileID}">
                            <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><xsl:value-of select="substring(DateCreated,0,11)" /></td>  
        			<td><xsl:value-of select="InitialErrors" /></td>
        			<td><xsl:value-of select="InitialErrors - RemainingErrors" /></td>  
        			<td><xsl:value-of select="ApprovedMappings" /></td>
        			<td>
        				<xsl:choose>
        					<xsl:when test="normalize-space(ResolvingUserName)">
        						<xsl:value-of select="ResolvingUserName" />
        					</xsl:when>
        					<xsl:otherwise>None</xsl:otherwise>
        				</xsl:choose>
        			</td>     
        			<td>
        				<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>
    	</table>	
	</xsl:template>

</xsl:stylesheet>

