<?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="hr-batch-grid" title="HR batches" model="com.axelor.apps.hr.db.HrBatch">
		<field name="code" x-bind="{{code|unaccent|uppercase}}"/>
		<field name="actionSelect"/>
		<field name="company" if="__config__.app.getApp('base').getEnableMultiCompany()"/>
		<field name="description"/>
    </grid>
 
	<form name="hr-batch-form" title="HR Batch" model="com.axelor.apps.hr.db.HrBatch" width="large" onNew="action-hr-batch-record-default,action-hr-batch-attrs-employee-set-domain" onLoad="action-hr-batch-attrs-employee-set-domain">
	  	<panel name="mainPanel">
		    <field name="actionSelect"/>
		    <field name="code" x-bind="{{code|unaccent|uppercase}}" onChange="action-base-batch-condition-check-unique-code"/>
		    <field name="company" canEdit="false"/>
		</panel>
		<panel-tabs name="mainPanelTab">
            <panel name="leaveManagementPanel" title="Leave management" hidden="true" showIf="actionSelect == 1">
                <field name="leaveReason" colSpan="3" onChange="action-hr-batch-record-day-number-default" requiredIf="actionSelect == 1"/>
			    <field name="comments" colSpan="9"/>
                <field name="dayNumber" colSpan="3" requiredIf="actionSelect == 1"/>
			    <field name="useWeeklyPlanningCoef" colSpan="3"/>
   				<field name="planningSet" grid-view="weekly-planning-grid" form-view="weekly-planning-form" widget="TagSelect"/>
			    <field name="startDate" colSpan="3"/>
			    <field name="endDate" colSpan="3"/>
                <panel-related name="employeeSetPanel" field="employeeSet" target="com.axelor.apps.hr.db.Employee" onSelect="action-hr-batch-attrs-employee-set-domain" grid-view="employee-lite-grid" form-view="employee-form" canNew="false" colSpan="12"/>
				<button name="leaveManagementBatchBtn" title="Leave management batch" onClick="save,action-hrbatch-method-hr-batch"/>
			</panel>

			<panel name="seniorityLeaveManagementPanel" title="Seniority leave management page" hidden="true" showIf="actionSelect == 2">
			    <field name="leaveReason" colSpan="4" />
			    <field name="comments" colSpan="8"/>
			    <field name="startDate" colSpan="4"/>
			    <field name="endDate" colSpan="4"/>
			    <field name="referentialDate" colSpan="4" />
				<button name="seniorityLeaveManagementBatchBtn" readonlyIf="leaveReason == null" title="Seniority leave management batch" onClick="save,action-hrbatch-method-hr-batch"/>
			</panel>

			<panel name="payrollPreparationGenerationPanel" title="Payroll preparation generation page" hidden="true" showIf="actionSelect == 3">
			    <field name="period" domain="self.year.company = :company AND self.year.typeSelect = 2" colSpan="4" canEdit="false" canView="false" />
   				<field name="planningSet" grid-view="weekly-planning-grid" form-view="weekly-planning-form" widget="TagSelect" colSpan="8"/>
   			    <field name="comments" colSpan="12"/>
		   		<panel-related name="employeeSetPanel" field="employeeSet" target="com.axelor.apps.hr.db.Employee" grid-view="employee-lite-grid" form-view="employee-form" canNew="false" colSpan="12"/>
				<button name="payrollPreparationGenerationBatchBtn" readonlyIf="period == null" title="Payroll preparation generation batch" onClick="save,action-hrbatch-method-hr-batch"/>
			</panel>

			<panel  name="payrollPreparationExportPanel" title="Payroll preparation export page" hidden="true" showIf="actionSelect == 4">
				<field name="period" domain="self.year.company = :company AND self.year.typeSelect = 2" colSpan="4" canEdit="false" canView="false"/>
				<field name="payrollPreparationExportTypeSelect" colSpan="4"/>
				<field name="exportAlreadyExported" colSpan="4"/>
				<spacer name="exportSpacer"/>
				<button name="payrollPreparationExportBatchBtn" readonlyIf="period == null || payrollPreparationExportTypeSelect == null" title="Payroll preparation export batch" onClick="save,action-hrbatch-method-hr-batch"/>
			</panel>

            <panel name="leaveManagementResetPanel" title="Leave counter reset" hidden="true" showIf="actionSelect == 5">
                <field name="leaveReason" colSpan="3" onChange="action-hr-batch-record-day-number-default"/>
                <field name="comments" colSpan="9"/>
                <field name="startDate" colSpan="3"/>
                <field name="endDate" colSpan="3"/>
                <panel-related name="planningSetPanel" field="planningSet" target="com.axelor.apps.base.db.WeeklyPlanning" grid-view="weekly-planning-grid" form-view="weekly-planning-form" widget="TagSelect" colSpan="12"/>
                <panel-related name="employeeSetPanel" field="employeeSet" target="com.axelor.apps.hr.db.Employee" grid-view="employee-lite-grid" form-view="employee-form" canNew="false" colSpan="12"/>
                <button name="leaveManagementBatchBtn" title="Leave management batch" onClick="save,action-hrbatch-method-hr-batch"/>
            </panel>
            
            <panel title="Export des salariés" hidden="true" showIf="actionSelect == 6">
            	<field name="employmentContractExportTypeSelect" colSpan="4"/>
            	<spacer name="employmentContractExportSpacer" colSpan="8"/>
            	<button name="employmentContractExportBatchBtn" readonlyIf="employmentContractExportTypeSelect == null" title="Employment contract export batch" onClick="save,action-hrbatch-method-hr-batch" colSpan="4"/>
            </panel>
            
            <panel title="Email reminder for timesheets" hidden="true" showIf="actionSelect == 7">
                <field name="daysBeforeReminder" />
                <field name="template" widget="SuggestBox" form-view="template-form" grid-view="template-grid" />
                <button name="emailReminderForTimesheetsBatchBtn" title="Email reminder for timesheet filling batch" onClick="save, action-hrbatch-method-hr-batch" />
            </panel>

			<panel name="informationsPanel" title="Informations">
				<field name="createdOn" title="Created on"/>
				<field name="createdBy" title="Created by" form-view="user-form" grid-view="user-grid" canEdit="false"/>
				<field name="description" colSpan="12" />
				<panel-related name="batchListPanel" field="batchList" colSpan="12" form-view="batch-form" grid-view="batch-grid" readonly="true"/>
			</panel>
		</panel-tabs>
	</form>

	<action-method name="action-hrbatch-method-hr-batch">
		<call class="com.axelor.apps.hr.web.HrBatchController" method="launchHrBatch"/>
	</action-method>
	
	<action-record name="action-hr-batch-record-default" model="com.axelor.apps.hr.db.HrBatch">
		<field name="company" expr="eval: __user__.activeCompany"/>
	</action-record>
	
	<action-record name="action-hr-batch-record-day-number-default" model="com.axelor.apps.hr.db.HrBatch">
		<field name="dayNumber" expr="eval: leaveReason?.defaultDayNumberGain"/>
	</action-record>

    <action-attrs name="action-hr-batch-attrs-employee-set-domain">
        <attribute for="employeeSet" name="domain" expr="eval: null"/>
        <attribute for="employeeSet" name="domain" expr="eval: &quot;self.mainEmploymentContract.payCompany.id = ${company.id}&quot;" if="eval: company != null"/>
    </action-attrs>
	

</object-views>