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

    <xsl:include href="/app/tools/rps/templates/ajax_request.xsl" />
    <xsl:include href="/app/tools/common/production/templates/components/index.xsl" />


    <xsl:template name="pickLayout">
        <xsl:call-template name="helpLink">
            <xsl:with-param name="helpType" select="'Tab'" />
        </xsl:call-template>
        <xsl:call-template name="openRunStatusMessage" />
        <div id="mcpsViewTable">
            <h3>MCPS Reporting</h3>
            <xsl:choose>
                <xsl:when test="Form/TypeList/Type">
                    <xsl:call-template name="mcpsLicenseList" />
                </xsl:when>
                <xsl:otherwise>
                    <p class="emptyMessage">
                        No MCPS licenses have been created for this album.
                    </p>
                </xsl:otherwise>
            </xsl:choose>
        </div>
    </xsl:template>

    <xsl:template name="mcpsLicenseList">
        <table class="Table Table-with-highlight">
            <thead>
                <tr class="Table-row Table-row-header">
                    <th class="Table-col">Product</th>
                    <th class="Table-col">Product ID</th>
                    <th class="Table-col">MCPS ID</th>
                    <th class="Table-col">Release Date</th>
                    <th class="Table-col status">Status</th>
                    <th class="Table-col status">Deleted</th>
                    <th class="Table-col Table-col-all-actions">Actions</th>
                </tr>
            </thead>
            <tbody>
                <xsl:for-each select="Form/TypeList/Type">
                    <xsl:call-template name="mcpsLicenseRow" />
                </xsl:for-each>
            </tbody>
        </table>
    </xsl:template>


    <xsl:template name="mcpsLicenseRow">

        <xsl:variable name="productTypeID" select="ProductTypeID" />
        <xsl:variable name="product" select="/Root/Form/ProductList/Product[ProductTypeID = $productTypeID]" />
        <xsl:variable name="mcpsLicense" select="/Root/Form/McpsLicenseList/McpsLicense[ProductID = $product/ProductID]" />

        <tr class="Table-row Table-row-data">
            <td class="Table-col">
                <a href="uk_mech?c=show_mcps_license&amp;ProductID={$product/ProductID}">
                    <xsl:value-of select="Description" />
                </a>
            </td>

            <xsl:if test="$mcpsLicense">
                <td class="Table-col">
                    <xsl:value-of select="$product/ProductCode" />
                </td>
                <td class="Table-col">
                    <xsl:value-of select="$mcpsLicense/McpsID" />
                </td>
                <td class="Table-col">
                    <xsl:value-of select="$product/ReleaseDate" />
                </td>
                <td class="Table-col">
                    <xsl:value-of select="/Root/Form/StatusList/Status[ProductStatusID = $product/ProductStatusID]/Description" />
                </td>
                <td class="Table-col">
                    <xsl:choose>
                        <xsl:when test="$product/Deleted = 1">Yes</xsl:when>
                        <xsl:otherwise>No</xsl:otherwise>
                    </xsl:choose>
                </td>
            </xsl:if>

            <xsl:if test="not($mcpsLicense)">
                <td colspan="5" class="Table-col Table-col-error">NOT CONFIGURED</td>
            </xsl:if>

            <td class="Table-col Table-col-all-actions">
                <a href="uk_mech?c=edit_mcps_license&amp;ProductID={$product/ProductID}">Edit</a>
            </td>
        </tr>
    </xsl:template>

</xsl:stylesheet>
