<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--                                                                  -->
<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/bookpub/templates/global.xsl" />
    <xsl:include href="/app/tools/bookpub/templates/tracker/messages.xsl" />
    <xsl:include href="/app/tools/bookpub/templates/tracker/tracker_new_files.xsl" />

    <xsl:variable name="displayPriceExceptions" select="/Root/Access/bookpub/tracker/price_exceptions" />
    <xsl:variable name="currentPage">
        <xsl:choose>
            <xsl:when test="/Root/Files/OpenFiles/page &gt; /Root/Files/OpenFiles/pageCount">1</xsl:when>
            <xsl:otherwise><xsl:value-of select="/Root/Files/OpenFiles/page" /></xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

    <xsl:template name="pickLayout">
        <input type="hidden" name="grossRevenueEnabled" id="grossRevenueEnabled" value="" />
        <script type="text/javascript" src="/production/javascript/bookpub/tracker.js"></script>
        <xsl:call-template name="helpLink">
            <xsl:with-param name="extraParams">&amp;period_id=<xsl:value-of select="Period/PeriodID" /><xsl:if test="/Root/ClientTypes/ClientType[ClientTypeID = 9]/IsClientTypeFlag = 1">&amp;price_validation=1</xsl:if></xsl:with-param>
        </xsl:call-template>
        <xsl:choose>
            <xsl:when test="/Root/Period/PeriodID = 0">
                <xsl:call-template name="currentPeriodLayout" />
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="closedPeriodLayout" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="periodNav">
        <div class="PeriodNav raptorPeriodNav">
            <div class="PeriodNav-wrapper">
                <div class="PeriodNav-container PeriodNav-container-prev">
                    <div class="PeriodNav-prev">
                        <xsl:choose>
                            <xsl:when test="normalize-space(/Root/Period/PrevPeriodID) > 0">
                                <xsl:call-template name="uiButton">
                                    <xsl:with-param name="iconLeftType" select="'arrow-left'" />
                                    <xsl:with-param name="content" select="'Previous Period'" />
                                    <xsl:with-param name="url">?period=<xsl:value-of select="Period/PrevPeriodID" /></xsl:with-param>
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:otherwise>
                                &#160;
                            </xsl:otherwise>
                        </xsl:choose>
                    </div>
                </div>
                <div class="PeriodNav-container PeriodNav-container-title">
                    <h2 class="PeriodNav-title">
                        <xsl:choose>
                            <xsl:when test="/Root/Period/Name != ''">
                                <xsl:value-of select="/Root/Period/Name" />
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="/Root/Period/StartDate" /> -
                                <xsl:choose>
                                    <xsl:when test="normalize-space(/Root/Period/EndDate)">
                                        <xsl:value-of select="/Root/Period/EndDate" />
                                    </xsl:when>
                                    <xsl:otherwise>Present</xsl:otherwise>
                                </xsl:choose>
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:if test="/Root/Period/PeriodID = 0">
                            <xsl:text> (Current)</xsl:text>
                            <xsl:if test="Access/bookpub/tracker/edit_period">
                                &#160;
                                <a class="js-tooltip PeriodNav-edit-link" href="/bookpub/tracker?c=edit_period&amp;period={/Root/Period/PeriodID}&amp;page={Pagination/CurrentPage}" title="Edit Period Name">
                                    <xsl:call-template name="icon">
                                        <xsl:with-param name="type" select="'edit'" />
                                        <xsl:with-param name="role" select="'action'" />
                                    </xsl:call-template>
                                </a>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test="/Root/Access/bookpub/tracker/edit_period_notes = 1">
                            &#160;
                            <a class="js-tooltip PeriodNav-note">
                                <xsl:attribute name="href">/bookpub/tracker?c=edit_period_notes&amp;page=<xsl:value-of select="$currentPage" />&amp;period=<xsl:value-of select="/Root/Period/PeriodID"/></xsl:attribute>
                                <xsl:choose>
                                    <xsl:when test="/Root/Period/Notes = ''">
                                        <xsl:attribute name="class">js-tooltip PeriodNav-edit-link</xsl:attribute>
                                        <xsl:attribute name="title">Add Note</xsl:attribute>
                                        <xsl:call-template name="icon">
                                            <xsl:with-param name="type" select="'note'" />
                                            <xsl:with-param name="role" select="'action'" />
                                        </xsl:call-template>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:attribute name="title"><xsl:value-of select="/Root/Period/Notes" /></xsl:attribute>
                                        <xsl:choose>
                                            <xsl:when test="string-length(/Root/Period/Notes) &gt; 10">
                                                <xsl:value-of select="concat( substring(/Root/Period/Notes,1,10), '...')" />
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="substring(/Root/Period/Notes,1,10)" />
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </a>
                        </xsl:if>
                    </h2>
                </div>
                <div class="PeriodNav-container PeriodNav-container-next">
                    <div class="PeriodNav-next">
                        <xsl:choose>
                            <xsl:when test="normalize-space(/Root/Period/NextPeriodID)">
                                <xsl:call-template name="uiButton">
                                    <xsl:with-param name="iconRightType" select="'arrow-right'" />
                                    <xsl:with-param name="content" select="'Next Period'" />
                                    <xsl:with-param name="url">?period=<xsl:value-of select="Period/NextPeriodID" /></xsl:with-param>
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:otherwise>
                                &#160;
                            </xsl:otherwise>
                        </xsl:choose>
                    </div>
                </div>
            </div>
        </div>
    </xsl:template>

    <xsl:template name="currentPeriodLayout">
        <xsl:call-template name="periodNav" />

        <div class="Tracker-section">
            <xsl:call-template name="uploadErrors" />
            <xsl:if test="Messages/Message/Type = 'error'">
                <xsl:call-template name="trackerErrorMessages" />
            </xsl:if>
            <xsl:if test="RejectedFiles/RejectedFile">
                <xsl:call-template name="rejectedFileMessages" />
            </xsl:if>
            <xsl:if test="Messages/Message/Code != 'form_submit_success'">
                <xsl:call-template name="trackerSuccessMessages" />
            </xsl:if>
            <xsl:if test="/Root/Access/bookpub/tracker/upload">
                <xsl:call-template name="trackerNewFiles" />
            </xsl:if>
        </div>

        <xsl:if test="Files/OnHoldFiles/OnHoldFile">
            <div class="Tracker-section">
                <xsl:call-template name="trackerOnHoldChart" />
            </div>
        </xsl:if>

        <div class="Tracker-section">
            <xsl:call-template name="trackerOpenChart" />
        </div>

        <div class="Tracker-section">
            <xsl:call-template name="trackerClosedChart" />
        </div>

        <xsl:if test="Access/bookpub/tracker/close = 1 and Period/PeriodID = 0">
            <div class="Tracker-close-period-wrapper">
                <xsl:call-template name="uiButton">
                    <xsl:with-param name="elemType" select="'button'" />
                    <xsl:with-param name="type" select="'primary'" />
                    <xsl:with-param name="content" select="'Close Current Period'" />
                    <xsl:with-param name="id" select="'confirmBoxOpener'" />
                    <xsl:with-param name="disabled">
                        <xsl:if test="not(Files/ClosedFiles/ClosedFile) or /Root/Form/RoyaltyRunStatus/CanEdit = 0">
                            <xsl:text>true</xsl:text>
                        </xsl:if>
                    </xsl:with-param>
                    <xsl:with-param name="onClick">confirmClosePeriod(<xsl:value-of select="Files/OpenFiles/openFileCount" />);</xsl:with-param>
                </xsl:call-template>
            </div>
        </xsl:if>
    </xsl:template>


    <xsl:template name="currentPeriodDownloads">
        <xsl:variable name="currentPeriodDownloadsItems">
            <map>
                <xsl:if test="Access/bookpub/tracker/currentrecon = 1">
                    <mapEntry><name>Current Reconciliation Report</name><value>currentrecon</value></mapEntry>
                </xsl:if>
                <xsl:if test="Access/bookpub/tracker/trackerdl = 1">
                    <mapEntry><name>File Summary</name><value>trackerdl</value></mapEntry>
                </xsl:if>
                <xsl:if test="Access/bookpub/tracker/exceptionsdl = 1">
                    <mapEntry>
                        <name>Generate Catalog Exceptions Report</name>
                        <value>allexceptions</value>
                        <separated>true</separated>
                        <custom>true</custom>
                        <dataAttrs>
                            <attr>
                                <name>data-report-id</name>
                                <value>exceptionsdl</value>
                            </attr>
                            <attr>
                                <name>data-date-is-loading</name>
                                <value>
                                    <xsl:if test="Report/Exceptions/Status = 1">
                                        <xsl:text>true</xsl:text>
                                    </xsl:if>
                                </value>
                            </attr>
                        </dataAttrs>
                    </mapEntry>

                    <mapEntry>
                        <name>All Catalog Exceptions</name>
                        <value>exceptionsdl</value>
                        <xsl:if test="Report/Exceptions/Status = 0 or not(Report/Exceptions/DateGenerated)">
                            <disabled>true</disabled>
                        </xsl:if>

                        <dataAttrs>
                            <attr>
                                <name>data-date-generated</name>
                                <value><xsl:value-of select="Report/Exceptions/DateGenerated" /></value>
                            </attr>
                            <attr>
                                <name>data-date-is-generatable</name>
                                <value>true</value>
                            </attr>
                        </dataAttrs>

                    </mapEntry>
                </xsl:if>
                <xsl:if test="Access/bookpub/tracker/price_exceptionsdl = 1">
                    <mapEntry>
                        <name>Generate Price Exceptions Report</name>
                        <value>all_price_exceptions</value>
                        <separated>true</separated>
                        <custom>true</custom>
                        <dataAttrs>
                            <attr>
                                <name>data-report-id</name>
                                <value>price_exceptionsdl</value>
                            </attr>
                            <attr>
                                <name>data-date-is-loading</name>
                                <value>
                                    <xsl:if test="Report/PriceExceptions/Status = 1">
                                        <xsl:text>true</xsl:text>
                                    </xsl:if>
                                </value>
                            </attr>
                        </dataAttrs>
                    </mapEntry>

                    <mapEntry>
                        <name>All Price Exceptions</name>
                        <value>price_exceptionsdl</value>
                        <xsl:if test="Report/PriceExceptions/Status = 0 or not(Report/PriceExceptions/DateGenerated)">
                            <disabled>true</disabled>
                        </xsl:if>

                        <dataAttrs>
                            <attr>
                                <name>data-date-generated</name>
                                <value><xsl:value-of select="Report/PriceExceptions/DateGenerated" /></value>
                            </attr>

                            <attr>
                                <name>data-date-is-generatable</name>
                                <value>true</value>
                            </attr>
                        </dataAttrs>

                    </mapEntry>
                </xsl:if>
            </map>
        </xsl:variable>

        <xsl:call-template name="uiDropdown">
            <xsl:with-param name="items" select="$currentPeriodDownloadsItems"/>
            <xsl:with-param name="id" select="'tracker-download-reports-dropdown'"/>
            <xsl:with-param name="align" select="'right'"/>
            <xsl:with-param name="caption" select="'Download Reports'"/>
            <xsl:with-param name="renderIndependent" select="'true'"/>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="trackerOpenChart">
        <xsl:variable name="openFilePref" select="OpenFileSettings/FileType" />
        <xsl:variable name="serviceSelected" select="OpenFileSettings/ServiceID" />
        <xsl:variable name="pageSize" select="OpenFileSettings/PageSize" />
        <div class="Tracker-open-chart" id="openFileContainer">
            <h3 class="Tracker-sub-header">Open Files</h3>
            <div class="Table-controls Table-controls-top">
                <div class="Table-controls-item">
                    <form action="/bookpub/tracker" id="openFilesSetting" method="post" >
                        <div class="Form-group Form-group-horizontal">
                            <div class="Form-item">
                                <label class="Form-label">
                                    <span class="Form-label-caption">Now Viewing</span>
                                    <div class="Form-input-wrapper">
                                        <xsl:variable name="selectFiletype">
                                            <map>
                                                <mapEntry><value>1</value><name>Current Files</name></mapEntry>
                                                <mapEntry><value>2</value><name>Suspense Files</name></mapEntry>
                                                <mapEntry><value>3</value><name>All Files</name></mapEntry>
                                            </map>
                                        </xsl:variable>
                                        <xsl:call-template name="uiDropdown">
                                            <xsl:with-param name="items" select="$selectFiletype"/>
                                            <xsl:with-param name="name" select="'fileType'" />
                                            <xsl:with-param name="id" select="'fileType'" />
                                            <xsl:with-param name="active" select="$openFilePref" />
                                            <xsl:with-param name="className" select="'Tracker-now-view-select'"/>
                                        </xsl:call-template>
                                    </div>
                                </label>
                            </div>
                            <div class="Form-item">
                                <label class="Form-label">
                                    <span class="Form-label-caption">From</span>
                                    <div class="Form-input-wrapper">
                                        <xsl:variable name="selectServiceid">
                                            <map>
                                                <mapEntry><value>0</value><name>All Services</name></mapEntry>
                                                <xsl:for-each select="OpenFileSettings/ServiceList/Service">
                                                    <mapEntry><value><xsl:value-of select="serviceID"/></value><name><xsl:value-of select="serviceName" /></name></mapEntry>
                                                </xsl:for-each>
                                            </map>
                                        </xsl:variable>
                                        <xsl:call-template name="uiDropdown">
                                            <xsl:with-param name="items" select="$selectServiceid"/>
                                            <xsl:with-param name="name" select="'serviceID'" />
                                            <xsl:with-param name="id" select="'serviceID'" />
                                            <xsl:with-param name="active" select="$serviceSelected" />
                                            <xsl:with-param name="className" select="'Tracker-from-service-select'"/>
                                        </xsl:call-template>
                                    </div>
                                </label>
                            </div>
                            <div class="Form-item">
                                <label class="Form-label">
                                    <span class="Form-label-caption">Files per Page</span>
                                    <div class="Form-input-wrapper">
                                        <xsl:variable name="selectPagesize">
                                            <map>
                                                <mapEntry><value>25</value><name>25</name></mapEntry>
                                                <mapEntry><value>50</value><name>50</name></mapEntry>
                                                <mapEntry><value>100</value><name>100</name></mapEntry>
                                                <mapEntry><value>all</value><name>All</name></mapEntry>
                                            </map>
                                        </xsl:variable>
                                        <xsl:call-template name="uiDropdown">
                                            <xsl:with-param name="items" select="$selectPagesize"/>
                                            <xsl:with-param name="name" select="'pageSize'" />
                                            <xsl:with-param name="id" select="'pageSize'" />
                                            <xsl:with-param name="active" select="$pageSize" />
                                            <xsl:with-param name="className" select="'Tracker-files-count-select'"/>
                                        </xsl:call-template>
                                    </div>
                                </label>
                            </div>
                            <div class="Form-item">
                                <xsl:call-template name="uiButton">
                                    <xsl:with-param name="content">
                                        Update
                                    </xsl:with-param>
                                    <xsl:with-param name="elemType" select="'submit'" />
                                </xsl:call-template>
                            </div>
                        </div>
                    </form>
                </div>
                <xsl:if test="Access/bookpub/tracker/upload or Access/bookpub/tracker/currentrecon">
                    <div class="Table-controls-item Table-controls-item-additive">
                        <xsl:call-template name="currentPeriodDownloads" />
                    </div>
                </xsl:if>
            </div>
            <form name="qwikclose" id="qwikclose" action="/bookpub/tracker" method="post">
                <input type="hidden" name="page" value="{Params/page}" />
                <xsl:if test="Files/OpenFiles/totalRecords > 0">
                    <div class="Table-wrapper">
                        <table class="Table Table-with-highlight">
                            <thead>
                                <xsl:call-template name="openFileHeaderRow" />
                            </thead>
                            <tbody>
                                <xsl:for-each select="Files/OpenFiles/OpenFile">
                                    <xsl:call-template name="openFileRow" />
                                </xsl:for-each>
                            </tbody>
                        </table>
                    </div>
                </xsl:if>
                <xsl:if test="Files/OpenFiles/totalRecords = 0">
                    <div class="Pagination-info">
                        <span class="Pagination-total-count">0</span> files
                    </div>
                </xsl:if>
                <xsl:if test="Access/bookpub/tracker/qwikclose = 1 and Files/OpenFiles/totalRecords > 0">
                    <div class="Tracker-table-controls Table-controls Table-controls-bottom">
                        <div class="Table-controls-item Table-controls-item-buttons">
                            <input type="hidden" name="c" value="qwikclose"/>
                            <input type="hidden" name="formSubmit" value="1" />
                            <xsl:call-template name="uiButton">
                                <xsl:with-param name="content" select="'Finish Selected Files'" />
                                <xsl:with-param name="type" select="'primary'" />
                                <xsl:with-param name="disabled" select="'true'" />
                                <xsl:with-param name="id" select="'qwikcloseBoxOpener'" />
                            </xsl:call-template>
                        </div>
                        <div class="Table-controls-item Table-controls-item-pagination">
                            <xsl:if test="Files/OpenFiles/totalRecords > 0">
                                <xsl:call-template name="uiPagination">
                                    <xsl:with-param name="lastPage" select="Files/OpenFiles/pageCount" />
                                    <xsl:with-param name="totalCount" select="Files/OpenFiles/totalRecords" />
                                    <xsl:with-param name="currentPage" select="$currentPage" />
                                </xsl:call-template>
                            </xsl:if>
                        </div>
                    </div>
                </xsl:if>
            </form>
        </div>
    </xsl:template>

    <xsl:template name="openFileHeaderRow">
        <xsl:if test="$displayPriceExceptions = 1">
            <tr class="Table-row Table-row-header">
                <xsl:if test="floor( /Root/Client/TypeMask div 2048) mod 2 = 1">
                    <th class="Table-col" />
                </xsl:if>
                <xsl:if test="/Root/Access/bookpub/tracker/qwikclose = 1">
                    <th class="Table-col"/>
                </xsl:if>
                <th class="Table-col" colspan="6" />
                <th class="Table-col Table-col-nowrap" colspan="4">Exceptions</th>
                <xsl:if test="/Root/Access/bookpub/tracker/notes">
                    <th class="Table-col" />
                </xsl:if>
                <th class="Table-col" />
            </tr>
        </xsl:if>
        <tr class="Table-row Table-row-header">
            <xsl:if test="/Root/Access/bookpub/tracker/qwikclose = 1">
                <th class="Table-col Table-col-select">
                    <xsl:call-template name="uiCheckbox">
                        <xsl:with-param name="name" select="'select_all'"/>
                        <xsl:with-param name="className" select="'qwikcloseCheckAll'"/>
                    </xsl:call-template>
                </th>
            </xsl:if>
            <xsl:call-template name="openFileHeaderCell">
                <xsl:with-param name="sortBy" select="'service_name'" />
                <xsl:with-param name="displayName" select="'Service'" />
            </xsl:call-template>
            <xsl:call-template name="openFileHeaderCell">
                <xsl:with-param name="sortBy" select="'orig_file_name'" />
                <xsl:with-param name="displayName" select="'File Name'" />
            </xsl:call-template>
            <xsl:call-template name="openFileHeaderCell">
                <xsl:with-param name="sortBy" select="'date_created'" />
                <xsl:with-param name="displayName" select="'Received'" />
            </xsl:call-template>
            <xsl:call-template name="openFileHeaderCell">
                <xsl:with-param name="sortBy" select="'units'" />
                <xsl:with-param name="displayName" select="'Units'" />
                <xsl:with-param name="class" select="'Table-col-amount'" />
            </xsl:call-template>
            <xsl:call-template name="openFileHeaderCell">
                <xsl:with-param name="sortBy" select="'revenue'" />
                <xsl:with-param name="displayName" select="'Revenue'" />
                <xsl:with-param name="class" select="'Table-col-amount'" />
            </xsl:call-template>
            <xsl:if test="floor( /Root/Client/TypeMask div 2048) mod 2 = 1">
                <th class="Table-col Table-col-icon">
                    <span class="js-tooltip" title="Alternate Currency Conversion">Alt</span>
                </th>
            </xsl:if>
            <xsl:call-template name="openFileHeaderCell">
                <xsl:with-param name="sortBy" select="'records'" />
                <xsl:with-param name="displayName" select="'Records'" />
                <xsl:with-param name="class" select="'Table-col-amount'" />
            </xsl:call-template>
            <xsl:choose>
                <xsl:when test="$displayPriceExceptions = 1">
                    <xsl:call-template name="openFileHeaderCell">
                        <xsl:with-param name="sortBy" select="'remaining_exceptions'" />
                        <xsl:with-param name="displayName" select="'Catalog'" />
                        <xsl:with-param name="class" select="'Table-col-amount'" />
                        <xsl:with-param name="colspan" select="'2'" />
                    </xsl:call-template>
                    <xsl:call-template name="openFileHeaderCell">
                        <xsl:with-param name="sortBy" select="'price_exceptions_unapproved'" />
                        <xsl:with-param name="displayName" select="'Price'" />
                        <xsl:with-param name="class" select="'Table-col-amount'" />
                        <xsl:with-param name="colspan" select="'2'" />
                    </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                     <xsl:call-template name="openFileHeaderCell">
                        <xsl:with-param name="sortBy" select="'remaining_exceptions'" />
                        <xsl:with-param name="displayName" select="'Exceptions'" />
                        <xsl:with-param name="class" select="'Table-col-amount'" />
                        <xsl:with-param name="colspan" select="'2'" />
                    </xsl:call-template>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:if test="/Root/Access/bookpub/tracker/notes">
                <xsl:call-template name="openFileHeaderCell">
                    <xsl:with-param name="sortBy" select="'notes'" />
                    <xsl:with-param name="displayName" select="'Notes'" />
                    <xsl:with-param name="class" select="'Table-col Table-col-icon'" />
                </xsl:call-template>
            </xsl:if>
            <th class="Table-col Table-col-icon">
                Delete
            </th>
        </tr>
    </xsl:template>

    <xsl:template name="openFileHeaderCell">
        <xsl:param name="sortBy" />
        <xsl:param name="displayName" />
        <xsl:param name="class" />
        <xsl:param name="colspan" select="'1'" />
        <th colspan="{$colspan}" class="Table-col {$class} Table-col-nowrap">
            <xsl:variable name="sortOrder">
                <xsl:choose>
                    <xsl:when test="/Root/OpenFileSettings/SortBy = $sortBy and (/Root/OpenFileSettings/ReverseSort = 0 or /Root/OpenFileSettings/ReverseSort = '')">1</xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <xsl:call-template name="uiTableSorting">
                <xsl:with-param name="caption" select="$displayName" />
                <xsl:with-param name="sortBy" select="OpenFileSettings/SortBy"/>
                <xsl:with-param name="name" select="$sortBy"/>
                <xsl:with-param name="sortReverse" select="/Root/OpenFileSettings/ReverseSort" />
                <xsl:with-param name="onClick">
                    location.href='/bookpub/tracker?page=<xsl:value-of select="$currentPage" />&amp;sortBy=<xsl:value-of select="$sortBy" />'
                </xsl:with-param>
            </xsl:call-template>
        </th>
    </xsl:template>

    <xsl:template name="openFileRow">
        <tr class="Table-row Table-row-data">
            <xsl:if test="/Root/Access/bookpub/tracker/qwikclose = 1">
                <td class="Table-col Table-col-select">
                    <xsl:if test="QwikClose = 1">
                        <xsl:call-template name="uiCheckbox">
                            <xsl:with-param name="name" select="'file'"/>
                            <xsl:with-param name="className" select="'qwikcloseBox'"/>
                            <xsl:with-param name="value">
                                <xsl:value-of select="FileID" />
                            </xsl:with-param>
                            <xsl:with-param name="onClick">
                                qwikcloseToggled(this.checked)
                            </xsl:with-param>
                        </xsl:call-template>
                    </xsl:if>
                </td>
            </xsl:if>
            <td class="Table-col">
                <xsl:value-of select="ServiceName" />
            </td>
            <td class="Table-col">
                <a name="file{FileID}" />
                <xsl:choose>
                    <xsl:when test="/Root/Access/bookpub/tracker/saveas">
                        <a href="/bookpub/tracker?c=saveas&amp;file={FileID}&amp;period={/Root/Period/PeriodID}" class="js-tooltip">
                            <xsl:if test="/Root/User/AccessLevel = 1">
                                <xsl:attribute name="title">
                                    <xsl:if test="OriginalServiceID &gt; 0">
                                        <xsl:value-of select="concat(OriginalServiceName, ' Template', '&lt;br /&gt;')" />
                                    </xsl:if>
                                    Importer Version:
                                    <xsl:value-of select="VersionNum" />
                                </xsl:attribute>
                            </xsl:if>
                            <xsl:value-of select="PrettyFileName" />
                        </a>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="PrettyFileName" />
                    </xsl:otherwise>
                </xsl:choose>
            </td>
            <td class="Table-col">
                <xsl:value-of select="DateCreated" />
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="Units" />
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:if test="CurrencyCode != /Root/Client/Locale/CurrencyFormat/CurrencyCode">
                    <xsl:choose>
                        <xsl:when test="/Root/Access/bookpub/tracker/revenue = 1 and (Revenue = '' or normalize-space(InputRevenue))">
                            (<a href="/bookpub/tracker?c=revenue&amp;file={FileID}&amp;page={$currentPage}"><xsl:value-of select="Revenue/currency_symbol" /><xsl:value-of select="translate(translate(Revenue, '-', '&#8209;'), ' ', '&#160;')" />&#160;<xsl:value-of select="CurrencyCode" /></a>)
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:if test="InputConversionRate != 0">
                                (<xsl:value-of select="translate(translate(Revenue, '-', '&#8209;'), ' ', '&#160;')" />&#160;<xsl:value-of select="CurrencyCode" />)
                            </xsl:if>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:if>
                <xsl:choose>
                    <xsl:when test="/Root/Access/bookpub/tracker/revenue = 1 and ParentFileID = '' and HasChild = 0 and (Revenue/@value = 0 or Revenue = '' or normalize-space(InputRevenue))">
                        <xsl:choose>
                            <xsl:when test="CurrencyCode = /Root/Client/Locale/CurrencyFormat/CurrencyCode">
                                <a href="/bookpub/tracker?c=revenue&amp;file={FileID}&amp;page={$currentPage}">
                                    <xsl:call-template name="revenueAmount" />
                                </a>
                            </xsl:when>
                            <xsl:when test="normalize-space(Revenue) and InputConversionRate != 0 and normalize-space(InputRevenue) = ''">
                                <a href="/bookpub/tracker?c=revenue&amp;file={FileID}&amp;page={$currentPage}">
                                    <xsl:call-template name="revenueAmount" />
                                </a>
                            </xsl:when>
                            <xsl:when test="normalize-space(Revenue) and InputConversionRate != 0">
                                <a href="/bookpub/tracker?c=currency&amp;file={FileID}&amp;page={$currentPage}">
                                    <xsl:call-template name="revenueAmount" />
                                </a>
                            </xsl:when>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:when test="/Root/Access/bookpub/tracker/currency = 1 and ParentFileID = '' and HasChild = 0 and normalize-space(Revenue) and (ConversionInput != 0 or InputConversionRate != 0)">
                        <a href="/bookpub/tracker?c=currency&amp;file={FileID}&amp;page={$currentPage}">
                            <xsl:call-template name="revenueAmount" />
                        </a>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:if test="not(File/MultipleRevenue)">
                            <xsl:choose>
                                <xsl:when test="InputConversionRate != 0 and ParentFileID = '' and HasChild = 0">
                                    <a href="/bookpub/tracker?c=currency&amp;file={FileID}&amp;page={$currentPage}">
                                        <xsl:call-template name="revenueAmount" />
                                    </a>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="revenueAmount" />
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:if>
                        <xsl:if test="File/MultipleRevenue and ParentFileID = '' and HasChild = 0 and CurrencyCode != /Root/Client/Locale/CurrencyFormat/CurrencyCode">
                            <a href="/bookpub/tracker?c=revenue&amp;file={FileID}&amp;page={$currentPage}">
                                <xsl:call-template name="revenueAmount" />
                            </a>
                        </xsl:if>
                        <xsl:if test="File/MultipleRevenue and ParentFileID = '' and HasChild = 0 and CurrencyCode = /Root/Client/Locale/CurrencyFormat/CurrencyCode">
                            <xsl:call-template name="revenueAmount" />
                        </xsl:if>
                        <xsl:if test="File/MultipleRevenue and (ParentFileID != '' or HasChild = 1)">
                            <xsl:call-template name="revenueAmount" />
                        </xsl:if>
                    </xsl:otherwise>
                </xsl:choose>
            </td>
            <!-- Alternate Currency Conversion = bit 11 of RSCOMMON.client_type (2048 = 2^11) -->
            <xsl:if test="floor( /Root/Client/TypeMask div 2048) mod 2 = 1">
                <td class="Table-col Table-col-icon">
                    <xsl:choose>
                        <xsl:when test="CurrencyCode != 'MUL'">
                            <xsl:if test="AlternateConversionRate">
                                <a href="/bookpub/tracker?c=currency&amp;file={FileID}&amp;page={$currentPage}" class="js-tooltip" title="{translate(AlternateConversionRate*Revenue/@value,'$','')} {AlternateCurrencyCode}">
                                    <xsl:call-template name="icon">
                                        <xsl:with-param name="type" select="'currency'" />
                                        <xsl:with-param name="role" select="'action'" />
                                    </xsl:call-template>
                                </a>
                            </xsl:if>
                            <xsl:if test="ParentFileID = '' and HasChild = 0 and not(AlternateConversionRate)">
                                <a href="/bookpub/tracker?c=currency&amp;file={FileID}&amp;page={$currentPage}">Alt</a>
                            </xsl:if>
                        </xsl:when>
                        <xsl:when test="CurrencyCode = 'MUL'">

                            <xsl:variable name="titleText">
                                <xsl:for-each select="AlternateCurrencyList/Currency[string(AlternateCurrencyTotal) != '']">
                                        <xsl:value-of select="concat(format-number(AlternateCurrencyTotal, '#.##'), ' ', AlternateCurrencyCode)"/>
                                        <xsl:if test="position() != last()">
                                            <xsl:text>, &#10;</xsl:text>
                                        </xsl:if>
                                </xsl:for-each>
                            </xsl:variable>

                            <xsl:if test="AlternateConversionRate">
                                <a href="/bookpub/tracker?c=currency&amp;file={FileID}&amp;page={$currentPage}" class="js-tooltip" data-title="{$titleText}">
                                    <xsl:call-template name="icon">
                                        <xsl:with-param name="type" select="'currency'" />
                                        <xsl:with-param name="role" select="'action'" />
                                    </xsl:call-template>
                                </a>
                            </xsl:if>
                            <xsl:if test="ParentFileID = '' and HasChild = 0 and not(AlternateConversionRate)">
                                <a href="/bookpub/tracker?c=currency&amp;file={FileID}&amp;page={$currentPage}">Alt</a>
                            </xsl:if>
                        </xsl:when>
                        <xsl:otherwise>
                            &#160;
                        </xsl:otherwise>
                    </xsl:choose>
                </td>
            </xsl:if>
            <td class="Table-col Table-col-amount Table-col-nowrap">
                <xsl:value-of select="Records" />
            </td>
            <td class="Table-col Table-col-amount Table-col-nowrap">
                <xsl:choose>
                    <xsl:when test="RemainingExceptions/@raw != 0 and /Root/Access/bookpub/tracker/exceptions = 1 and /Root/Access/bookpub/matcher/match = 1">
                        <a href="/bookpub/matcher?file={FileID}&amp;trackerPage={$currentPage}&amp;c=sale">
                            <xsl:value-of select="RemainingExceptions" />
                        </a>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="RemainingExceptions" />
                    </xsl:otherwise>
                </xsl:choose>
            </td>
            <td class="Table-col Table-col-icon">
                <xsl:if test="RemainingExceptions/@raw != 0 and /Root/Access/bookpub/tracker/exceptions = 1">
                    <a href="/bookpub/tracker?c=exceptions&amp;file={FileID}" title="Download Catalog Exceptions Report" class="js-tooltip">
                        <xsl:call-template name="icon">
                            <xsl:with-param name="type" select="'download'" />
                            <xsl:with-param name="role" select="'action'" />
                        </xsl:call-template>
                    </a>
                </xsl:if>
            </td>
            <xsl:variable name="priceExceptionCount">
                <xsl:choose>
                    <xsl:when test="normalize-space(PriceExceptionsUnapproved/@raw)">
                        <xsl:value-of select="PriceExceptionsUnapproved/@raw" />
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <xsl:if test="$displayPriceExceptions = 1">
                <td class="Table-col Table-col-amount Table-col-nowrap">
                    <xsl:choose>
                        <xsl:when test="Service/ClientConfig/ValidatePrice != 1">-</xsl:when>
                        <xsl:when test="PriceExceptions/@raw &gt; 0 and /Root/Access/bookpub/price/exceptions = 1">
                            <a href="/bookpub/price?File={FileID}&amp;c=exceptions&amp;Service={ServiceID}&amp;trackerPage={$currentPage}">
                                <xsl:value-of select="PriceExceptionsUnapproved" />
                            </a>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$priceExceptionCount" />
                        </xsl:otherwise>
                    </xsl:choose>
                </td>
                <td class="Table-col Table-col-icon">
                    <xsl:if test="PriceExceptions/@raw &gt; 0 and /Root/Access/bookpub/tracker/price_exceptions = 1 and Service/ClientConfig/ValidatePrice = 1">
                        <a href="/bookpub/tracker?c=price_exceptions&amp;file={FileID}" title="Download Price Exceptions Report" class="js-tooltip">
                            <xsl:call-template name="icon">
                                <xsl:with-param name="type" select="'download'" />
                                <xsl:with-param name="role" select="'action'" />
                            </xsl:call-template>
                        </a>
                    </xsl:if>
                </td>
            </xsl:if>
            <xsl:variable name="catalogExceptionCount">
                <xsl:choose>
                    <xsl:when test="normalize-space(RemainingExceptions/@raw)">
                        <xsl:value-of select="RemainingExceptions/@raw" />
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <xsl:variable name="exceptionCount">
                <xsl:choose>
                    <xsl:when test="$displayPriceExceptions = 1">
                        <xsl:value-of select="$catalogExceptionCount + $priceExceptionCount" />
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="$catalogExceptionCount" />
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <xsl:if test="/Root/Access/bookpub/tracker/notes">
                <td class="Table-col Table-col-icon">
                    <a class="js-tooltip">
                        <xsl:attribute name="href">/bookpub/tracker?c=notes&amp;page=<xsl:value-of select="$currentPage" />&amp;file=<xsl:value-of select="FileID" />&amp;period=<xsl:value-of select="/Root/Period/PeriodID"/></xsl:attribute>
                        <xsl:choose>
                            <xsl:when test="normalize-space(Notes) = ''">
                                <xsl:attribute name="title">Add Note</xsl:attribute>
                                <xsl:call-template name="icon">
                                    <xsl:with-param name="type" select="'note'" />
                                    <xsl:with-param name="role" select="'action'" />
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:attribute name="title"><xsl:value-of select="Notes" /></xsl:attribute>
                                <xsl:value-of select="substring(Notes,1,3)" />
                            </xsl:otherwise>
                        </xsl:choose>
                    </a>
                </td>
            </xsl:if>
            <td class="Table-col Table-col-icon">
                <xsl:if test="/Root/Access/bookpub/tracker/delete = 1 and HasChild = 0 and ParentFileID = ''">
                    <xsl:variable name="apos">'</xsl:variable>
                    <xsl:variable name="escaped">"</xsl:variable>
                    <a title="Delete File" class="js-tooltip">
                        <xsl:attribute name="href">javascript:confirmDeleteFile('<xsl:value-of select="translate(PrettyFileName,$apos,$escaped)" />',<xsl:value-of select="FileID" />,<xsl:value-of select="$currentPage" />,<xsl:value-of select="TotalExceptions/@raw" />,<xsl:value-of select="RemainingExceptions/@raw" />)</xsl:attribute>
                        <xsl:call-template name="icon">
                            <xsl:with-param name="type" select="'delete'" />
                            <xsl:with-param name="role" select="'action'" />
                        </xsl:call-template>
                    </a>
                </xsl:if>
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="revenueAmount">
        <xsl:choose>
            <xsl:when test="normalize-space(RevenueBase)">
                <xsl:value-of select="RevenueBase" />
            </xsl:when>
            <xsl:when test="normalize-space(Revenue)">
                <xsl:value-of select="Revenue" />
            </xsl:when>
            <xsl:when test="FileStatus = 4"><xsl:value-of select="/Root/Client/Locale/CurrencyFormat/Symbol" />0<xsl:value-of select="/Root/Client/Locale/NumericFormat/Decimal" />00</xsl:when>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="trackerClosedChart">
        <div class="Tracker-closed-chart">
            <h3 class="Tracker-sub-header">Finished Files</h3>
            <div>
                <xsl:if test="Files/ClosedFiles/ClosedFile">
                    <xsl:attribute name="class">scrollTable</xsl:attribute>
                    <xsl:attribute name="id">closedFilesContainer</xsl:attribute>
                    <div class="Table-wrapper">
                        <table class="Table Table-with-highlight">
                            <thead>
                                <xsl:call-template name="trackerClosedHeaderRow" />
                            </thead>
                            <tbody>
                                <xsl:for-each select="Files/ClosedFiles/ClosedFile">
                                    <xsl:call-template name="closedFileRow" />
                                </xsl:for-each>
                            </tbody>
                        </table>
                    </div>
                </xsl:if>
            </div>
            <xsl:if test="not(Files/ClosedFiles/ClosedFile)">
                <p>Files have not been finished for this period.</p>
            </xsl:if>
            <xsl:call-template name="trackerDialogueBox" />
        </div>
    </xsl:template>

    <xsl:template name="trackerDialogueBox">
        <xsl:if test="Access/bookpub/tracker/close = 1 and Period/PeriodID = 0">
            <form action="/bookpub/tracker" id="royaltyClose" name="royaltyClose">
                <input type="hidden" name="c" value="close" />
                <input type="hidden" id="royaltyCloseFiles" name="royaltyCloseFiles" value="{Files/UnprocessedCount}" />
                <xsl:if test="not(Files/ClosedFiles/ClosedFile)">
                    <p>At least 1 file must be processed before a period can be closed.</p>
                </xsl:if>
            </form>
        </xsl:if>
    </xsl:template>

    <xsl:template name="trackerOnHoldChart">
        <div class="Tracker-on-hold">
            <h3 class="Tracker-sub-header">Files On Hold</h3>
            <table class="Table Table-with-highlight">
                <thead>
                    <tr class="Table-row Table-row-header">
                        <th class="Table-col Tracker-col-service">Service</th>
                        <th class="Table-col Tracker-col-file-name">File Name</th>
                        <th class="Table-col">Errors</th>
                        <th class="Table-col Table-col-shrink">Received</th>
                        <xsl:if test="/Root/Access/bookpub/tracker/notes">
                            <th class="Table-col Table-col-icon">Notes</th>
                        </xsl:if>
                        <xsl:if test="/Root/User/AccessLevel = 1 or /Root/User/AccessLevel = 2">
                            <th class="Table-col Table-col-icon">Delete</th>
                        </xsl:if>
                    </tr>
                </thead>
                <tbody>
                    <xsl:for-each select="Files/OnHoldFiles/OnHoldFile">
                        <xsl:sort select="DateCreated" order="descending" />
                        <tr class="Table-row Table-row-data">
                            <td class="Table-col Tracker-col-service">
                                <xsl:value-of select="ServiceName" />
                            </td>
                            <td class="Table-col Tracker-col-file-name">
                                <a>
                                    <xsl:if test="/Root/Access/bookpub/tracker/saveas = 1">
                                        <xsl:attribute name="href">/bookpub/tracker?c=saveas&amp;file=<xsl:value-of select="FileID" />&amp;period=<xsl:value-of select="/Root/Period/PeriodID" /></xsl:attribute>
                                    </xsl:if>
                                    <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="PrettyFileName" />
                                </a>
                            </td>
                            <td class="Table-col">
                                Missing Sales File Attributes
                            </td>
                            <td class="Table-col Table-col-shrink">
                                <xsl:value-of select="DateCreated" />
                            </td>
                            <xsl:if test="/Root/Access/bookpub/tracker/notes">
                                <td class="Table-col Table-col-icon">
                                    <a class="js-tooltip">
                                        <xsl:attribute name="href">/bookpub/tracker?c=notes&amp;file=<xsl:value-of select="FileID" />&amp;period=<xsl:value-of select="/Root/Period/PeriodID"/>&amp;page=<xsl:value-of select="$currentPage" /></xsl:attribute>
                                        <xsl:choose>
                                            <xsl:when test="normalize-space(Notes) = ''">
                                                <xsl:attribute name="title">Add Note</xsl:attribute>
                                                <xsl:call-template name="icon">
                                                    <xsl:with-param name="type" select="'note'" />
                                                    <xsl:with-param name="role" select="'action'" />
                                                </xsl:call-template>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:attribute name="title"><xsl:value-of select="Notes" /></xsl:attribute>
                                                <xsl:value-of select="substring(Notes,1,3)" />
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </a>
                                </td>
                            </xsl:if>
                            <xsl:if test="/Root/User/AccessLevel = 1 or /Root/User/AccessLevel = 2">
                                <td class="Table-col Table-col-icon">
                                    <xsl:variable name="apos">'</xsl:variable>
                                    <xsl:variable name="escaped">"</xsl:variable>
                                    <a title="Delete File" class="js-tooltip">
                                        <xsl:attribute name="href">javascript:confirmDeleteFile('<xsl:value-of select="translate(PrettyFileName,$apos,$escaped)" />',<xsl:value-of select="FileID" />,<xsl:value-of select="$currentPage" />,0,0)</xsl:attribute>
                                        <xsl:call-template name="icon">
                                            <xsl:with-param name="type" select="'delete'" />
                                            <xsl:with-param name="role" select="'action'" />
                                        </xsl:call-template>
                                    </a>
                                </td>
                            </xsl:if>
                        </tr>
                    </xsl:for-each>
                </tbody>
            </table>
        </div>
    </xsl:template>

    <xsl:template name="closedPeriodLayout">
        <xsl:call-template name="periodNav" />
        <div class="Tracker-downloads Tracker-section">
            <xsl:if test="Messages/Message/Type = 'error'">
                <xsl:call-template name="trackerErrorMessages" />
            </xsl:if>
            <xsl:if test="Messages/Message/Type = 'success'">
                <xsl:call-template name="trackerSuccessMessages" />
            </xsl:if>
            <div class="Tracker-downloads-wrapper">
                <xsl:call-template name="trackerDownload" />
                <xsl:call-template name="periodSummary" />
            </div>
        </div>
        <div class="Tracker-files Tracker-section">
            <xsl:call-template name="trackerClosedChart" />
        </div>
    </xsl:template>

    <xsl:template name="trackerDownload">
        <h3>Download Closed Period Reports</h3>
        <div class="Tracker-downloads-content">
            <ul class="Tracker-download-list">
                <xsl:if test="/Root/Report/RoyaltyExcel">
                    <li class="Tracker-download-item">
                        <xsl:call-template name="uiDownloadLink">
                            <xsl:with-param name="url">/bookpub/tracker?c=download_royalty_report_excel&amp;period=<xsl:value-of select="Period/PeriodID" /></xsl:with-param>
                            <xsl:with-param name="text" select="'Output File (Excel)'" />
                        </xsl:call-template>
                    </li>
                </xsl:if>


                <li class="Tracker-download-item">
                    <xsl:choose>
                        <xsl:when test="/Root/Report/Royalty/Status = 1">
                            <xsl:call-template name="uiDownloadLink">
                                <xsl:with-param name="url">/bookpub/tracker?c=download_royalty_report&amp;period=<xsl:value-of select="Period/PeriodID" /></xsl:with-param>
                                <xsl:with-param name="text" select="'Output File'" />
                            </xsl:call-template>

                            <xsl:if test="/Root/Access/bookpub/tracker/redeliver_royalty_report = 1">
                                <span style="margin-left: 10px">
                                (<a title="Redeliver Output File" href="javascript:confirmRedeliver({/Root/Period/PeriodID})">
                                    <span>
                                        <span class="DownloadLink-icon">
                                            <xsl:call-template name="icon">
                                                <xsl:with-param name="type" select="'upload'" />
                                            </xsl:call-template>
                                        </span>
                                    </span>
                                    <span class="DownloadLink-text">
                                        <span class="DownloadLink-text-wrapper">
                                            Redeliver
                                        </span>
                                    </span>
                                </a>)
                                </span>
                            </xsl:if>
                        </xsl:when>
                        <xsl:otherwise>
                            <p>Reports Generating…</p>
                        </xsl:otherwise>
                    </xsl:choose>
                </li>


                <xsl:if test="/Root/Report/Reconciliation/Status = 1">
                    <li class="Tracker-download-item">
                        <xsl:call-template name="uiDownloadLink">
                            <xsl:with-param name="url">/bookpub/tracker?c=download_recon_report&amp;period=<xsl:value-of select="Period/PeriodID" /></xsl:with-param>
                            <xsl:with-param name="text" select="'Reconciliation'" />
                        </xsl:call-template>
                    </li>
                </xsl:if>
                <xsl:if test="/Root/Access/bookpub/tracker/redo_reports">
                    <li class="Tracker-download-item">
                        <xsl:call-template name="uiButton">
                            <xsl:with-param name="content">Delete and Regenerate Report Files</xsl:with-param>
                            <xsl:with-param name="type" select="'text-inline'" />
                            <xsl:with-param name="size" select="'large'" />
                            <xsl:with-param name="iconLeftType" select="'refresh'" />
                            <xsl:with-param name="onClick">confirmRegenerateReports(<xsl:value-of select="Period/PeriodID" />)</xsl:with-param>
                        </xsl:call-template>
                    </li>
                </xsl:if>
            </ul>
        </div>
    </xsl:template>

    <xsl:template name="periodSummary">
        <div class="Tracker-summary">
            <h3>Period Summary</h3>
            <p>Total Revenue: <strong><xsl:value-of select="Period/RevenueTotal" /></strong></p>
            <p>Total Units: <strong><xsl:value-of select="Period/UnitTotal" /></strong></p>
            <p>File Count: <strong><xsl:value-of select="Period/FileCount" /></strong></p>
        </div>
    </xsl:template>

    <xsl:template name="trackerClosedHeaderRow">
        <tr class="Table-row Table-row-header">
            <xsl:if test="not(Files/ClosedFiles/ClosedFile)">
                <xsl:attribute name="class">Table-row Table-row-header Table-row-textchartempty</xsl:attribute>
            </xsl:if>
            <th class="Table-col">Service</th>
            <th class="Table-col">File Name</th>
            <th class="Table-col">Received</th>
            <th class="Table-col Table-col-amount">Units</th>
            <th class="Table-col Table-col-amount">Revenue</th>
            <xsl:if test="floor( /Root/Client/TypeMask div 2048) mod 2 = 1">
                <th class="Table-col Table-col-icon">
                    <span class="js-tooltip" title="Alternate Currency Conversion">Alt</span>
                </th>
            </xsl:if>
            <th class="Table-col Table-col-amount">Records</th>
            <th class="Table-col">Closed</th>
            <xsl:if test="/Root/Access/bookpub/tracker/notes">
                <th class="Table-col Table-col-icon">Notes</th>
            </xsl:if>
            <th class="Table-col Table-col-icon"></th>
        </tr>
    </xsl:template>

    <xsl:template name="closedFileRow">
        <tr class="Table-row Table-row-data">
            <td class="Table-col">
                <xsl:choose>
                    <xsl:when test="TypeID = 5">License Income</xsl:when>
                    <xsl:otherwise><xsl:value-of select="ServiceName" /></xsl:otherwise>
                </xsl:choose>
            </td>
            <td class="Table-col">
                <a name="file{FileID}" />
                <xsl:choose>
                    <xsl:when test="/Root/Access/bookpub/tracker/saveas">
                        <a href="/bookpub/tracker?c=saveas&amp;file={FileID}&amp;period={/Root/Period/PeriodID}" class="js-tooltip">
                            <xsl:if test="/Root/User/AccessLevel = 1">
                                <xsl:attribute name="title">Importer Version: <xsl:value-of select="VersionNum" /></xsl:attribute>
                            </xsl:if>
                            <xsl:value-of select="PrettyFileName" />
                        </a>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="PrettyFileName" />
                    </xsl:otherwise>
                </xsl:choose>
            </td>
            <td class="Table-col">
                <xsl:value-of select="DateCreated" />
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="Units" />
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:if test="CurrencyCode != /Root/Client/Locale/CurrencyFormat/CurrencyCode">
                    (<xsl:value-of select="Revenue" />&#160;<xsl:value-of select="CurrencyCode" />)&#160;
                </xsl:if>
                <xsl:call-template name="revenueAmount" />&#160;
                <xsl:if test="CurrencyCode != /Root/Client/Locale/CurrencyFormat/CurrencyCode">
                    <span title="View Conversion Rate" class="js-tooltip Table-action-item">
                        <xsl:attribute name="title">
                            View Conversion Rate&lt;br&gt;
                        </xsl:attribute>
                        <a href="javascript:void(0);" id="conversion_rate{FileID}">
                            <xsl:call-template name="icon">
                                <xsl:with-param name="type" select="'note'" />
                                <xsl:with-param name="role" select="'action'" />
                            </xsl:call-template>
                        </a>
                        <div id="dialog{FileID}" title="conversionRateModal">
                            <xsl:call-template name="loader" />
                        </div>
                        <script type="text/javascript">
                            $('#dialog<xsl:value-of select="FileID" />').dialog({
                                autoOpen : false,
                                minWidth: 530,
                                closeOnEscape: true,
                                modal : false,
                                title: 'Currency Conversion',
                                position: {
                                    my: 'center top',
                                    at: 'center bottom',
                                    of: $('#conversion_rate<xsl:value-of select="FileID" />')
                                },
                                open: function () {
                                    $(this).load('/bookpub/tracker?c=ajax_currency&amp;file=<xsl:value-of select="FileID" />')
                                }
                            });
                            $('#conversion_rate<xsl:value-of select="FileID" />').on('click', function () {
                                $('#dialog<xsl:value-of select="FileID" />').dialog('open');
                                return false;
                            });
                        </script>
                    </span>
                </xsl:if>
            </td>
            <xsl:if test="floor( /Root/Client/TypeMask div 2048) mod 2 = 1">
                <td class="Table-col Table-col-icon">
                    <xsl:choose>
                        <xsl:when test="CurrencyCode != 'MUL'">
                            <xsl:choose>
                                <xsl:when test="AlternateConversionRate">
                                    <a class="js-tooltip" title="{translate(format-number(AlternateConversionRate*Revenue/@value, '#.##'),'$','')} {AlternateCurrencyCode}">
                                        <xsl:call-template name="icon">
                                            <xsl:with-param name="type" select="'currency'" />
                                            <xsl:with-param name="role" select="'action'" />
                                            <xsl:with-param name="cursor" select="'default'" />
                                        </xsl:call-template>
                                    </a>
                                </xsl:when>
                            </xsl:choose>
                        </xsl:when>
                        <xsl:when test="CurrencyCode = 'MUL'">
                            <xsl:variable name="titleText">
                                <xsl:for-each select="AlternateCurrencyList/Currency[string(AlternateCurrencyTotal) != '']">
                                        <xsl:value-of select="concat(format-number(AlternateCurrencyTotal, '#.##'), ' ', AlternateCurrencyCode)"/>
                                        <xsl:if test="position() != last()">
                                            <xsl:text>, &#10;</xsl:text>
                                        </xsl:if>
                                </xsl:for-each>
                            </xsl:variable>
                            <xsl:if test="AlternateConversionRate">
                                <a class="js-tooltip" data-title="{$titleText}">
                                    <xsl:call-template name="icon">
                                        <xsl:with-param name="type" select="'currency'" />
                                        <xsl:with-param name="role" select="'action'" />
                                    </xsl:call-template>
                                </a>
                            </xsl:if>
                        </xsl:when>
                        <xsl:otherwise>
                            &#160;
                        </xsl:otherwise>
                    </xsl:choose>
                </td>
            </xsl:if>
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="Records" />
            </td>
            <td class="Table-col">
                <xsl:value-of select="DateFinished" />
            </td>

            <xsl:if test="/Root/Access/bookpub/tracker/notes">
                <td class="Table-col Table-col-icon">
                    <a class="js-tooltip">
                        <xsl:attribute name="href">/bookpub/tracker?c=notes&amp;file=<xsl:value-of select="FileID" />&amp;period=<xsl:value-of select="/Root/Period/PeriodID"/>&amp;page=<xsl:value-of select="$currentPage" /></xsl:attribute>
                        <xsl:choose>
                            <xsl:when test="normalize-space(Notes) = ''">
                                <xsl:attribute name="title">Add Note</xsl:attribute>
                                <xsl:call-template name="icon">
                                    <xsl:with-param name="type" select="'note'" />
                                    <xsl:with-param name="role" select="'action'" />
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:attribute name="title"><xsl:value-of select="Notes" /></xsl:attribute>
                                <xsl:value-of select="substring(Notes,1,3)" />
                            </xsl:otherwise>
                        </xsl:choose>
                    </a>
                </td>
            </xsl:if>
            <td class="Table-col Table-col-icon">
                <xsl:if test="/Root/Access/bookpub/tracker/reopen = 1 and /Root/Period/PeriodID = 0">
                    <xsl:call-template name="uiButton">
                        <xsl:with-param name="size" select="'small'" />
                        <xsl:with-param name="content" select="'Reopen File'" />
                        <xsl:with-param name="url">
                            <xsl:text>/bookpub/tracker?c=reopen&amp;file=</xsl:text>
                            <xsl:value-of select="FileID" />
                            <xsl:text>#file</xsl:text>
                            <xsl:value-of select="FileID" />
                        </xsl:with-param>
                    </xsl:call-template>
                </xsl:if>
            </td>
        </tr>
    </xsl:template>

</xsl:stylesheet>
