<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--  $Id$  -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
	xmlns:dyn="http://exslt.org/dynamic" extension-element-prefixes="dyn">
	<xsl:output method="html" indent="no" doctype-system="" encoding="utf-8" />

	<xsl:include href="/app/tools/rps/templates/global.xsl" />
	<xsl:include href="show.xsl" />
	<xsl:include href="search.xsl" />
	<xsl:include href="edit.xsl" />

    <xsl:template name="pickLayout">
        <script type="text/javascript" src="/production/javascript/rps/payor.js?v=2" />
        <link href="/production/css/rps/payor.css?v=2" rel="stylesheet" type="text/css" />
        <div class="MainBaseSection">
            <xsl:choose>
                <xsl:when test="$cmd = 'edit'">
                    <xsl:call-template name="payorEditLayout" />
                </xsl:when>
                <xsl:when test="$cmd = 'show'">
                    <xsl:call-template name="payorViewLayout" />
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="payorSearchLayout" />
                </xsl:otherwise>
            </xsl:choose>
        </div>
    </xsl:template>

	<xsl:template name="submitButton">
		<xsl:choose>
			<xsl:when test="$cmd = 'edit'">
				<xsl:call-template name="uiButton">
					<xsl:with-param name="className" select="'Form-button'"/>
					<xsl:with-param name="content">
						<xsl:choose>
							<xsl:when test="normalize-space(Form/Payor/PayorID)">Update</xsl:when>
							<xsl:otherwise>Create</xsl:otherwise>
						</xsl:choose>
					</xsl:with-param>
					<xsl:with-param name="type" select="'primary'"/>
					<xsl:with-param name="elemType" select="'submit'"/>
					<xsl:with-param name="name" select="'submit'"/>
					<xsl:with-param name="id" select="'submitButton'"/>
					<xsl:with-param name="disabled">
						<xsl:if test="$openRuns = 1">true</xsl:if>
					</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$cmd = 'show'">
				<xsl:call-template name="uiButton">
					<xsl:with-param name="className" select="'Form-button'"/>
					<xsl:with-param name="content" select="'Edit'"/>
					<xsl:with-param name="type" select="'primary'"/>
					<xsl:with-param name="onClick">javascript:location.href='payor?PayorID=<xsl:value-of select="Form/Payor/PayorID" />&amp;c=edit'</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="uiButton">
					<xsl:with-param name="className" select="'Form-button'"/>
					<xsl:with-param name="content" select="'Add New Payor'"/>
					<xsl:with-param name="type" select="'primary'"/>
					<xsl:with-param name="onClick">javascript:location.href='payor?c=edit'</xsl:with-param>
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="cancelButton">
		<xsl:choose>
			<xsl:when test="$cmd = 'edit' and normalize-space(Form/Payor/PayorID)">
                <xsl:call-template name="uiButton">
                    <xsl:with-param name="className" select="'Form-button-left'"/>
                    <xsl:with-param name="content" select="'Delete'"/>
                    <xsl:with-param name="type" select="'danger'"/>
                    <xsl:with-param name="name" select="'deleteButton'"/>
                    <xsl:with-param name="disabled">
                        <xsl:if test="($openRuns = 1) or (Form/Payor/IsLinked &gt; 0) or (Form/Payor/IsDefault &gt; 0)">true</xsl:if>
                    </xsl:with-param>
                    <xsl:with-param name="onClick">confirmDeletePayor(<xsl:value-of select="Form/Payor/PayorID"/>)</xsl:with-param>
                </xsl:call-template>
                <xsl:if test="Form/Payor/IsLinked &gt; 0">
                    <div class="HelpText HelpText-bybutton">This payor has been associated with a contract and/or license and cannot be deleted.</div>
                </xsl:if>
                <xsl:if test="Form/Payor/IsDefault &gt; 0">
                    <div class="HelpText HelpText-bybutton">Default payor cannot be deleted.</div>
                </xsl:if>
				<xsl:call-template name="uiButton">
					<xsl:with-param name="className" select="'Form-button'"/>
					<xsl:with-param name="content" select="'Return to Payor'"/>
					<xsl:with-param name="onClick">location.href='payor?PayorID=<xsl:value-of select="Params/PayorID"/>&amp;c=show'</xsl:with-param>
				</xsl:call-template>

			</xsl:when>
			<xsl:when test="$cmd = 'edit' and not(normalize-space(Form/Payor/PayorID))">
				<xsl:call-template name="uiButton">
					<xsl:with-param name="className" select="'Form-button'"/>
					<xsl:with-param name="content" select="'Create and Add Another'"/>
					<xsl:with-param name="type" select="'primary'"/>
					<xsl:with-param name="onClick">modifyFieldValue('ReturnTo','/rps/payor?c=edit&amp;msg=success|form_submit_success');</xsl:with-param>
					<xsl:with-param name="name" select="'submitButton'"/>
					<xsl:with-param name="id" select="'addAnotherButton'"/>
					<xsl:with-param name="elemType" select="'submit'"/>
				</xsl:call-template>
				<xsl:call-template name="uiButton">
					<xsl:with-param name="className" select="'Form-button'"/>
					<xsl:with-param name="content" select="'Back to Payors'"/>
					<xsl:with-param name="onClick">location.href='/rps/payor'</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$cmd = 'show'">
				<xsl:call-template name="uiButton">
					<xsl:with-param name="name" select="'Back'"/>
					<xsl:with-param name="className" select="'Form-button'"/>
					<xsl:with-param name="content" select="'Back to Payors'"/>
					<xsl:with-param name="onClick">location.href='/rps/payor'</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$cmd = 'search'">
				<xsl:call-template name="uiButton">
					<xsl:with-param name="name" select="'Back'"/>
					<xsl:with-param name="className" select="'Form-button'"/>
					<xsl:with-param name="content" select="'Back to Admin'"/>
					<xsl:with-param name="onClick">location.href='/rps/display?d=config'</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

</xsl:stylesheet>
