<!--                                                                  -->
<!--  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:template name="payeeViewLayout">
        <div class="PayeeView">
        <xsl:call-template name="helpLink" />

            <xsl:call-template name="errorMessageBox">
                <xsl:with-param name="errorMessage" select="Messages/Message/Code" />
            </xsl:call-template>

            <xsl:call-template name="successMessageGeneral">
                <xsl:with-param name="successMessage">Payee successfully updated!</xsl:with-param>
            </xsl:call-template>

            <script src="/production/javascript/jquery/jquery-3.6.0.min.js"></script>
            <link href="/production/css/portal.css" media="screen" rel="stylesheet" type="text/css" />
            <div id="confirmResend" title="Resend Invite">
                <form id="resend_form" action="/rps/portal/resend" method="post">
                    <input type="hidden" name="resend" value="1"/>
                    <input type="hidden" name="payeeID" value="{Form/ArtistPayee/ArtistPayeeID}"/>
                    <input type="hidden" name="payeeType" value="1"/>
                    <input type="hidden" id="payeeRecipientFlex" name="payeeRecipientID" value=""/>
                </form>
            </div>
            <script>
                function failResend() {
                    var popHTML = '<p class="Modal-paragraph">Unable to resend invite.</p>';
                    popHTML += '<p class="Modal-paragraph">You can only resend an invite once per day. Please try again later.</p>';
                    jsInlinePop(
                        popHTML,
                        "Okay",
                        'hideInlinePop();',
                        '',
                        '$(\'input[name="mainButton"]\').remove();',
                        'Resend Invite'
                    );
                }
                function confirmResend() {
                    var recipient = document.getElementById('payeeRecipientFlex');
                    recipient.setAttribute('value', 0);
                    var popHTML = '<p class="Modal-paragraph">Are you sure you want to resend an invite to this contact?</p>';
                    jsInlinePop(popHTML,"Resend",
                        <xsl:choose>
                            <xsl:when test="Form/ArtistPayee/CanInvite = '1'">
                                "$('#resend_form').submit();"
                            </xsl:when>
                            <xsl:otherwise>
                                "failResend();"
                            </xsl:otherwise>
                        </xsl:choose>,
                        null,
                        null,
                        'Resend Invite'
                    );
                }
                $(function() {
                    $("#viewConfirm").on('click', function() {
                        confirmResend();
                        return false;
                    });
                });
                function confirmRecipientResend(recipientID, canResend) {
                    if ( !canResend ) {
                        failResend();
                        return;
                    }
                    var flex = document.getElementById('payeeRecipientFlex');
                    flex.setAttribute('value', recipientID);
                    var popHTML = '<p class="Modal-paragraph">Are you sure you want to resend an invite to this contact?</p>';
                    jsInlinePop(popHTML,"Resend", "$('#resend_form').submit();",null,null,'Resend Invite');
                    return 1;
                }
            </script>
            <section class="PageShow-section PayeeShow-section">
                <h2>Payee</h2>
                <div class="InformationCols">
                    <div class="InformationCols-item">
                        <xsl:call-template name="column1View" />
                    </div>
                    <div class="InformationCols-item" style="width:66.6666%">
                        <xsl:call-template name="column2View" />
                    </div>
                </div>
                <div class="PageShow-last-modified">
                    <p class="HelpText">
                        Last modified <xsl:value-of select="Form/ArtistPayee/ModifiedDate" /><xsl:if test="normalize-space(Form/ArtistPayee/ModifiedBy)"> by <xsl:value-of select="Form/ArtistPayee/ModifiedBy" /></xsl:if>
                    </p>
                </div>
            </section>
            <xsl:if test="count(Form/ArtistContractList/ArtistContract) &gt; 0">
                <xsl:call-template name="contractList">
                    <xsl:with-param name="contracts" select="Form/ArtistContractList/ArtistContract" />
                    <xsl:with-param name="type">Payee</xsl:with-param>
                </xsl:call-template>
            </xsl:if>
            <xsl:if test="count(Form/PayorList/Payor) &gt; 0">
                <xsl:call-template name="payorList" />
            </xsl:if>
        </div>
        <xsl:call-template name="buttons" />
    </xsl:template>

    <xsl:template name="column1View">
        <div class="ValuePair">

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

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

            <xsl:if test="Form/ArtistPayee/ShowAbacusData = 1">
                <xsl:call-template name="uiValuePairItem">
                    <xsl:with-param name="label" select="'Account ID (Abacus)'" />
                    <xsl:with-param name="value" select="Form/ArtistPayee/AbacusAccountID" />
                </xsl:call-template>
                <xsl:call-template name="uiValuePairItem">
                    <xsl:with-param name="label" select="'Contract ID (Abacus)'" />
                    <xsl:with-param name="value" select="Form/ArtistPayee/AbacusContractID" />
                </xsl:call-template>
            </xsl:if>


            <xsl:call-template name="uiValuePairItem">
                <xsl:with-param name="label" select="'Status'" />
                <xsl:with-param name="value">
                    <xsl:choose>
                        <xsl:when test="Form/ArtistPayee/Status = 0">Inactive</xsl:when>
                        <xsl:when test="Form/ArtistPayee/Status = 2">On-hold</xsl:when>
                        <xsl:otherwise>Active</xsl:otherwise>
                    </xsl:choose>
                </xsl:with-param>
            </xsl:call-template>
        </div>
        <div class="ValuePair">
            <xsl:call-template name="uiValuePairItem">
                <xsl:with-param name="label" select="'Address 1'" />
                <xsl:with-param name="value" select="Form/ArtistPayee/StreetAddress" />
            </xsl:call-template>

            <xsl:call-template name="uiValuePairItem">
                <xsl:with-param name="label" select="'Address 2'" />
                <xsl:with-param name="value" select="Form/ArtistPayee/StreetAddress2" />
            </xsl:call-template>

            <xsl:call-template name="uiValuePairItem">
                <xsl:with-param name="label" select="'Address 3'" />
                <xsl:with-param name="value" select="Form/ArtistPayee/StreetAddress3" />
            </xsl:call-template>

            <xsl:call-template name="uiValuePairItem">
                <xsl:with-param name="label" select="'City'" />
                <xsl:with-param name="value" select="Form/ArtistPayee/City" />
            </xsl:call-template>

            <xsl:call-template name="uiValuePairItem">
                <xsl:with-param name="label" select="'State/Province'" />
                <xsl:with-param name="value" select="Form/ArtistPayee/StateProvince" />
            </xsl:call-template>

            <xsl:call-template name="uiValuePairItem">
                <xsl:with-param name="label" select="'ZIP/Postal'" />
                <xsl:with-param name="value" select="Form/ArtistPayee/PostalCode" />
            </xsl:call-template>

            <xsl:call-template name="uiValuePairItem">
                <xsl:with-param name="label" select="'Country'" />
                <xsl:with-param name="value" select="Form/ArtistPayee/CountryCode" />
            </xsl:call-template>
        </div>
        <div class="ValuePair">
            <xsl:call-template name="uiValuePairItem">
                <xsl:with-param name="label" select="'E-mail'" />
                <xsl:with-param name="value" select="Form/ArtistPayee/Email" />
            </xsl:call-template>

            <xsl:call-template name="uiValuePairItem">
                <xsl:with-param name="label" select="'Phone'" />
                <xsl:with-param name="value" select="Form/ArtistPayee/PhoneNumber" />
            </xsl:call-template>

            <xsl:call-template name="uiValuePairItem">
                <xsl:with-param name="label" select="'Fax'" />
                <xsl:with-param name="value" select="Form/ArtistPayee/FaxNumber" />
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="column2View">
        <xsl:variable name="clientID" select="/Root/User/ClientID" />
        <div class="ValuePair">

            <xsl:call-template name="uiValuePairItem">
                <xsl:with-param name="label" select="'Tax ID'" />
                <xsl:with-param name="value" select="Form/ArtistPayee/TaxID" />
            </xsl:call-template>

            <xsl:call-template name="uiValuePairItem">
                <xsl:with-param name="label" select="'Comments'" />
                <xsl:with-param name="value" select="Form/ArtistPayee/Comments" />
                <xsl:with-param name="replaceLineBreak" select="'true'" />
            </xsl:call-template>

        </div>
        <xsl:if test="ClientTypes/ClientType[ClientTypeID = 11]/IsClientTypeFlag = 1"><!-- XXX FEATURE_FLAG XXX -->
            <div class="ValuePair">
                <xsl:call-template name="uiValuePairItem">
                    <xsl:with-param name="label" select="'Statement Distribution'" />
                    <xsl:with-param name="value">
                        <xsl:choose>
                            <xsl:when test="Form/ArtistPayee/Distribution = 0">Manual</xsl:when>
                            <xsl:when test="Form/ArtistPayee/Distribution = 1">Online Through Payee Portal</xsl:when>
                            <xsl:otherwise></xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>
                </xsl:call-template>

                <xsl:if test="Form/ArtistPayee/Distribution = 1">
                    <div class="ValuePair-item">
                        <div class="ValuePair-label">Statement Distribution Status</div>
                        <div class="ValuePair-value">
                            <xsl:choose>
                                <xsl:when test="Form/ArtistPayee/DateConfirmed = ''">
                                    <i>Waiting on confirmation.</i>&#xA0;&#xA0;<a href="#" id="viewConfirm">Resend</a><br/>
                                </xsl:when>
                                <xsl:otherwise>Confirmed <xsl:value-of select="Form/ArtistPayee/DateConfirmed" /></xsl:otherwise>
                            </xsl:choose>
                        </div>
                    </div>
                </xsl:if>
            </div>
        </xsl:if>

        <xsl:if test="Form/ArtistPayee/Distribution = 1">
            <xsl:call-template name="renderAdditionalRecipientsBlock" />
        </xsl:if>

    </xsl:template>


    <xsl:template name="renderAdditionalRecipientsBlock">

        <div class="ValuePair-item" style="border-top: 1px solid #d9d2d0">
            <label class="Form-label">
                <br/>
                <span class="Form-label-caption">Additional Statement Recipients</span>
            </label>
            <xsl:choose>
            <xsl:when test="count(Form/ArtistPayeeRecipients) &gt; 0">
                <table id="recipientViewTable">
                    <tr>
                         <th style="padding:0 10px 0 0"><span class="Form-label-caption">Recipient</span></th>
                         <th style="padding:0 10px 0 0"><span class="Form-label-caption">E-mail</span></th>
                         <th style="padding:0 10px 0 0"><span class="Form-label-caption">Statement Distribution Status</span></th>
                    </tr>
                    <xsl:for-each select="Form/ArtistPayeeRecipients">
                        <xsl:call-template name="renderRecipientViewTableRow">
                            <xsl:with-param name="i" select="position()" />
                        </xsl:call-template>
                    </xsl:for-each>
                </table>
            </xsl:when>
            <xsl:otherwise>
                <span class="ValuePair-value">-</span>
            </xsl:otherwise>
            </xsl:choose>
        </div>

    </xsl:template>


    <xsl:template name="renderRecipientViewTableRow">

        <xsl:param name="i" select="0"/>
        <tr>
            <td style="padding:0 10px 15px 0">
                <div class="ValuePair-value">
                    <xsl:value-of select="Name" />
                </div>
            </td>
            <td style="padding:0 10px 15px 0">
                <div class="ValuePair-value">
                    <xsl:value-of select="Email" />
                </div>
            </td>
            <td style="padding:0 10px 15px 0">
                <div class="ValuePair-value">
                    <xsl:choose>
                        <xsl:when test="DateConfirmed = ''">
                            <i>Waiting on confirmation.</i>&#160;&#160;
                            <a href="#" id="{concat('viewConfirm_Alt', $i)}" onClick="confirmRecipientResend( {StatementRecipientID}, {translate(number(CanInvite), 'aN', '0')} );return false;">Resend</a>
                        </xsl:when>
                        <xsl:otherwise>Confirmed <xsl:value-of select="DateConfirmed" /></xsl:otherwise>
                    </xsl:choose>
                </div>
            </td>
         </tr>

    </xsl:template>

</xsl:stylesheet>
