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

    <record id="res_config_settings_view_form_fusion_clock" model="ir.ui.view">
        <field name="name">res.config.settings.view.form.fusion.clock</field>
        <field name="model">res.config.settings</field>
        <field name="inherit_id" ref="base.res_config_settings_view_form"/>
        <field name="priority">95</field>
        <field name="arch" type="xml">
            <xpath expr="//form" position="inside">
                <app data-string="Fusion Clock" string="Fusion Clock" name="fusion_clock" groups="fusion_clock.group_fusion_clock_manager">

                    <!-- ============================================================ -->
                    <!-- Work Schedule -->
                    <!-- ============================================================ -->
                    <block title="Work Schedule" name="fclk_work_schedule">
                        <setting id="fclk_default_schedule" string="Default Schedule"
                                 help="Scheduled start and end times used when no shift is assigned to an employee.">
                            <div class="content-group">
                                <div class="row mt16">
                                    <label for="fclk_default_clock_in_time" string="Clock-In" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_default_clock_in_time" widget="float_time"/>
                                </div>
                                <div class="row mt8">
                                    <label for="fclk_default_clock_out_time" string="Clock-Out" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_default_clock_out_time" widget="float_time"/>
                                </div>
                            </div>
                        </setting>
                        <setting id="fclk_auto_break" string="Auto-Deduct Break"
                                 help="Automatically deduct unpaid break from worked hours on clock-out.">
                            <field name="fclk_auto_deduct_break"/>
                            <div class="content-group" invisible="not fclk_auto_deduct_break">
                                <div class="row mt16">
                                    <label for="fclk_default_break_minutes" string="Duration (min)" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_default_break_minutes"/>
                                </div>
                                <div class="row mt8">
                                    <label for="fclk_break_threshold_hours" string="Min. Shift" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_break_threshold_hours" widget="float_time"/>
                                </div>
                            </div>
                        </setting>
                    </block>

                    <!-- ============================================================ -->
                    <!-- Attendance Rules -->
                    <!-- ============================================================ -->
                    <block title="Attendance Rules" name="fclk_attendance_rules">
                        <setting id="fclk_auto_clockout" string="Auto Clock-Out"
                                 help="Automatically clock out employees after their shift end time plus a grace period.">
                            <field name="fclk_enable_auto_clockout"/>
                            <div class="content-group" invisible="not fclk_enable_auto_clockout">
                                <div class="row mt16">
                                    <label for="fclk_grace_period_minutes" string="Grace (min)" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_grace_period_minutes"/>
                                </div>
                                <div class="row mt8">
                                    <label for="fclk_max_shift_hours" string="Max Shift" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_max_shift_hours" widget="float_time"/>
                                </div>
                            </div>
                        </setting>
                        <setting id="fclk_penalties" string="Penalty Tracking"
                                 help="Deduct minutes from worked hours when employees clock in late or clock out early.">
                            <field name="fclk_enable_penalties"/>
                            <div class="content-group" invisible="not fclk_enable_penalties">
                                <div class="row mt16">
                                    <label for="fclk_penalty_grace_minutes" string="Grace (min)" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_penalty_grace_minutes"/>
                                </div>
                                <div class="row mt8">
                                    <label for="fclk_penalty_deduction_minutes" string="Deduction (min)" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_penalty_deduction_minutes"/>
                                </div>
                            </div>
                        </setting>
                        <setting id="fclk_overtime" string="Overtime Tracking"
                                 help="Calculate and track overtime when net hours exceed the daily or weekly threshold.">
                            <field name="fclk_enable_overtime"/>
                            <div class="content-group" invisible="not fclk_enable_overtime">
                                <div class="row mt16">
                                    <label for="fclk_daily_overtime_threshold" string="Daily Limit" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_daily_overtime_threshold" widget="float_time"/>
                                </div>
                                <div class="row mt8">
                                    <label for="fclk_weekly_overtime_threshold" string="Weekly Limit" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_weekly_overtime_threshold" widget="float_time"/>
                                </div>
                            </div>
                        </setting>
                    </block>

                    <!-- ============================================================ -->
                    <!-- Notifications -->
                    <!-- ============================================================ -->
                    <block title="Notifications" name="fclk_notifications">
                        <setting id="fclk_office_user" string="Office User"
                                 help="User who receives activity notifications for attendance issues (late arrivals, excessive absences).">
                            <div class="content-group">
                                <div class="row mt16">
                                    <label for="fclk_office_user_id" string="User" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_office_user_id"/>
                                </div>
                                <div class="row mt8">
                                    <label for="fclk_very_late_threshold_minutes" string="Late Alert (min)" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_very_late_threshold_minutes"/>
                                </div>
                                <div class="row mt8">
                                    <label for="fclk_max_monthly_absences" string="Max Absences" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_max_monthly_absences"/>
                                </div>
                            </div>
                        </setting>
                        <setting id="fclk_employee_notifications" string="Employee Reminders"
                                 help="Send clock-in and clock-out reminders to employees based on their shift schedule.">
                            <field name="fclk_enable_employee_notifications"/>
                            <div class="content-group" invisible="not fclk_enable_employee_notifications">
                                <div class="row mt16">
                                    <label for="fclk_reminder_before_shift_minutes" string="Late Reminder (min)" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_reminder_before_shift_minutes"/>
                                </div>
                                <div class="row mt8">
                                    <label for="fclk_reminder_before_end_minutes" string="End Reminder (min)" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_reminder_before_end_minutes"/>
                                </div>
                            </div>
                        </setting>
                        <setting id="fclk_weekly_summary" string="Weekly Summary"
                                 help="Send a weekly attendance summary email to each employee on Monday.">
                            <field name="fclk_send_weekly_summary"/>
                        </setting>
                    </block>

                    <!-- ============================================================ -->
                    <!-- Location & Verification -->
                    <!-- ============================================================ -->
                    <block title="Location &amp; Verification" name="fclk_location_settings">
                        <setting id="fclk_ip_fallback" string="IP Fallback"
                                 help="Allow IP-based location verification when GPS is unavailable.">
                            <field name="fclk_enable_ip_fallback"/>
                        </setting>
                        <setting id="fclk_photo_verification" string="Photo Verification"
                                 help="Require selfie on clock-in. Per-location control is available in each location's settings.">
                            <field name="fclk_enable_photo_verification"/>
                        </setting>
                        <setting id="fclk_google_maps" string="Google Maps API Key"
                                 help="Required for location geocoding and map previews in clock location setup.">
                            <div class="content-group">
                                <div class="row mt16">
                                    <label for="fclk_google_maps_api_key" string="API Key" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_google_maps_api_key" class="o_input" placeholder="AIza..." password="True"/>
                                </div>
                            </div>
                        </setting>
                        <setting id="fclk_manage_locations" string="Clock Locations"
                                 help="Configure geofenced clock-in/out locations with GPS radius, IP ranges, and verification rules.">
                            <div class="content-group">
                                <div class="mt16">
                                    <button name="%(fusion_clock.action_fusion_clock_location)d" type="action"
                                            string="Manage Locations" icon="oi-arrow-right" class="btn-link"/>
                                </div>
                            </div>
                        </setting>
                    </block>

                    <!-- ============================================================ -->
                    <!-- Kiosk & Portal -->
                    <!-- ============================================================ -->
                    <block title="Kiosk &amp; Portal" name="fclk_kiosk_portal">
                        <setting id="fclk_kiosk" string="Kiosk Mode"
                                 help="Allow employees to clock in/out from a shared device (tablet or computer).">
                            <field name="fclk_enable_kiosk"/>
                            <div class="content-group" invisible="not fclk_enable_kiosk">
                                <div class="row mt16">
                                    <field name="fclk_kiosk_pin_required"/>
                                    <label for="fclk_kiosk_pin_required" class="ms-1"/>
                                </div>
                            </div>
                        </setting>
                        <setting id="fclk_corrections" string="Correction Requests"
                                 help="Allow employees to request timesheet corrections from the portal.">
                            <field name="fclk_enable_correction_requests"/>
                        </setting>
                        <setting id="fclk_sounds" string="Clock Sounds"
                                 help="Play audio confirmation sounds when employees clock in or out.">
                            <field name="fclk_enable_sounds"/>
                        </setting>
                    </block>

                    <!-- ============================================================ -->
                    <!-- Pay Period & Reports -->
                    <!-- ============================================================ -->
                    <block title="Pay Period &amp; Reports" name="fclk_pay_period_reports">
                        <setting id="fclk_pay_period" string="Pay Period Schedule"
                                 help="Defines how often attendance reports are generated and the start/end dates of each reporting period.">
                            <div class="content-group">
                                <div class="row mt16">
                                    <label for="fclk_pay_period_type" string="Frequency" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_pay_period_type"/>
                                </div>
                                <div class="row mt8">
                                    <label for="fclk_pay_period_start" string="Anchor Date" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_pay_period_start"/>
                                </div>
                            </div>
                        </setting>
                        <setting id="fclk_auto_reports" string="Auto-Generate Reports"
                                 help="Automatically create attendance reports at the end of each pay period.">
                            <field name="fclk_auto_generate_reports"/>
                        </setting>
                        <setting id="fclk_employee_copies" string="Send Employee Copies"
                                 help="Email individual attendance reports to each employee at the end of each pay period.">
                            <field name="fclk_send_employee_reports"/>
                        </setting>
                        <setting id="fclk_internal_recipients" string="Internal Recipients"
                                 help="Select internal users who should receive batch attendance reports.">
                            <div class="content-group">
                                <div class="row mt16">
                                    <label for="fclk_report_recipient_user_ids" string="Users" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_report_recipient_user_ids" widget="many2many_tags"/>
                                </div>
                            </div>
                        </setting>
                        <setting id="fclk_external_recipients" string="External Recipients"
                                 help="Additional email addresses for batch report delivery (e.g., external payroll agency).">
                            <div class="content-group">
                                <div class="row mt16">
                                    <label for="fclk_report_recipient_emails" string="Emails" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_report_recipient_emails" class="o_input" placeholder="payroll@agency.com, manager@company.com"/>
                                </div>
                            </div>
                        </setting>
                        <setting id="fclk_csv_mapping" string="CSV Column Mapping"
                                 help="Custom column names for CSV export (JSON format). Leave blank for defaults.">
                            <div class="content-group">
                                <div class="row mt16">
                                    <label for="fclk_csv_column_mapping" string="Mapping" class="col-lg-5 o_light_label"/>
                                    <field name="fclk_csv_column_mapping" class="o_input"/>
                                </div>
                            </div>
                        </setting>
                    </block>

                </app>
            </xpath>
        </field>
    </record>

</odoo>
