<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!-- Application Received Wizard Form View -->
    <record id="view_application_received_wizard_form" model="ir.ui.view">
        <field name="name">fusion_claims.application.received.wizard.form</field>
        <field name="model">fusion_claims.application.received.wizard</field>
        <field name="arch" type="xml">
            <form string="Application Received">
                <div class="alert alert-info mb-3" role="alert">
                    <strong><i class="fa fa-info-circle"/> Upload Required Documents</strong>
                    <p class="mb-0">Please upload the ADP application documents received from the client.</p>
                </div>

                <field name="sale_order_id" invisible="1"/>
                <field name="has_pending_page11_request" invisible="1"/>
                <field name="has_signed_page11" invisible="1"/>

                <group>
                    <group string="Original ADP Application">
                        <field name="original_application" filename="original_application_filename"
                               widget="binary" class="oe_inline"/>
                        <field name="original_application_filename" invisible="1"/>
                    </group>
                    
                    <group string="Signed Pages 11 &amp; 12">
                        <field name="signed_pages_11_12" filename="signed_pages_filename"
                               widget="binary" class="oe_inline"/>
                        <field name="signed_pages_filename" invisible="1"/>

                        <div invisible="has_signed_page11" class="mt-2">
                            <span class="text-muted small">Don't have signed pages? </span>
                            <button name="action_request_page11_signature" type="object"
                                    string="Request Remote Signature"
                                    class="btn btn-sm btn-outline-warning"
                                    icon="fa-pencil-square-o"
                                    help="Send Page 11 to a family member or agent for digital signing"/>
                        </div>

                        <div invisible="not has_pending_page11_request" class="mt-2">
                            <div class="alert alert-warning mb-0 py-2 px-3">
                                <i class="fa fa-clock-o"/> A remote signing request has been sent.
                                You can proceed without uploading signed pages -- they will be auto-filled when signed.
                            </div>
                        </div>

                        <div invisible="not has_signed_page11 or signed_pages_11_12" class="mt-2">
                            <div class="alert alert-success mb-0 py-2 px-3">
                                <i class="fa fa-check-circle"/> Page 11 has been signed remotely.
                            </div>
                        </div>
                    </group>
                </group>
                
                <group>
                    <field name="notes" placeholder="Any notes about the received application..."/>
                </group>
                
                <footer>
                    <button name="action_confirm" type="object" 
                            string="Confirm Application Received" class="btn-primary"
                            icon="fa-check"/>
                    <button string="Cancel" class="btn-secondary" special="cancel"/>
                </footer>
            </form>
        </field>
    </record>

    <!-- Action for the wizard -->
    <record id="action_application_received_wizard" model="ir.actions.act_window">
        <field name="name">Application Received</field>
        <field name="res_model">fusion_claims.application.received.wizard</field>
        <field name="view_mode">form</field>
        <field name="target">new</field>
    </record>
</odoo>
