<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--  $Id$  -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">


  <xsl:variable name="lockedRecord">
    <xsl:choose>
      <xsl:when test="/Root/Form/ArtistContract/Status = 2">1</xsl:when>
      <xsl:when test="/Root/Form/ArtistContract/Status = 3">1</xsl:when>
      <xsl:when test="$openRuns = 1">1</xsl:when>
      <xsl:otherwise>0</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>


  <xsl:template name="cCompEditLayout">
    <form action="/rps/ccomp" name="cCompEntry" id="cCompEntry" method="post">
    <div class="section">
      <xsl:call-template name="contractView" />
      <br />
      <xsl:call-template name="openRunStatusMessage" />
	  <xsl:call-template name="cCompEdit" />
      <br /><br />
    </div>
    <xsl:call-template name="buttons" />
    </form>
  </xsl:template>

  <xsl:template name="cCompEdit">
    <fieldset>
      <legend>Controlled Composition Clause</legend>
      <script src="/production/javascript/validateCComp.js?t={$now}" type="text/javascript"></script>
      <input type="hidden" name="formSubmit" value="1" />
      <input type="hidden" name="c" value="edit" />
      <input type="hidden" name="ArtistContractID" value="{Params/ArtistContractID}" />
      <input type="hidden" name="Form_ControlledComposition_ArtistContractID" value="{Form/ArtistContract/ArtistContractID}" />
      <xsl:if test="normalize-space(Form/ControlledComposition/ControlledCompositionID)">
        <input type="hidden" name="Form_ControlledComposition_ControlledCompositionID" value="{Form/ControlledComposition/ControlledCompositionID}" />
        <input type="hidden" name="CCompID" value="{Form/ControlledComposition/ControlledCompositionID}" />
      </xsl:if>
      <p class="formHeader">
        <xsl:choose>
          <xsl:when test="Form/ArtistContract/Status = 2">This clause is used in a pending statement and may not be edited at this time.</xsl:when>
          <xsl:when test="Form/ArtistContract/Status = 3">This clause has been locked and may not be edited.</xsl:when>
          <xsl:otherwise>Enter controlled composition clause information here.</xsl:otherwise>
        </xsl:choose>
      </p>
      <hr />
      <div class="insideFieldset">
      	<xsl:call-template name="errorMessageGeneral" />
      	<xsl:call-template name="column1Edit" />
      </div>
    </fieldset>
  </xsl:template>

  <xsl:template name="column1Edit">
    <table class="singleColumn">
      <tr>
        <td class="leftCol"><label for="Form_ControlledComposition_ControlledCompositionID_TrackCap">*Track Cap:</label></td>
        <td class="catalogNumber">
          <xsl:call-template name="inlineError">
            <xsl:with-param name="path">Form/ControlledComposition/TrackCap</xsl:with-param>
            <xsl:with-param name="displayName">Track Cap</xsl:with-param>
          </xsl:call-template>
          <input type="text" class="percentWholeField" name="Form_ControlledComposition_TrackCap" id="Form_ControlledComposition_TrackCap" value="{Form/ControlledComposition/TrackCap}">
            <xsl:if test="$lockedRecord = 1">
              <xsl:attribute name="disabled">disabled</xsl:attribute>
            </xsl:if>
          </input>
        </td>
      </tr>
      <tr>
        <td class="leftCol"><label for="Form_ControlledComposition_RateType">*Rate Type:</label></td>
        <td>
          <xsl:call-template name="inlineError">
            <xsl:with-param name="path">Form/ControlledComposition/RateType</xsl:with-param>
            <xsl:with-param name="displayName">Rate Type</xsl:with-param>
          </xsl:call-template>
          <xsl:if test="normalize-space(Form/ControlledComposition/RateType)">
            <script type="text/javascript">
              <xsl:choose>
                <xsl:when test="Form/ControlledComposition/RateType = 3">
                  requireField('Form_ControlledComposition_PennyRate','Penny Rate must be entered.<br />');
              </xsl:when>
              <xsl:otherwise>
                requireField('Form_ControlledComposition_RateBasis','Rate Basis must be selected.<br />');
              </xsl:otherwise>
            </xsl:choose>
          </script>
        </xsl:if>
        <select name="Form_ControlledComposition_RateType" onChange="checkRateType(this,'Form_ControlledComposition_');">
          <xsl:if test="$lockedRecord = 1">
            <xsl:attribute name="disabled">disabled</xsl:attribute>
          </xsl:if>
          <option value="">Choose...</option>
          <option value="1">
            <xsl:if test="Form/ControlledComposition/RateType = 1">
              <xsl:attribute name="selected">selected</xsl:attribute>
            </xsl:if>
            Stat Rate
          </option>
            <option value="2">
              <xsl:if test="Form/ControlledComposition/RateType = 2">
                <xsl:attribute name="selected">selected</xsl:attribute>
              </xsl:if>
              Minimum Stat
            </option>
            <option value="3">
              <xsl:if test="Form/ControlledComposition/RateType = 3">
                <xsl:attribute name="selected">selected</xsl:attribute>
              </xsl:if>
              Penny Rate
            </option>
          </select>
        </td>
      </tr>
      <tr>
        <td class="leftCol"><label for="Form_ControlledComposition_RatePercentage">*Rate Percent:</label></td>
        <td>
          <xsl:call-template name="inlineError">
            <xsl:with-param name="path">Form/ControlledComposition/RatePercentage</xsl:with-param>
            <xsl:with-param name="displayName">Rate Percent</xsl:with-param>
          </xsl:call-template>
          <input type="text" class="percentField" name="Form_ControlledComposition_RatePercentage" id="Form_ControlledComposition_RatePercentage" value="{Form/ControlledComposition/RatePercentage}">
            <xsl:if test="$lockedRecord = 1">
              <xsl:attribute name="disabled">disabled</xsl:attribute>
            </xsl:if>
          </input>%
        </td>
      </tr>
      <tr>
        <td class="leftCol"><label for="Form_ControlledComposition_RateBasis">*Rate Basis:</label></td>
        <td>
          <xsl:call-template name="inlineError">
            <xsl:with-param name="path">Form/ControlledComposition/RateBasis</xsl:with-param>
            <xsl:with-param name="displayName">Rate Basis</xsl:with-param>
          </xsl:call-template>
          <select name="Form_ControlledComposition_RateBasis" id="Form_ControlledComposition_RateBasis" onChange="checkRateBasis(this,'Form_ControlledComposition_');">
            <xsl:if test="$lockedRecord = 1 or Form/ControlledComposition/RateType = '3'">
              <xsl:attribute name="disabled">disabled</xsl:attribute>
            </xsl:if>
            <option value="">Choose...</option>
            <option value="2">
              <xsl:if test="Form/ControlledComposition/RateBasis = 2">
                <xsl:attribute name="selected">selected</xsl:attribute>
              </xsl:if>
              Lock Date
            </option>
            <option value="1">
              <xsl:if test="Form/ControlledComposition/RateBasis = 1">
                <xsl:attribute name="selected">selected</xsl:attribute>
              </xsl:if>
              Sales Date
            </option>
          </select>
        </td>
      </tr>
      <tr>
        <td class="leftCol">
          <label for="Form_ControlledComposition_PennyRate">*Penny Rate: </label>
        </td>
        <td>
          <xsl:call-template name="inlineError">
            <xsl:with-param name="path">Form/ControlledComposition/PennyRate</xsl:with-param>
            <xsl:with-param name="displayName">Penny Rate</xsl:with-param>
          </xsl:call-template>
          <input type="text" class="rateField" name="Form_ControlledComposition_PennyRate" id="Form_ControlledComposition_PennyRate">
            <xsl:if test="Form/ControlledComposition/RateType = 3">
              <xsl:attribute name="value"><xsl:value-of select="Form/ControlledComposition/PennyRate" /></xsl:attribute>
            </xsl:if>
            <xsl:if test="$lockedRecord = 1 or Form/ControlledComposition/RateType != '3'">
              <xsl:attribute name="disabled">disabled</xsl:attribute>
            </xsl:if>
          </input>
        </td>
      </tr>
      <tr>
        <td class="leftCol"><label for="Form_ControlledComposition_LockDate">Lock Date:</label></td>
        <td>
          <xsl:call-template name="inlineError">
            <xsl:with-param name="path">Form/ControlledComposition/LockDate</xsl:with-param>
            <xsl:with-param name="displayName">Lock Date</xsl:with-param>
          </xsl:call-template>
          <input type="text" name="Form_ControlledComposition_LockDate" id="Form_ControlledComposition_LockDate" value="{Form/ControlledComposition/LockDate}" class="dateField">
              <xsl:if test="$openRuns = 1">
                <xsl:attribute name="disabled">disabled</xsl:attribute>
              </xsl:if>
          </input>
          <xsl:if test="$openRuns = 0">
            <a title="Select Lock Date">
                <img src="/production/images/icons/office/Calendar-(16x16).gif" class="calendarIcon" id="calendarIcon" />
            </a>
					<xsl:call-template name="calendar">
						<xsl:with-param name="fieldID">Form_ControlledComposition_LockDate</xsl:with-param>
						<xsl:with-param name="buttonID">calendarIcon</xsl:with-param>
					</xsl:call-template>
		    </xsl:if>
        </td>
      </tr>
      <tr>
        <td class="leftCol">
          <label for="Form_ControlledComposition_ReservePercentage">Reserve Percent: </label>
        </td>
        <td>
          <xsl:call-template name="inlineError">
            <xsl:with-param name="path">Form/ControlledComposition/ReservePercentage</xsl:with-param>
            <xsl:with-param name="displayName">Reserve Percent</xsl:with-param>
          </xsl:call-template>
          <input type="text" class="percentField" name="Form_ControlledComposition_ReservePercentage" id="Form_ControlledComposition_ReservePercentage" value="{Form/ControlledComposition/ReservePercentage}">
              <xsl:if test="$openRuns = 1">
                <xsl:attribute name="disabled">disabled</xsl:attribute>
              </xsl:if>
          </input>%
        </td>
      </tr>
      <tr>
        <td class="leftCol"><label for="Form_ControlledComposition_ReserveLiquidation">Liquidation Schedule:</label></td>
        <td>
          <xsl:call-template name="inlineError">
            <xsl:with-param name="path">Form/ControlledComposition/ReserveLiquidationList</xsl:with-param>
            <xsl:with-param name="displayName">Liquidation Schedule</xsl:with-param>
          </xsl:call-template>
          <xsl:call-template name="liquidationSchedule">
            <xsl:with-param name="liquidationPrefix">Form_ControlledComposition_ReserveLiquidationList_ReserveLiquidation_</xsl:with-param>
            <xsl:with-param name="liquidationList" select="Form/ControlledComposition/ReserveLiquidationList/ReserveLiquidation" />
            <xsl:with-param name="lockedRecord" select="$lockedRecord" />
            <xsl:with-param name="liquidationID" select="Form/ControlledComposition/ControlledCompositionID" />
            <xsl:with-param name="liquidationIDName">TrackLicenseID</xsl:with-param>
          </xsl:call-template>
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <br />*Required field
        </td>
      </tr>
    </table>
  </xsl:template>

</xsl:stylesheet>
