<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <!-- Employee Form: Fusion Clock Tab -->
    <record id="view_employee_form_fusion_clock" model="ir.ui.view">
        <field name="name">hr.employee.form.fusion.clock</field>
        <field name="model">hr.employee</field>
        <field name="inherit_id" ref="hr.view_employee_form"/>
        <field name="arch" type="xml">
            <xpath expr="//notebook" position="inside">
                <page string="Fusion Clock" name="fusion_clock_tab"
                      groups="fusion_clock.group_fusion_clock_manager,fusion_clock.group_fusion_clock_team_lead">

                    <!-- Configuration & Status -->
                    <group>
                        <group string="Configuration">
                            <field name="x_fclk_enable_clock"/>
                            <field name="x_fclk_shift_id"/>
                            <field name="x_fclk_default_location_id"/>
                            <field name="x_fclk_break_minutes"/>
                            <field name="x_fclk_kiosk_pin" password="True"
                                   groups="fusion_clock.group_fusion_clock_manager"/>
                        </group>
                        <group string="Status">
                            <field name="x_fclk_ontime_streak"/>
                            <field name="x_fclk_absences_this_month"/>
                            <field name="x_fclk_absences_this_year"/>
                            <field name="x_fclk_overtime_this_week" widget="float_time"/>
                            <field name="x_fclk_overtime_this_month" widget="float_time"/>
                            <field name="x_fclk_pending_reason"/>
                        </group>
                    </group>

                    <!-- Activity Log Sub-Tabs -->
                    <notebook>
                        <page string="Clock Events" name="fclk_sub_clock_events">
                            <field name="x_fclk_activity_log_ids" nolabel="1" colspan="2"
                                   domain="[('log_type', 'in', ['clock_in', 'clock_out'])]">
                                <list create="false" delete="false" limit="20" default_order="log_date desc">
                                    <field name="log_date"/>
                                    <field name="log_type"/>
                                    <field name="description"/>
                                    <field name="location_id"/>
                                    <field name="source"/>
                                </list>
                            </field>
                        </page>

                        <page string="Penalties" name="fclk_sub_penalties">
                            <field name="x_fclk_activity_log_ids" nolabel="1" colspan="2"
                                   domain="[('log_type', 'in', ['late_clock_in', 'early_clock_out'])]">
                                <list create="false" delete="false" limit="20" default_order="log_date desc">
                                    <field name="log_date"/>
                                    <field name="log_type"/>
                                    <field name="description"/>
                                </list>
                            </field>
                        </page>

                        <page string="Geofence" name="fclk_sub_geofence">
                            <field name="x_fclk_activity_log_ids" nolabel="1" colspan="2"
                                   domain="[('log_type', 'in', ['outside_geofence', 'ip_fallback'])]">
                                <list create="false" delete="false" limit="20" default_order="log_date desc">
                                    <field name="log_date"/>
                                    <field name="log_type"/>
                                    <field name="description"/>
                                    <field name="latitude"/>
                                    <field name="longitude"/>
                                    <field name="distance"/>
                                </list>
                            </field>
                        </page>

                        <page string="System" name="fclk_sub_system">
                            <field name="x_fclk_activity_log_ids" nolabel="1" colspan="2"
                                   domain="[('log_type', 'in', ['auto_clock_out', 'missed_clock_out'])]">
                                <list create="false" delete="false" limit="20" default_order="log_date desc">
                                    <field name="log_date"/>
                                    <field name="log_type"/>
                                    <field name="description"/>
                                    <field name="attendance_id"/>
                                </list>
                            </field>
                        </page>

                        <page string="Absences" name="fclk_sub_absences">
                            <field name="x_fclk_activity_log_ids" nolabel="1" colspan="2"
                                   domain="[('log_type', '=', 'absent')]">
                                <list create="false" delete="false" limit="20" default_order="log_date desc">
                                    <field name="log_date"/>
                                    <field name="description"/>
                                </list>
                            </field>
                        </page>

                        <page string="Leave Requests" name="fclk_sub_leaves">
                            <field name="x_fclk_leave_request_ids" nolabel="1" colspan="2">
                                <list create="false" delete="false" limit="20" default_order="leave_date desc">
                                    <field name="leave_date"/>
                                    <field name="reason"/>
                                    <field name="state"/>
                                    <field name="created_from"/>
                                </list>
                            </field>
                        </page>

                        <page string="Reasons" name="fclk_sub_reasons">
                            <field name="x_fclk_activity_log_ids" nolabel="1" colspan="2"
                                   domain="[('log_type', '=', 'reason_provided')]">
                                <list create="false" delete="false" limit="20" default_order="log_date desc">
                                    <field name="log_date"/>
                                    <field name="description"/>
                                </list>
                            </field>
                        </page>

                        <page string="Overtime" name="fclk_sub_overtime">
                            <field name="x_fclk_activity_log_ids" nolabel="1" colspan="2"
                                   domain="[('log_type', '=', 'overtime')]">
                                <list create="false" delete="false" limit="20" default_order="log_date desc">
                                    <field name="log_date"/>
                                    <field name="description"/>
                                    <field name="attendance_id"/>
                                </list>
                            </field>
                        </page>

                        <page string="Corrections" name="fclk_sub_corrections">
                            <field name="x_fclk_correction_ids" nolabel="1" colspan="2">
                                <list create="false" delete="false" limit="20">
                                    <field name="attendance_id"/>
                                    <field name="requested_check_in"/>
                                    <field name="requested_check_out"/>
                                    <field name="reason"/>
                                    <field name="state" decoration-success="state == 'approved'"
                                           decoration-danger="state == 'rejected'"
                                           decoration-warning="state == 'pending'"/>
                                </list>
                            </field>
                        </page>

                        <page string="Streaks" name="fclk_sub_streaks">
                            <field name="x_fclk_activity_log_ids" nolabel="1" colspan="2"
                                   domain="[('log_type', '=', 'streak_milestone')]">
                                <list create="false" delete="false" limit="20" default_order="log_date desc">
                                    <field name="log_date"/>
                                    <field name="description"/>
                                </list>
                            </field>
                        </page>
                    </notebook>

                </page>
            </xpath>
        </field>
    </record>

</odoo>
