<?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>
    <!-- ADP Export Wizard Form -->
    <record id="view_fusion_claims_export_wizard_form" model="ir.ui.view">
        <field name="name">fusion.central.export.wizard.form</field>
        <field name="model">fusion_claims.export.wizard</field>
        <field name="arch" type="xml">
            <form string="Export ADP Claims">
                <!-- Draft State: Configuration -->
                <group invisible="state == 'done'">
                    <group string="Export Configuration">
                        <field name="vendor_code" placeholder="e.g., 1234567"/>
                        <field name="export_date"/>
                    </group>
                    <group string="Invoices to Export">
                        <field name="invoice_ids" widget="many2many_tags" readonly="1" nolabel="1"/>
                    </group>
                </group>
                
                <!-- Done State: Results -->
                <group invisible="state != 'done'">
                    <div class="alert alert-success" role="alert">
                        <h5><i class="fa fa-check-circle"/> Export Complete!</h5>
                        <field name="export_summary" nolabel="1"/>
                    </div>
                    
                    <!-- Warnings if any -->
                    <div class="alert alert-warning" role="alert" invisible="not warnings">
                        <h5><i class="fa fa-exclamation-triangle"/> Warnings</h5>
                        <field name="warnings" nolabel="1"/>
                    </div>
                    
                    <group string="Download Export File">
                        <field name="export_filename" readonly="1"/>
                        <field name="export_file" filename="export_filename" readonly="1"/>
                    </group>
                    
                    <div class="text-muted small" invisible="not saved_to_export_records">
                        <i class="fa fa-folder-open"/> File saved to Fusion Claims &gt; ADP &gt; Export Files
                    </div>
                </group>
                
                <field name="state" invisible="1"/>
                <field name="saved_to_export_records" invisible="1"/>
                <field name="warnings" invisible="1"/>
                
                <footer>
                    <button string="Export" name="action_export" type="object" 
                            class="btn-primary" invisible="state == 'done'"
                            icon="fa-download"/>
                    <button string="Download" class="btn-primary" invisible="state != 'done'"
                            special="cancel"/>
                    <button string="Close" class="btn-secondary" special="cancel"/>
                </footer>
            </form>
        </field>
    </record>

    <!-- Menu Action -->
    <record id="action_fusion_claims_export_wizard" model="ir.actions.act_window">
        <field name="name">Export ADP Claims</field>
        <field name="res_model">fusion_claims.export.wizard</field>
        <field name="view_mode">form</field>
        <field name="target">new</field>
    </record>
</odoo>
