<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<object-views xmlns="http://axelor.com/xml/ns/object-views"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://axelor.com/xml/ns/object-views http://axelor.com/xml/ns/object-views/object-views_5.2.xsd">
    
    <grid name="target-grid" title="Objectives" model="com.axelor.apps.crm.db.Target">
        <field name="name"/>
        <field name="code" x-bind="{{code|unaccent|uppercase}}"/>
        <field name="periodTypeSelect"/>
        <field name="fromDate"/>
        <field name="toDate"/>
    </grid>

	<form name="target-form" title="Objective" model="com.axelor.apps.crm.db.Target"
		width="large" onLoad="action-target-method-update,save" onSave="action-target-validate">
		<panel name="informationPanel">
			<field name="$fullName" showTitle="false" colSpan="12">
				<viewer depends="name,code">
					<![CDATA[
						<h3>
							{{record.code}} - {{record.name}}
						</h3>
					]]>
				</viewer>
				<editor x-show-titles="true">
					<field name="code" x-bind="{{code|unaccent|uppercase}}"
						colSpan="4" css="label-bold bold large" required="true" />
					<field name="name" colSpan="8" css="label-bold bold large"
						required="true" />
				</editor>
			</field>
			<field name="user" colSpan="6" showIf="team == null" canNew="false"
				canView="false" canEdit="false" form-view="user-form" grid-view="user-grid" />
			<field if="__config__.app.getApp('base').getTeamManagement()"
				colSpan="6" name="team" showIf="user == null" canEdit="false"
				form-view="team-form" grid-view="team-grid" />
			<static />
		</panel>
		<panel-tabs name="mainPanelTab">
			<panel name="opportunityPanel" title="Opportunity">
				<panel name="targetPanel" title="Target vs Real" colSpan="12">
					<field name="opportunityAmountWonTarget" colSpan="5" />
					<static colSpan="2"><![CDATA[<span style="height:21px; line-height: 21px; margin-top:18px; display:inline-block">VS</span>]]></static>
					<field name="opportunityAmountWon" showTitle="false" colSpan="5" />
					<field name="opportunityCreatedNumberTarget" colSpan="5" />
					<static colSpan="2"><![CDATA[<span style="height:21px; line-height: 21px; margin-top:18px; display:inline-block">VS</span>]]></static>
					<field name="opportunityCreatedNumber" showTitle="false"
						colSpan="5" />
					<field name="opportunityCreatedWonTarget" colSpan="5" />
					<static colSpan="2"><![CDATA[<span style="height:21px; line-height: 21px; margin-top:18px; display:inline-block">VS</span>]]></static>
					<field name="opportunityCreatedWon" showTitle="false"
						colSpan="5" />
				</panel>
			</panel>
			<panel name="eventsPanel" title="Events">
				<panel name="targetVsRealPanel" title="Target vs Real" colSpan="12">
					<field name="callEmittedNumberTarget" colSpan="5" />
					<static colSpan="2"><![CDATA[<span style="height:21px; line-height: 21px; margin-top:18px; display:inline-block">VS</span>]]></static>
					<field name="callEmittedNumber" showTitle="false" colSpan="5" />
					<field name="meetingNumberTarget" colSpan="5" />
					<static colSpan="2"><![CDATA[<span style="height:21px; line-height: 21px; margin-top:18px; display:inline-block">VS</span>]]></static>
					<field name="meetingNumber" showTitle="false" colSpan="5" />
				</panel>
			</panel>
		</panel-tabs>

		<panel sidebar="true" name="characteristicsPanel" title="Characteristics"
			canCollapse="true">
			<field name="periodTypeSelect" />
			<field name="fromDate" colSpan="6" required="true" />
			<field name="toDate" colSpan="6" required="true" />
		</panel>
	</form>

    
    <action-method name="action-target-method-update">
    	<call class="com.axelor.apps.crm.web.TargetController" method="update"/>
    </action-method>
    
    <action-validate name="action-target-validate">
    	<error message="From date must be less than the to date" if="fromDate > toDate"/>
    </action-validate>
    
</object-views>