<?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="timesheet-grid" title="Timesheet" model="com.axelor.apps.hr.db.Timesheet" canNew="false" groupBy="user" orderBy="user,-fromDate">
		<menubar>
			<menu name="timesheetToolsMenu" title="Tools" icon="fa-wrench" showTitle="true">
				<item name="seeTimesheetLinesItem" action="action-timesheet-method-timesheet-line-historic" title="See timesheet lines"/>
			</menu>
		</menubar>
		<hilite color="danger" if="statusSelect == 4"/>
		<hilite color="success" if="statusSelect == 3"/>
		<hilite color="warning" if="statusSelect == 2"/>
		<field name="company" form-view="company-form" grid-view="company-grid" if="__config__.app.getApp('base').getEnableMultiCompany()"/>
		<field name="fromDate"/>
		<field name="toDate"/>
		<field name="sentDate"/>
		<field name="statusSelect"/>
		<field name="user" form-view="user-form" grid-view="user-grid"/>
	</grid>
	
	<grid name="all-timesheet-grid" title="All timesheets" model="com.axelor.apps.hr.db.Timesheet" canNew="false" groupBy="user" orderBy="user,-fromDate">
		<menubar>
			<menu name="timesheetToolsMenu" title="Tools" icon="fa-wrench" showTitle="true">
				<item name="seeTimesheetLinesItem" action="action-timesheet-method-all-timesheet-line" title="See timesheet lines"/>
			</menu>
		</menubar>
		<hilite color="danger" if="statusSelect == 4"/>
		<hilite color="success" if="statusSelect == 3"/>
		<hilite color="warning" if="statusSelect == 2"/>
		<field name="company" form-view="company-form" grid-view="company-grid" if="__config__.app.getApp('base').getEnableMultiCompany()"/>
		<field name="fromDate"/>
		<field name="toDate"/>
		<field name="sentDate"/>
		<field name="statusSelect"/>
		<field name="user" form-view="user-form" grid-view="user-grid"/>
	</grid>
	
	<grid name="my-timesheets-grid" title="My Timesheets" model="com.axelor.apps.hr.db.Timesheet" canNew="false" orderBy="-fromDate">
		<menubar>
			<menu name="timesheetToolsMenu" title="Tools" icon="fa-wrench" showTitle="true">
				<item name="seeTimesheetLinesItem" action="action-timesheet-see-timesheet-lines" title="See timesheet lines"/>
			</menu>
		</menubar>
		<hilite color="danger" if="statusSelect == 4"/>
		<hilite color="success" if="statusSelect == 3"/>
		<hilite color="warning" if="statusSelect == 2"/>
		<field name="company" form-view="company-form" grid-view="company-grid" if="__config__.app.getApp('base').getEnableMultiCompany()"/>
		<field name="fromDate"/>
		<field name="toDate"/>
		<field name="sentDate"/>
		<field name="statusSelect"/>
	</grid>
	
	<grid name="timesheet-validate-grid" title="Timesheet" model="com.axelor.apps.hr.db.Timesheet" canNew="false" orderBy="user,-fromDate">
		<menubar>
			<menu name="timesheetToolsMenu" title="Tools" icon="fa-wrench" showTitle="true">
				<item name="timesheetValidatedBySubordinatesItem" action="com.axelor.apps.hr.web.timesheet.TimesheetController:showSubordinateTimesheets" title="Show timesheets to be validated by my subordinates"/>
				<item name="seeTimesheetLinesItem" action="action-timesheet-method-timesheet-line-validate" title="See timesheet lines"/>
			</menu>
		</menubar>
		<hilite background="danger" if="$moment(fromDate).diff(todayDate,'days') &lt;= 0"/>
  		<hilite background="warning" if="$moment(todayDate).diff(sentDate,'days') &gt;= 7 || $moment(todayDate).diff(fromDate,'days') &gt;= 15"/> 
		<field name="company" form-view="company-form" grid-view="company-grid" if="__config__.app.getApp('base').getEnableMultiCompany()"/>
		<field name="fromDate"/>
		<field name="toDate"/>
		<field name="sentDate"/>
		<field name="periodTotal"/>
		<field name="statusSelect"/>
		<field name="user" form-view="user-form" grid-view="user-grid"/>
	</grid>

	<form name="timesheet-form" title="Timesheet" model="com.axelor.apps.hr.db.Timesheet" cols="12" width="large"
	    onNew="action-group-timesheet-onnew"
	    onLoad="action-timesheet-group-onload" canNew="false"
	    onSave="action-timesheet-group-onsave" canCopy="false">
	    <menubar>
            <menu name="timesheetToolsMenu" title="Reports" icon="fa-files-o">
				<item name="printTimesheetItem" title="Print" action="save,action-print-timesheet"/>
			</menu>
			<menu title="Tools" icon="fa-wrench">
				<item title="Lines Generation Wizard" showIf="statusSelect == 1" action="action-timesheet-record-default-generation-date,action-timesheet-attrs-set-log-time-title,action-timesheet-attrs-generate-lines-panel-hidden-false"/>
				<item title="Generate Lines From Expected Planning" showIf="statusSelect == 1" action="save,action-timesheet-method-generate-lines-from-expected-planning" />
			</menu>
		</menubar>
		<panel name="mainPanel">
			<panel name="detailsPanel" colSpan="9">
				<panel name="headPanel" colSpan="12">
					<field name="statusSelect" colSpan="10" widget="NavSelect" showTitle="false"/>
					<field name="showEditor" colSpan="2" title="Editor" widget="boolean-switch" onChange="action-timesheet-attrs-refresh-editor" if="__config__.app.getApp('timesheet').getTimesheetEditor()"/>
				</panel>
				<field name="company" colSpan="5" form-view="company-form" grid-view="company-grid" onChange="action-hr-record-empty-user"/>
				<field name="user" colSpan="5" form-view="user-form" onChange="action-timesheet-group-user-onchange" onSelect="action-hr-attrs-set-user-domain" grid-view="user-grid" canNew="false" canEdit="false" canView="false"/>
				<field name="timeLoggingPreferenceSelect" readonly="true" hidden="true" />
				<field name="user.employee" hidden="true" />
				<field if-module="axelor-business-production" if=" __config__.app.getApp('production')?.getManageBusinessProduction()" name="user.employee.timesheetImputationSelect" hidden="true"/>
				<field name="fromDate" onChange="action-timesheet-validate-fromDate,action-timesheet-record-to-date" colSpan="5" />
				<field name="toDate" onChange="action-timesheet-validate-toDate" colSpan="5" />
				<button name="createBtn" title="Create" colSpan="2" hideIf="id" if="__config__.app.getApp('timesheet').getTimesheetEditor()"  onClick="save,action-timesheet-set-show-editor,action-timesheet-attrs-refresh-editor,action-timesheet-attrs-panels,save" />
			</panel>
			
			<panel name="actionsPanel" colSpan="3" itemSpan="12">
				<button name="confirmBtn" onClick="action-timesheet-group-confirm" title="Confirm" hideIf="statusSelect &gt; 1" icon="fa-check-square-o"/>
				<button name="continueBtn" onClick="action-timesheet-group-continue,close" title="Continue" showIf="statusSelect == 2 &amp;&amp; user != null &amp;&amp; user.code == $user" icon="fa-arrow-right"/>
				<button name="confirmContinueBtn" onClick="action-timesheet-group-confirm-continue,close" title="Confirm &amp; Continue" hideIf="statusSelect &gt; 1" icon="fa-check-square-o"/>
				<button name="validateBtn" hidden="true" onClick="action-timesheet-group-validate" title="Validate" icon="fa-check" css="btn-success"/>
				<button name="refuseBtn" hidden="true" onClick="action-timesheet-group-refuse" title="Refuse" icon="fa-times" css="btn-danger" />
				<button name="cancelBtn" hidden="true" onClick="save,action-timesheet-method-cancel,action-timesheet-attrs-buttons" title="Cancel" icon="fa-times-circle" css="btn-danger"/>
				<button name="draftBtn" onClick="save,action-timesheet-method-draft,action-timesheet-attrs-buttons" title="Return to draft status" showIf="statusSelect &gt; 3 "/>
				<button name="startStopFormBtn" title="Start&amp;Stop Timer" onClick="action-timesheet-method-timesheet-timer" hideIf="statusSelect != 1"
						if="__config__.app.isApp('timesheet') &amp;&amp; __config__.app.getApp('timesheet').getEnableTimer()"/>
			</panel>
		</panel>
		
		<panel name="generateLinesPanel" title="Generate Lines automatically" hidden="true">
		    <field name="$fromGenerationDate" title="From generation date" widget="Date" onChange="action-hr-condition-automatic-from-generation-date"/>
			<field name="$toGenerationDate" title="To generation date" widget="Date" onChange="action-hr-condition-automatic-to-generation-date"/>
			<field name="$project" title="Project" target="com.axelor.apps.project.db.Project" domain="self.imputable=true and self." type="many-to-one" form-view="project-form" grid-view="project-grid" onSelect="action-hr-timesheet-attrs-domain-project" onChange="action-hr-timesheet-record-empty-product"/>
			<field name="$product" title="Activity" type="many-to-one" target="com.axelor.apps.base.db.Product" Select="action-hr-timesheet-attrs-domain-product" onSelect="action-hr-timesheet-attrs-domain-product" widget="SuggestBox" form-view="product-form" grid-view="product-grid"/>
			<field name="$logTime" type="decimal"/>
			<button name="generateLinesBtn" title="Generate lines" onClick="com.axelor.apps.hr.web.timesheet.TimesheetController:generateLines,action-timesheet-attrs-generate-lines-panel-hidden-true,save,action-timesheet-attrs-refresh-editor"/>
		</panel>
		<panel name="linesPanel">
			<panel-dashlet name="timesheetLineEditorPanel" colSpan="12" action="action-timesheet-show-timesheet-line-editor" showIf="showEditor" height="365"/>
			<panel-related name="timesheetLineListPanel" field="timesheetLineList" canMove="true" orderBy="sequence" colSpan="12" height="20" grid-view="timesheet-line-timesheet-grid" editable="true" form-view="timesheet-line-timesheet-form" hidden="true" showIf="!showEditor &amp;&amp; !$readonly() &amp;&amp; !($enableTimesheetManufOrder &amp;&amp; user.employee.timesheetImputationSelect == 2)" x-can-copy="true"/>
			<panel-related name="timesheetLineListPanel" field="timesheetLineList"  colSpan="12" height="20" grid-view="timesheet-line-timesheet-manuf-order-grid" editable="true" form-view="timesheet-line-timesheet-manuf-order-form" hidden="true" showIf="!showEditor &amp;&amp; !$readonly() &amp;&amp; $enableTimesheetManufOrder &amp;&amp; user.employee.timesheetImputationSelect == 2" x-can-copy="true" if-module="axelor-business-production" if=" __config__.app.getApp('production')?.getManageBusinessProduction()"/>
			<panel-related name="timesheetLineListPanel" field="timesheetLineList" canMove="true" orderBy="sequence" colSpan="12" height="20" grid-view="timesheet-line-timesheet-readonly-grid" form-view="timesheet-line-timesheet-form" hidden="true" showIf="!showEditor &amp;&amp; $readonly() &amp;&amp; !($enableTimesheetManufOrder &amp;&amp; user.employee.timesheetImputationSelect == 2)" x-can-copy="true" />
			<panel-related name="timesheetLineListPanel" field="timesheetLineList" colSpan="12" height="20" grid-view="timesheet-line-timesheet-readonly-manuf-order-grid" form-view="timesheet-line-timesheet-manuf-order-form" hidden="true" showIf="!showEditor &amp;&amp; $readonly() &amp;&amp; $enableTimesheetManufOrder &amp;&amp; user.employee.timesheetImputationSelect == 2" x-can-copy="true" if-module="axelor-business-production" if=" __config__.app.getApp('production')?.getManageBusinessProduction()"/>
			<button name="fullScreenEditorBtn" colSpan="3" title="Fullscreen Editor" showIf="id != null &amp;&amp; showEditor" if="__config__.app.getApp('timesheet').getTimesheetEditor()" onClick="save,action-timesheet-method-open-timesheet-editor"/>
			<field name="$showActivity" hidden="true" type="boolean"/>
			<field name="$enableTimesheetManufOrder" hidden="true" type="boolean"/>
		</panel>
		<panel name="totalsPanel" title="Totals on period">
			<field name="periodTotal" readonly="true"/>
			<field name="$periodTotalConvert" type="decimal" readonly="true" hidden="true"/>
		</panel>
		<panel-dashlet name="totalHoursPerDayPanel" title="Total Hours per Day" hidden="true" showIf="id &amp;&amp; user.employee.timesheetImputationSelect != 2" action="action-timesheet-view-total-hours-per-day"/>
		<panel name="validationInfoPanel" showIf="sentDate != null">
		 	<field name="sentDate"/>
			<field name="validatedBy" canEdit="false" form-view="user-form" grid-view="user-grid" showIf="validatedBy != null"/>
			<field name="refusedBy"  canEdit="false"  form-view="user-form" grid-view="user-grid" showIf="refusedBy != null"/>
			<field name="validationDate" showIf="validationDate != null"/>
			<field name="refusalDate" showIf="refusalDate != null"/>
			<field name="groundForRefusal" showIf="statusSelect == 4" colSpan="12"/>
		</panel>
		<panel name="attrsPanel">
			<field name="attrs" colSpan="12" />
		</panel>
		<panel-mail name="mailPanel">
		  <mail-messages limit="4" />
		  <mail-followers />
	    </panel-mail>
	</form>
	
	<form name="popup-timesheet-refusal-form" title="Ground for refusal" model="com.axelor.apps.hr.db.Timesheet">
		<field name="groundForRefusal" showTitle="false"/>
	</form>
	
	<form name="popup-timesheet-form" title="Select the timesheet you want to edit" model="com.axelor.apps.base.db.Wizard" onNew="action-timesheet-attrs-domain-timesheet-select">
		<field name="$timesheetSelect" title="Select Timesheet" type="many-to-one" target="com.axelor.apps.hr.db.Timesheet" widget="SuggestBox" />
		<button name="editTimesheetSelectedBtn" title="Edit Timesheet Selected" onClick="action-timesheet-validate-timesheet-selected,action-timesheet-method-edit-timesheet-selected,close"/>
	</form>

	<action-group name="action-timesheet-group-user-onchange">
		<action name="action-timesheet-method-update-time-logging-preference"/>
		<action name="action-timesheet-attrs-set-visible-duration-title"/>
	</action-group>

	<action-group name="action-timesheet-group-onsave">
		<action name="action-timesheet-validate-toDate"/>
		<action name="action-timesheet-method-timesheet-compute-period-total"/>
		<action name="action-timesheet-method-update-operation-order" if="__config__.app.getApp('production')?.getManageBusinessProduction()"/>
	</action-group>

	<action-group name="action-timesheet-group-onload">
		<action name="action-timesheet-method-set-show-activity"/>
		<action name="action-timesheet-attrs-enable-timesheet-manuforder" if="__config__.app.getApp('production')?.getManageBusinessProduction()"/>
		<action name="action-timesheet-attrs-buttons"/>
		<action name="action-timesheet-attrs-set-visible-duration-title"/>
		<action  name="action-timesheet-attrs-title-project"/>
		<action name="action-timesheet-attrs-from-date"/>
		<action name="action-timesheet-attrs-panels"/>
		<action name="action-timesheet-attrs-refresh-editor"/>
		<action name="action-timesheet-method-timesheet-compute-period-total"/>
	</action-group>
	
	<action-attrs name="action-hr-timesheet-attrs-domain-product">
		<attribute name="domain" expr="eval:$project == null || __repo__(Project).find($project.id).productSet?.empty ? &quot;self.isActivity = true&quot; : &quot;self.isActivity = true AND EXISTS(SELECT p FROM Project p WHERE p = :$project AND self MEMBER OF p.productSet)&quot;" for="$product"/>
	</action-attrs>

	<action-group name="action-timesheet-group-confirm">
		<action name="save"/>
		<action name="action-timesheet-method-confirm"/>
		<action name="action-timesheet-attrs-buttons"/>
	</action-group>

    <action-group name="action-timesheet-group-continue">
        <action name="save"/>
        <action name="action-timesheet-method-continue"/>
        <action name="action-timesheet-attrs-buttons"/>
    </action-group>

	<action-group name="action-timesheet-group-confirm-continue">
		<action name="save"/>
		<action name="action-timesheet-method-confirm-continue"/>
		<action name="action-timesheet-attrs-buttons"/>
	</action-group>
	
	<action-group name="action-timesheet-group-validate">
		<action name="save"/>
		<action name="action-timesheet-method-valid"/>
		<action name="action-timesheet-attrs-buttons"/>
	</action-group>
	
	<action-group name="action-timesheet-group-refuse">
		<action name="save"/>
		<action name="action-timesheet-method-refuse"/>
		<action name="action-timesheet-refusal-popup-form"/>
		<action name="action-timesheet-attrs-buttons"/>
	</action-group>
	
	<action-group name="action-group-timesheet-onnew">
		<action name="action-timesheet-record-default"/>
		<action name="action-timesheet-method-set-show-activity" />
		<action name="action-timesheet-attrs-enable-timesheet-manuforder" if="__config__.app.getApp('production')?.getManageBusinessProduction()"/>
		<action name="action-timesheet-attrs-buttons"/>
		<action name="action-timesheet-attrs-set-visible-duration-title"/>
		<action name="action-timesheet-record-from-period-date"/>
		<action name="action-timesheet-record-to-date" if="fromDate != null"/>
		<action name="action-timesheet-prefill-lines" if="toDate != null &amp;&amp; (__config__.app.getApp('timesheet').getCreateLinesForLeaves() || __config__.app.getApp('timesheet').getCreateLinesForHolidays())"/>
		<action name="action-timesheet-attrs-title-project"/>
		<action name="action-timesheet-attrs-from-date-on-new"/>
		<action name="action-timesheet-attrs-panels"/>
	</action-group>

	<action-method name="action-timesheet-prefill-lines">
		<call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="prefillLines" />
	</action-method>

	<action-method name="action-timesheet-method-timesheet-compute-period-total">
		<call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="timesheetPeriodTotalController"/>
	</action-method>

	<action-method name="action-timesheet-method-update-time-logging-preference" model="com.axelor.apps.hr.db.Timesheet">
        <call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="updateTimeLoggingPreference"/>
	</action-method>
	
	<action-method name="action-timesheet-method-generate-lines-from-expected-planning">
		<call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="generateLinesFromExpectedPlanning"/>
	</action-method>

	<action-record name="action-timesheet-record-default" model="com.axelor.apps.hr.db.Timesheet">
	    <field name="user" expr="eval:__user__"/>
		<field name="timeLoggingPreferenceSelect" expr="eval: __user__?.employee?.timeLoggingPreferenceSelect"/>
	    <field name="company" expr="eval: __user__.employee?.mainEmploymentContract?.payCompany ?: __user__.activeCompany"/>
	</action-record>

	<action-record name="action-hr-timesheet-record-empty-product" model="com.axelor.apps.hr.db.Timesheet">
		<field name="$product" expr="eval:null" if="!$project?.productSet?.contains(product)"/>
	</action-record>
	
	<action-record name="action-timesheet-record-default-generation-date" model="com.axelor.apps.hr.db.Timesheet">
	    <field name="$fromGenerationDate" expr="eval:fromDate"/>
	    <field name="$toGenerationDate" expr="eval:toDate" if="toDate != null"/>
	</action-record>

	<action-record name="action-timesheet-record-to-date" model="com.axelor.apps.hr.db.Timesheet">
		<field name="toDate" expr="eval:fromDate.with(java.time.DayOfWeek.FRIDAY)" if="toDate == null &amp;&amp; fromDate != null &amp;&amp;  __config__.app.getApp('timesheet').getDefaultEndFormat() == 1"/>
		<field name="toDate" expr="eval:fromDate.withDayOfMonth(fromDate.lengthOfMonth())" if="toDate == null &amp;&amp; fromDate != null &amp;&amp;  __config__.app.getApp('timesheet').getDefaultEndFormat() == 2"/>
	</action-record>
	
	<action-validate name="action-timesheet-validate-timesheet-selected">
		<error message="You have to choose at least one timesheet" if="timesheetSelect == null"/>
	</action-validate>
	
	<action-validate name="action-timesheet-validate-toDate">
		<error message="Invalid date" if="toDate != null &amp;&amp; toDate &lt; fromDate" action="action-timesheet-null-toDate"/>
	</action-validate>
	
	<action-validate name="action-timesheet-validate-fromDate">
		<error message="Invalid date, it can't be in the future" if="fromDate.isAfter(__date__)" action="action-timesheet-null-fromDate"/>
	</action-validate>
	
	<action-attrs name="action-hr-timesheet-attrs-domain-project">
		<attribute name="domain" for="$project" expr="eval: &quot; ${user?.id} MEMBER OF self.membersUserSet OR self.assignedTo.id = ${user?.id} &quot;"/>
	</action-attrs>
	
	<action-attrs name="action-timesheet-attrs-title-project">
		<attribute name="title" for="$project" expr="eval: __config__.app.getApp('project').getProjectLabel()" if="__config__.app.isApp('project') &amp;&amp; !com.google.common.base.Strings.isNullOrEmpty(__config__.app.getApp('project').getProjectLabel())"/>
		<attribute name="title" for="timesheetLineList.project" expr="eval: __config__.app.getApp('project').getProjectLabel()" if="__config__.app.isApp('project') &amp;&amp; !com.google.common.base.Strings.isNullOrEmpty(__config__.app.getApp('project').getProjectLabel())"/>
	</action-attrs>
	
	<action-attrs name="action-timesheet-attrs-domain-timesheet-select">
		<attribute name="domain" for="$timesheetSelect" expr="eval: &quot; self.statusSelect = 1 AND self.user = ${__user__.id} &quot;"/>
	</action-attrs>
	
	<action-attrs name="action-timesheet-attrs-buttons">
		<attribute name="hidden" for="validateBtn" expr="eval: !(statusSelect == 2 &amp;&amp; (__user__ == user?.employee?.managerUser || (__user__ == user &amp;&amp; user?.employee?.managerUser == null) || __user__.employee?.hrManager))"/>
		<attribute name="hidden" for="cancelBtn" expr="eval: !(statusSelect == 1) &amp;&amp; !(statusSelect == 2 &amp;&amp; (__user__ == user?.employee?.managerUser || (__user__ == user &amp;&amp; user?.employee?.managerUser == null) || __user__.employee?.hrManager))"/>
		<attribute name="hidden" for="refuseBtn" expr="eval: !(statusSelect == 2 &amp;&amp; (__user__ == user?.employee?.managerUser || (__user__ == user &amp;&amp; user?.employee?.managerUser == null) || __user__.employee?.hrManager))"/>
		<attribute name="readonly" for="headPanel" expr="eval: (statusSelect == 2 &amp;&amp; !(__user__ == user?.employee?.managerUser || (__user__ == user &amp;&amp; user?.employee?.managerUser == null)|| __user__.employee?.hrManager)) || statusSelect &gt; 2"/>
		<attribute name="hidden" for="getTimeFromTask" expr="eval: (statusSelect == 2 &amp;&amp; !(__user__ == user?.employee?.managerUser || (__user__ == user &amp;&amp; user?.employee?.managerUser == null)|| __user__.employee?.hrManager)) || statusSelect &gt; 2"/>
		<attribute name="readonly" for="timesheetLineList" expr="eval: (statusSelect == 2 &amp;&amp; !(__user__ == user?.employee?.managerUser || (__user__ == user &amp;&amp; user?.employee?.managerUser == null)|| __user__.employee?.hrManager)) || statusSelect &gt; 2"/>
        <attribute name="hidden" for="timesheetLineList.product" expr="eval: !$showActivity"/>
        <attribute name="hidden" for="$product" expr="eval: !$showActivity"/>
        <attribute name="readonly" for="company" expr="eval: true" if="!__user__.employee?.hrManager"/>
        <attribute name="readonly" for="company" expr="eval: statusSelect &gt; 2" if="__user__.employee?.hrManager"/>
        <attribute name="readonly" for="user" expr="eval: true" if="!__user__.employee?.hrManager"/>
        <attribute name="readonly" for="user" expr="eval: statusSelect &gt; 2" if="__user__.employee?.hrManager"/>
	</action-attrs>
	
	<action-attrs name="action-timesheet-attrs-set-visible-duration-title">
        <attribute name="title" for="timesheetLineList.duration" expr="eval: timeLoggingPreferenceSelect == 'days' ? com.axelor.i18n.I18n.get('Days') : timeLoggingPreferenceSelect == 'minutes' ? com.axelor.i18n.I18n.get('Minutes') : com.axelor.i18n.I18n.get('Hours')" />
        <attribute name="title" for="totalHoursPerDayPanel" expr="eval: timeLoggingPreferenceSelect == 'days' ? com.axelor.i18n.I18n.get('Total Days in the period') : timeLoggingPreferenceSelect == 'minutes' ? com.axelor.i18n.I18n.get('Total Minutes per Day') : com.axelor.i18n.I18n.get('Total Hours per Day')"/>
	</action-attrs>
	
	<action-attrs name="action-timesheet-attrs-set-log-time-title">
	    <attribute name="title" for="$logTime" expr="eval: timeLoggingPreferenceSelect == 'days' ? com.axelor.i18n.I18n.get('Duration(in day per day)') : timeLoggingPreferenceSelect == 'minutes' ? com.axelor.i18n.I18n.get('Duration(minutes by day)') : com.axelor.i18n.I18n.get('Duration(hours by day)')" />
	</action-attrs>
	
	<action-attrs name="action-timesheet-attrs-generate-lines-panel-hidden-true">
		<attribute name="hidden" for="generateLinesPanel" expr="true"/>
	</action-attrs>
	
	<action-attrs name="action-timesheet-attrs-generate-lines-panel-hidden-false">
		<attribute name="hidden" for="generateLinesPanel" expr="false"/>
	</action-attrs>
	
	<action-attrs name="action-timesheet-attrs-from-date-on-new">
		<attribute name="readonly" for="fromDate" expr="eval: __repo__(Timesheet).all().filter('self.user = ?1 AND self.statusSelect != ?2 ORDER BY self.toDate DESC', __user__, TimesheetRepository.STATUS_CANCELED).fetchOne() != null"/>
	</action-attrs>
	
	<action-attrs name="action-timesheet-attrs-from-date">
		<attribute name="readonly" for="fromDate" expr="eval: fromDate != null"/>
	</action-attrs>

	<action-attrs name="action-timesheet-attrs-refresh-editor">
		<attribute name="refresh" for="timesheetLineEditorPanel" expr="eval:true" if="showEditor"/>
	</action-attrs>

	<action-attrs name="action-timesheet-attrs-panels">
		<attribute name="hidden" for="actionsPanel" expr="eval:id == null" if="__config__.app.getApp('timesheet').getTimesheetEditor()"/>
		<attribute name="hidden" for="linesPanel" expr="eval:id == null" if="__config__.app.getApp('timesheet').getTimesheetEditor()"/>
	</action-attrs>

	<action-attrs name="action-timesheet-set-show-editor">
		<attribute name="value" for="showEditor" expr="eval:true"/>
	</action-attrs>


	<action-attrs name="action-timesheet-attrs-set-user-domain">
		<attribute name="domain" for="user" expr="eval: &quot;self.employee.&quot;"/>
	</action-attrs>

	<action-attrs name="action-timesheet-attrs-enable-timesheet-manuforder">
		<attribute for="$enableTimesheetManufOrder" name="value" expr="eval: __config__.app.getApp('production').getEnableTimesheetOnManufOrder()"/>
	</action-attrs>

	<action-record name="action-timesheet-record-from-period-date" model="com.axelor.apps.hr.db.Timesheet">
		<field name="fromDate" expr="eval: __repo__(Timesheet).all().filter('self.user = ?1 AND self.statusSelect != ?2 ORDER BY self.toDate DESC', __user__, TimesheetRepository.STATUS_CANCELED).fetchOne()?.toDate?.plusDays(1)"/>
	</action-record>
	
	<action-record name="action-timesheet-null-fromDate" model="com.axelor.apps.hr.db.Timesheet">
		<field name="fromDate" expr="eval: null"/>
	</action-record>
	
	<action-record name="action-timesheet-null-toDate" model="com.axelor.apps.hr.db.Timesheet">
		<field name="toDate" expr="eval: null"/>
	</action-record>
	
	<action-method name="action-timesheet-method-confirm">
		<call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="confirm"/>
	</action-method>

    <action-method name="action-timesheet-method-continue">
        <call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="continueBtn"/>
    </action-method>
	
	<action-method name="action-timesheet-method-confirm-continue">
		<call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="confirmContinue"/>
	</action-method>
	
	<action-method name="action-timesheet-method-valid">
		<call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="valid"/>
	</action-method>
	
	<action-method name="action-timesheet-method-refuse">
		<call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="refuse"/>
	</action-method>
	
	<action-method name="action-timesheet-method-cancel">
		<call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="cancel"/>
	</action-method>

	<action-method name="action-timesheet-method-draft">
		<call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="draft"/>
	</action-method>
	
	<action-method name="action-timesheet-method-timesheet-timer">
		<call class="com.axelor.apps.hr.web.timesheet.timer.TSTimerController" method="editTimesheetTimerFromTimesheet"/>
	</action-method>
	
	<action-method name="action-timesheet-method-edit-timesheet-selected">
		<call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="editTimesheetSelected"/>
	</action-method>
	
	<action-method name="action-print-timesheet">
    	<call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="printTimesheet"/>
    </action-method>

    <action-method name="action-timesheet-method-set-show-activity">
    	<call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="setShowActivity"/>
    </action-method>

	<action-method name="action-timesheet-method-open-timesheet-editor">
    	<call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="openTimesheetEditor"/>
    </action-method>

	<action-view name="action-timesheet-view-total-hours-per-day" title="">
  		<view name="chart.total.hours.per.day" type="chart"/>
    	<context name="timesheet_id" expr="eval: id"/>
	</action-view>
	
	<action-view name="action-timesheet-refusal-popup-form" title="Ground for refusal" model="com.axelor.apps.hr.db.Timesheet">
    	<view type="form" name="popup-timesheet-refusal-form"/>
        <view-param name="popup" value="reload"/>
        <view-param name="show-toolbar" value="false"/>
  		<view-param name="show-confirm" value="true" />
	  	<view-param name="popup-save" value="true"/>
	  	<view-param name="forceEdit" value="true" />
    	<context name="_showRecord" expr="eval: id"/>
    </action-view>

    <action-view name="action-timesheet-show-timesheet-line-editor" title="Timesheet lines">
    	<view type="html" name="hr/timesheet?timesheetId={{id}}&amp;showActivity={{$showActivity}}" />
    </action-view>

    <action-view name="action-timesheet-see-timesheet-lines" title="See timesheet lines"
		model="com.axelor.apps.hr.db.TimesheetLine">
		<view type="grid" name="timesheet-line-grid"/>
		<view type="form" name="timesheet-line-form"/>
		<domain>self.timesheet.user = :user_id AND self.timesheet.company = :company_id</domain>
		<context name="user_id" expr="eval: user_id"/>
		<context name="company_id" expr="eval: company_id"/>
	</action-view>
	
	<action-method name="action-timesheet-method-all-timesheet-line">
		<call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="allTimesheetLine"/>
	</action-method>

	<action-method name="action-timesheet-method-timesheet-line-validate">
		<call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="validateTimesheetLine"/>
	</action-method>

	<action-method name="action-timesheet-method-timesheet-line-historic">
		<call class="com.axelor.apps.hr.web.timesheet.TimesheetController" method="historicTimesheetLine"/>
	</action-method>

	<action-attrs name="action-hr-attrs-set-user-domain">
		<attribute for="user" name="domain" if="company &amp;&amp; __user__?.employee?.hrManager" expr="eval: &quot; self.employee.id IN (${(__repo__(EmploymentContract).all().filter('self.payCompany.id = :companyId').bind('companyId', company.id).fetch().collect{it -> it?.employee.id ?: 0}+[0]).join(',')}) &quot;"/>
		<attribute for="user" name="domain" if="company &amp;&amp; !__user__?.employee?.hrManager" expr="eval: &quot; self.employee.id IN (${(__repo__(EmploymentContract).all().filter('self.payCompany.id = :companyId').bind('companyId', company.id).fetch().collect{it -> it.employee}.findAll{it -> it?.managerUser?.id == __user__.id || it?.id == __user__?.employee?.id}.collect{it -> it.id}+[0]).join(',')}) &quot;"/>
		<attribute for="user" name="domain" if="!company" expr="eval: &quot; self.employee.id IN (0) &quot;"/>
	</action-attrs>

	<action-record name="action-hr-record-empty-user" model="com.axelor.apps.hr.db.Timesheet">
		<field name="user" expr="eval: null"/>
	</action-record>

	<action-condition name="action-hr-condition-automatic-from-generation-date">
		<check if="eval: fromGenerationDate != null &amp;&amp; ((toDate == null &amp;&amp; fromGenerationDate &lt; fromDate.toString()) || 
			(toDate != null &amp;&amp; (fromGenerationDate &lt; fromDate.toString() || fromGenerationDate == toDate.toString() || fromGenerationDate &gt; toDate.toString())) ||
			(toGenerationDate != null &amp;&amp; fromGenerationDate > toGenerationDate))" 
			field="$fromGenerationDate" error="Automatic generation dates must be included in the timesheet period"/>
	</action-condition>

	<action-condition name="action-hr-condition-automatic-to-generation-date">
		<check if="eval: toGenerationDate != null &amp;&amp; ((toDate != null &amp;&amp; (toGenerationDate &gt; toDate.toString() || toGenerationDate == fromDate.toString() || toGenerationDate &lt; fromDate.toString())) || 
			(fromGenerationDate != null &amp;&amp; fromGenerationDate > toGenerationDate))" 
			field="$toGenerationDate" error="Automatic generation dates must be included in the timesheet period"/>
	</action-condition>

</object-views>
