<?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>
    <!-- ===================================================================== -->
    <!-- CASE CLOSE VERIFICATION WIZARD FORM -->
    <!-- ===================================================================== -->
    <record id="view_case_close_verification_wizard_form" model="ir.ui.view">
        <field name="name">fusion_claims.case.close.verification.wizard.form</field>
        <field name="model">fusion_claims.case.close.verification.wizard</field>
        <field name="arch" type="xml">
            <form string="Close Case - Audit Trail Verification">
                <field name="sale_order_id" invisible="1"/>
                <field name="all_verified" invisible="1"/>
                
                <!-- Header Banner -->
                <div class="alert alert-info mb-3" role="alert">
                    <h5 class="mb-2"><i class="fa fa-clipboard-check"/> Audit Trail Verification</h5>
                    <p class="mb-0">
                        Before closing this case, please verify all required documents are uploaded
                        and vendor bills are linked for audit purposes.
                    </p>
                </div>
                
                <!-- Missing Items Warning -->
                <div class="alert alert-warning mb-3" role="alert" invisible="all_verified">
                    <h5 class="mb-2"><i class="fa fa-exclamation-triangle"/> Missing Items</h5>
                    <field name="missing_items" nolabel="1" readonly="1" 
                           widget="text" style="white-space: pre-wrap;"/>
                </div>
                
                <!-- All Verified Success -->
                <div class="alert alert-success mb-3" role="alert" invisible="not all_verified">
                    <h5 class="mb-0"><i class="fa fa-check-circle"/> All Items Verified</h5>
                    <p class="mb-0">All required documents and vendor bills are present.</p>
                </div>
                
                <!-- Verification Checklist -->
                <group string="Document Checklist">
                    <group>
                        <div class="d-flex align-items-center mb-2">
                            <field name="has_signed_pages" widget="boolean" readonly="1" class="me-2"/>
                            <span>Signed Pages 11 &amp; 12</span>
                        </div>
                        <div class="d-flex align-items-center mb-2">
                            <field name="has_final_application" widget="boolean" readonly="1" class="me-2"/>
                            <span>Final Application</span>
                        </div>
                    </group>
                    <group>
                        <div class="d-flex align-items-center mb-2">
                            <field name="has_proof_of_delivery" widget="boolean" readonly="1" class="me-2"/>
                            <span>Proof of Delivery</span>
                        </div>
                        <div class="d-flex align-items-center mb-2">
                            <field name="has_vendor_bills" widget="boolean" readonly="1" class="me-2"/>
                            <span>Vendor Bills (<field name="vendor_bill_count" readonly="1" class="oe_inline"/> linked)</span>
                        </div>
                    </group>
                </group>
                
                <!-- Closing Notes -->
                <group string="Closing Notes (Optional)">
                    <field name="closing_notes" nolabel="1" placeholder="Enter any notes for this case closure..."
                           colspan="2"/>
                </group>
                
                <footer>
                    <button name="action_close_case" type="object" 
                            string="Close Case" class="btn-primary"
                            invisible="not all_verified"/>
                    <button name="action_close_case" type="object" 
                            string="Close Case" class="btn-secondary"
                            invisible="all_verified"
                            confirm="Some items are missing. Are you sure you want to close this case?"/>
                    <button name="action_close_anyway" type="object" 
                            string="Close Anyway (Incomplete)" class="btn-warning"
                            invisible="all_verified"
                            confirm="This will close the case with an incomplete audit trail. Continue?"/>
                    <button string="Cancel" class="btn-secondary" special="cancel"/>
                </footer>
            </form>
        </field>
    </record>

    <!-- ===================================================================== -->
    <!-- CASE CLOSE VERIFICATION WIZARD ACTION -->
    <!-- ===================================================================== -->
    <record id="action_case_close_verification_wizard" model="ir.actions.act_window">
        <field name="name">Close Case</field>
        <field name="res_model">fusion_claims.case.close.verification.wizard</field>
        <field name="view_mode">form</field>
        <field name="target">new</field>
        <field name="binding_model_id" ref="sale.model_sale_order"/>
    </record>
</odoo>
