<!--                                                                  -->
<!--  Copyright (C) 2010 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:template name="dashboardSalesTrends">
        <xsl:param name="module" />
        <xsl:param name="title" />

        <script type="text/javascript" src="/production/javascript/bookpub/modules/sales_trends.js?v=2"></script>
        <h2><xsl:value-of select="$title" /></h2>
        <form name="salesTrendsFilter" id="salesTrendsFilter" onSubmit="filterSalesTrends('salesTrendsChart'); return false;">
            <div class="Form-group Form-group-horizontal">
                <div class="Form-item Bookdashboard-salesformitem">
                    <label class="Form-label">
                        <span class="Form-label-caption">Period</span>
                        <div class="Form-input-wrapper Bookdashboard-select">
                            <xsl:variable name="timeframeOpts">
                                <map>
                                    <mapEntry>
                                        <name>Last 3 Months</name>
                                        <value>3</value>
                                    </mapEntry>
                                    <mapEntry>
                                        <name>Last 6 Months</name>
                                        <value>6</value>
                                    </mapEntry>
                                    <mapEntry>
                                        <name>Last 12 Months</name>
                                        <value>12</value>
                                    </mapEntry>
                                    <mapEntry>
                                        <name>Year-To-Date</name>
                                        <value>ytd</value>
                                    </mapEntry>
                                </map>
                            </xsl:variable>
                            <xsl:call-template name="uiDropdown">
                                <xsl:with-param name="items" select="$timeframeOpts"/>
                                <xsl:with-param name="name" select="'timeframe'" />
                                <xsl:with-param name="id" select="'timeframe'" />
                                <xsl:with-param name="active" select="Params/timeframe" />
                            </xsl:call-template>
                        </div>
                    </label>
                </div>
                <div class="Form-item Bookdashboard-salesformitem">
                    <label class="Form-label">
                        <span class="Form-label-caption">Services</span>
                        <div class="Form-input-wrapper Bookdashboard-select">
                            <xsl:variable name="serviceOpts">
                                <map>
                                    <mapEntry>
                                        <value></value>
                                        <name>All Services</name>
                                    </mapEntry>
                                    <xsl:for-each select="$module/ServiceList/Service">
                                        <xsl:sort select="ServiceNameClean" />
                                        <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="$serviceOpts"/>
                                <xsl:with-param name="name" select="'service'" />
                                <xsl:with-param name="id" select="'service'" />
                                <xsl:with-param name="active" select="/Root/Params/service" />
                            </xsl:call-template>
                        </div>
                    </label>
                </div>
                <div class="Form-item Bookdashboard-salesformitem">
                    <label class="Form-label">
                        <span class="Form-label-caption">Imprints</span>
                        <div class="Form-input-wrapper Bookdashboard-select">
                            <xsl:variable name="imprintOpts">
                                <map>
                                    <mapEntry>
                                        <value></value>
                                        <name>All Imprints</name>
                                    </mapEntry>
                                    <xsl:for-each select="$module/ImprintList/Imprint">
                                        <mapEntry>
                                            <value><xsl:value-of select="ImprintID" /></value>
                                            <name><xsl:value-of select="Name" /></name>
                                        </mapEntry>
                                    </xsl:for-each>
                                </map>
                            </xsl:variable>
                            <xsl:call-template name="uiDropdown">
                                <xsl:with-param name="items" select="$imprintOpts"/>
                                <xsl:with-param name="name" select="'imprint'" />
                                <xsl:with-param name="id" select="'imprint'" />
                                <xsl:with-param name="active" select="/Root/Params/imprint" />
                            </xsl:call-template>
                        </div>
                    </label>
                </div>
                <div class="Form-item">
                    <xsl:call-template name="uiButton">
                        <xsl:with-param name="elemType" select="'submit'" />
                        <xsl:with-param name="content" select="'Apply'" />
                    </xsl:call-template>
                </div>
            </div>
        </form>
        <xsl:call-template name="salesTrendsChart">
            <xsl:with-param name="module" select="$module" />
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="salesTrendsChart">
        <xsl:param name="module" />
        <div id="salesTrendsChart" class="SalesChart js-rs-html-content">
            <map name="sales_trends" id="sales_trends" class="SalesChart-map">
                <xsl:value-of select="$module/ImageMap" disable-output-escaping="yes" />
            </map>
            <img class="SalesChart-image" src="{$module/ChartSource}" id="" usemap="#sales_trends" />
        </div>
    </xsl:template>

</xsl:stylesheet>
