<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <template id="report_timesheet_document">
            <t t-call="web.external_layout">
                <t t-set="o" t-value="o.with_context(lang=lang)" />
                <div class="page">
                    <h2>
                        Feuille de Temps
                    </h2>

                    <div id="informations" class="row mt32 mb32">
                        <div class="col-auto mw-100 mb-2" name="employee">
                            <strong>Employé</strong>
                            <p class="m-0" t-field="o.user_id.name"/>
                        </div>
                        <div class="col-auto mw-100 mb-2" >
                            <strong>Date de début</strong>
                            <p class="m-0" t-field="o.date_start"/>
                        </div>
                        <div class="col-auto mw-100 mb-2" name="date_end">
                            <strong>Date de fin</strong>
                            <p class="m-0" t-field="o.date_end"/>
                        </div>
                    </div>

                    <table class="table table-sm o_main_table" name="invoice_line_table">
                        <thead>
                            <tr>
                                <th class="text-left"><span>Date</span></th>
                                <th class="text-left"><span>Code activité UR</span></th>
                                <th class="text-left"><span>Contact</span></th>
                                <th class="text-left"><span>Dispositif</span></th>
                                <th class="text-left"><span>Durée</span></th>
                            </tr>
                        </thead>
                        <tbody class="invoice_tbody">
                            <t t-foreach="o.timesheet_ids" t-as="line">
                                <tr>
                                    <td><span t-field="line.date"/></td>
                                    <td><span t-field="line.project_id"/></td>
                                    <td><span t-field="line.partner_id"/></td>
                                    <td><span t-field="line.ur_financial_system_id"/></td>
                                    <td class="text-right"><span t-field="line.unit_amount" t-options="{'widget': 'duration', 'digital': True, 'unit': 'hour', 'round': 'minute'}"/></td>
                                </tr>
                            </t>
                            <tr>
                                <td />
                                <td />
                                <td />
                                <td class="text-right"><strong>Total</strong></td>
                                <td class="text-right"><strong t-esc="sum(o.timesheet_ids.mapped('unit_amount'))" t-options="{'widget': 'duration', 'digital': True, 'unit': 'hour', 'round': 'minute'}"/></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </t>
        </template>

        <template id="report_timesheet">
            <t t-call="web.html_container">
                <t t-foreach="docs" t-as="o">
                    <t t-set="lang" t-value="o.user_id.lang"/>
                    <t t-call="cgscop_timesheet.report_timesheet_document" t-lang="lang"/>
                </t>
            </t>
        </template>

        <!-- QWeb Reports -->
        <report
            id="cgscop_timesheet_report"
            model="cgscop.timesheet.print"
            string="Feuilles de Temps"
            report_type="qweb-pdf"
            name="cgscop_timesheet.report_timesheet"
            file="cgscop_timesheet.report_timesheet"
            menu="False"
        />

        
    </data>
</odoo>