<!--                                                                  -->
<!--  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="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 4.01//EN" encoding="utf-8" />

    <xsl:include href="/app/tools/rps/templates/global.xsl" />
	<xsl:include href="shared.xsl" />

	<xsl:variable name="pendingTransactionCount" select="count(/Root/Form/Account/FinanceAccount/PendingTransactionList/PendingTransaction)" />
	
	<xsl:variable name="pendingPrefix">Form_Account_FinanceAccount_PendingTransactionList_PendingTransaction_</xsl:variable>

	<xsl:variable name="openRuns">
	    <xsl:choose>
	        <xsl:when test="/Root/Form/OpenRuns">
	            <xsl:value-of select="/Root/Form/OpenRuns" />
	        </xsl:when>
	        <xsl:otherwise>0</xsl:otherwise>
	    </xsl:choose>
	</xsl:variable>	
	

    <xsl:template name="pickLayout">
        <script type="text/javascript" src="/production/javascript/validateTransactions.js?t={$now}" />

        <xsl:call-template name="payeeInformationSection" />
        
        <xsl:call-template name="transactionTabs" />
    
        <div class="section withTabs">
    
        	<div id="mainTransactionPanel">
     	    </div> 			

        </div>     
        
        <xsl:call-template name="tabSetup" />   

    </xsl:template>
    
    
    <xsl:template name="transactionTabs">
        <div class="sectionNav">
    	    <table>
    		    <tr>
    			    <td>
    				    <ul id="transactionNav"></ul>
    			    </td>
    		    </tr>
    	    </table>
        </div>
    </xsl:template>    


    <xsl:template name="payeeInformationSection">
        <div class="section">

            <xsl:call-template name="helpLink" />
        
            <input type="hidden" name="formSubmit" value="1" />
            <input type="hidden" name="c" value="{$cmd}" />
			
		    <xsl:if test="Params/PayorID">
			    <input type="hidden" name="PayorID" value="{Params/PayorID}" />
		    </xsl:if>		    
            
            <xsl:if test="Params/PublisherID">
                <input type="hidden" name="PublisherID" value="{Params/PublisherID}" />
            </xsl:if>

            <xsl:if test="$openRuns &gt; 0">
                <br />
                <xsl:call-template name="openRunMessage">
                    <xsl:with-param name="runArea1">
                        <xsl:if test="$area = 'publisher'">mechanical</xsl:if>
                        <xsl:if test="$area = 'ca_publisher'">ca_mechanical</xsl:if>
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:if>              			
	
	        <xsl:call-template name="payeeInformation" />

            <br /><br />
        </div>
        
    </xsl:template>


	<xsl:template name="payeeInformation">
        <fieldset id="payorView">
            <legend>Payor</legend>
            <div class="column1">
                <table style="padding-top: 0; margin-top: 0;">
                    <tr>
                        <td class="leftCol">Publisher Name:</td>
                        <td><xsl:value-of select="Form/Publisher/PublisherName" /></td>
                    </tr>
                    <tr>
                        <td class="leftCol">Type:</td>
                        <td>
                            <xsl:choose>
                                <xsl:when test="Form/Publisher/IsAgency = 1">Agency</xsl:when>
                                <xsl:when test="Form/Publisher/IsAdmin = 1">Administrator</xsl:when>
                                <xsl:otherwise>Standard</xsl:otherwise>
                            </xsl:choose>
                        </td>
                    </tr>
                    <xsl:if test="Form/Publisher/IsAdmin = 0">
                        <tr>
                            <td class="leftCol">Admin:</td>
                            <td><xsl:value-of select="Form/Publisher/AdminName" /></td>
                        </tr>
                    </xsl:if>
                    <xsl:if test="Form/Publisher/IsAgency = 0">
                        <tr>
                            <td class="leftCol">Agent:</td>
                            <td><xsl:value-of select="Form/Publisher/AgentName" /></td>
                        </tr>
                    </xsl:if>                                                           
                </table>
            </div>
            <div class="column2">
                <table style="padding-top: 0; margin-top: 0;">
                    <tr>
                        <td class="leftCol">Payor Name:</td>
                        <td><xsl:value-of select="Form/Payor/Name" /></td>
                    </tr>
                    <tr>
                        <td class="leftCol">Client Payor #:</td>
                        <td><xsl:value-of select="Form/Payor/ClientPayorID" /></td>
                    </tr>
                    <tr>
                        <td class="leftCol">Status:</td>
                        <td>
    					    <xsl:if test="Form/Payor/Inactive = 1">Inactive</xsl:if>
    					    <xsl:if test="Form/Payor/Inactive = 0">Active</xsl:if>
    					</td>
                    </tr>
                    <tr>
                        <td class="leftCol">Total # Licenses:</td>
                        <td><xsl:value-of select="Form/Payor/PublisherLicenseCount" /></td>
                    </tr>                                                       
                </table>
            </div>            
        </fieldset>
    </xsl:template>
    
    
    <xsl:template name="tabSetup">
        <script type="text/javascript">
    
            var directTab        = new Object();
            directTab.url        = "?c=edit_direct&amp;PayorID=<xsl:value-of select="Form/Payor/PayorID" />&amp;PublisherID=<xsl:value-of select="Form/Publisher/PublisherID" />";
            directTab.id         = "directTab";
            directTab.text       = "Direct Statement";
            <xsl:variable name="editDirectPermission">
                <xsl:if test="$area = 'publisher'">
                    <xsl:value-of select="Access/rps/publisher/edit_direct" />
                </xsl:if>
                <xsl:if test="$area = 'ca_publisher'">
                    <xsl:value-of select="Access/rps/ca_publisher/edit_direct" />
                </xsl:if>                
            </xsl:variable>
            directTab.visible    = "<xsl:value-of select="$editDirectPermission" />";
            directTab.enabled    = "1";
            directTab.show_count = "1";
            directTab.loading_image = "/production/images/loading.gif";

            var agentTab        = new Object();
            agentTab.url        = "?c=edit_indirect&amp;PayorID=<xsl:value-of select="Form/Payor/PayorID" />&amp;PublisherID=<xsl:value-of select="Form/Publisher/PublisherID" />&amp;IndirectPublisherID=<xsl:value-of select="Form/Publisher/AgentID" />";
            agentTab.id         = "agentTab";
            agentTab.text       = "Agent Statement";
            <xsl:variable name="editAgentPermission">
                <xsl:choose>
                    <xsl:when test="normalize-space(Form/Publisher/AgentID)">
                        <xsl:if test="$area = 'publisher'">
                            <xsl:value-of select="Access/rps/publisher/edit_indirect" />
                        </xsl:if>
                        <xsl:if test="$area = 'ca_publisher'">
                            <xsl:value-of select="Access/rps/ca_publisher/edit_indirect" />
                        </xsl:if>
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>                
            </xsl:variable>
            agentTab.visible    = "<xsl:value-of select="$editAgentPermission" />";
            agentTab.enabled    = "1";
            agentTab.show_count = "1";
            agentTab.loading_image = "/production/images/loading.gif";    

            var adminTab        = new Object();
            adminTab.url        = "?c=edit_indirect&amp;PayorID=<xsl:value-of select="Form/Payor/PayorID" />&amp;PublisherID=<xsl:value-of select="Form/Publisher/PublisherID" />&amp;IndirectPublisherID=<xsl:value-of select="Form/Publisher/AdminID" />";
            adminTab.id         = "adminTab";
            adminTab.text       = "Admin Statement";
            <xsl:variable name="editAdminPermission">
                <xsl:choose>
                    <xsl:when test="normalize-space(Form/Publisher/AdminID) and not(normalize-space(Form/Publisher/AgentID))">
                        <xsl:if test="$area = 'publisher'">
                            <xsl:value-of select="Access/rps/publisher/edit_indirect" />
                        </xsl:if>
                        <xsl:if test="$area = 'ca_publisher'">
                            <xsl:value-of select="Access/rps/ca_publisher/edit_indirect" />
                        </xsl:if>   
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>             
            </xsl:variable>
            adminTab.visible    = "<xsl:value-of select="$editAdminPermission" />";
            adminTab.enabled    = "1";
            adminTab.show_count = "1";
            adminTab.loading_image = "/production/images/loading.gif";    
   
    
            var aTabs = new Array( directTab, agentTab, adminTab );
            var oTabUpdateObj = new RSCatalogTabOnclickUpdate( "oTabUpdateObj", "mainTransactionPanel", "transactionNav", aTabs );
    
            <xsl:choose>
                <xsl:when test="Params/tab = 'agentTab'">
                    oTabUpdateObj.ActivateTab( 'agentTab' );
                </xsl:when>   
                <xsl:when test="Params/tab = 'adminTab'">
                    oTabUpdateObj.ActivateTab( 'adminTab' );
                </xsl:when>                  
                <xsl:otherwise>
                    oTabUpdateObj.ActivateTab( 'directTab' );
                </xsl:otherwise>
            </xsl:choose>

        </script>    
    </xsl:template>


</xsl:stylesheet>
