<!--                                                                  -->
<!--  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:variable name="productType" select="/Root/Form/TypeList/Type[ProductTypeID = /Root/Form/Product/ProductTypeID]/Type" />

    <xsl:template name="productShowLayout">
        <div class="ProductShow">
            <xsl:call-template name="successMessageGeneral">
                <xsl:with-param name="successMessage">Product successfully updated!</xsl:with-param>
            </xsl:call-template>
            <div class="PageShow-section">
                <xsl:call-template name="albumView" />
            </div>
            <div class="PageShow-section">
                <xsl:call-template name="productShow" />
            </div>
            <div class="PageShow-section">
                <xsl:call-template name="priceShow" />
            </div>
            <div class="PageShow-section">
                <xsl:call-template name="trackListShow" />
            </div>
        </div>
        <xsl:call-template name="buttons" />
    </xsl:template>

    <xsl:template name="productShow">
        <fieldset class="Form-fieldset">
            <h2>Product</h2>
            <div class="ProductShow-product InformationCols">
                <xsl:call-template name="column1Show" />
                <xsl:call-template name="column2Show" />
            </div>
        </fieldset>
    </xsl:template>

    <xsl:template name="column1Show">
        <div class="ProductShow-product-col InformationCols-item">
            <div class="ValuePair">
                <xsl:call-template name="uiValuePairItem">
                    <xsl:with-param name="label" select="'Type'"/>
                    <xsl:with-param name="value" select="Form/TypeList/Type[ProductTypeID = /Root/Form/Product/ProductTypeID]/Description"/>
                </xsl:call-template>

                <xsl:call-template name="uiValuePairItem">
                    <xsl:with-param name="label" select="'Product Title'"/>
                    <xsl:with-param name="value" select="Form/Product/Title"/>
                </xsl:call-template>

                <xsl:call-template name="uiValuePairItem">
                    <xsl:with-param name="label" select="'Product ID'"/>
                    <xsl:with-param name="value" select="Form/Product/ProductCode"/>
                </xsl:call-template>

                <xsl:call-template name="uiValuePairItem">
                    <xsl:with-param name="label" select="'UPC'"/>
                    <xsl:with-param name="value" select="Form/Product/UPC"/>
                </xsl:call-template>
            </div>
        </div>
    </xsl:template>

    <xsl:template name="column2Show">
        <div class="ProductShow-product-col InformationCols-item">
            <div class="ValuePair">

                <xsl:call-template name="uiValuePairItem">
                    <xsl:with-param name="label" select="'Release Date'"/>
                    <xsl:with-param name="value" select="Form/Product/ReleaseDate"/>
                </xsl:call-template>

                <xsl:call-template name="uiValuePairItem">
                    <xsl:with-param name="label" select="'Status'"/>
                    <xsl:with-param name="value">
                        <xsl:for-each select="Form/StatusList/Status[ProductStatusID = /Root/Form/Product/ProductStatusID]">
                            <xsl:value-of select="Description" />
                        </xsl:for-each>
                    </xsl:with-param>
                </xsl:call-template>

                <xsl:if test="ClientTypes/ClientType[ClientTypeID = 6]/IsClientTypeFlag = 1">
                    <xsl:call-template name="uiValuePairItem">
                        <xsl:with-param name="label" select="'Deleted'"/>
                        <xsl:with-param name="value">
                            <xsl:choose>
                                <xsl:when test="Form/Product/Deleted = 0">
                                    No
                                </xsl:when>
                                <xsl:otherwise>
                                    Yes
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:with-param>
                    </xsl:call-template>

                    <xsl:if test="Form/Product/Deleted != 0">
                        <xsl:call-template name="uiValuePairItem">
                            <xsl:with-param name="label" select="'Deletion Date'"/>
                            <xsl:with-param name="value" select="Form/Product/DeletedDate"/>
                        </xsl:call-template>
                    </xsl:if>
                </xsl:if>

            </div>
        </div>
    </xsl:template>

    <xsl:template name="priceShow">
        <fieldset class="Form-fieldset">
            <h2>Prices</h2>
            <xsl:variable name="priceTest">
                <xsl:for-each select="Form/PriceLevelList/PriceLevel[Type = $productType]">
                    <xsl:variable name="priceLevelID" select="PriceLevelID" />
                    <xsl:for-each select="/Root/Form/Product/PriceList/Price[PriceLevelID = $priceLevelID]">
                        <xsl:value-of select="PriceID" />
                    </xsl:for-each>
                </xsl:for-each>
            </xsl:variable>
            <xsl:choose>
                <xsl:when test="normalize-space($priceTest)">
                    <div class="ValuePair">
                        <xsl:choose>
                            <xsl:when test="Form/TypeList/Type[ProductTypeID = /Root/Form/Product/ProductTypeID]/Type = 1">
                                <xsl:for-each select="Form/PriceLevelList/PriceLevel[Type = 1]">
                                    <xsl:call-template name="priceLevelRowShow" />
                                </xsl:for-each>
                                <div class="ValuePair-item">
                                    <span class="ValuePair-label">Default</span>
                                    <span class="ValuePair-value">
                                        <xsl:for-each select="Form/PriceLevelList/PriceLevel[Type = 1]">
                                            <xsl:if test="PriceLevelID = /Root/Form/Product/DefaultPriceLevelID">
                                                <xsl:value-of select="Name" />
                                            </xsl:if>
                                        </xsl:for-each>
                                    </span>
                                </div>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:for-each select="Form/PriceLevelList/PriceLevel[Type != 1]">
                                    <xsl:call-template name="priceLevelRowShow" />
                                </xsl:for-each>
                            </xsl:otherwise>
                        </xsl:choose>
                    </div>
                </xsl:when>
                <xsl:otherwise>
                    <p>No price information has been entered.</p>
                </xsl:otherwise>
            </xsl:choose>
        </fieldset>
    </xsl:template>

    <xsl:template name="priceLevelRowShow">
        <xsl:variable name="priceLevelID" select="PriceLevelID" />
        <xsl:if test="normalize-space(/Root/Form/Product/PriceList/Price[PriceLevelID = $priceLevelID]/ProductPriceID)">
            <div class="ValuePair-item">
                <span class="ValuePair-label"><xsl:value-of select="Name" /></span>
                <span class="ValuePair-value">
                    <xsl:for-each select="/Root/Form/PriceList/Price">
                        <xsl:if test="PriceID = /Root/Form/Product/PriceList/Price[PriceLevelID = $priceLevelID]/PriceID">
                            <xsl:call-template name="formatDollars">
                                <xsl:with-param name="dollarAmount" select="Retail" />
                            </xsl:call-template>
                        </xsl:if>
                    </xsl:for-each>
                </span>
            </div>
        </xsl:if>
    </xsl:template>

    <xsl:template name="trackListShow">
        <xsl:variable name="includedTracks" select="count(/Root/Form/Product/TrackList/Track[Included = 1])" />
        <fieldset class="Form-fieldset" id="productTrackTableShow">
            <h2>Tracks</h2>
            <xsl:choose>
                <xsl:when test="$includedTracks &gt; 0">
                    <table class="Table">
                        <thead>
                            <tr class="Table-row Table-row-header">
                                <th class="Table-col" id="trackIncl">Status</th>
                                <xsl:if test="$showAlbumPurchaseOnly = 1">
                                    <th class="Table-col" id="trackAlbumOnly">Album Purchase Only</th>
                                </xsl:if>
                                <th class="Table-col" id="trackNum">Track</th>
                                <th class="Table-col" id="trackName">Name</th>
                                <th class="Table-col" id="trackLength">Length</th>
                                <th class="Table-col">Media Type</th>
                                <th class="Table-col" id="discNum">Disc #</th>
                                <th class="Table-col" id="discTrack">Disc Track</th>
                            </tr>
                        </thead>
                        <tbody>
                            <xsl:for-each select="/Root/Form/Product/TrackList/Track[Included = 1]">
                                <xsl:call-template name="trackListShowRow" />
                            </xsl:for-each>
                        </tbody>
                    </table>
                    <xsl:variable name="pagination" select="/Root/Form/Product/TrackList/Pagination" />
                    <xsl:if test="$pagination/TotalPages > 1">
                        <div class="Table-controls Table-controls-bottom">
                            <div class="Table-controls-item Table-controls-item-pagination">
                                <xsl:call-template name="uiPagination">
                                    <xsl:with-param name="lastPage" select="$pagination/TotalPages"/>
                                    <xsl:with-param name="currentPage" select="$pagination/Current"/>
                                    <xsl:with-param name="searchPreffix" select="'c=show&amp;'"/>
                                    <xsl:with-param name="searchParams">
                                        <xsl:text>&amp;ProductID=</xsl:text>
                                        <xsl:value-of select="/Root/Form/Product/ProductID" />
                                    </xsl:with-param>
                                </xsl:call-template>
                            </div>
                        </div>
                    </xsl:if>

                </xsl:when>
                <xsl:otherwise>
                    <div class="insideFieldset">
                        No tracks have been included for this product.
                    </div>
                </xsl:otherwise>
            </xsl:choose>
        </fieldset>
    </xsl:template>

    <xsl:template name="trackListShowRow">
        <xsl:variable name="trackID" select="TrackID" />
        <tr>
            <xsl:call-template name="uiEvenOddTrClass">
                <xsl:with-param name="position" select="position()" />
            </xsl:call-template>
            <td class="Table-col">
                <xsl:if test="Included = 1 and IsBonusTrack != 1">Included</xsl:if>
            </td>
            <xsl:if test="$showAlbumPurchaseOnly = 1">
                <td class="Table-col">
                    <xsl:choose>
                        <xsl:when test="AlbumOnly &gt; 0">Yes</xsl:when>
                        <xsl:otherwise>No</xsl:otherwise>
                    </xsl:choose>
                </td>
            </xsl:if>
            <td class="Table-col"><xsl:if test="TrackOrder &lt; 10">0</xsl:if><xsl:value-of select="TrackOrder" /></td>
            <td class="Table-col"><xsl:value-of select="Title" /></td>
            <td class="Table-col"><xsl:value-of select="Duration" /></td>
            <td class="Table-col">
                <xsl:choose>
                    <xsl:when test="MediaType = 2">Video</xsl:when>
                    <xsl:otherwise>Audio</xsl:otherwise>
                </xsl:choose>
            </td>
            <td class="Table-col"><xsl:value-of select="DiscNumber" /></td>
            <td class="Table-col"><xsl:value-of select="DiscTrack" /></td>
        </tr>
    </xsl:template>

</xsl:stylesheet>
