<!--  $Id$  -->
<!--                                                                  -->
<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">Support Role 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">
    <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="SupportRoleID"><xsl:attribute name="value"><xsl:value-of select="Form/SupportRoleID" /></xsl:attribute></input>
      <input type="hidden" name="action"><xsl:attribute name="value"><xsl:value-of select="Params/action" /></xsl:attribute></input>
      <xsl:choose>
        <xsl:when test="Form/SupportRoleID &gt; 0">
          <xsl:call-template name="displayDetail" />
          <xsl:call-template name="displayModules" />

          <xsl:call-template name="submitButton" />
        </xsl:when>
        <xsl:when test="/Root/Params/action = 'new'">
          <xsl:call-template name="displayDetail" />

          <xsl:call-template name="submitButton" />
        </xsl:when>
        <xsl:otherwise>
          Role not found
        </xsl:otherwise>
      </xsl:choose>
    </form>
    </div>
  </xsl:template>

  <xsl:template name="displayDetail" >
    <fieldset>
      <legend>Support Role</legend>
      <table>

        <tr>
          <xsl:call-template name="textField" >
            <xsl:with-param name="label">Support Role ID</xsl:with-param>
            <xsl:with-param name="value" select = "Form/SupportRoleID" />
          </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_Name</xsl:with-param>
            <xsl:with-param name="value" select = "Form/Name" />
          </xsl:call-template>
        </tr>


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

  <xsl:template name="displayModules" >
      <fieldset>
        <legend>Module Access</legend>
        <table>
          <tr>
            <td></td>
            <td>read</td>
            <td>write</td>
          </tr>

          <xsl:for-each select="Form/Modules/Module" >
            <tr>

              <td><xsl:value-of select="Name" /></td>

              <xsl:call-template name="checkboxField" >
                <xsl:with-param name="name">module_read_<xsl:value-of select="Slug" /></xsl:with-param>
                <xsl:with-param name="value" select = "CanAccess" />
              </xsl:call-template>

              <xsl:call-template name="checkboxField" >
                <xsl:with-param name="name">module_write_<xsl:value-of select="Slug" /></xsl:with-param>
                <xsl:with-param name="value" select = "CanWrite" />
              </xsl:call-template>

            </tr>
          </xsl:for-each>

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

</xsl:stylesheet>
