<!--                                                                  -->
<!--  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="shared.xsl" />

    <xsl:template name="pickLayout">
        <div class="MainBaseSection">
            <form name="payorTransaction" id="payorTransaction" method="post" action="{$area}">
                <div class="PublisherEdit">
                    <section class="PageShow-section PubliserEditDirect-section">
                        <xsl:call-template name="payeeInformationSection" />
                    </section>
                    <section class="PageShow-section PubliserEditDirect-section">
                        <xsl:call-template name="payorTransactionEdit" />
                    </section>
                    <xsl:call-template name="buttons" />
                </div>
            </form>
            <xsl:call-template name="transactionTypeArray" />
        </div>
    </xsl:template>

    <xsl:template name="payorTransactionEdit">
        <input type="hidden" name="formSubmit" value="1" />
        <input type="hidden" name="c" value="{$cmd}" />
        <input type="hidden" name="PayorID" value="{Params/PayorID}" />
        <input type="hidden" name="PublisherID" value="{Params/PublisherID}" />

        <xsl:if test="//*[@e]">
            <xsl:call-template name="errorMessageGeneral" />
        </xsl:if>

        <xsl:if test="$cmd = 'edit_indirect'">
            <!-- first let's do the active admin/agent -->
            <xsl:for-each select="Form/AccountList/Account[IndirectPublisherID = $indirectPublisherID]">
                <xsl:call-template name="transactions" />
            </xsl:for-each>
            <!-- and now the rest -->
            <xsl:for-each select="Form/AccountList/Account[IndirectPublisherID != $indirectPublisherID]">
                <xsl:call-template name="transactions" />
            </xsl:for-each>
        </xsl:if>

        <xsl:if test="$cmd = 'edit_direct'">
            <!-- only one account, but let's reference it the same way -->
            <xsl:for-each select="Form/AccountList/Account">
                <xsl:call-template name="transactions" />
            </xsl:for-each>
        </xsl:if>
    </xsl:template>

    <xsl:template name="payeeInformationSection">
        <xsl:call-template name="helpLink" />
        <xsl:call-template name="openRunStatusMessage" />
        <xsl:call-template name="payeeInformation" />
    </xsl:template>

    <xsl:template name="payeeInformation">
        <section class="PageShow-section">
            <h2>Payee Information</h2>
            <div class="InformationCols">
                <div class="InformationCols-item">
                    <div class="ValuePair">

                        <xsl:call-template name="uiValuePairItem">
                            <xsl:with-param name="label" select="'Publisher Name'" />
                            <xsl:with-param name="value" select="Form/Publisher/PublisherName" />
                        </xsl:call-template>

                        <xsl:call-template name="uiValuePairItem">
                            <xsl:with-param name="label" select="'Publisher Type'" />
                            <xsl:with-param name="value">
                                <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>
                            </xsl:with-param>
                        </xsl:call-template>

                        <!-- show CMRRA manufacturer data if this is an agency -->
                        <xsl:if test="$area = 'ca_publisher' and Form/Publisher/IsAgency = 1">
                            <xsl:call-template name="manufacturerIDField" />
                            <xsl:call-template name="manufacturerNameField" />
                        </xsl:if>

                        <xsl:if test="$cmd = 'edit_indirect'">
                            <xsl:call-template name="uiValuePairItem">
                                <xsl:with-param name="label" select="'Admin'" />
                                <xsl:with-param name="value" select="Form/Publisher/AdminName" />
                            </xsl:call-template>

                            <xsl:call-template name="uiValuePairItem">
                                <xsl:with-param name="label" select="'Agent'" />
                                <xsl:with-param name="value" select="Form/Publisher/AgentName" />
                            </xsl:call-template>
                        </xsl:if>

                        <xsl:call-template name="uiValuePairItem">
                            <xsl:with-param name="label" select="'Total # Licenses'" />
                            <xsl:with-param name="value">
                                <xsl:if test="$cmd = 'edit_indirect'">
                                    <xsl:choose>
                                        <xsl:when test="$publisherDirect = 1">
                                            0
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:value-of select="Form/Payor/PublisherIndirectLicenseCount" />
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:if>
                                <xsl:if test="$cmd = 'edit_direct'">
                                    <xsl:choose>
                                        <xsl:when test="$publisherDirect = 1">
                                            <xsl:value-of select="Form/Payor/PublisherTotalLicenseCount" />
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:value-of select="Form/Payor/PublisherDirectLicenseCount" />
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:if>
                            </xsl:with-param>
                        </xsl:call-template>
                    </div>
                </div>
                <div class="InformationCols-item">
                    <div class="ValuePair">
                        <xsl:call-template name="uiValuePairItem">
                            <xsl:with-param name="label" select="'Payor Name'" />
                            <xsl:with-param name="value" select="Form/Payor/Name" />
                        </xsl:call-template>

                        <xsl:call-template name="uiValuePairItem">
                            <xsl:with-param name="label" select="'Client Payor #'" />
                            <xsl:with-param name="value" select="Form/Payor/ClientPayorID" />
                        </xsl:call-template>

                        <xsl:call-template name="uiValuePairItem">
                            <xsl:with-param name="label" select="'Status'" />
                            <xsl:with-param name="value">
                                <xsl:if test="Form/Payor/Inactive = 1">Inactive</xsl:if>
                                <xsl:if test="Form/Payor/Inactive = 0">Active</xsl:if>
                            </xsl:with-param>
                        </xsl:call-template>

                        <xsl:call-template name="uiValuePairItem">
                            <xsl:with-param name="label" select="'Default'" />
                            <xsl:with-param name="value">
                                <xsl:if test="Form/Payor/IsDefault = 1">Yes</xsl:if>
                                <xsl:if test="Form/Payor/IsDefault = 0">No</xsl:if>
                            </xsl:with-param>
                        </xsl:call-template>

                        <xsl:choose>
                            <xsl:when test="$cmd = 'edit_indirect'">
                                <xsl:call-template name="minPaymentTextValue" />
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:call-template name="minPaymentField" />
                            </xsl:otherwise>
                        </xsl:choose>
                    </div>
                </div>
            </div>
        </section>
    </xsl:template>

    <xsl:template name="manufacturerIDField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item ValuePair-item Form-item-price-field</xsl:text>
                <xsl:if test="Form/AccountList/Account/ManufacturerID[@e]">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>

            </xsl:attribute>
            <label class="Form-label">
                <span class="Form-label-caption">
                    CMRRA Manufacturer ID
                </span>
                <div class="Form-input-wrapper">
                    <input class="Input Form-input" name="Form_AccountList_Account_0_ManufacturerID" id="Form_AccountList_Account_0_ManufacturerID" type="text" value="{Form/AccountList/Account/ManufacturerID}">
                        <xsl:if test="$openRuns &gt; 0">
                            <xsl:attribute name="disabled">disabled</xsl:attribute>
                        </xsl:if>
                    </input>
                </div>
            </label>
            <div class="Form-error-text-wrapper">
                <xsl:call-template name="inlineError">
                    <xsl:with-param name="path">Form/AccountList/Account/ManufacturerID</xsl:with-param>
                    <xsl:with-param name="displayName">CMRRA Manufacturer ID:</xsl:with-param>
                </xsl:call-template>
            </div>
        </div>
    </xsl:template>

    <xsl:template name="manufacturerNameField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item ValuePair-item Form-item-price-field</xsl:text>
                <xsl:if test="Form/AccountList/Account/ManufacturerName[@e]">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>

            </xsl:attribute>
            <label class="Form-label">
                <span class="Form-label-caption">
                    Manufacturer Name
                </span>
                <input class="Input Form-input" name="Form_AccountList_Account_0_ManufacturerName" id="Form_AccountList_Account_0_ManufacturerName" type="text" value="{Form/AccountList/Account/ManufacturerName}">
                    <xsl:if test="$openRuns &gt; 0">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                    </xsl:if>
                </input>
            </label>
            <div class="Form-error-text-wrapper">
                <xsl:call-template name="inlineError">
                    <xsl:with-param name="path">Form/AccountList/Account/ManufacturerName</xsl:with-param>
                    <xsl:with-param name="displayName">Manufacturer Name:</xsl:with-param>
                </xsl:call-template>
            </div>
        </div>
    </xsl:template>

    <xsl:variable name="minPaymentLabelCaption">
        Minimum Payment (<xsl:value-of select="$publisherCurrencyCode" />)
    </xsl:variable>

    <xsl:template name="minPaymentField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item ValuePair-item Form-item-price-field</xsl:text>
                <xsl:if test="Form/AccountList/Account/MinPayment[@e]">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>

            </xsl:attribute>
            <label class="Form-label">
                <span class="Form-label-caption">
                    <xsl:value-of select="$minPaymentLabelCaption" />
                </span>
                <div class="Form-input-wrapper">
                    <input name="Form_AccountList_Account_0_MinPayment" class="Input Form-input" id="Form_AccountList_Account_0_MinPayment" type="text" value="{Form/AccountList/Account/MinPayment}">
                        <xsl:if test="$openRuns &gt; 0">
                            <xsl:attribute name="disabled">disabled</xsl:attribute>
                        </xsl:if>
                    </input>
                </div>
            </label>
            <div class="Form-error-text-wrapper">
                <xsl:call-template name="inlineError">
                    <xsl:with-param name="path">Form/AccountList/Account/MinPayment</xsl:with-param>
                    <xsl:with-param name="displayName">Minimum Payment</xsl:with-param>
                </xsl:call-template>
            </div>
        </div>
    </xsl:template>

    <xsl:template name="minPaymentTextValue">
        <div class="ValuePair-item">
            <span class="ValuePair-label">
                <xsl:value-of select="$minPaymentLabelCaption" />
            </span>
            <div class="ValuePair-value">
                <xsl:choose>
                    <xsl:when test="normalize-space($indirectPublisherType)">
                        <i>See <xsl:value-of select="$indirectPublisherType" /></i>
                    </xsl:when>
                    <xsl:otherwise>N/A</xsl:otherwise>
                </xsl:choose>
            </div>
        </div>
    </xsl:template>

    <xsl:template name="transactions">
        <section class="PageShow-section PubliserEditDirect-transactions-section js-transactions-adding-block">
            <xsl:variable name="transactionPubID" select="IndirectPublisherID" />
            <xsl:variable name="transactionPubName">
                <xsl:choose>
                    <xsl:when test="/Root/Form/AccountList/PublisherList/Publisher/PublisherID = $transactionPubID">
                        <xsl:value-of select="/Root/Form/AccountList/PublisherList/Publisher[PublisherID = $transactionPubID]/PublisherName" /><xsl:if test="$transactionPubID != $indirectPublisherID"> (Historical)</xsl:if>
                    </xsl:when>
                    <xsl:otherwise><xsl:value-of select="$indirectPublisherName" /></xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <xsl:call-template name="pendingTransactions">
                <xsl:with-param name="transactionPubName" select="$transactionPubName" />
            </xsl:call-template>
            <xsl:if test="FinanceAccount/TransactionList/Transaction">
                <xsl:call-template name="transactionHistory">
                    <xsl:with-param name="transactionPubName" select="$transactionPubName" />
                </xsl:call-template>
            </xsl:if>
        </section>
    </xsl:template>

    <xsl:template name="pendingTransactions">
        <xsl:param name="transactionPubName" />
        <xsl:variable name="accountPosition" select="@i" />
        <xsl:variable name="pendingTransactionCount" select="count(FinanceAccount/PendingTransactionList/PendingTransaction)" />
        <xsl:variable name="pendingPrefix">Form_AccountList_Account_<xsl:value-of select="@i" />_FinanceAccount_PendingTransactionList_PendingTransaction_</xsl:variable>
        <input type="hidden" name="TransactionCount{@i}" id="TransactionCount{@i}" value="{$pendingTransactionCount}" />
        <section class="PageShow-section">
            <h2>Pending Transactions<xsl:if test="$cmd = 'edit_indirect'"> - <xsl:value-of select="$transactionPubName" /></xsl:if></h2>
            <div class="Form-header">
                <p>Enter transaction information here.</p>
            </div>
            <table class="Table pendingTransactions js-transactions-adding-table" id="transactionTable{@i}">
                <thead>
                    <tr class="Table-row Table-row-header">
                        <th class="Table-col">Type</th>
                        <th class="Table-col">
                            <span class="Table-col-wrapper">Amount (<xsl:value-of select="$publisherCurrencyCode" />)</span>
                            <xsl:call-template name="helpIcon">
                                <xsl:with-param name="tip">Positive Adjustment adds to the payee balance, a negative&lt;br&gt;Adjustment subtracts from the payee balance</xsl:with-param>
                                <xsl:with-param name="linkID">amountHelp</xsl:with-param>
                            </xsl:call-template>
                        </th>
                        <th class="Table-col Table-col-shrink">Transaction Date</th>
                        <th class="Table-col checkCol">Check #</th>
                        <th class="Table-col memoCol">Memo</th>
                        <th class="Table-col Table-col-icon">Delete</th>
                    </tr>
                </thead>
                <tbody>
                    <xsl:choose>
                        <xsl:when test="$pendingTransactionCount &gt; 0">
                            <xsl:for-each select="FinanceAccount/PendingTransactionList/PendingTransaction">
                                <xsl:call-template name="pendingTransactionRow">
                                    <xsl:with-param name="accountPosition" select="$accountPosition" />
                                    <xsl:with-param name="pendingPrefix" select="$pendingPrefix" />
                                    <xsl:with-param name="pendingTransactionCount" select="$pendingTransactionCount" />
                                </xsl:call-template>
                            </xsl:for-each>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="pendingTransactionRow">
                                <xsl:with-param name="accountPosition" select="$accountPosition" />
                                <xsl:with-param name="pendingPrefix" select="$pendingPrefix" />
                                <xsl:with-param name="pendingTransactionCount" select="$pendingTransactionCount" />
                            </xsl:call-template>
                        </xsl:otherwise>
                    </xsl:choose>
                </tbody>
            </table>
            <xsl:if test="$openRuns = 0">

                <xsl:call-template name="uiButton">
                    <xsl:with-param name="content" select="'Add Another Transaction'" />
                    <xsl:with-param name="iconLeftType" select="'add'" />
                    <xsl:with-param name="className" select="'Table-add-row-button js-transactions-adding-button'" />
                    <xsl:with-param name="type" select="'text-inline'" />
                </xsl:call-template>

            </xsl:if>
        </section>
    </xsl:template>

    <xsl:template name="pendingTransactionRow">
        <xsl:param name="accountPosition" />
        <xsl:param name="pendingPrefix" />
        <xsl:param name="pendingTransactionCount" />
        <xsl:variable name="transactionPosition" select="position() - 1" />
        <xsl:variable name="transactionAccountID" select="AccountID" />
        <tr class="Table-row Table-row-data Table-row-inputs" id="transaction{position()}" data-prefix="{$pendingPrefix}">
            <td class="Table-col PayorTransactionEdit-type-code-col">
                <div class="Form-item">
                    <xsl:attribute name="class">
                        <xsl:text>Form-item</xsl:text>
                        <xsl:if test="TypeCode[@e]">
                            <xsl:text> Form-item-error</xsl:text>
                        </xsl:if>

                    </xsl:attribute>
                    <label class="Form-label">
                        <div class="Form-input-wrapper PayorTransactionEdit-type-code-field">

                            <xsl:variable name="payorTransactionTypeItems">
                                <map>
                                    <mapEntry><name>Choose...</name><value></value></mapEntry>
                                    <mapEntry><name>Adjustment</name><value>2</value></mapEntry>
                                    <mapEntry><name>Advance</name><value>3</value></mapEntry>
                                    <xsl:if test="$area != 'license'">
                                        <mapEntry><name>Payment</name><value>4</value></mapEntry>
                                    </xsl:if>
                                </map>
                            </xsl:variable>
                            <xsl:call-template name="uiDropdown">
                                <xsl:with-param name="items" select="$payorTransactionTypeItems"/>
                                <xsl:with-param name="name">
                                    <xsl:value-of select="$pendingPrefix" />
                                    <xsl:value-of select="$transactionPosition" />
                                    <xsl:text>_TypeCode</xsl:text>
                                </xsl:with-param>
                                <xsl:with-param name="id">
                                    <xsl:value-of select="$pendingPrefix" />
                                    <xsl:value-of select="$transactionPosition" />
                                    <xsl:text>_TypeCode</xsl:text>
                                </xsl:with-param>
                                <xsl:with-param name="active" select="TypeCode"/>
                                <xsl:with-param name="className" select="''"/>
                                <xsl:with-param name="disabled">
                                    <xsl:if test="$openRuns &gt; 0">
                                        <xsl:test>true</xsl:test>
                                    </xsl:if>
                                </xsl:with-param>
                            </xsl:call-template>

                        </div>
                    </label>
                    <div class="Form-error-text-wrapper">
                        <p class="Form-error">Type must be selected</p>
                    </div>
                </div>
            </td>
            <td class="Table-col">
                <div class="Form-item">
                    <xsl:attribute name="class">
                        <xsl:text>Form-item</xsl:text>
                        <xsl:if test="Amount[@e]">
                            <xsl:text> Form-item-error</xsl:text>
                        </xsl:if>

                    </xsl:attribute>
                    <label class="Form-label">
                        <div class="Form-input-wrapper">
                            <input name="{$pendingPrefix}{$transactionPosition}_Amount" class="Input Form-input" id="{$pendingPrefix}{$transactionPosition}_Amount" type="text" value="{Amount}">
                                <xsl:if test="$openRuns &gt; 0">
                                    <xsl:attribute name="disabled">disabled</xsl:attribute>
                                </xsl:if>
                            </input>
                        </div>
                    </label>
                    <div class="Form-error-text-wrapper">
                        <xsl:if test="//Amount[@e = 'field_blank']"><p class="Form-error">Amount cannot be blank</p></xsl:if>
                        <xsl:if test="//Amount[@e = 'field_invalid']"><p class="Form-error">Amount is invalid.</p></xsl:if>
                        <xsl:if test="//Amount[@e = 'field_out_of_range']"><p class="Form-error">Amount must be a positive number.</p></xsl:if>
                    </div>
                </div>
            </td>
            <td class="Table-col Table-col-shrink">
                <div class="Form-item">
                    <xsl:attribute name="class">
                        <xsl:text>Form-item</xsl:text>
                        <xsl:if test="TransactionDate[@e]">
                            <xsl:text> Form-item-error</xsl:text>
                        </xsl:if>

                    </xsl:attribute>
                    <label class="Form-label">
                        <div class="Form-input-wrapper">
                            <xsl:call-template name="uiDatepicker">
                                <xsl:with-param name="name">
                                    <xsl:value-of select="$pendingPrefix"/>
                                    <xsl:value-of select="$transactionPosition"/>
                                    <xsl:text>_TransactionDate</xsl:text>
                                </xsl:with-param>
                                <xsl:with-param name="id">
                                    <xsl:value-of select="$pendingPrefix"/>
                                    <xsl:value-of select="$transactionPosition"/>
                                    <xsl:text>_TransactionDate</xsl:text>
                                </xsl:with-param>

                                <xsl:with-param name="value" select="TransactionDate" />
                                <xsl:with-param name="disabled">
                                    <xsl:if test="$openRuns &gt; 0">
                                        <xsl:text>true</xsl:text>
                                    </xsl:if>
                                </xsl:with-param>
                                <xsl:with-param name="iconId">
                                    <xsl:text>calendarIcon</xsl:text>
                                    <xsl:value-of select="$transactionPosition" />
                                </xsl:with-param>

                            </xsl:call-template>
                        </div>
                    </label>
                    <div class="Form-error-text-wrapper">
                        <p class="Form-error">Transaction Date is invalid</p>
                    </div>
                </div>
            </td>
            <td class="Table-col">
                <div class="Form-item">
                    <xsl:attribute name="class">
                        <xsl:text>Form-item</xsl:text>
                        <xsl:if test="CheckNumber[@e]">
                            <xsl:text> Form-item-error</xsl:text>
                        </xsl:if>

                    </xsl:attribute>
                    <label class="Form-label">
                        <div class="Form-input-wrapper">
                            <input name="{$pendingPrefix}{$transactionPosition}_CheckNumber" id="{$pendingPrefix}{$transactionPosition}_CheckNumber" type="text" value="{CheckNumber}" class="Input Form-input">
                                <xsl:if test="$openRuns &gt; 0">
                                    <xsl:attribute name="disabled">disabled</xsl:attribute>
                                </xsl:if>
                            </input>
                        </div>
                    </label>
                    <div class="Form-error-text-wrapper">
                        <p class="Form-error">Check # is invalid</p>
                    </div>
                </div>
            </td>
            <td class="Table-col">
                <div class="Form-item">
                    <xsl:attribute name="class">
                        <xsl:text>Form-item</xsl:text>
                        <xsl:if test="Memo[@e]">
                            <xsl:text> Form-item-error</xsl:text>
                        </xsl:if>
                    </xsl:attribute>
                    <label class="Form-label">
                        <div class="Form-input-wrapper">
                            <input name="{$pendingPrefix}{$transactionPosition}_Memo" id="{$pendingPrefix}{$transactionPosition}_Memo" type="text" value="{Memo}" class="Input Form-input">
                                <xsl:if test="$openRuns &gt; 0">
                                    <xsl:attribute name="disabled">disabled</xsl:attribute>
                                </xsl:if>
                            </input>
                        </div>
                    </label>
                </div>
            </td>
            <td class="Table-col Table-col-icon PayorTransactionEdit-delete-col">
                <div class="Form-item Form-item-inline">
                    <div class="Form-label">
                        <div class="Form-input-wrapper">
                            <xsl:call-template name="uiDeleteRowTrigger">
                                <xsl:with-param name="name">
                                    <xsl:value-of select="$pendingPrefix"/>
                                    <xsl:value-of select="$transactionPosition"/>
                                    <xsl:text>_Delete</xsl:text>
                                </xsl:with-param>
                                <xsl:with-param name="id">
                                    <xsl:value-of select="$pendingPrefix"/>
                                    <xsl:value-of select="$transactionPosition"/>
                                    <xsl:text>_Delete</xsl:text>
                                </xsl:with-param>
                                <xsl:with-param name="value" select="1"/>
                                <xsl:with-param name="disabled">
                                    <xsl:if test="$openRuns &gt; 0">
                                        <xsl:text>true</xsl:text>
                                    </xsl:if>
                                </xsl:with-param>
                            </xsl:call-template>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="transactionHistory">
        <xsl:param name="transactionPubName" />
        <section class="PageShow-section">
            <h2>Transaction History<xsl:if test="$cmd = 'edit_indirect'"> - <xsl:value-of select="$transactionPubName" /></xsl:if></h2>
            <table class="Table Table-with-highlight transactionHistory">
                <xsl:call-template name="historyHeaderRow" />
                <xsl:for-each select="FinanceAccount/TransactionList/Transaction">
                    <xsl:call-template name="historyTransactionRow" />
                </xsl:for-each>
            </table>
        </section>
    </xsl:template>


    <xsl:template name="historyHeaderRow">
        <tr class="Table-row Table-row-header">
            <th class="Table-col">Type</th>
            <th class="Table-col Table-col-amount">Amount</th>
            <th class="Table-col">Transaction Date</th>
            <th class="Table-col">Check #</th>
            <th class="Table-col">Memo</th>
            <th class="Table-col Table-col-amount">Balance</th>
        </tr>
    </xsl:template>


    <xsl:template name="historyTransactionRow">
        <tr class="Table-row Table-row-data">
            <td class="Table-col">
                <xsl:call-template name="transactionTypeCode">
                    <xsl:with-param name="typeCode" select="TypeCode" />
                </xsl:call-template>
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="Amount" />
            </td>
            <td class="Table-col"><xsl:value-of select="TransactionDate" /></td>
            <td class="Table-col"><xsl:value-of select="CheckNumber" /></td>
            <td class="Table-col">
                <xsl:choose>
                    <xsl:when test="Memo = 'See Admin' or Memo = 'See Agent'">
                        <i><xsl:value-of select = "Memo" /></i>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:call-template name="replaceLineBreak">
                            <xsl:with-param name="string" select="Memo"/>
                        </xsl:call-template>
                    </xsl:otherwise>
                </xsl:choose>
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="Balance" />
            </td>
        </tr>
    </xsl:template>


    <xsl:template name="transactionTypeCode">
        <xsl:param name="typeCode" />
        <xsl:if test="$typeCode = 1">Opening Balance</xsl:if>
        <xsl:if test="$typeCode = 2">Adjustment</xsl:if>
        <xsl:if test="$typeCode = 3">Advance</xsl:if>
        <xsl:if test="$typeCode = 4">Payment</xsl:if>
        <xsl:if test="$typeCode = 5">Closing Balance</xsl:if>
    </xsl:template>


    <xsl:template name="transactionTypeArray">
        <script type="text/javascript">
            // setting up an arrays for adding new transactions

            var types = new Object();

            types[2] = 'Adjustment';
            types[3] = 'Advance';
            types[4] = 'Payment';

        </script>
    </xsl:template>

    <xsl:template name="submitButton">
        <xsl:call-template name="uiButton">
            <xsl:with-param name="type" select="'primary'" />
            <xsl:with-param name="className" select="'Form-button'" />
            <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="content" select="'Update'" />
            <xsl:with-param name="disabled">
                <xsl:if test="$openRuns &gt; 0">
                    <xsl:text>true</xsl:text>
                </xsl:if>
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="cancelButton">
        <xsl:call-template name="uiButton">
            <xsl:with-param name="content" select="'Return to Publisher'" />
            <xsl:with-param name="className" select="'Form-button'" />
            <xsl:with-param name="url">
                <xsl:text>?PublisherID=</xsl:text>
                <xsl:value-of select="Form/Publisher/PublisherID" />
                <xsl:text>&amp;c=show</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>

</xsl:stylesheet>


