﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="/">
        <xsl:variable name="PortalItemID" select="AjaxRequest/Params/PortalItemID"></xsl:variable>
        <xsl:variable name="SourceID" select="AjaxRequest/Params/SourceID"></xsl:variable>
        <xsl:variable name="SourceStepsXML" select="AjaxRequest/SourceStepsXML/."></xsl:variable>
        <xsl:variable name="TemplateURL" select="AjaxRequest/TemplateURL"></xsl:variable>
        <xsl:variable name="SourceStepTypeXML" select="AjaxRequest/StepTypesXML/."></xsl:variable>
        <xsl:variable name="CommunityAdmin" select="AjaxRequest/UserRoles/Role[RoleName = 'Community Admin']"></xsl:variable>

        <table class="tableMaster" cellpadding="3" cellspacing="0">
            <xsl:if test="count($SourceStepsXML/SourceStep) &gt; 0">
                <tr>
                    <td width="10%">
                        <span class="packageTitle">
                            Order
                        </span>
                    </td>
                    <td width="20%">
                        <span class="packageTitle">
                            Step
                        </span>
                    </td>
                    <td width="10%">
                        <span class="packageTitle">
                            Type
                        </span>
                    </td>
                    <td width="20%">
                        <span class="packageTitle">
                            Description
                        </span>
                    </td>
                    <td width="25%">
                        <span class="packageTitle">
                            SpToExec
                        </span>
                    </td>
                    <td width="15%">
                        <span class="packageTitle">
                            Admin
                        </span>
                    </td>
                </tr>
                <xsl:for-each select="$SourceStepsXML/SourceStep">
                    <xsl:variable name="StepTypeID" select="StepTypeID"></xsl:variable>
                    <xsl:variable name="backgroundColor">
                        <xsl:choose>
                            <xsl:when test="position() mod 2 = 0">
                                <xsl:text>#DCDCDC</xsl:text>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:text></xsl:text>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>


                    <tr id="tr_Steps_{$PortalItemID}_{StepID}" style="background-color:{$backgroundColor};">
                        <td>
                            <span id="span_SeqNum_{$PortalItemID}_{StepID}" class="publicationSummary">
                                <xsl:value-of select="SeqNum"/>
                            </span>
                            <input id="txt_SeqNum_{$PortalItemID}_{StepID}" type="text" value="{SeqNum}" class="text" style="display:none;width:50px;"></input>
                        </td>
                        <td>
                            <span id="span_Step_{$PortalItemID}_{StepID}" class="publicationSummary">
                                <xsl:value-of select="Step"/>
                            </span>
                            <input id="txt_Step_{$PortalItemID}_{StepID}" type="text" value="{Step}" class="text" style="display:none;width:100px;"></input>
                        </td>
                        <td>
                            <span id="span_StepTypeID_{$PortalItemID}_{StepID}" class="publicationSummary">
                                <xsl:value-of select="StepTypeID"/>
                            </span>
                            <select id="opt_StepType_{$PortalItemID}_{StepID}" class="smallDropdown" style="display:none;width:70px;">
                                <option>-Select-</option>
                                <xsl:for-each select="$SourceStepTypeXML/StepType">
                                    <xsl:variable name="StepTypeId" select="StepTypeID"></xsl:variable>

                                    <xsl:choose>
                                        <xsl:when test="$StepTypeId = $StepTypeID">
                                            <option value="{$StepTypeId}" selected="selected">
                                                <xsl:value-of select="StepType"/>
                                            </option>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <option value="{$StepTypeId}">
                                                <xsl:value-of select="StepType"/>
                                            </option>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:for-each>
                            </select>
                        </td>
                        <td>
                            <span id="span_Desc_{$PortalItemID}_{StepID}" class="publicationSummary">
                                <xsl:value-of select="Description"/>
                            </span>
                            <textarea id="txt_Description_{$PortalItemID}_{StepID}" style="display:none;width:120px;height:16px;resize:none;"
                                     onkeyup="control_TextAreaAutoGrow('txt_Description_{$PortalItemID}_{StepID}');"
                                     onFocus="removeWhiteSpace('txt_Description_{$PortalItemID}_{StepID}');"></textarea>
                        </td>
                        <td>
                            <span id="span_SpToExec_{$PortalItemID}_{StepID}" class="publicationSummary">
                                <xsl:value-of select="SPtoExec"/>
                            </span>
                            <input id="txt_SpToExec_{$PortalItemID}_{StepID}" type="text" value="{SPtoExec}" class="text" style="display:none;width:130px;"></input>
                        </td>
                        <td>
                            <select id="opt_StepAdmin_{$PortalItemID}_{StepID}" class="smallDropdown" style="width:80px;"
                                    onchange="SelectDataXStepAdminOption('{$PortalItemID}','opt_StepAdmin_{$PortalItemID}_{StepID}','{$SourceID}','{StepID}');">
                                <option value="-99">-Select-</option>
                                <option value="1">Edit</option>
                                <xsl:if test="$CommunityAdmin">
                                    <option value="2">Delete</option>
                                </xsl:if>
                            </select>
                            <div id="btnUpdate_{$PortalItemID}_{StepID}" class="verticallyMiddle onMouseOver textCenter divBrowseGradient spanBrowseGradientTextGray"
                                style="width:70px;line-height:22px;display:none;"
                                onclick="UpdateDataXSourceStep('{$PortalItemID}','{$SourceID}','txt_SeqNum_{$PortalItemID}_{StepID}','txt_Step_{$PortalItemID}_{StepID}',
                          'opt_StepType_{$PortalItemID}_{StepID}','txt_Description_{$PortalItemID}_{StepID}','txt_SpToExec_{$PortalItemID}_{StepID}','{StepID}');">
                                <span id="span_Column" class="capitalFont">update</span>
                            </div>
                        </td>
                    </tr>
                </xsl:for-each>
            </xsl:if>
            <tr>
                <td colspan="5">
                    <div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray" style="width:100px;line-height:22px;"
                        onmouseover="document.getElementById('img_AddStep').src='{$TemplateURL}Web/Images/Ver_2_0/icon_add_over.png';"
                        onmouseout="document.getElementById('img_AddStep').src='{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png';"
                        onclick="DataX_AddNewStep('{$PortalItemID}','{$SourceID}','divTransactions');">
                        <img id="img_AddStep" src="{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" style="padding-left:8px;" class="marginRight5"></img>
                        <span id="span_Step" class="capitalFont">add a step</span>
                    </div>
                </td>
            </tr>
        </table>
    </xsl:template>
</xsl:stylesheet>
