<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:import href="Common.xslt"/>

  <xsl:template name="Main_Proto">
    <xsl:param name="CodeReg"/>
    <xsl:param name="CodeStage"/>
    <xsl:param name="SessionID"/>
    <p />
    <xsl:call-template name="Main_First">
      <xsl:with-param name="X1" select="$CodeReg"/>
      <xsl:with-param name="X2" select="'startA'"/>
      <xsl:with-param name="X3" select="$SessionID"/>
      <xsl:with-param name="T2" select="'Проверяемый пакет документов'"/>
    </xsl:call-template>
    <p />

    <table align="center">
      <xsl:attribute name="width">
        <xsl:value-of select="$TableWidth"/>
      </xsl:attribute>
      <xsl:call-template name="Table4" />
      <tr>
        <td colspan="4" align="center">
          <span style="font-weight:bold">
            <xsl:text>ЭТАП </xsl:text>
            <xsl:value-of select="position()"/>
          </span>
        </td>
      </tr>
      <tr>
        <td colspan="4">
          <xsl:call-template name="ControlStageBox">
            <xsl:with-param name="siz" select="100"/>
            <xsl:with-param name="code" select="$CodeStage"/>
          </xsl:call-template>
        </td>
      </tr>
      <tr>
        <td>
          <span>
            <xsl:text>Результат</xsl:text>
          </span>
        </td>
        <td>
          <xsl:call-template name="Result">
            <xsl:with-param name="res" select="Protocol/Info/Result"/>
          </xsl:call-template>          
        </td>
        <td>
          <span>
            <xsl:text>Дата</xsl:text>
          </span>
        </td>
        <td>
          <xsl:call-template name="DateBox">
            <xsl:with-param name="siz" select="25"/>
            <xsl:with-param name="val" select="Protocol/Info/Date"/>
          </xsl:call-template>
        </td>
      </tr>
      <xsl:if test="Protocol/Info/Error!=''">
        <tr>
          <td colspan="4">
            <div>
              <xsl:text>Перечень ошибок и предупреждений</xsl:text>
            </div>
            <xsl:call-template name="Textarea">
              <xsl:with-param name="text" select="Protocol/Info/Error"/>
            </xsl:call-template>
          </td>
        </tr>
      </xsl:if>
    </table>
    
    <xsl:for-each select="Protocol/Realty/Object_Realty">
      <p />
      <table align="center">
        <xsl:attribute name="width">
          <xsl:value-of select="$TableWidth"/>
        </xsl:attribute>
        <xsl:call-template name="Table4"/>
        <tr>
          <td colspan="4" align="center">
            <span style="font-weight:bold">
              <xsl:text>ЭТАП </xsl:text>
              <xsl:value-of select="position()+1"/>
            </span>
          </td>
        </tr>
        <tr>
          <td colspan="4">
            <xsl:call-template name="ControlStageBox">
              <xsl:with-param name="siz" select="100"/>
              <xsl:with-param name="code" select="$CodeStage"/>
              <xsl:with-param name="comment" select="Definition"/>
            </xsl:call-template>
          </td>
        </tr>
        <tr>
          <td>
            <span>
              <xsl:text>Результат</xsl:text>
            </span>
          </td>
          <td>
            <xsl:call-template name="Result">
              <xsl:with-param name="res" select="Result"/>
            </xsl:call-template>            
          </td>
          <td colspan="2">
            <xsl:call-template name="TextBox">
              <xsl:with-param name="siz" select="50"/>
              <xsl:with-param name="val" select="GUID"/>
            </xsl:call-template>
          </td>
        </tr>
        <!--xsl:if test="GUID!=''">
          <tr>
            <td colspan="4">
              <xsl:call-template name="TextBox">
                <xsl:with-param name="siz" select="100"/>
                <xsl:with-param name="val" select="GUID"/>
              </xsl:call-template>
            </td>
          </tr>
        </xsl:if-->
        <xsl:if test="Error!=''">
          <tr>
            <td colspan="4">
              <div>
                <xsl:text>Перечень ошибок и предупреждений</xsl:text>
              </div>
              <xsl:call-template name="Textarea">
                <xsl:with-param name="text" select="Error"/>
              </xsl:call-template>
            </td>
          </tr>
        </xsl:if>
      </table>
    </xsl:for-each>

  </xsl:template>

  <xsl:template name="Main">
    <xsl:param name="CodeReg"/>
    <xsl:param name="CodeStage"/>
    <xsl:param name="SessionID"/>
    <P align="center">
      <span style="font-weight:bold">
        <xsl:text>Протокол контроля АИС ГКН</xsl:text>
      </span>
    </P>
    <xsl:call-template name="Main_Proto">
      <xsl:with-param name="CodeReg" select="$CodeReg"/>
      <xsl:with-param name="CodeStage" select="$CodeStage"/>
      <xsl:with-param name="SessionID" select="$SessionID"/>
    </xsl:call-template>
  </xsl:template>

</xsl:stylesheet>
