<?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>
    <!-- ===================================================================== -->
    <!-- SUBMISSION VERIFICATION WIZARD FORM -->
    <!-- ===================================================================== -->
    <record id="view_submission_verification_wizard_form" model="ir.ui.view">
        <field name="name">fusion_claims.submission.verification.wizard.form</field>
        <field name="model">fusion_claims.submission.verification.wizard</field>
        <field name="arch" type="xml">
            <form string="ADP Submission Verification">
                <field name="sale_order_id" invisible="1"/>
                
                <sheet>
                    <div class="oe_title mb-3">
                        <h2>
                            <i class="fa fa-clipboard-check text-primary"/> 
                            Stage 1: Submission Verification
                        </h2>
                    </div>
                    
                    <div class="alert alert-info mb-4" role="alert">
                        <p class="mb-0">
                            <strong>Instructions:</strong> Select which device types are being submitted 
                            in the ADP application. This selection will be compared against the 
                            approval letter during Stage 2 verification.
                        </p>
                    </div>
                    
                    <group col="4" class="mb-4">
                        <group colspan="2">
                            <div class="d-flex align-items-center">
                                <span class="badge bg-secondary fs-5 me-2">
                                    <field name="total_device_types" nolabel="1"/>
                                </span>
                                <span class="text-muted">Total Device Types</span>
                            </div>
                        </group>
                        <group colspan="2">
                            <div class="d-flex align-items-center">
                                <span class="badge bg-success fs-5 me-2">
                                    <field name="selected_device_types" nolabel="1"/>
                                </span>
                                <span class="text-muted">Selected for Submission</span>
                            </div>
                        </group>
                    </group>
                    
                    <field name="is_submit_mode" invisible="1"/>
                    <field name="device_type_mapping" invisible="1"/>
                    
                    <notebook>
                        <page string="Device Types" name="device_types">
                            <field name="line_ids" nolabel="1">
                                <list string="Device Types" editable="bottom" create="0" delete="0"
                                      decoration-success="selected" decoration-muted="not selected">
                                    <field name="selected" string="Submit" widget="boolean_toggle"/>
                                    <field name="device_type" string="Device Type" readonly="1" force_save="1"/>
                                    <field name="product_count" string="Products" readonly="1" force_save="1"/>
                                    <field name="adp_portion" string="ADP Portion" widget="monetary" readonly="1" force_save="1"/>
                                    <field name="total_amount" string="Total Amount" widget="monetary" readonly="1" force_save="1"/>
                                    <field name="currency_id" column_invisible="1"/>
                                </list>
                            </field>
                        </page>
                        <page string="Product Details" name="product_details">
                            <field name="line_ids" nolabel="1" readonly="1">
                                <list string="Product Details" create="0" delete="0"
                                      decoration-success="selected" decoration-muted="not selected">
                                    <field name="selected" string="✓" readonly="1"/>
                                    <field name="device_type" string="Device Type"/>
                                    <field name="product_details" string="Products Included"/>
                                    <field name="currency_id" column_invisible="1"/>
                                </list>
                            </field>
                        </page>
                        <!-- Document Upload tab - only visible in Submit Application mode -->
                        <page string="Upload Documents" name="documents" invisible="not is_submit_mode">
                            <div class="alert alert-warning mb-3" role="alert">
                                <strong><i class="fa fa-upload"/> Upload Required Documents</strong>
                                <p class="mb-0">Please upload the final application and XML file for ADP submission.</p>
                            </div>
                            <group>
                                <group string="Final Application (PDF)">
                                    <field name="final_application" filename="final_application_filename"
                                           widget="binary" required="is_submit_mode"/>
                                    <field name="final_application_filename" invisible="1"/>
                                </group>
                                <group string="XML Data File">
                                    <field name="xml_file" filename="xml_filename"
                                           widget="binary" required="is_submit_mode"/>
                                    <field name="xml_filename" invisible="1"/>
                                </group>
                            </group>
                        </page>
                    </notebook>
                </sheet>
                
                <footer>
                    <button name="action_select_all" type="object" 
                            string="Select All" class="btn-outline-secondary"
                            icon="fa-check-square-o"/>
                    <button name="action_confirm_submission" type="object" 
                            string="Confirm Submission" class="btn-primary"
                            icon="fa-paper-plane"/>
                    <button string="Cancel" class="btn-secondary" special="cancel"/>
                </footer>
            </form>
        </field>
    </record>
    
    <!-- ===================================================================== -->
    <!-- ACTION TO OPEN WIZARD -->
    <!-- ===================================================================== -->
    <record id="action_submission_verification_wizard" model="ir.actions.act_window">
        <field name="name">Verify Submission</field>
        <field name="res_model">fusion_claims.submission.verification.wizard</field>
        <field name="view_mode">form</field>
        <field name="target">new</field>
        <field name="binding_model_id" ref="sale.model_sale_order"/>
        <field name="binding_view_types">form</field>
    </record>
</odoo>
