<?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.
-->

<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://ofbiz.apache.org/Widget-Screen" xsi:schemaLocation="http://ofbiz.apache.org/Widget-Screen http://ofbiz.apache.org/dtds/widget-screen.xsd">
     <screen name="FindLeads">
        <section>
            <actions>
                <set field="titleProperty" value="MarketingFindLeads"/>
                <set field="currentUrl" value="FindLeads"/>
                <set field="headerItem" value="Leads"/>
                <set field="helpAnchor" value="_sfa_leads_findlist_screen"/>
                <set field="setLeadtDescription" value="${groovy:session.setAttribute(&quot;leadDescription&quot;,headerItem)}"/>
                <set field="removeAccountDescription" value="${groovy:session.removeAttribute(&quot;accountDescription&quot;)}"/>
                <set field="removeContactDescription" value="${groovy:session.removeAttribute(&quot;contactDescription&quot;)}"/>
            </actions>
            <widgets>
                <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="pre-body">
                        <include-menu name="MainActionMenu" location="${parameters.mainMenuLocation}"/>
                        <decorator-section-include name="pre-body"/>
                    </decorator-section>
                    <decorator-section name="left-column">
                        <include-screen name="leftbar" location="component://marketing/widget/sfa/CommonScreens.xml"/>
                    </decorator-section>
                    <decorator-section name="body">
                        <section>
                            <widgets>
                                <include-menu name="LeadSubTabBar" location="${parameters.mainMenuLocation}"/>
                                <container style="no-clear">
                                    <decorator-screen name="FindScreenDecorator" location="component://common/widget/CommonScreens.xml">
                                        <decorator-section name="search-options">
                                            <include-menu name="LeadFindTabBar" location="${parameters.mainMenuLocation}"/>
                                            <include-form name="FindLeads" location="component://marketing/widget/sfa/forms/LeadForms.xml"/>
                                        </decorator-section>
                                        <decorator-section name="search-results">
                                            <section>
                                                <condition>
                                                    <or>
                                                        <if-empty field="parameters.all"/>
                                                        <if-compare field="parameters.all" operator="equals" value="true"/>
                                                    </or>
                                                </condition>
                                                <widgets>
                                                    <!-- list all leads -->
                                                    <label style="h1" text="${uiLabelMap.SfaAllLeads}"/>
                                                    <include-form name="ListLeads" location="component://marketing/widget/sfa/forms/LeadForms.xml"/>
                                                </widgets>
                                                <fail-widgets>
                                                    <!-- list my leads -->
                                                    <label style="h1" text="${uiLabelMap.SfaMyLeads}"/>
                                                    <include-form name="ListMyLeads" location="component://marketing/widget/sfa/forms/LeadForms.xml"/>
                                                </fail-widgets>
                                            </section>
                                        </decorator-section>
                                    </decorator-screen>
                                </container>
                            </widgets>
                        </section>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="NewLead">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleCreateLead"/>
                <set field="headerItem" value="Leads"/>
                <property-to-field field="defaultCountryGeoId" resource="general" property="country.geo.id.default" default="USA"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonLeadDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet title="${uiLabelMap.CommonCreate} ${uiLabelMap.SfaLead}">
                            <include-form name="CreateLead" location="component://marketing/widget/sfa/forms/LeadForms.xml"/>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="ConvertLead">
        <section>
            <actions>
                <set field="headerItem" value="Leads"/>
                <set field="tabButtonItem" value="ConvertLead"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonLeadDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <section>
                            <condition>
                                <not><if-empty field="parameters.partyGroupId"/></not>
                            </condition>
                            <widgets>
                                <screenlet title="${uiLabelMap.SfaConvertLead}">
                                    <include-form name="ConvertLead" location="component://marketing/widget/sfa/forms/LeadForms.xml"/>
                                </screenlet>
                            </widgets>
                            <fail-widgets>
                                <label text="Please first add related company." style="h2"/>
                                <screenlet title="${uiLabelMap.PageTitleAddRelatedCompany}" >
                                    <include-form name="AddRelatedCompany" location="component://marketing/widget/sfa/forms/LeadForms.xml"/>
                                </screenlet>
                            </fail-widgets>
                        </section>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="CloneLead">
        <section>
            <actions>
                <set field="headerItem" value="Leads"/>
                <set field="tabButtonItem" value="CloneLead"/>
                <script location="component://marketing/src/main/groovy/org/apache/ofbiz/marketing/sfa/CloneLead.groovy"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonLeadDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet title="${uiLabelMap.SfaCloneLead}">
                            <include-form name="CreateLead" location="component://marketing/widget/sfa/forms/LeadForms.xml"/>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="MergeLeads">
        <section>
            <actions>
                <set field="headerItem" value="Leads"/>
                <set field="tabButtonItem" value="MergeLeads"/>
                <script location="component://marketing/src/main/groovy/org/apache/ofbiz/marketing/sfa/MergeContacts.groovy"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonLeadDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet title="${uiLabelMap.SfaMergeLeads}">
                            <include-form name="MergeLeads" location="component://marketing/widget/sfa/forms/LeadForms.xml"/>
                        </screenlet>
                        <section>
                            <condition>
                                <if-compare-field field="parameters.partyIdFrom" operator="not-equals" to-field="parameters.partyIdTo"/>
                            </condition>
                            <widgets>
                                <platform-specific>
                                    <html><html-template location="component://marketing/template/lead/MergeLeads.ftl"/></html>
                                </platform-specific>
                            </widgets>
                            <fail-widgets>
                                <label text="${uiLabelMap.SfaCanNotMergeSameLeads}" style="h3"></label>
                            </fail-widgets>
                        </section>
                     </decorator-section>
                 </decorator-screen>
             </widgets>
         </section>
    </screen>

    <screen name="NewLeadFromVCard">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleCreateLeadFromVCard"/>
                <set field="headerItem" value="Leads"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonLeadDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet title="${uiLabelMap.PageTitleCreateLeadFromVCard}">
                            <container><label style="h3" text="${uiLabelMap.SfaAutoCreateLeadByImportingVCard}"/></container>
                            <include-form  name="NewLeadFromVCard" location="component://marketing/widget/sfa/forms/LeadForms.xml"/>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="LeadPartyDataSource">
        <section>
            <actions>
                <set field="partyId" from-field="parameters.partyId"/>
                <entity-and entity-name="PartyDataSource" list="partyDataSources">
                    <field-map field-name="partyId" from-field="partyId"/>
                </entity-and>
            </actions>
            <widgets>
                <screenlet title="${uiLabelMap.SfaLeadSource}" >
                    <include-form name="AddLeadPartyDataSource" location="component://marketing/widget/sfa/forms/LeadForms.xml"/>
                    <include-form name="ViewLeadPartyDataSources" location="component://marketing/widget/sfa/forms/LeadForms.xml"/>
                </screenlet>
            </widgets>
        </section>
    </screen>

    <screen name="AddRelatedCompany">
        <section>
            <actions>
                <set field="headerItem" value="Leads"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonLeadDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet title="${uiLabelMap.PageTitleAddRelatedCompany}" >
                            <include-form name="AddRelatedCompany" location="component://marketing/widget/sfa/forms/LeadForms.xml"/>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
</screens>
