<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright 2024-2025 Nexa Systems Inc.
    License OPL-1 (Odoo Proprietary License v1.0)
    Part of the Fusion Claim Assistant product family.
-->
<odoo>
    <!-- Add Fusion Central Settings as a new app block -->
    <record id="res_config_settings_view_form_fusion_claims" model="ir.ui.view">
        <field name="name">res.config.settings.view.form.fusion.central</field>
        <field name="model">res.config.settings</field>
        <field name="inherit_id" ref="base.res_config_settings_view_form"/>
        <field name="arch" type="xml">
            <xpath expr="//form" position="inside">
                <app data-string="Fusion Claims" string="Fusion Claims" name="fusion_claims"
                     groups="fusion_claims.group_fusion_claims_manager">
                    <h2>ADP Billing</h2>
                    
                    <div class="row mt-4 o_settings_container">
                        <!-- ADP Vendor Code -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">ADP Vendor Code</span>
                                <div class="text-muted">Your ADP vendor/location code for claim submissions</div>
                                <div class="mt-2">
                                    <field name="fc_vendor_code" placeholder="e.g., 1234567"/>
                                </div>
                            </div>
                        </div>
                    </div>

                    <h2>ADP Posting Schedule</h2>
                    
                    <div class="row mt-4 o_settings_container">
                        <!-- Posting Schedule Configuration -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Posting Cycle</span>
                                <div class="text-muted">Configure the bi-weekly ADP posting schedule</div>
                                <div class="mt-2">
                                    <div class="row mb-2">
                                        <label for="fc_adp_posting_base_date" class="col-5 col-form-label">Base Posting Date</label>
                                        <div class="col-7">
                                            <field name="fc_adp_posting_base_date"/>
                                        </div>
                                    </div>
                                    <div class="row mb-2">
                                        <label for="fc_adp_posting_frequency_days" class="col-5 col-form-label">Frequency (Days)</label>
                                        <div class="col-7">
                                            <field name="fc_adp_posting_frequency_days"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="alert alert-info mt-3" role="alert">
                                    <strong>Schedule Info:</strong>
                                    <ul class="mb-0 mt-1">
                                        <li>Submission Deadline: Wednesday 6 PM before posting day</li>
                                        <li>Payment Processed: Posting day + 7 days</li>
                                        <li>Payment Received: Posting day + ~10 days</li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                        
                        <!-- Reminder Recipients -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Automatic Reminders</span>
                                <div class="text-muted">Configure who receives ADP billing reminders</div>
                                <div class="mt-2">
                                    <div class="row mb-2">
                                        <label for="fc_adp_billing_reminder_user_id" class="col-12 col-form-label">
                                            Billing Deadline Person
                                        </label>
                                        <div class="col-12">
                                            <field name="fc_adp_billing_reminder_user_id" 
                                                   domain="[('share', '=', False)]"
                                                   placeholder="Select user for billing reminders..."/>
                                            <div class="text-muted small">Reminded on Monday to complete billing by Wednesday 6 PM</div>
                                        </div>
                                    </div>
                                    <div class="row mt-3">
                                        <label for="fc_adp_correction_reminder_user_ids" class="col-12 col-form-label">
                                            Correction Alert Recipients
                                        </label>
                                        <div class="col-12">
                                            <field name="fc_adp_correction_reminder_user_ids" 
                                                   widget="many2many_tags"
                                                   domain="[('share', '=', False)]"
                                                   placeholder="Select users for correction alerts..."/>
                                            <div class="text-muted small">Notified when invoices need correction/resubmission</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <h2>Email Notifications</h2>
                    
                    <div class="row mt-4 o_settings_container">
                        <!-- Enable/Disable Notifications -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_left_pane">
                                <field name="fc_enable_email_notifications"/>
                            </div>
                            <div class="o_setting_right_pane">
                                <label for="fc_enable_email_notifications"/>
                                <div class="text-muted">
                                    Send automated email notifications when ADP workflow status changes 
                                    (assessment completed, application submitted, approved, denied, case closed, etc.)
                                </div>
                            </div>
                        </div>
                        
                        <!-- Office CC Emails -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Office Notification Recipients</span>
                                <div class="text-muted">
                                    These contacts will receive a copy (CC) of all automated ADP notifications 
                                    so the office staff can stay in the loop.
                                </div>
                                <div class="mt-2">
                                    <field name="fc_office_notification_ids" 
                                           widget="many2many_tags"
                                           domain="[('user_ids.share', '=', False)]"
                                           options="{'no_create': True}"/>
                                </div>
                            </div>
                        </div>
                        
                        <!-- Application Reminder Days -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Application Reminders</span>
                                <div class="text-muted">
                                    Automated reminders to therapist to submit the ADP application.
                                </div>
                                <div class="mt-2 row">
                                    <div class="col-4">
                                        <field name="fc_application_reminder_days"/>
                                    </div>
                                    <div class="col-8 pt-2 text-muted">days after assessment (first reminder)</div>
                                </div>
                                <div class="mt-2 row">
                                    <div class="col-4">
                                        <field name="fc_application_reminder_2_days"/>
                                    </div>
                                    <div class="col-8 pt-2 text-muted">days after first reminder (second reminder)</div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Workflow Lock Settings -->
                    <h2 class="mt-4">Workflow Settings</h2>
                    <div class="row mt-4 o_settings_container">
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_left_pane">
                                <field name="fc_allow_sale_type_override"/>
                            </div>
                            <div class="o_setting_right_pane">
                                <label for="fc_allow_sale_type_override"/>
                                <div class="text-muted">
                                    Allow changing Sale Type even after application is submitted.
                                    Use this for cases where additional benefits (ODSP, etc.) are discovered.
                                </div>
                            </div>
                        </div>
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_left_pane">
                                <field name="fc_allow_document_lock_override"/>
                            </div>
                            <div class="o_setting_right_pane">
                                <label for="fc_allow_document_lock_override"/>
                                <div class="text-muted">
                                    Allow users in the "Document Lock Override" group to edit locked documents
                                    on old cases. Turn this OFF once all legacy cases are processed.
                                </div>
                            </div>
                        </div>
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Designated Vendor Signer</span>
                                <div class="text-muted">
                                    The user who signs Page 12 on behalf of the company.
                                </div>
                                <div class="mt-2">
                                    <field name="fc_designated_vendor_signer"
                                           domain="[('share', '=', False)]"/>
                                </div>
                            </div>
                        </div>
                    </div>

                    <h2>AI Client Intelligence</h2>

                    <div class="row mt-4 o_settings_container">
                        <!-- AI API Key -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">AI API Key</span>
                                <div class="text-muted">
                                    OpenAI API key for Client Intelligence chat and AI analysis features.
                                </div>
                                <div class="mt-2">
                                    <field name="fc_ai_api_key" placeholder="sk-..." password="True"/>
                                </div>
                            </div>
                        </div>
                        <!-- AI Model -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">AI Model</span>
                                <div class="text-muted">
                                    Which AI model to use for client intelligence queries.
                                </div>
                                <div class="mt-2">
                                    <field name="fc_ai_model"/>
                                </div>
                            </div>
                        </div>
                        <!-- Auto XML Parse -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_left_pane">
                                <field name="fc_auto_parse_xml"/>
                            </div>
                            <div class="o_setting_right_pane">
                                <label for="fc_auto_parse_xml"/>
                                <div class="text-muted">
                                    Automatically parse ADP XML files when uploaded to sale orders
                                    and create/update client profiles.
                                </div>
                            </div>
                        </div>
                    </div>

                    <h2>March of Dimes</h2>

                    <div class="row mt-4 o_settings_container">
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Default MOD Email</span>
                                <div class="text-muted">
                                    Email used for sending initial quotations and documents to March of Dimes.
                                </div>
                                <div class="mt-2">
                                    <field name="fc_mod_default_email" placeholder="hvmp@marchofdimes.ca"/>
                                </div>
                            </div>
                        </div>
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">March of Dimes Vendor Code</span>
                                <div class="text-muted">
                                    Your vendor code assigned by March of Dimes.
                                </div>
                                <div class="mt-2">
                                    <field name="fc_mod_vendor_code" placeholder="e.g. TRD0001234"/>
                                </div>
                            </div>
                        </div>
                    </div>

                    <h2>Twilio SMS</h2>

                    <div class="row mt-4 o_settings_container">
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_left_pane">
                                <field name="fc_twilio_enabled"/>
                            </div>
                            <div class="o_setting_right_pane">
                                <label for="fc_twilio_enabled"/>
                                <div class="text-muted">
                                    Send SMS confirmations for assessment bookings and key status updates via Twilio.
                                </div>
                            </div>
                        </div>
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Twilio Phone Number</span>
                                <div class="mt-2">
                                    <field name="fc_twilio_phone_number" placeholder="+1234567890"/>
                                </div>
                            </div>
                        </div>
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Account SID</span>
                                <div class="mt-2">
                                    <field name="fc_twilio_account_sid" password="True"/>
                                </div>
                            </div>
                        </div>
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Auth Token</span>
                                <div class="mt-2">
                                    <field name="fc_twilio_auth_token" password="True"/>
                                </div>
                            </div>
                        </div>
                    </div>

                    <h2>March of Dimes Follow-Up</h2>

                    <div class="row mt-4 o_settings_container">
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Follow-up Interval</span>
                                <div class="text-muted">
                                    Days between follow-up reminders for MOD cases awaiting funding.
                                </div>
                                <div class="mt-2">
                                    <field name="fc_mod_followup_interval_days"/> days
                                </div>
                            </div>
                        </div>
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Auto-Email Escalation Delay</span>
                                <div class="text-muted">
                                    Days after a follow-up activity is overdue before sending an automatic email to the client.
                                </div>
                                <div class="mt-2">
                                    <field name="fc_mod_followup_escalation_days"/> days
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- ============================================================= -->
                    <!-- DATA MIGRATION -->
                    <!-- ============================================================= -->
                    <h2>Data Migration</h2>
                    <div class="row mt-4 o_settings_container">
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Migrate Export Files from Documents</span>
                                <div class="text-muted">
                                    Move existing ADP export files from the Documents app into the
                                    new ADP Export Files menu. Only needs to be run once after upgrading.
                                </div>
                                <div class="mt-2">
                                    <button name="action_migrate_adp_export_files"
                                            string="Migrate Export Files"
                                            type="object"
                                            class="btn-secondary"
                                            icon="fa-exchange"
                                            confirm="This will migrate all ADP export files from Documents to the new Export Files menu. Continue?"/>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- ============================================================= -->
                    <!-- ODSP CONFIGURATION -->
                    <!-- ============================================================= -->
                    <h2>ODSP Configuration</h2>
                    <div class="row mt16 o_settings_container">
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">SA Mobility Email</span>
                                <div class="text-muted">
                                    Email address for SA Mobility submissions (can be changed if the government email changes).
                                </div>
                                <div class="mt-2">
                                    <field name="fc_sa_mobility_email" placeholder="samobility@ontario.ca"/>
                                </div>
                            </div>
                        </div>
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">SA Mobility Phone</span>
                                <div class="text-muted">
                                    SA Mobility phone number for reference.
                                </div>
                                <div class="mt-2">
                                    <field name="fc_sa_mobility_phone" placeholder="1-888-222-5099"/>
                                </div>
                            </div>
                        </div>
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Default ODSP Office</span>
                                <div class="text-muted">
                                    Default ODSP office contact for new ODSP cases.
                                </div>
                                <div class="mt-2">
                                    <field name="fc_odsp_default_office_id"/>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- ===== PORTAL BRANDING ===== -->
                    <h2>Portal Branding</h2>
                    <div class="row mt16 o_settings_container">
                        <div class="col-12 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Portal Gradient Theme</span>
                                <div class="text-muted mb-3">
                                    Choose a preset gradient or customize your own colors for the portal dashboard.
                                </div>

                                <div class="mb-3">
                                    <field name="fc_portal_gradient_preset" widget="radio"/>
                                </div>

                                <div class="d-flex flex-wrap gap-2 mb-3">
                                    <button type="object" name="action_set_gradient_green_teal"
                                            class="btn btn-sm btn-outline-secondary d-flex align-items-center gap-2">
                                        <span style="display:inline-block;width:20px;height:20px;border-radius:4px;background:linear-gradient(135deg,#5ba848 0%,#3a8fb7 60%,#2e7aad 100%);"/>
                                        Green to Teal
                                    </button>
                                    <button type="object" name="action_set_gradient_blue_purple"
                                            class="btn btn-sm btn-outline-secondary d-flex align-items-center gap-2">
                                        <span style="display:inline-block;width:20px;height:20px;border-radius:4px;background:linear-gradient(135deg,#4a90d9 0%,#7b68ee 60%,#6a5acd 100%);"/>
                                        Blue to Purple
                                    </button>
                                    <button type="object" name="action_set_gradient_orange_red"
                                            class="btn btn-sm btn-outline-secondary d-flex align-items-center gap-2">
                                        <span style="display:inline-block;width:20px;height:20px;border-radius:4px;background:linear-gradient(135deg,#f7971e 0%,#e44d26 60%,#c0392b 100%);"/>
                                        Sunset Orange
                                    </button>
                                    <button type="object" name="action_set_gradient_dark_slate"
                                            class="btn btn-sm btn-outline-secondary d-flex align-items-center gap-2">
                                        <span style="display:inline-block;width:20px;height:20px;border-radius:4px;background:linear-gradient(135deg,#2c3e50 0%,#4a6274 60%,#34495e 100%);"/>
                                        Dark Slate
                                    </button>
                                </div>

                                <div class="row mb-3" invisible="fc_portal_gradient_preset != 'custom'">
                                    <div class="col-md-4">
                                        <span class="o_form_label">Start Color</span>
                                        <field name="fc_portal_gradient_start" widget="color"/>
                                    </div>
                                    <div class="col-md-4">
                                        <span class="o_form_label">Mid Color</span>
                                        <field name="fc_portal_gradient_mid" widget="color"/>
                                    </div>
                                    <div class="col-md-4">
                                        <span class="o_form_label">End Color</span>
                                        <field name="fc_portal_gradient_end" widget="color"/>
                                    </div>
                                </div>

                                <div class="mb-2">
                                    <span class="o_form_label">Preview</span>
                                    <div class="text-muted small">Preview updates after saving settings.</div>
                                </div>
                                <field name="fc_portal_gradient_preview" widget="html" readonly="1" class="border-0"/>
                            </div>
                        </div>
                    </div>

                    <!-- Hidden fields for field mappings (still needed for ir.config_parameter storage) -->
                    <div class="d-none">
                        <field name="fc_field_sale_type"/>
                        <field name="fc_field_so_client_type"/>
                        <field name="fc_field_so_authorizer"/>
                        <field name="fc_field_invoice_type"/>
                        <field name="fc_field_inv_client_type"/>
                        <field name="fc_field_inv_authorizer"/>
                        <field name="fc_field_product_code"/>
                        <field name="fc_field_sol_serial"/>
                        <field name="fc_field_aml_serial"/>
                        <field name="fc_field_so_claim_number"/>
                        <field name="fc_field_so_client_ref_1"/>
                        <field name="fc_field_so_client_ref_2"/>
                        <field name="fc_field_so_delivery_date"/>
                        <field name="fc_field_so_adp_status"/>
                        <field name="fc_field_so_service_start"/>
                        <field name="fc_field_so_service_end"/>
                        <field name="fc_field_inv_claim_number"/>
                        <field name="fc_field_inv_client_ref_1"/>
                        <field name="fc_field_inv_client_ref_2"/>
                        <field name="fc_field_inv_delivery_date"/>
                        <field name="fc_field_inv_service_start"/>
                        <field name="fc_field_inv_service_end"/>
                        <field name="fc_field_sol_placement"/>
                        <field name="fc_field_aml_placement"/>
                        <field name="fc_field_product_adp_price"/>
                        <field name="fc_field_so_primary_serial"/>
                        <field name="fc_field_inv_primary_serial"/>
                    </div>
                </app>
            </xpath>
        </field>
    </record>
</odoo>
