<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <record id="view_page11_sign_request_list" model="ir.ui.view">
        <field name="name">fusion.page11.sign.request.list</field>
        <field name="model">fusion.page11.sign.request</field>
        <field name="arch" type="xml">
            <list>
                <field name="sale_order_id"/>
                <field name="signer_name"/>
                <field name="signer_email"/>
                <field name="signer_type"/>
                <field name="sent_date"/>
                <field name="signed_date"/>
                <field name="expiry_date"/>
                <field name="state" widget="badge"
                       decoration-success="state == 'signed'"
                       decoration-info="state == 'sent'"
                       decoration-warning="state == 'expired'"
                       decoration-danger="state == 'cancelled'"/>
            </list>
        </field>
    </record>

    <record id="view_page11_sign_request_form" model="ir.ui.view">
        <field name="name">fusion.page11.sign.request.form</field>
        <field name="model">fusion.page11.sign.request</field>
        <field name="arch" type="xml">
            <form string="Page 11 Signing Request">
                <header>
                    <button name="action_resend" type="object" string="Resend Email"
                            class="btn-primary" invisible="state not in ('sent', 'expired')"/>
                    <button name="action_request_new_signature" type="object"
                            string="Request New Signature"
                            class="btn-warning" invisible="state not in ('signed', 'cancelled')"
                            confirm="This will cancel the current signed version and open a new signing request. Continue?"/>
                    <button name="action_cancel" type="object" string="Cancel"
                            class="btn-secondary" invisible="state not in ('draft', 'sent')"/>
                    <field name="state" widget="statusbar"
                           statusbar_visible="draft,sent,signed"/>
                </header>
                <sheet>
                    <group>
                        <group string="Request Details">
                            <field name="sale_order_id" readonly="1"/>
                            <field name="signer_name"/>
                            <field name="signer_email"/>
                            <field name="signer_type"/>
                            <field name="signer_relationship"
                                   invisible="signer_type == 'client'"/>
                        </group>
                        <group string="Dates">
                            <field name="sent_date" readonly="1"/>
                            <field name="expiry_date"/>
                            <field name="signed_date" readonly="1"/>
                        </group>
                    </group>
                    <group string="Consent" invisible="state != 'signed'">
                        <field name="consent_signed_by"/>
                        <field name="consent_declaration_accepted"/>
                    </group>
                    <group string="Agent Details"
                           invisible="consent_signed_by != 'agent' or state != 'signed'">
                        <group>
                            <field name="agent_first_name"/>
                            <field name="agent_last_name"/>
                            <field name="agent_phone"/>
                        </group>
                        <group>
                            <field name="agent_street"/>
                            <field name="agent_city"/>
                            <field name="agent_province"/>
                            <field name="agent_postal_code"/>
                        </group>
                    </group>
                    <group string="Signature" invisible="state != 'signed'">
                        <field name="signature_data" widget="image" readonly="1"/>
                    </group>
                    <group string="Signed PDF" invisible="state != 'signed' or not signed_pdf">
                        <field name="signed_pdf" filename="signed_pdf_filename"/>
                        <field name="signed_pdf_filename" invisible="1"/>
                    </group>
                    <group string="Custom Message" invisible="not custom_message">
                        <field name="custom_message" readonly="1" nolabel="1"/>
                    </group>
                </sheet>
            </form>
        </field>
    </record>
</odoo>
