<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:include href="/app/tools/support/templates/layout.xsl" />

  <xsl:template name="mainBody" >
    <xsl:call-template name="bodyTitle" >
      <xsl:with-param name="title">Distribution Service Detail</xsl:with-param>
    </xsl:call-template>
    <xsl:call-template name="bodyMessage" />
    <xsl:call-template name="displayForm" />
  </xsl:template>

  <xsl:template name="displayForm" >
    <div name="body_form">
      <xsl:choose>
        <xsl:when test="Form/ServiceID &gt; 0">
          <xsl:call-template name="displayDetail" />
          <xsl:call-template name="statusKey" />
        </xsl:when>
        <xsl:when test="/Root/Params/action = 'new'">
          <xsl:call-template name="displayDetail" />
          <xsl:call-template name="statusKey" />
        </xsl:when>
        <xsl:otherwise>
          Service not found
        </xsl:otherwise>
      </xsl:choose>
    </div>
  </xsl:template>

  <xsl:template name="statusKey" >
    <fieldset>
    <legend>Status</legend>
    <table>
      <tr>
        <td><b>Active</b></td><td>Currently delivering to service</td>
      </tr>
      <tr>
        <td><b>Inactive</b></td><td>Not delivering to the service, service does not appear in the UI</td>
      </tr>
      <tr>
        <td><b>Maintenance</b></td><td>Service appears in the UI, but no new deliveries will be sent to the service</td>
      </tr>
      <tr>
        <td><b>Development</b></td><td>Does not appear in the UI, but new delivers can be sent using the test delivery script.</td>
      </tr>
      <tr>
        <td><b>Deprecated</b></td><td>No new deliveries are sent to the services.  The service only appears in the UI if the album has been delivered the service.</td>
      </tr>
    </table>
    </fieldset>
  </xsl:template>

  <xsl:template name="displayDetail" >
    <form method="post" action="{$moduleURL}" >
      <input type="hidden" name="c"><xsl:attribute name="value"><xsl:value-of select="/Root/Cmd" /></xsl:attribute></input>
      <input type="hidden" name="ServiceID"><xsl:attribute name="value"><xsl:value-of select="Form/ServiceID" /></xsl:attribute></input>
      <input type="hidden" name="action"><xsl:attribute name="value"><xsl:value-of select="Params/action" /></xsl:attribute></input>
    <fieldset>
      <legend>Service</legend>
      <table>

        <tr>
          <xsl:call-template name="textField" >
            <xsl:with-param name="label">Service ID</xsl:with-param>
            <xsl:with-param name="value" select = "Form/ServiceID" />
          </xsl:call-template>
        </tr>

        <tr>
          <xsl:call-template name="textField" >
            <xsl:with-param name="label">Name</xsl:with-param>
            <xsl:with-param name="name">Form_ServiceName</xsl:with-param>
            <xsl:with-param name="value" select = "Form/ServiceName" />
          </xsl:call-template>
        </tr>

        <tr>
          <xsl:call-template name="listField" >
            <xsl:with-param name="label">Status</xsl:with-param>
            <xsl:with-param name="name">Form_Status</xsl:with-param>
            <xsl:with-param name="value" select = "Form/Status" />
            <xsl:with-param name="options" >
              <option name="active">Active</option>
              <option name="inactive">Inactive</option>
              <option name="development">Development</option>
              <option name="deprecated">Deprecated</option>
              <option name="maintenance">Maintenance</option>
            </xsl:with-param>
          </xsl:call-template>
        </tr>

        <tr>
          <xsl:call-template name="checkboxField" >
            <xsl:with-param name="label">Client Restricted</xsl:with-param>
            <xsl:with-param name="name">Form_ClientRestricted</xsl:with-param>
            <xsl:with-param name="value" select = "Form/ClientRestricted" />
          </xsl:call-template>
        </tr>


        <tr><td></td><td>
          <xsl:call-template name="submitButton" />
        </td></tr>

      </table>
    </fieldset>
    </form>
  </xsl:template>

  <xsl:template name="displayPages" >
    <fieldset>
      <legend>Pages</legend>
      <table>
        <xsl:call-template name="displayPageRowHeader" />
        <xsl:for-each select="Form/Pages/Page">
          <xsl:call-template name="displayPageRow" />
        </xsl:for-each>

        <tr><td colspan="2">
          <xsl:call-template name="addButton" >
            <xsl:with-param name="buttonText">Add Page</xsl:with-param>
            <xsl:with-param name="addCommand">page_detail</xsl:with-param>
            <xsl:with-param name="extraArgs">
              <ModuleID><xsl:value-of select="Form/ModuleID" /></ModuleID>
            </xsl:with-param>
          </xsl:call-template>
        </td></tr>

      </table>
    </fieldset>
  </xsl:template>

  <xsl:template name="displayPageRowHeader" >
    <tr class="header">
      <th>Name</th>
      <th>Command</th>
      <th>Index</th>
      <th>Development</th>
      <th></th>
      <th></th>
    </tr>
  </xsl:template>

  <xsl:template name="displayPageRow" >
    <tr class="row{position() mod 2}">
      <td><xsl:value-of select="Name" /></td>
      <td><xsl:value-of select="Command" /></td>
      <td><xsl:value-of select="DisplayOrder" /></td>
      <td>
        <xsl:choose>
          <xsl:when test="Development">Yes</xsl:when>
          <xsl:otherwise>No</xsl:otherwise>
        </xsl:choose>
      </td>
      <td>
        <a >
          <xsl:attribute name="href"><xsl:value-of select="$moduleURL" />?c=page_detail&amp;ModulePageID=<xsl:value-of select="ModulePageID" /></xsl:attribute>
          edit
        </a>
      </td>
      <td>
        <a >
          <xsl:attribute name="href"><xsl:value-of select="$moduleURL" />?c=page_delete&amp;ModulePageID=<xsl:value-of select="ModulePageID" /></xsl:attribute>
          delete
        </a>
      </td>
    </tr>
  </xsl:template>

</xsl:stylesheet>
