<?xml version="1.0"?>
<t t-name="mrp.report_mrporder">
    <t t-call="web.html_container">
        <t t-foreach="docs" t-as="o">
            <t t-call="web.internal_layout">
                <div class="page">
                    <div class="oe_structure"/>
                    <div class="row">
                        <div class="col-7">
                            <h2><span t-field="o.name">MRP-001</span></h2>
                        </div>
                        <div class="col-5">
                            <span class="text-end">
                                <span t-field="o.name" t-options="{'widget': 'barcode', 'width': 600, 'height': 100, 'img_style': 'width:350px;height:60px'}">Package barcode</span>
                            </span>
                        </div>
                    </div>
                    <div class="row mt32 mb32">
                        <div class="col-3" t-if="o.origin">
                            <strong>Source:</strong><br/>
                            <span t-field="o.origin">Vendor ABC</span>
                        </div>
                        <div class="col-3" t-if="o.user_id">
                            <strong>Responsible:</strong><br/>
                            <span t-field="o.user_id">John Doe</span>
                        </div>
                        <div class="col-3" t-if="o.state not in ('done', 'cancel') and o.date_deadline">
                            <strong>Deadline:</strong><br/>
                            <span t-field="o.date_deadline">2023-09-15</span>
                        </div>
                    </div>

                    <div class="row mt32 mb32">
                        <div class="col-3">
                            <strong>Product:</strong><br/>
                            <span t-field="o.product_id">Laptop Model X</span>
                        </div>
                        <div class="col-3" t-if="o.product_description_variants">
                            <strong>Description:</strong><br/>
                            <span t-field="o.product_description_variants">Laptop with 16GB RAM</span>
                        </div>
                        <div class="col-3">
                            <strong>Quantity to Produce:</strong><br/>
                            <span t-field="o.product_qty">100</span>
                            <span t-field="o.product_uom_id.name" groups="uom.group_uom">Units</span>
                        </div>
                        <div class="col-3" t-if="o.qty_producing">
                            <strong>Quantity Producing:</strong><br/>
                            <span t-field="o.qty_producing">50</span>
                            <span t-field="o.product_uom_id.name" groups="uom.group_uom">Units</span>
                        </div>
                    </div>

                    <div t-if="o.workorder_ids" groups="mrp.group_mrp_routings">
                        <h3>
                            <span t-if="o.state == 'done'">Operations Done</span>
                            <span t-elif="o.is_planned">Operations Planned</span>
                            <span t-else="">Operations</span>
                        </h3>
                        <table class="table table-sm">
                            <tr>
                                <th><strong>Operation</strong></th>
                                <th><strong>WorkCenter</strong></th>
                                <th><strong>Duration (minutes)</strong></th>
                                <th t-if="o.state in ('progress', 'to_close')"><strong>Actual Duration (minutes)</strong></th>
                                <th style="width:30%"><strong>Barcode</strong></th>
                            </tr>
                            <tr t-foreach="o.workorder_ids" t-as="line2">
                                <td><span t-field="line2.name">Assembling</span></td>
                                <td><span t-field="line2.workcenter_id.name">Center A</span></td>
                                <td>
                                    <span t-if="o.state != 'done'" t-field="line2.duration_expected">60</span>
                                    <span t-if="o.state == 'done'" t-field="line2.duration">58</span>
                                </td>
                                <td t-if="o.state in ('progress', 'to_close')">
                                    <span t-field="line2.duration">58</span>
                                </td>
                                <td>
                                    <span t-field="line2.barcode" t-options="{'widget': 'barcode', 'width': 600, 'height': 100, 'img_style': 'width:100%;height:35px'}">987654321098</span>
                                </td>
                            </tr>
                        </table>
                    </div>

                    <div t-if="o.move_raw_ids">
                        <t t-call="mrp.report_mrp_production_components"/>

                    </div>
                    <div class="oe_structure"/>
                </div>
            </t>
        </t>
    </t>
</t>

