<!--                                                                  -->
<!--  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="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 4.01//EN" encoding="utf-8" />

  <xsl:include href="/app/tools/rps/templates/global.xsl" />

  <xsl:include href="/app/tools/rps/templates/statement_settings/settings.xsl" />

  <xsl:template name="pickLayout">
    <form name="artistSettingsEdit" id="artistSettingsEdit" method="post" action="/rps/artist_statement_settings">
      <xsl:call-template name="artistSettingsHistoryLayout" />
      <xsl:call-template name="settingsButtons" />
    </form>
  </xsl:template>


  <xsl:variable name="currentPage"><xsl:value-of select="/Root/SettingsHistory/Pagination/CurrentPage"/></xsl:variable>
  <xsl:variable name="totalCount"><xsl:value-of select="/Root/SettingsHistory/Pagination/TotalCount"/></xsl:variable>


  <xsl:template name="submitButton">
    <!-- by default this is disabled; we'll enable it if we're on the active setting and user clicks on a checkbox -->
    <input name="submit" type="submit" id="submitButton" value="Save" onClick="processSave();">
       <xsl:attribute name="disabled">disabled</xsl:attribute>
    </input>

  </xsl:template>

  <xsl:template name="cancelButton">
    <!-- by default this is disabled; we'll enable it if we're on the active setting and user clicks on a checkbox -->
    <input type="button" name="Back" value="Cancel" id="cancelButton" onClick="processCancel({$currentPage}); return true;">
       <xsl:attribute name="disabled">disabled</xsl:attribute>
    </input>
  </xsl:template>

  <xsl:template name="backToAdminButton">
    <input type="button" name="Back" value="Back to Admin" id="backToAdminButton" onClick="processBackToAdmin(); return true;" />
  </xsl:template>

  <xsl:template name="settingsButtons">
    <xsl:call-template name="submitButton" />&#160;
    <xsl:call-template name="cancelButton" />&#160;
    <xsl:call-template name="backToAdminButton" />
  </xsl:template>


  <xsl:template name="artistSettingsHistoryLayout">
      <div class="section">
         <xsl:call-template name="openRunStatusMessage" />
         <input type="hidden" name="formSubmit" value="1" />
         <input type="hidden" name="c" value="edit" />
         <xsl:call-template name="errorMessageGeneral" />
         <xsl:call-template name="artistSettingsHistoryLayoutDetail" />
         <br />
      </div>

  </xsl:template>

  <xsl:template name="artistSettingsHistoryLayoutDetail">
  
      <xsl:call-template name="successMessageGeneral">
          <xsl:with-param name="successMessage">Settings successfully updated!</xsl:with-param>
      </xsl:call-template>
          
      <p class="formHeader">Artist Payee Statement Settings</p>
      <hr />    
      
      <xsl:choose>

        <xsl:when test="SettingsHistory/Pagination/CurrentPage > (SettingsHistory/Pagination/TotalCount - 1)">
          <P>Illegal settings ID number</P>
        </xsl:when>
        <xsl:otherwise>

          <!-- at this point, $currentPage is valid -->

          <!--                                  -->
          <!-- display prev/next header section -->
          <!--                                  -->

          <table class="textChart" id="artistSettingsHeader">
            <tr>

              <!-- Display 'previous' link if applicable -->

              <td class="left" style="width:25%">
                <xsl:choose>
                  <xsl:when test="($currentPage + 1) &lt; $totalCount">
                     <a class="artistStatementSettings" href="?id={$currentPage + 1}">&#171; Previous</a>
                  </xsl:when>
                  <xsl:otherwise>&#160;</xsl:otherwise>
                </xsl:choose>
              </td>

              <!-- Display date range that the settings apply to -->

              <td class="center">

                <xsl:variable name="dateCreated">
                  <xsl:choose>
                    <xsl:when test="SettingsHistory/ArtistStatementSetting[@i=$currentPage]/DateCreated = ''">
                      <xsl:value-of select="'Beginning'" />
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:value-of select="SettingsHistory/ArtistStatementSetting[@i=$currentPage]/DateCreated" />
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:variable>

                <xsl:variable name="dateEnded">
                  <xsl:choose>
                    <xsl:when test="SettingsHistory/ArtistStatementSetting[@i=$currentPage]/DateEnded = ''">
                      <xsl:value-of select="'Current'" />
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:value-of select="SettingsHistory/ArtistStatementSetting[@i=$currentPage]/DateEnded" />
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:variable>


                <P class="artistStatementSettingsDateRange">
                      <xsl:value-of select="$dateCreated" /> - 
                      <xsl:value-of select="$dateEnded" />
                </P>
              </td>

              <!-- Display 'next' link if applicable -->

              <td class="right" style="width:25%">
                <xsl:choose>
                  <xsl:when test="$currentPage > 0">
                     <a class="artistStatementSettings" href="?id={$currentPage - 1}">Next &#187;</a>
                  </xsl:when>
                  <xsl:otherwise>&#160;</xsl:otherwise>
                </xsl:choose>
              </td>
            </tr>
          </table>

          <!--                                                                 -->
          <!-- Display the settings table; this may be larger than the browser -->
          <!-- window, so wrap it in a div to allow scrolling if necessary     -->
          <!--                                                                 -->

          <div class="artistStatementSettings">

            <table class="artistStatementSettings">

              <!-- Display the artist settings indicated by SettingsHistory/Pagination/CurrentPage -->

              <!-- Display the header row for all settings -->

              <xsl:call-template name="displaySettingsHeaderRow" />

              <!-- Display the option row for all settings (disabled w/ FB703) -->

              <!-- xsl:call-template name="displaySettingsOptionalRow" /-->

              <!-- Display the notes row for all settings -->

              <xsl:call-template name="displaySettingsNoteRow" />

              <!-- Display the checkbox row for all settings -->

              <xsl:variable name="canEdit">
                <xsl:choose>
                  <xsl:when test="$currentPage = 0">

                    <xsl:choose>
                      <xsl:when test="$openRuns = 1 or $currentPage > 0">
                        <xsl:value-of select="'0'" />
                      </xsl:when>
                      <xsl:otherwise>
                        <xsl:value-of select="'1'" />
                      </xsl:otherwise>
                   </xsl:choose>

                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="'0'" />
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:variable>

              <xsl:call-template name="displaySettingsCheckboxRow">
                  <xsl:with-param name="showBoxes">1</xsl:with-param>
                  <xsl:with-param name="canEdit"> <xsl:value-of select="$canEdit" /></xsl:with-param>
              </xsl:call-template>

            </table> <!-- end of settings table -->
          
          </div>

          <div style="width: 99%; margin: auto;height:100%;">
            <P>Add or remove optional fields from your artist payee statements. The sample below shows how your current statement will appear to payees.</P>
            &#160; <!-- filler to allow bottom scrollbar to be fully seen -->
            <hr width="60%"/>
            <xsl:call-template name="statement_samples" />
          </div>

        </xsl:otherwise>
      </xsl:choose>

  </xsl:template> <!-- artistSettingsHistoryLayoutDetail -->

  <xsl:template name="unit_sample">
     <table class="artistStatementSampleSettings">
     <tr><td colspan="6"><b>Unit Royalties</b></td></tr>
     <tr>
         <xsl:call-template name="displayUnitRoyaltiesSampleHeader" />
     </tr>
     <tr>
       <xsl:call-template name="displayUnitRoyaltiesSample" />
     </tr>
     </table>
  </xsl:template>

  <xsl:template name="netrev_sample">
     <table class="artistStatementSampleSettings">
     <tr><td colspan="6"><b>Net Revenue Royalties</b></td></tr>
     <tr>
         <xsl:call-template name="displayNetRevenueRoyaltiesSampleHeader" />
     </tr>
     <tr>
       <xsl:call-template name="displayNetRevenueRoyaltiesSample" />
     </tr>
     </table>
  </xsl:template>

  <xsl:template name="statement_samples">
    <div style="padding: 1px; text-align:left; overflow: auto;" >
      <div style="text-align:left;">All-Time Greatest Hits | Armstrong (RS1001)</div>
      <div style="height: 5px;"/>
      <xsl:call-template name="unit_sample" />
      <div style="height: 5px;"/>
      <xsl:call-template name="netrev_sample" />
    </div>
  </xsl:template>


</xsl:stylesheet>
