<?xml version="1.0"?>
<t name="My Timesheets" t-name="hr_timesheet.portal_my_timesheets">
        <t t-call="portal.portal_layout">
            <t t-set="breadcrumbs_searchbar" t-value="True"/>

            <t t-call="portal.portal_searchbar">
                <t t-set="title">Timesheets</t>
            </t>
            <t t-if="not grouped_timesheets">
                <div class="alert alert-warning" role="alert">
                    There are no timesheets.
                </div>
            </t>
            <t t-if="grouped_timesheets">
                <t t-call="portal.portal_table">
                    <thead>
                        <tr>
                            <th t-if="not groupby == 'date'">Date</th>
                            <th t-if="not groupby == 'employee_id'">Employee</th>
                            <th t-if="not groupby == 'project_id'">Project</th>
                            <th t-if="not groupby == 'task_id'">Task</th>
                            <th>Description</th>
                            <th class="text-end" t-att-colspan="2 if groupby != 'none' else 0" name="t_label">Time Spent</th>
                        </tr>
                    </thead>
                    <t t-foreach="grouped_timesheets" t-as="timesheets_with_hours">
                        <t t-set="timesheets" t-value="timesheets_with_hours[0]"/>
                        <t t-set="hours_spent" t-value="timesheets_with_hours[1]"/>
                        <tbody style="font-size: 0.8rem">
                            <tr t-if="not groupby =='none'" class="table-light">
                                <t t-if="groupby == 'project_id'">
                                    <th colspan="5">
                                        <span t-field="timesheets[0].project_id.name"/>
                                    </th>
                                </t>
                                <t t-elif="groupby == 'task_id'">
                                    <th colspan="5">
                                        <span t-if="timesheets[0].task_id" t-field="timesheets[0].task_id.name"/>
                                        <span t-else="">No Task</span>
                                    </th>
                                </t>
                                <t t-elif="groupby == 'date'">
                                    <th colspan="5">
                                        <span t-field="timesheets[0].date"/>
                                    </th>
                                </t>
                                <t t-elif="groupby == 'employee_id'">
                                    <th colspan="5">
                                        <span t-field="timesheets[0].employee_id.name"/>
                                    </th>
                                </t>
                                <t t-elif="groupby == 'parent_task_id'">
                                    <th colspan="6">
                                        <span t-if="timesheets[0].parent_task_id" t-field="timesheets[0].parent_task_id.name"/>
                                        <span t-else="">No Parent Task</span>
                                    </th>
                                </t>
                                <th colspan="1" class="text-end text-muted">
                                    <t t-if="is_uom_day">
                                        Total: <span t-esc="timesheets._convert_hours_to_days(hours_spent)" t-options="{&quot;widget&quot;: &quot;timesheet_uom&quot;}"/>
                                    </t>
                                    <t t-else="">
                                        Total: <span t-esc="hours_spent" t-options="{&quot;widget&quot;: &quot;float_time&quot;}"/>
                                    </t>
                                </th>
                            </tr>
                        </tbody>
                        <tbody style="font-size: 0.8rem">
                            <t t-foreach="timesheets" t-as="timesheet">
                                <tr>
                                    <td t-if="not groupby == 'date'"><span t-field="timesheet.date" t-options="{&quot;widget&quot;: &quot;date&quot;}"/></td>
                                    <td t-if="not groupby == 'employee_id'"><span t-field="timesheet.employee_id" t-att-title="timesheet.employee_id.display_name"/></td>
                                    <td t-if="not groupby == 'project_id'"><span t-field="timesheet.project_id" t-att-title="timesheet.project_id.display_name"/></td>
                                    <td t-if="not groupby == 'task_id'"><span t-field="timesheet.task_id" t-att-title="timesheet.task_id.display_name"/></td>
                                    <td><span t-esc="timesheet.name" t-att-title="timesheet.name"/></td>
                                    <td class="text-end" t-att-colspan="2 if groupby != 'none' else 0">
                                        <span t-if="is_uom_day" t-esc="timesheet._get_timesheet_time_day()" t-options="{&quot;widget&quot;: &quot;timesheet_uom&quot;}"/>
                                        <span t-else="" t-field="timesheet.unit_amount" t-options="{&quot;widget&quot;: &quot;float_time&quot;}"/>
                                    </td>
                                </tr>
                            </t>
                        </tbody>
                    </t>
                </t>
            </t>
        </t>
    </t>

    