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

    <!-- Generic Payroll Report PDF Template -->
    <template id="payroll_report_pdf_template">
        <t t-call="web.html_container">
            <t t-call="web.external_layout">
                <div class="page">
                    <!-- Header -->
                    <div class="row mb-4">
                        <div class="col-8">
                            <h2><t t-out="options.get('report_name', 'Payroll Report')"/></h2>
                            <p class="text-muted mb-0">
                                <t t-if="options.get('date')">
                                    Period: <t t-out="options['date'].get('date_from', '')"/> 
                                    to <t t-out="options['date'].get('date_to', '')"/>
                                </t>
                            </p>
                        </div>
                        <div class="col-4 text-end">
                            <strong><t t-out="company.name"/></strong><br/>
                            <small class="text-muted">
                                Generated: <t t-out="datetime.datetime.now().strftime('%Y-%m-%d %H:%M')"/>
                            </small>
                        </div>
                    </div>

                    <!-- Report Table -->
                    <table class="table table-sm table-bordered">
                        <thead class="table-dark">
                            <tr>
                                <t t-foreach="columns" t-as="column">
                                    <th t-att-class="column.get('type') in ['monetary', 'float'] and 'text-end' or ''">
                                        <t t-out="column.get('name', '')"/>
                                    </th>
                                </t>
                            </tr>
                        </thead>
                        <tbody>
                            <t t-foreach="lines" t-as="line">
                                <tr t-att-class="line.get('level', 0) &lt; 0 and 'fw-bold' or ''">
                                    <t t-foreach="columns" t-as="column">
                                        <td t-att-class="column.get('type') in ['monetary', 'float'] and 'text-end' or ''">
                                            <t t-set="value" t-value="line.get('values', {}).get(column.get('field'), '')"/>
                                            <t t-if="column.get('type') == 'monetary' and value">
                                                $<t t-out="'{:,.2f}'.format(float(value))"/>
                                            </t>
                                            <t t-elif="column.get('type') == 'float' and value">
                                                <t t-out="'{:,.2f}'.format(float(value))"/>
                                            </t>
                                            <t t-else="">
                                                <t t-out="value"/>
                                            </t>
                                        </td>
                                    </t>
                                </tr>
                            </t>
                        </tbody>
                    </table>

                    <!-- Footer -->
                    <div class="row mt-4">
                        <div class="col-12 text-center">
                            <small class="text-muted">
                                This report is computer-generated. Please retain for your records.
                            </small>
                        </div>
                    </div>
                </div>
            </t>
        </t>
    </template>

</odoo>
