<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:template name="currentPeriodDownloads">
        <xsl:variable name="currentPeriodDownloadsItems">
            <map>
                <xsl:if test="Access/app/tracker/currentrecon = 1">
                    <mapEntry><name>Current Reconciliation Report</name><value>currentrecon</value></mapEntry>
                </xsl:if>
                <xsl:if test="Access/app/tracker/trackerdl = 1">
                    <mapEntry><name>File Summary</name><value>trackerdl</value></mapEntry>
                </xsl:if>
                <xsl:if test="Access/app/tracker/exceptionsdl = 1">
                    <mapEntry>
                        <name>Generate 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="/Root/ExceptionsFile/Status = 1">
                                        <xsl:text>true</xsl:text>
                                    </xsl:if>
                                </value>
                            </attr>
                        </dataAttrs>
                    </mapEntry>
                    <mapEntry>
                        <name>All Exceptions</name>
                        <value>exceptionsdl</value>
                        <xsl:if test="/Root/ExceptionsFile/Status = 0 or not(/Root/ExceptionsFile/DateGenerated)">
                            <disabled>true</disabled>
                        </xsl:if>

                        <dataAttrs>
                            <attr>
                                <name>data-date-generated</name>
                                <value><xsl:value-of select="/Root/ExceptionsFile/DateGenerated" /></value>
                            </attr>
                            <attr>
                                <name>data-date-is-generatable</name>
                                <value>true</value>
                            </attr>
                        </dataAttrs>
                    </mapEntry>
                </xsl:if>

                <xsl:if test="Access/app/tracker/consolidated_exceptionsdl = 1">
                    <mapEntry>
                        <name>Generate Consolidated Exceptions Report</name>
                        <value>consolidated_exceptions</value>
                        <separated>true</separated>
                        <custom>true</custom>
                        <dataAttrs>
                            <attr>
                                <name>data-report-id</name>
                                <value>consolidated_exceptionsdl</value>
                            </attr>
                            <attr>
                                <name>data-date-is-loading</name>
                                <value>
                                    <xsl:if test="/Root/ConsolidatedExceptionsFile/Status = 1">
                                        <xsl:text>true</xsl:text>
                                    </xsl:if>
                                </value>
                            </attr>
                        </dataAttrs>
                    </mapEntry>
                    <mapEntry>
                        <name>Consolidated Exceptions Report</name>
                        <value>consolidated_exceptionsdl</value>
                        <xsl:if test="/Root/ConsolidatedExceptionsFile/Status = 0 or not(/Root/ConsolidatedExceptionsFile/DateGenerated)">
                            <disabled>true</disabled>
                        </xsl:if>

                        <dataAttrs>
                            <attr>
                                <name>data-date-generated</name>
                                <value><xsl:value-of select="/Root/ConsolidatedExceptionsFile/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="pageSize" select="OpenFileSettings/PageSize" />
        <xsl:variable name="serviceSelected" select="OpenFileSettings/ServiceID" />

        <div class="Tracker-open-chart" id="openFileContainer">

            <div style="display: flex; justify-content: space-between;">
                <h3 class="Tracker-sub-header">Open Files</h3>
                <xsl:if test="/Root/Files/NeedCurrencyConversionCount &gt; 0">
                    <xsl:call-template name="uiButton">
                        <xsl:with-param name="content">Conversion Rate Entry</xsl:with-param>
                        <xsl:with-param name="type" select="'primary'" />
                        <xsl:with-param name="id" select="'conversion_rate_entry'" />
                        <xsl:with-param name="onClick">location.href='/app/tracker?c=currency_conversion_entry'</xsl:with-param>
                    </xsl:call-template>
                </xsl:if>
            </div>

            <div class="Table-controls Table-controls-top">
                <div class="Table-controls-item">
                    <form class="Form Form-horizontal" action="#" id="openFilesSetting" method="post" onsubmit="openFilesCookie(document.getElementById('openFileDisplay').value,document.getElementById('pageSize').value,'{OpenFileSettings/SortBy}', '{OpenFileSettings/ReverseSort}', document.getElementById('serviceID').value); return false;">
                        <div class="Form-item">
                            <label class="Form-label">
                                <span class="Form-label-caption">Now Viewing</span>
                                <div class="Form-input-wrapper">

                                    <xsl:variable name="openFileDisplayItems">
                                        <map>
                                            <mapEntry><name>Current Files</name><value>1</value></mapEntry>
                                            <mapEntry><name>Suspense Files</name><value>2</value></mapEntry>
                                            <mapEntry><name>
                                                <xsl:value-of select="Client/Locale/CurrencyFormat/Symbol" />0<xsl:value-of select="Client/Locale/NumericFormat/Decimal" />00 Revenue Files
                                            </name><value>3</value></mapEntry>
                                            <mapEntry><name>All Files</name><value>0</value></mapEntry>
                                        </map>
                                    </xsl:variable>
                                    <xsl:call-template name="uiDropdown">
                                        <xsl:with-param name="items" select="$openFileDisplayItems"/>
                                        <xsl:with-param name="id" select="'openFileDisplay'"/>
                                        <xsl:with-param name="name" select="'openFileDisplay'"/>
                                        <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="pageSizeItems">
                                        <map>
                                            <mapEntry><name>25</name><value>25</value></mapEntry>
                                            <mapEntry><name>50</name><value>50</value></mapEntry>
                                            <mapEntry><name>100</name><value>100</value></mapEntry>
                                            <mapEntry><name>All</name><value>all</value></mapEntry>
                                        </map>
                                    </xsl:variable>
                                    <xsl:call-template name="uiDropdown">
                                        <xsl:with-param name="items" select="$pageSizeItems"/>
                                        <xsl:with-param name="id" select="'pageSize'"/>
                                        <xsl:with-param name="name" 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>
                    </form>
                </div>
                <div class="Table-controls-item Table-controls-item-additive">
                    <xsl:call-template name="currentPeriodDownloads" />
                </div>
            </div>

            <form name="qwikclose" id="qwikclose" action="/app/tracker" method="post">
                <input type="hidden" name="page" value="{Params/page}" />

                <xsl:if test="Files/OpenFiles">
                    <div class="Table-wrapper">
                        <table class="Table Table-with-highlight">
                            <thead>
                                <xsl:call-template name="trackerOpenHeaderRow" />
                            </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="Access/app/tracker/qwikclose = 1 and Files/OpenFiles ">
                    <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">
                                    Finish Selected Files
                                </xsl:with-param>
                                <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">
                                <xsl:call-template name="uiPagination">
                                    <xsl:with-param name="lastPage" select="Pagination/LastPage" />
                                    <xsl:with-param name="totalCount" select="Pagination/TotalCount" />
                                    <xsl:with-param name="currentPage" select="Pagination/CurrentPage" />
                                </xsl:call-template>
                            </xsl:if>
                        </div>
                    </div>
                </xsl:if>
            </form>
        </div>
    </xsl:template>

    <xsl:template name="trackerOpenFilesSort">
        <xsl:param name="name" />
        <xsl:param name="caption" />

        <xsl:variable name="sortOrder">
            <xsl:choose>
                <xsl:when test="OpenFileSettings/SortBy = $name and (OpenFileSettings/ReverseSort = 0 or 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="$caption" />
            <xsl:with-param name="sortBy" select="OpenFileSettings/SortBy"/>
            <xsl:with-param name="name" select="$name"/>
            <xsl:with-param name="sortReverse" select="OpenFileSettings/ReverseSort" />
            <xsl:with-param name="onClick">
                openFilesCookie(<xsl:value-of select="OpenFileSettings/FileType" />,'<xsl:value-of select="OpenFileSettings/PageSize" />','<xsl:value-of select="$name" />', <xsl:value-of select="$sortOrder" />, <xsl:value-of select="OpenFileSettings/ServiceID" />)
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="trackerOpenHeaderRow">
        <tr class="Table-row Table-row-header">
            <th class="Table-col" colspan="8"></th>
            <th class="Table-col Table-col-common" colspan="2">Exceptions</th>
            <th class="Table-col" colspan="3"></th>
        </tr>
        <tr class="Table-row Table-row-header">
            <xsl:if test="/Root/Access/app/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>

            <th class="Table-col" nowrap="nowrap">
                <xsl:call-template name="trackerOpenFilesSort">
                    <xsl:with-param name="name" select="''"/>
                    <xsl:with-param name="caption" select="'Service'" />
                </xsl:call-template>
            </th>

            <th class="Table-col" nowrap="nowrap">
                <xsl:call-template name="trackerOpenFilesSort">
                    <xsl:with-param name="name" select="'orig_file_name'"/>
                    <xsl:with-param name="caption" select="'File Name'" />
                </xsl:call-template>
            </th>

            <th class="Table-col" nowrap="nowrap">
                <xsl:call-template name="trackerOpenFilesSort">
                    <xsl:with-param name="name" select="'date_created'"/>
                    <xsl:with-param name="caption" select="'Received'" />
                </xsl:call-template>
            </th>

            <th class="Table-col Table-col-amount" nowrap="nowrap">
                <xsl:call-template name="trackerOpenFilesSort">
                    <xsl:with-param name="name" select="'units'"/>
                    <xsl:with-param name="caption" select="'Units'" />
                </xsl:call-template>
            </th>

            <th class="Table-col">
                <xsl:call-template name="trackerOpenFilesSort">
                    <xsl:with-param name="name" select="'input_dist_fee_pct'"/>
                    <xsl:with-param name="caption" select="'Dist. Fee'" />
                </xsl:call-template>
            </th>

            <th class="Table-col Table-col-amount" nowrap="nowrap">
                <xsl:call-template name="trackerOpenFilesSort">
                    <xsl:with-param name="name" select="'revenue'"/>
                    <xsl:with-param name="caption" select="'Revenue'" />
                </xsl:call-template>
            </th>

            <th class="Table-col" nowrap="nowrap">
                <xsl:call-template name="trackerOpenFilesSort">
                    <xsl:with-param name="name" select="'records'"/>
                    <xsl:with-param name="caption" select="'Records'" />
                </xsl:call-template>
            </th>

            <th class="Table-col" nowrap="nowrap">
                <xsl:call-template name="trackerOpenFilesSort">
                    <xsl:with-param name="name" select="'total_exceptions'"/>
                    <xsl:with-param name="caption" select="'Initial'" />
                </xsl:call-template>
            </th>

            <th class="Table-col" nowrap="nowrap" colspan="2">
                <xsl:call-template name="trackerOpenFilesSort">
                    <xsl:with-param name="name" select="'remaining_exceptions'"/>
                    <xsl:with-param name="caption" select="'Left'" />
                </xsl:call-template>
            </th>

            <xsl:if test="/Root/Access/app/tracker/notes">
                <th class="Table-col Table-col-icon" nowrap="nowrap">
                    <xsl:call-template name="trackerOpenFilesSort">
                        <xsl:with-param name="name" select="'notes'"/>
                        <xsl:with-param name="caption" select="'Notes'" />
                    </xsl:call-template>
                </th>
            </xsl:if>
            <th class="Table-col Table-col-icon" nowrap="nowrap">Delete</th>
        </tr>
    </xsl:template>

    <xsl:template name="openFileRow">
        <tr class="Table-row Table-row-data">
            <xsl:if test="FileID = /Root/Params/Highlight">
                <xsl:attribute name="class">hi</xsl:attribute>
            </xsl:if>

            <xsl:if test="/Root/Access/app/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:call-template>
                    </xsl:if>
                </td>
            </xsl:if>

            <td class="Table-col"><xsl:value-of select="ServiceName" /></td>
            <td class="Table-col openFileName">
                <a name="file{FileID}" />
                <xsl:choose>
                    <xsl:when test="/Root/Access/app/tracker/saveas">
                        <a class="js-tooltip" href="/app/tracker?c=saveas&amp;file={FileID}&amp;period={/Root/Report/Period/PeriodID}">
                            <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="OrigFileNamePretty" />
                        </a>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="OrigFileNamePretty" />
                    </xsl:otherwise>
                </xsl:choose>
            </td>

            <td class="Table-col"><xsl:value-of select="DateCreatedPretty" /></td>

            <td class="Table-col Table-col-amount" nowrap="nowrap"><xsl:value-of select="UnitsPretty" /></td>

            <td class="Table-col">
                <xsl:if test="/Root/Access/app/tracker/distributionfee = 1 and normalize-space(ServiceID)">
                    <xsl:if test="ParentFileID != '' or HasChild = 1">

                        <xsl:call-template name="distFeeDisplay">
                            <xsl:with-param name="distFormats" select="DistributionFeeFormats" />
                            <xsl:with-param name="distFeePct" select="DistFeePct" />
                            <xsl:with-param name="adjustedRevenue" select="AdjustedRevenue" />
                            <xsl:with-param name="serviceID" select="ServiceID" />
                            <xsl:with-param name="version" select="VersionNum" />
                            <xsl:with-param name="physical" select="Physical" />
                        </xsl:call-template>

                    </xsl:if>
                    <xsl:if test="ParentFileID = '' and HasChild = 0">

                        <xsl:call-template name="distFeeDisplay">
                            <xsl:with-param name="distFormats" select="DistributionFeeFormats" />
                            <xsl:with-param name="distFeePct" select="DistFeePct" />
                            <xsl:with-param name="adjustedRevenue" select="AdjustedRevenue" />
                            <xsl:with-param name="makeLink" select="'1'" />
                            <xsl:with-param name="fileID" select="FileID" />
                            <xsl:with-param name="serviceID" select="ServiceID" />
                            <xsl:with-param name="version" select="VersionNum" />
                            <xsl:with-param name="physical" select="Physical" />
                        </xsl:call-template>

                    </xsl:if>
                </xsl:if>
            </td>

            <td class="Table-col Table-col-amount" nowrap="nowrap">
                <input type="hidden" name="grossRevenue" value="{GrossRevenue}" class="grossRevenue" />
                <xsl:if test="CurrencyCode != /Root/Client/Locale/CurrencyFormat/CurrencyCode">
                    <xsl:choose>
                        <xsl:when test="/Root/Access/app/tracker/revenue = 1 and (ParentFileID != '' and (Revenue = '' or normalize-space(InputRevenuePretty/value)))">
                            (<xsl:value-of select="RevenuePretty/symbol" /><xsl:value-of select="translate(translate(RevenuePretty/value, '-', '&#8209;'), ' ', '&#160;')" />&#160;<xsl:value-of select="CurrencyCode" />)&#160;
                        </xsl:when>
                        <xsl:when test="/Root/Access/app/tracker/revenue = 1 and (Revenue = '' or normalize-space(InputRevenuePretty/value))">
                            (<a href="/app/tracker?c=revenue&amp;file={FileID}&amp;page={/Root/Pagination/CurrentPage}"><xsl:value-of select="RevenuePretty/symbol" /><xsl:value-of select="translate(translate(RevenuePretty/value, '-', '&#8209;'), ' ', '&#160;')" />&#160;<xsl:value-of select="CurrencyCode" /></a>)&#160;
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:if test="NeedsConversionRate != 0 or InputConversionRate != 0">
                                (<xsl:if test="CurrencyCode != 'MUL'"><xsl:value-of select="RevenuePretty/symbol" /></xsl:if><xsl:value-of select="translate(translate(RevenuePretty/value, '-', '&#8209;'), ' ', '&#160;')" />&#160;<xsl:value-of select="CurrencyCode" />)&#160;
                            </xsl:if>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:if>
                <xsl:choose>
                    <xsl:when test="/Root/Access/app/tracker/revenue = 1 and ParentFileID = '' and HasChild = 0 and (translate(Revenue, translate(Revenue,'0123456789', ''), '') = 0 or Revenue = '' or normalize-space(InputRevenuePretty/value))">
                        <xsl:choose>
                            <xsl:when test="CurrencyCode = /Root/Client/Locale/CurrencyFormat/CurrencyCode">
                                <a href="/app/tracker?c=revenue&amp;file={FileID}&amp;page={/Root/Pagination/CurrentPage}">
                                    <xsl:call-template name="revenueAmount" />
                                </a>
                            </xsl:when>
                            <xsl:when test="normalize-space(RevenuePretty/value) and (NeedsConversionRate != 0 or InputConversionRate != 0) and normalize-space(InputRevenuePretty/value) = ''">
                                <a href="/app/tracker?c=revenue&amp;file={FileID}&amp;page={/Root/Pagination/CurrentPage}">
                                    <xsl:call-template name="revenueAmount" />
                                </a>
                            </xsl:when>
                            <xsl:when test="normalize-space(RevenuePretty/value) and (NeedsConversionRate != 0 or InputConversionRate != 0)">
                                <a href="/app/tracker?c=currency&amp;file={FileID}&amp;page={/Root/Pagination/CurrentPage}">
                                    <xsl:call-template name="revenueAmount" />
                                </a>
                            </xsl:when>

                        </xsl:choose>
                    </xsl:when>
                    <xsl:when test="/Root/Access/app/tracker/currency = 1 and ParentFileID = '' and HasChild = 0 and normalize-space(Revenue) and (ConversionInput != 0 or InputConversionRate != 0)">
                        <a href="/app/tracker?c=currency&amp;file={FileID}&amp;page={/Root/Pagination/CurrentPage}">
                            <xsl:call-template name="revenueAmount" />
                        </a>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:if test="not(File/MultipleRevenue)">
                            <xsl:choose>
                                <xsl:when test="(NeedsConversionRate = 1 or InputConversionRate != 0) and ParentFileID = '' and HasChild = 0">
                                    <a href="/app/tracker?c=currency&amp;file={FileID}&amp;page={/Root/Pagination/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="/app/tracker?c=revenue&amp;file={FileID}&amp;page={/Root/Pagination/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>

            <td class="Table-col" nowrap="nowrap"><xsl:value-of select="RecordsPretty" /></td>

            <td class="Table-col" nowrap="nowrap"><xsl:value-of select="TotalExceptions" /></td>

            <td class="Table-col" nowrap="nowrap">
                <xsl:choose>
                    <xsl:when test="translate(RemainingExceptions, translate(RemainingExceptions,'0123456789', ''), '') != 0 and /Root/Access/app/tracker/exceptions = 1">
                        <a href="/app/matcher?file={FileID}&amp;page={/Root/Pagination/CurrentPage}&amp;c=file">
                            <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="translate(RemainingExceptions, translate(RemainingExceptions,'0123456789', ''), '') != 0 and /Root/Access/app/tracker/exceptions = 1">
                    <a class="js-tooltip" href="/app/tracker?c=exceptions&amp;file={FileID}" title="Download Error File">
                        <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 test="/Root/Access/app/tracker/notes">
                <td class="Table-col Table-col-icon">
                    <a class="js-tooltip">
                        <xsl:attribute name="href">/app/tracker?c=notes&amp;page=<xsl:value-of select="/Root/Pagination/CurrentPage" />&amp;file=<xsl:value-of select="FileID" />&amp;period=<xsl:value-of select="/Root/Report/Period/PeriodID"/></xsl:attribute>
                        <xsl:choose>
                            <xsl:when test="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:variable name="apos">'</xsl:variable>
                <xsl:variable name="escaped">"</xsl:variable>
                <xsl:choose>
                    <xsl:when test="/Root/Access/app/tracker/delete = 1 and HasChild = 0 and ParentFileID = ''">
                        <span title="Delete File" class="Tracker-table-delete-trigger Icon-trigger js-tooltip" data-tooltip-position="top">
                            <xsl:attribute name="data-file-name">
                                <xsl:value-of select="translate(OrigFileNamePretty,$apos,$escaped)" />
                            </xsl:attribute>
                            <xsl:attribute name="data-file-id">
                                <xsl:value-of select="FileID" />
                            </xsl:attribute>
                            <xsl:attribute name="data-page">
                                <xsl:value-of select="/Root/Pagination/CurrentPage" />
                            </xsl:attribute>
                            <xsl:attribute name="data-initial">
                                <xsl:value-of select="translate(TotalExceptions, translate(TotalExceptions, '0123456789', ''), '')" />
                            </xsl:attribute>
                            <xsl:attribute name="data-left">
                                <xsl:value-of select="translate(RemainingExceptions, translate(RemainingExceptions, '0123456789', ''), '')" />
                            </xsl:attribute>
                            <xsl:call-template name="icon">
                                <xsl:with-param name="type" select="'delete'" />
                                <xsl:with-param name="role" select="'action'" />
                            </xsl:call-template>
                        </span>
                    </xsl:when>
                    <xsl:when test="/Root/Access/app/tracker/delete_split = 1 and (HasChild = 0 or ParentFileID = '') and sum(.//RelatedFile/PeriodID) = 0">
                        <span title="Delete File" class="Tracker-table-delete-trigger Icon-trigger js-tooltip" data-tooltip-position="top">
                            <xsl:attribute name="data-file-name">
                                <xsl:value-of select="translate(OrigFileNamePretty,$apos,$escaped)" />
                            </xsl:attribute>
                            <xsl:attribute name="data-file-id">
                                <xsl:value-of select="FileID" />
                            </xsl:attribute>
                            <xsl:attribute name="data-page">
                                <xsl:value-of select="/Root/Pagination/CurrentPage" />
                            </xsl:attribute>
                            <xsl:attribute name="data-split">
                                <xsl:value-of select="'true'" />
                            </xsl:attribute>
                            <xsl:attribute name="data-related-file-names">
                                <xsl:for-each select="RelatedFileList/RelatedFile">
                                    <xsl:sort select="OrigFileNamePretty" />
                                    <xsl:value-of select="translate(OrigFileNamePretty,$apos,$escaped)" /><xsl:text>!!!!!</xsl:text>
                                </xsl:for-each>
                            </xsl:attribute>
                            <xsl:attribute name="data-initial">
                                <xsl:value-of select="translate(TotalExceptions, translate(TotalExceptions, '0123456789', ''), '')" />
                            </xsl:attribute>
                            <xsl:attribute name="data-left">
                                <xsl:value-of select="translate(RemainingExceptions, translate(RemainingExceptions, '0123456789', ''), '')" />
                            </xsl:attribute>
                            <xsl:call-template name="icon">
                                <xsl:with-param name="type" select="'delete'" />
                                <xsl:with-param name="role" select="'action'" />
                            </xsl:call-template>
                        </span>
                    </xsl:when>
                </xsl:choose>
            </td>

        </tr>
    </xsl:template>

</xsl:stylesheet>
