<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->
<forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ofbiz.apache.org/Widget-Form" xsi:schemaLocation="http://ofbiz.apache.org/Widget-Form http://ofbiz.apache.org/dtds/widget-form.xsd">

    <!-- form whose input filters the ListGatewayResponses -->
    <form name="FindGatewayResponses" type="single" target="FindGatewayResponses" title=""
        header-row-style="header-row" default-table-style="basic-table">
        <field name="paymentGatewayResponseId" title="${uiLabelMap.AccountingPaymentGatewayResponseId}">
            <text-find/>
        </field>
        <field name="paymentServiceTypeEnumId">
            <drop-down allow-empty="true">
                <entity-options entity-name="Enumeration" key-field-name="enumId">
                    <entity-constraint name="enumTypeId" operator="equals" value="PRDS_PAYSVC"/>
                    <entity-order-by field-name="sequenceId"/>
                </entity-options>
            </drop-down>
        </field>
        <field name="orderPaymentPreferenceId" title="${uiLabelMap.AccountingOrderPaymentPreferenceId}">
            <text-find/>
        </field>
        <field name="paymentMethodTypeId">
            <drop-down allow-empty="true">
                <entity-options entity-name="PaymentMethodType" key-field-name="paymentMethodTypeId">
                    <entity-order-by field-name="description"/>
                </entity-options>
            </drop-down>
        </field>
        <field name="transCodeEnumId">
            <drop-down allow-empty="true">
                <entity-options entity-name="Enumeration" key-field-name="enumId">
                    <entity-constraint name="enumTypeId" operator="equals" value="PGT_CODE"/>
                    <entity-order-by field-name="sequenceId"/>
                </entity-options>
            </drop-down>
        </field>
        <field name="referenceNum">
            <text-find size="60" maxlength="60"/>
        </field>
        <field name="performSearch"><hidden value="Y"/></field>
        <field name="noConditionFind"><hidden value="Y"/><!-- if this isn't there then with all fields empty no query will be done --></field>
        <field name="submitButton" title="${uiLabelMap.CommonFind}" widget-style="smallSubmit">
            <submit button-type="button"/>
        </field>
    </form>
    
    <!-- Brings up a list of gateway responses. TODO: should cut down data displayd -->
    <grid name="ListGatewayResponses" use-row-submit="true" target="" title="" list-name="listIt" paginate-target="FindGatewayResponses"
        odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
        <actions>
            <set field="entityName" value="PaymentGatewayResponse"/>
            <set field="orderBy" value="transactionDate DESC"/>
            <service service-name="performFind" result-map="result" result-map-list="listIt">
                <field-map field-name="inputFields" from-field="requestParameters"/>
                <field-map field-name="entityName" from-field="entityName"/>
                <field-map field-name="orderBy" from-field="orderBy"/>
                <field-map field-name="viewIndex" from-field="viewIndex"/>
                <field-map field-name="viewSize" from-field="viewSize"/>
            </service>
        </actions>
        <auto-fields-entity entity-name="PaymentGatewayResponse" default-field-type="display"/>
        <!-- note that this overrides auto-fields-entity -->
        <field name="paymentGatewayResponseId" widget-style="buttontext">
          <hyperlink description="${paymentGatewayResponseId}" target="ViewGatewayResponse">
                <parameter param-name="paymentGatewayResponseId"/>
            </hyperlink>
        </field>
        <field name="paymentServiceTypeEnumId">
            <display-entity entity-name="Enumeration" key-field-name="enumId"/>
        </field>
        <field name="paymentMethodTypeId">
            <display-entity entity-name="PaymentMethodType" key-field-name="paymentMethodTypeId"/>
        </field>
        <field name="transCodeEnumId">
            <display-entity entity-name="Enumeration" key-field-name="enumId"/>
        </field>
    </grid>
    
    <!-- presents the orderId and orderPaymentPreferenceId for a gateway response with links to the order -->
    <form name="ViewGatewayResponseRelations" type="single" target="" title=""
        header-row-style="header-row" default-table-style="basic-table">
        <field name="orderId" widget-style="buttontext">
            <hyperlink description="${orderId}" target="/ordermgr/control/orderview" also-hidden="false" target-type="inter-app">
                <parameter param-name="orderId"/>
            </hyperlink>
        </field>
        <field name="orderPaymentPreferenceId"><display/></field>
    </form>
    
    <grid name="ViewGatewayResponsePayments" list-name="payments" title="" header-row-style="header-row-2" default-table-style="basic-table hover-bar">
        <field name="paymentId" widget-style="buttontext">
            <hyperlink description="${paymentId}" target="paymentOverview">
                <parameter param-name="paymentId"/>
            </hyperlink>
        </field>
        <field name="paymentTypeId" title="${uiLabelMap.AccountingPaymentType}"><display-entity entity-name="PaymentType"/></field>
        <field name="statusId" title="${uiLabelMap.CommonStatus}"><display-entity entity-name="StatusItem"/></field>
        <field name="comments"><display/></field>
        <field name="partyIdFrom" title="${uiLabelMap.AccountingFromParty}">
            <display-entity entity-name="PartyNameView" key-field-name="partyId" description="${groupName}${lastName},${firstName}">
                <sub-hyperlink target="/partymgr/control/viewprofile" target-type="inter-app" description="[${partyIdFrom}]" >
                    <parameter param-name="partyId" from-field="partyIdFrom"/>
                </sub-hyperlink>
            </display-entity>
        </field>
        <field name="partyIdTo" title="${uiLabelMap.AccountingToParty}">
            <display-entity entity-name="PartyNameView" key-field-name="partyId" description="${groupName}${lastName},${firstName}">
                <sub-hyperlink target="/partymgr/control/viewprofile" target-type="inter-app" description="[${partyIdTo}]" >
                    <parameter param-name="partyId" from-field="partyIdTo"/>
                </sub-hyperlink>
            </display-entity>
        </field>
        <field name="effectiveDate"><display/></field>
        <field name="currencyUomId"><hidden/></field>
        <field name="amount"><display also-hidden="false" type="currency" currency="${currencyUomId}"/></field>
    </grid>
    
    <!-- displays the gateway response in detail -->
    <form name="ViewGatewayResponse" type="single" target="processCaptureTransaction" title="" default-map-name="paymentGatewayResponse"
        header-row-style="header-row" default-table-style="basic-table">
        <auto-fields-entity entity-name="PaymentGatewayResponse" default-field-type="display"/>
        <!-- TODO: what is the correct way to ensure that the response was authorized?
        <field name="submitButton" use-when="paymentGatewayResponse!=null&amp;&amp;paymentGatewayResponse.getString(&quot;gatewayFlag&quot;).equals(&quot;A&quot;)" title="${uiLabelMap.AccountingCapture}" widget-style="smallSubmit"><submit button-type="button"/></field>
        -->
        <field name="paymentServiceTypeEnumId">
            <display-entity entity-name="Enumeration" key-field-name="enumId"/>
        </field>
        <field name="paymentMethodTypeId">
            <display-entity entity-name="PaymentMethodType" key-field-name="paymentMethodTypeId"/>
        </field>
        <field name="transCodeEnumId">
            <display-entity entity-name="Enumeration" key-field-name="enumId"/>
        </field>
    </form>
    
    <!-- form for authorizing a transaction -->
    <form name="AuthorizeTransaction" type="single" target="processAuthorizeTransaction" title=""
        header-row-style="header-row" default-table-style="basic-table">
        <field name="orderId"><text/></field>
        <field name="orderPaymentPreferenceId"><text/></field>
        <field name="paymentMethodTypeId" title="${uiLabelMap.CommonPaymentMethodType}">
            <drop-down allow-empty="false">
                <entity-options entity-name="PaymentMethodType"/>
            </drop-down>
        </field>
        <field name="overrideAmount" title="${uiLabelMap.AccountingAmount}"><text/></field>
        <field name="submitButton" title="${uiLabelMap.AccountingAuthorize}" widget-style="smallSubmit"><submit button-type="button"/></field>
    </form>
    
    <!-- form for capturing a transaction -->
    <form name="CaptureTransaction" type="single" target="processCaptureTransaction" title=""
        header-row-style="header-row" default-table-style="basic-table">
        <field name="orderId"><text/></field>
        <field name="orderPaymentPreferenceId"><text/></field>
        <field name="paymentMethodTypeId" title="${uiLabelMap.CommonPaymentMethodType}">
            <drop-down allow-empty="false">
                <entity-options entity-name="PaymentMethodType"/>
            </drop-down>
        </field>
        <field name="paymentTypeId" title="${uiLabelMap.AccountingPaymentType}">
            <drop-down allow-empty="false">
                <entity-options entity-name="PaymentType" key-field-name="paymentTypeId">
                    <entity-constraint name="parentTypeId" operator="equals" value="RECEIPT"/>
                </entity-options>
            </drop-down>
        </field>
        <field name="captureAmount" title="${uiLabelMap.AccountingAmount}"><text/></field>
        <field name="submitButton" title="${uiLabelMap.AccountingCapture}" widget-style="smallSubmit"><submit button-type="button"/></field>
    </form>
</forms>
