<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <!-- Cheque Layout Settings Form View -->
    <record id="view_cheque_layout_settings_form" model="ir.ui.view">
        <field name="name">cheque.layout.settings.form</field>
        <field name="model">cheque.layout.settings</field>
        <field name="arch" type="xml">
            <form string="Cheque Layout Settings">
                <header>
                    <button name="action_open_preview" type="object" string="Visual Preview" class="btn-primary" icon="fa-eye"/>
                    <button name="action_set_as_default" type="object" string="Set as Default" invisible="is_default"/>
                </header>
                <sheet>
                    <div class="oe_button_box" name="button_box">
                        <button name="action_open_preview" type="object" class="oe_stat_button" icon="fa-image">
                            <span>Preview</span>
                        </button>
                    </div>
                    <widget name="web_ribbon" title="Default" bg_color="text-bg-success" invisible="not is_default"/>
                    <div class="oe_title">
                        <h1>
                            <field name="name" placeholder="Layout Name"/>
                        </h1>
                    </div>
                    <group>
                        <group>
                            <field name="company_id" groups="base.group_multi_company"/>
                            <field name="is_default" readonly="1"/>
                            <field name="active"/>
                        </group>
                        <group>
                            <field name="cheque_image" widget="image" options="{'size': [200, 260]}"/>
                            <field name="cheque_image_filename" invisible="1"/>
                        </group>
                    </group>
                    
                    <notebook>
                        <!-- Page Settings -->
                        <page string="Page &amp; Sections" name="page_settings">
                            <group>
                                <group string="Page Size">
                                    <field name="page_width"/>
                                    <field name="page_height"/>
                                </group>
                            </group>
                            <group>
                                <group string="Section 1: Cheque (Top)">
                                    <field name="section1_height"/>
                                </group>
                                <group string="Section 2: Stub 1 (Middle)">
                                    <field name="section2_start"/>
                                    <field name="section2_height"/>
                                </group>
                            </group>
                            <group>
                                <group string="Section 3: Stub 2 (Bottom)">
                                    <field name="section3_start"/>
                                    <field name="section3_height"/>
                                </group>
                            </group>
                        </page>
                        
                        <!-- Cheque Section Positions -->
                        <page string="Cheque Positions" name="cheque_positions">
                            <group>
                                <group string="Date Position">
                                    <field name="date_x" string="X Position (inches)"/>
                                    <field name="date_y" string="Y Position (inches)"/>
                                    <field name="date_font_size"/>
                                </group>
                                <group string="Amount Position">
                                    <field name="amount_x" string="X Position (inches)"/>
                                    <field name="amount_y" string="Y Position (inches)"/>
                                    <field name="amount_font_size"/>
                                </group>
                            </group>
                            <group>
                                <group string="Amount in Words Position">
                                    <field name="amount_words_x" string="X Position (inches)"/>
                                    <field name="amount_words_y" string="Y Position (inches)"/>
                                    <field name="amount_words_font_size"/>
                                </group>
                                <group string="Payee Name Position">
                                    <field name="payee_x" string="X Position (inches)"/>
                                    <field name="payee_y" string="Y Position (inches)"/>
                                    <field name="payee_font_size"/>
                                </group>
                            </group>
                            <group>
                                <group string="Payee Address Position">
                                    <field name="payee_address_x" string="X Position (inches)"/>
                                    <field name="payee_address_y" string="Y Position (inches)"/>
                                    <field name="payee_address_font_size"/>
                                </group>
                                <group string="Pay Period Position">
                                    <field name="cheque_pay_period_x" string="X Position (inches)"/>
                                    <field name="cheque_pay_period_y" string="Y Position (inches)"/>
                                </group>
                                <group string="Memo Position">
                                    <field name="memo_x" string="X Position (inches)"/>
                                    <field name="memo_y" string="Y Position (inches)"/>
                                    <field name="memo_font_size"/>
                                </group>
                            </group>
                        </page>
                        
                        <!-- Stub Section Settings -->
                        <page string="Stub Settings" name="stub_settings">
                            <group>
                                <group string="Layout Options">
                                    <field name="stub_full_width"/>
                                    <field name="stub_center_data"/>
                                    <field name="stub_content_margin" invisible="not stub_center_data"/>
                                </group>
                                <group string="Stub Padding (inches)">
                                    <field name="stub_padding_top"/>
                                    <field name="stub_padding_left"/>
                                    <field name="stub_padding_right"/>
                                    <field name="stub_padding_bottom"/>
                                </group>
                            </group>
                            <group>
                                <group string="Column Widths (%)">
                                    <field name="col1_width" string="Employee Info"/>
                                    <field name="col2_width" string="PAY/Benefits"/>
                                    <field name="col3_width" string="Taxes/Deductions"/>
                                    <field name="col4_width" string="Summary"/>
                                </group>
                                <group string="Font Sizes (pt)">
                                    <field name="stub_title_font_size"/>
                                    <field name="stub_content_font_size"/>
                                    <field name="stub_header_font_size"/>
                                </group>
                            </group>
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>

    <!-- Cheque Layout Settings List View -->
    <record id="view_cheque_layout_settings_tree" model="ir.ui.view">
        <field name="name">cheque.layout.settings.list</field>
        <field name="model">cheque.layout.settings</field>
        <field name="arch" type="xml">
            <list string="Cheque Layout Settings">
                <field name="name"/>
                <field name="company_id" groups="base.group_multi_company"/>
                <field name="is_default"/>
                <field name="active"/>
            </list>
        </field>
    </record>

    <!-- Cheque Layout Settings Action -->
    <record id="action_cheque_layout_settings" model="ir.actions.act_window">
        <field name="name">Cheque Layout Settings</field>
        <field name="res_model">cheque.layout.settings</field>
        <field name="view_mode">list,form</field>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                Configure cheque print layout
            </p>
            <p>
                Set up the exact X/Y positions for all fields on your pre-printed cheque stock.
                Upload an image of your cheque for visual alignment preview.
            </p>
        </field>
    </record>

    <!-- Preview Wizard Form View -->
    <record id="view_cheque_layout_preview_wizard_form" model="ir.ui.view">
        <field name="name">cheque.layout.preview.wizard.form</field>
        <field name="model">cheque.layout.preview.wizard</field>
        <field name="arch" type="xml">
            <form string="Cheque Layout Preview">
                <sheet>
                    <group>
                        <group string="Upload Cheque Image">
                            <field name="cheque_image" widget="image" options="{'size': [300, 400]}"/>
                        </group>
                    </group>
                    
                    <notebook>
                        <page string="Section Dividers" name="sections">
                            <group>
                                <group>
                                    <field name="section1_height" string="Cheque End (in)"/>
                                    <field name="section2_start" string="Stub 1 Start (in)"/>
                                    <field name="section3_start" string="Stub 2 Start (in)"/>
                                </group>
                            </group>
                        </page>
                        
                        <page string="Cheque Fields" name="cheque_fields">
                            <group>
                                <group string="Date">
                                    <field name="date_x" string="X (in)"/>
                                    <field name="date_y" string="Y (in)"/>
                                </group>
                                <group string="Amount">
                                    <field name="amount_x" string="X (in)"/>
                                    <field name="amount_y" string="Y (in)"/>
                                </group>
                            </group>
                            <group>
                                <group string="Amount in Words">
                                    <field name="amount_words_x" string="X (in)"/>
                                    <field name="amount_words_y" string="Y (in)"/>
                                </group>
                                <group string="Payee Name">
                                    <field name="payee_x" string="X (in)"/>
                                    <field name="payee_y" string="Y (in)"/>
                                </group>
                            </group>
                            <group>
                                <group string="Payee Address">
                                    <field name="payee_address_x" string="X (in)"/>
                                    <field name="payee_address_y" string="Y (in)"/>
                                </group>
                                <group string="Pay Period">
                                    <field name="cheque_pay_period_x" string="X (in)"/>
                                    <field name="cheque_pay_period_y" string="Y (in)"/>
                                </group>
                                <group string="Memo">
                                    <field name="memo_x" string="X (in)"/>
                                    <field name="memo_y" string="Y (in)"/>
                                </group>
                            </group>
                        </page>
                        
                        <page string="Stub Padding" name="stub_padding">
                            <group>
                                <group>
                                    <field name="stub_padding_top" string="Top Padding (in)"/>
                                    <field name="stub_padding_left" string="Left Padding (in)"/>
                                </group>
                            </group>
                        </page>
                    </notebook>
                    
                    <separator string="Live Preview"/>
                    <group>
                        <field name="preview_html" nolabel="1" colspan="2"/>
                    </group>
                </sheet>
                <footer>
                    <button name="action_save_and_close" type="object" string="Save &amp; Close" class="btn-primary"/>
                    <button name="action_print_test" type="object" string="Print Test" class="btn-secondary"/>
                    <button string="Cancel" class="btn-secondary" special="cancel"/>
                </footer>
            </form>
        </field>
    </record>

    <!-- Menu Item -->
    <!-- Menu will be added in fusion_payroll_menus.xml after parent is defined -->

</odoo>
