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

    <!-- Activity Log List View -->
    <record id="view_fusion_clock_activity_log_list" model="ir.ui.view">
        <field name="name">fusion.clock.activity.log.list</field>
        <field name="model">fusion.clock.activity.log</field>
        <field name="arch" type="xml">
            <list>
                <field name="log_date"/>
                <field name="employee_id"/>
                <field name="log_type"/>
                <field name="description"/>
                <field name="location_id" optional="show"/>
                <field name="source" optional="show"/>
                <field name="distance" optional="hide"/>
            </list>
        </field>
    </record>

    <!-- Activity Log Form View -->
    <record id="view_fusion_clock_activity_log_form" model="ir.ui.view">
        <field name="name">fusion.clock.activity.log.form</field>
        <field name="model">fusion.clock.activity.log</field>
        <field name="arch" type="xml">
            <form create="false" edit="false">
                <sheet>
                    <group>
                        <group>
                            <field name="employee_id"/>
                            <field name="log_type"/>
                            <field name="log_date"/>
                            <field name="source"/>
                        </group>
                        <group>
                            <field name="location_id"/>
                            <field name="attendance_id"/>
                            <field name="latitude"/>
                            <field name="longitude"/>
                            <field name="distance"/>
                        </group>
                    </group>
                    <group>
                        <field name="description"/>
                    </group>
                    <!-- Clock-in attempt location map -->
                    <group string="Clock Attempt Location"
                           invisible="not latitude or not longitude">
                        <field name="attempt_map_url" widget="image_url" nolabel="1" colspan="2"/>
                    </group>
                </sheet>
            </form>
        </field>
    </record>

    <!-- Activity Log Search View -->
    <record id="view_fusion_clock_activity_log_search" model="ir.ui.view">
        <field name="name">fusion.clock.activity.log.search</field>
        <field name="model">fusion.clock.activity.log</field>
        <field name="arch" type="xml">
            <search>
                <field name="employee_id"/>
                <field name="log_type"/>
                <separator/>
                <filter name="clock_events" string="Clock Events" domain="[('log_type', 'in', ['clock_in', 'clock_out'])]"/>
                <filter name="penalties" string="Penalties" domain="[('log_type', 'in', ['late_clock_in', 'early_clock_out'])]"/>
                <filter name="geofence" string="Geofence" domain="[('log_type', 'in', ['outside_geofence', 'ip_fallback'])]"/>
                <filter name="system" string="System" domain="[('log_type', 'in', ['auto_clock_out', 'missed_clock_out'])]"/>
                <filter name="absences" string="Absences" domain="[('log_type', '=', 'absent')]"/>
                <filter name="leaves" string="Leaves" domain="[('log_type', '=', 'leave_request')]"/>
                <filter name="overtime" string="Overtime" domain="[('log_type', '=', 'overtime')]"/>
                <separator/>
                <filter name="group_employee" string="Employee" context="{'group_by': 'employee_id'}"/>
                <filter name="group_type" string="Type" context="{'group_by': 'log_type'}"/>
                <filter name="group_date" string="Date" context="{'group_by': 'log_date:day'}"/>
            </search>
        </field>
    </record>

    <!-- Activity Log Action -->
    <record id="action_fusion_clock_activity_log" model="ir.actions.act_window">
        <field name="name">Activity Logs</field>
        <field name="res_model">fusion.clock.activity.log</field>
        <field name="view_mode">list,form</field>
        <field name="search_view_id" ref="view_fusion_clock_activity_log_search"/>
    </record>

</odoo>
