<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:include href="/app/tools/support/templates/layout.xsl" />
<xsl:include href="/app/tools/common/production/templates/list_nav.xsl" />
<xsl:include href="/app/tools/common/production/templates/components/index.xsl" />

<xsl:template name="mainBody" >
    <xsl:call-template name="bodyTitle" >
        <xsl:with-param name="title">DTMV Catalog Import Status</xsl:with-param>
    </xsl:call-template>
    <xsl:call-template name="listStatus" />
</xsl:template>

<xsl:template name="listStatus" >
    <fieldset>
        <legend>Catalog Import Status For <xsl:value-of select="SelectedClient/ClientName" /></legend>
        <xsl:call-template name="numericListNavSetup" />
            <table class="textChart">
                <tr>
                    <th>Import ID</th>
                    <th>Effective Date</th>
                    <th>Start Time</th>
                    <th>End Time</th>
                    <th>File Count</th>
                    <th>Status</th>
                </tr>
                <xsl:for-each select="StatusList/Status">
                    <xsl:call-template name="statusRow" />
                </xsl:for-each>
            </table>
    </fieldset>
</xsl:template>

<xsl:template name="statusRow" >
    <tr class="row{position() mod 2}">
        <xsl:variable name="linkClientID" select="/Root/SelectedClient/ClientID" />
        <xsl:variable name="linkImportID" select="CatalogImportID" />
        <td><A href="/support/dtmv?c=ci_s&amp;client={$linkClientID}&amp;import={$linkImportID}"><xsl:value-of select="CatalogImportID" /></A></td>
        <td><xsl:value-of select="Date" /></td>
        <td><xsl:value-of select="FetchStartTime" /></td>
        <td>
            <xsl:choose>
                <xsl:when test="StatusType = 'done' or StatusType = 'error'">
                    <xsl:choose>
                        <xsl:when test="ImportEndTime != '00/00/0000 00:00:00 AM'">
                            <xsl:value-of select="ImportEndTime" />
                        </xsl:when>
                        <xsl:when test="AnalysisEndTime != '00/00/0000 00:00:00 AM'">
                            <xsl:value-of select="AnalysisEndTime" />
                        </xsl:when>
                        <xsl:when test="StageEndTime != '00/00/0000 00:00:00 AM'">
                            <xsl:value-of select="StageEndTime" />
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="FetchEndTime" />
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:when>
                <xsl:otherwise> - - - </xsl:otherwise>
            </xsl:choose>
        </td>
        <td><xsl:value-of select="FileList/File/@size" /></td>
        <td><xsl:value-of select="StatusText" /></td>
    </tr>
</xsl:template>

<xsl:template name="numericListNavSetup">
    <xsl:call-template name="numericListNav">
        <xsl:with-param name="pagination">/Root/StatusList/Pagination</xsl:with-param>
        <xsl:with-param name="extraParams">
            <xsl:if test="/Root/Params/client">&amp;client=<xsl:value-of select="/Root/Params/client" /></xsl:if>
        </xsl:with-param>
    </xsl:call-template>
</xsl:template>

</xsl:stylesheet>
