<!--                                                                  -->
<!--  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:template name="pickLayout">
        <xsl:call-template name="searchResults" />
        <xsl:call-template name="buttons" />
    </xsl:template>

    <xsl:template name="searchResults">
        <xsl:choose>
            <xsl:when test="not(Params/Query) and count(ImprintList/Imprint) = 0">
                <p>No imprints have been created.</p>
            </xsl:when>
            <xsl:otherwise>
                <xsl:if test="Params/Query">
                    <h2>Search Results</h2>
                </xsl:if>
                <xsl:if test="count(ImprintList/Imprint) != 0">
                    <table class="Table Table-with-highlight">
                        <thead>
                            <tr class="Table-row Table-row-header">
                                <th class="Table-col">Name</th>
                                <th class="Table-col">Book Count</th>
                                <xsl:if test="Access/bookpub/admin/edit_imprint">
                                    <th class="Table-col Table-col-icon">Edit</th>
                                    <th class="Table-col Table-col-icon">Delete</th>
                                </xsl:if>
                            </tr>
                        </thead>
                        <tbody>
                            <xsl:for-each select="ImprintList/Imprint">
                                <tr class="Table-row Table-row-data">
                                    <td class="Table-col">
                                        <xsl:value-of select="Name" />
                                    </td>
                                    <td class="Table-col">
                                        <xsl:choose>
                                            <xsl:when test="BookCount &gt; 0">
                                                <a href="catalog?c=list_books&amp;ImprintID={ImprintID}"><xsl:value-of select="BookCount" /></a>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="BookCount" />
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </td>
                                    <xsl:if test="/Root/Access/bookpub/admin/edit_imprint">
                                        <td class="Table-col Table-col-icon">
                                            <a href="admin?c=edit_imprint&amp;ImprintID={ImprintID}">
                                                <xsl:call-template name="icon">
                                                    <xsl:with-param name="type" select="'edit'" />
                                                    <xsl:with-param name="role" select="'action'" />
                                                </xsl:call-template>
                                            </a>
                                        </td>
                                        <td class="Table-col Table-col-icon">
                                            <xsl:if test="BookCount = 0">
                                                <a href="admin?c=delete_imprint&amp;ImprintID={ImprintID}">
                                                    <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>
                                    </xsl:if>
                                </tr>
                            </xsl:for-each>
                        </tbody>
                    </table>
                </xsl:if>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="submitButton">
        <xsl:if test="Access/bookpub/admin/edit_imprint">
            <xsl:call-template name="uiButton">
                <xsl:with-param name="content" select="'Add New Imprint'"/>
                <xsl:with-param name="name" select="'submit'"/>
                <xsl:with-param name="id" select="'submitButton'"/>
                <xsl:with-param name="type" select="'primary'"/>
                <xsl:with-param name="className" select="'Form-button'"/>
                <xsl:with-param name="elemType" select="'submit'"/>
                <xsl:with-param name="onClick">javascript:location.href='admin?c=edit_imprint'</xsl:with-param>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>

    <xsl:template name="cancelButton">
        <xsl:call-template name="uiButton">
            <xsl:with-param name="content" select="'Back to Admin'" />
            <xsl:with-param name="type" select="'default'"/>
            <xsl:with-param name="className" select="'Form-button'"/>
            <xsl:with-param name="onClick">javascript:location.href='/bookpub/admin'</xsl:with-param>
        </xsl:call-template>
    </xsl:template>

</xsl:stylesheet>
