<?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 name="FindSalesForecast" type="single" target="FindSalesForecast" extends="LookupSalesForecast"
            extends-resource="component://marketing/widget/LookupForms.xml"
            header-row-style="header-row" default-table-style="basic-table">
        <field name="submitButton" title="${uiLabelMap.CommonFind}"><submit button-type="button"/></field>
    </form>
    <form name="SalesForecastSearchResults" type="list" list-name="listIt" paginate-target="FindForecasts" view-size="5"
            odd-row-style="alternate-row" default-table-style="basic-table hover-bar" header-row-style="header-row-2" separate-columns="true">
        <actions>
            <service service-name="performFind" result-map="result" result-map-list="listIt">
                <field-map field-name="inputFields" from-field="parameters"/>
                <field-map field-name="entityName" value="SalesForecast"/>
                <field-map field-name="viewIndex" from-field="viewIndex"/>
                <field-map field-name="viewSize" from-field="viewSize"/>
            </service>
        </actions>
        <auto-fields-entity entity-name="SalesForecast" default-field-type="display"/>
        <field name="salesForecastId" widget-style="buttontext">
            <hyperlink description="${salesForecastId}" target="EditSalesForecast" also-hidden="false">
                <parameter param-name="salesForecastId"/>
            </hyperlink>
        </field>
        <field name="percentOfQuotaForecast"><hidden/></field>
        <field name="percentOfQuotaClosed"><hidden/></field>
        <field name="pipelineAmount"><hidden/></field>
        <field name="createdByUserLoginId"><hidden/></field>
        <field name="modifiedByUserLoginId"><hidden/></field>
    </form>

    <form name="EditSalesForecast" type="single" target="updateSalesForecast" default-map-name="salesForecast">
        <alt-target use-when="salesForecast==null" target="createSalesForecast"/>
        <auto-fields-service service-name="updateSalesForecast"/>

        <field name="salesForecastId" use-when="salesForecastId!=null"><display/></field>
        <field name="salesForecastId" use-when="salesForecast==null&amp;&amp;salesForecastId==null"><ignored/></field>
        <field name="salesForecastId" use-when="salesForecast==null&amp;&amp;salesForecastId!=null" tooltip="${uiLabelMap.CommonCannotBeFound}: [${salesForecastId}]"><display also-hidden="false"/></field>

        <field name="parentSalesForecastId">
            <lookup target-form-name="LookupSalesForecast"/>
        </field>
        <field name="organizationPartyId">
            <lookup target-form-name="LookupPartyName"/>
        </field>
        <field name="internalPartyId">
            <lookup target-form-name="LookupPartyName"/>
        </field>
        <field name="currencyUomId">
            <drop-down allow-empty="true" no-current-selected-key="${defaultOrganizationPartyCurrencyUomId}">
                <entity-options key-field-name="uomId" description="${description} - ${abbreviation}" entity-name="Uom">
                    <entity-constraint name="uomTypeId" operator="equals" value="CURRENCY_MEASURE"/>
                    <entity-order-by field-name="description"/>
                </entity-options>
            </drop-down>
        </field>
        <field name="createdByUserLoginId"><hidden/></field>
        <field name="modifiedByUserLoginId"><hidden/></field>
        <field name="submitButton" title="${uiLabelMap.CommonSave}" use-when="salesForecast==null"><submit button-type="button"/></field>
        <field name="submitButton" title="${uiLabelMap.CommonUpdate}" use-when="salesForecast!=null"><submit button-type="button"/></field>
    </form>

    <form name="ListSalesForecastDetails" type="list" target="updateSalesForecastDetail" view-size="10"
            odd-row-style="alternate-row" default-table-style="basic-table hover-bar" separate-columns="true">
        <actions>
            <entity-condition entity-name="SalesForecastDetail">
                <condition-expr field-name="salesForecastId" from-field="parameters.salesForecastId"/>
            </entity-condition>
        </actions>
        <auto-fields-entity entity-name="SalesForecastDetail" default-field-type="edit"/>
        <field name="salesForecastId"><hidden/></field>
        <field name="salesForecastDetailId"><display/></field>
        <field name="quantityUomId">
            <drop-down allow-empty="true">
                <entity-options entity-name="UomAndType" key-field-name="uomId" description="[${typeDescription}] ${description}">
                    <entity-order-by field-name="uomTypeId"/>
                </entity-options>
            </drop-down>
        </field>
        <field name="productId" title="${uiLabelMap.AccountingProductId}">
            <lookup target-form-name="LookupProduct"/>
        </field>
        <field name="productCategoryId" title="${uiLabelMap.ProductProductCategoryId}">
            <lookup target-form-name="LookupProductCategory"/>
        </field>
        <field name="submitButton" title="${uiLabelMap.CommonUpdate}"><submit button-type="button"/></field>
        <field name="deleteLink" title="" widget-style="buttontext">
            <hyperlink description="${uiLabelMap.CommonDelete}" target="deleteSalesForecastDetail" also-hidden="false">
                <parameter param-name="salesForecastId"/>
                <parameter param-name="salesForecastDetailId"/>
            </hyperlink>
        </field>
    </form>

    <form name="AddSalesForecastDetail" type="single" target="createSalesForecastDetail">
        <auto-fields-entity entity-name="SalesForecastDetail"/>
        <field name="salesForecastId"><hidden/></field>
        <field name="salesForecastDetailId"><hidden/></field>
        <field name="quantityUomId">
            <drop-down allow-empty="true">
                <entity-options entity-name="UomAndType" key-field-name="uomId" description="[${typeDescription}] ${description}">
                    <entity-order-by field-name="uomTypeId"/>
                </entity-options>
            </drop-down>
        </field>
        <field name="productId" title="${uiLabelMap.AccountingProductId}">
            <lookup target-form-name="LookupProduct"/>
        </field>
        <field name="productCategoryId" title="${uiLabelMap.ProductProductCategoryId}">
            <lookup target-form-name="LookupProductCategory"/>
        </field>
        <field name="submitButton" title="${uiLabelMap.CommonAdd}"><submit button-type="button"/></field>
    </form>
</forms>
