<odoo>
  <record id="action_report_dc" model="ir.actions.report">
        <field name="name">DC Form</field>
        <field name="model">sos_dc</field>
        <field name="report_type">qweb-pdf</field>
        <field name="report_name">sos_inventory.report_dc</field>
        <field name="report_file">sos_inventory.report_dc</field>
        <field name="binding_model_id" eval="False"/>
        <field name="binding_type">report</field>
    </record>

<template id="report_dc">
    <t t-call="web.html_container">
        <t t-foreach="docs" t-as="o">
            <t t-call="web.external_layout">
                <link rel="stylesheet" href="/sos_inventory/static/src/css/style.css" />
                <t t-foreach="['Acknowledgement Copy', 'Customer Copy', 'Logistics Copy', 'Original Copy', 'Duplicate Copy']" t-as="copy_label">
                    <div class="page">
<t t-if="o.dc_type == 'customer_return'">
<h2 style="text-align:center">Delivery Challan - Returnable</h2>
<h5 style="text-align:center">Not For Sale</h5>
</t>
<t t-if="o.dc_type == 'out_souce_return'">
<h2 style="text-align:center">Delivery Challan - Returnable</h2>
<h5 style="text-align:center">Not For Sale</h5>

</t>
<t t-if="o.dc_type == 'customer_noreturn'">
<h2 style="text-align:center">Delivery Challan - Non-Returnable</h2>
</t>
<t t-if="o.dc_type == 'out_souce_noreturn'">
<h2 style="text-align:center">Delivery Challan - Non-Returnable</h2>
</t>
<t t-if="o.dc_type == 'others'">
<h2 style="text-align:center">Delivery Challan</h2>
</t>

                        <br/>
                        <!-- HTML Table -->
                    <table class="table table-bordered">
    <tbody>
        <tr>
            <!-- Left Side: Shipping and Billing Address -->
            <td style="width: 50%; vertical-align: top;">
                <span class="column">Shipping Address</span><br/><br/>
                <t t-if="o.service_provider_name.service_provider_name">
                    <t t-esc="o.service_provider_name.service_provider_name"/><br/>
                </t>
                <t t-if="o.to_address">
                    <t t-foreach="o.to_address.split(',')" t-as="part">
                        <t t-esc="part"/><br/>
                    </t>
                </t>
                <br/>
                <hr></hr>
                <span class="column">Billing Address</span><br/><br/>
                <t t-if="o.billing_address">
                    <t t-foreach="o.billing_address.split(',')" t-as="part">
                        <t t-esc="part"/><br/>
                    </t>
                </t>
                 <t t-if="o.customer_gst_no">
                 <hr></hr>
                 <span class="column">GST No</span><br/><br/>
                 <t t-esc="o.customer_gst_no"/>
                 </t>
                
            </td>

            <!-- Right Side: Other Fields -->
            <td style="width: 50%; vertical-align: top;">
                <table class="table table-bordered" style="margin-bottom: 0;">
                    <tr>
                        <td class="column">D.C. No</td>
                        <td><t t-esc="o.dc_no"/></td>
                    </tr>
                    <tr>
                        <td class="column">D.C. Date</td>
                        <td><t t-esc="o.dc_date"/></td>
                    </tr>
                    <tr>
                        <td class="column">Mode of Dispatch</td>
                        <td><t t-esc="o.dispatch_mode"/></td>
                    </tr>
                    <tr>
                        <td class="column">From Station</td>
                        <td><t t-esc="o.from_station"/></td>
                    </tr>
                    <tr>
                        <td class="column">To Station</td>
                        <td><t t-esc="o.to_station"/></td>
                    </tr>
                    <tr>
                        <td class="column">Purpose</td>
                        <td><t t-esc="o.purpose_remarks"/></td>
                    </tr>
                    <t t-if="o.invoice_no">
                    <tr>
                        <td class="column">Invoice No</td>
                        <td><t t-esc="o.invoice_no"/></td>
                    </tr>
                </t>
                <t t-if="o.po_no">
                    <tr>
                        <td class="column">PO No</td>
                        <td><t t-esc="o.po_no"/></td>
                    </tr>
                </t>

                    <t t-if="o.dispatch_mode == 'By Hand'">
                        <tr>
                            <td class="column">Carried By</td>
                            <td><t t-esc="o.carried_by.name"/></td>
                        </tr>
                    </t>
<t t-if="o.dc_type == 'out_souce_return'">
    <tr>
        <td class="column">Work Order No</td>
        <td><t t-esc="o.wo_no.wo_no"/></td>
    </tr>
    
    <t t-if="o.auto_load_sfg_items">
        <tr>
            <td class="column">SFG Items</td>
            <td>
                <ul>
                    <t t-foreach="o.auto_load_sfg_items" t-as="sfg">
                        <li><t t-esc="sfg.name"/></li>
                    </t>
                </ul>
            </td>
        </tr>
    </t>
</t>

                </table>
            </td>
        </tr>
    </tbody>
</table>

                        <br/>
                          <t t-if="len(o.line_ids_fg) > 0">
                        <table class="table table-bordered">
                            <tbody>
                            <tr><td colspan="5" class="column" style="background-color:#ccc">Finished Goods</td></tr>
                                <tr class="column">
                                    <td>S.No</td>
                                    <td>Name</td>
                                    <td>Serial/Batch No</td>
                                    <td>UOM</td>
                                    <td>Qty</td>
                                </tr>
                                <t t-foreach="o.line_ids_fg" t-as="line_items" t-index="index">
                                    <tr>
                                        <td><t t-esc="line_items_index + 1"/></td>
                                        <td><t t-esc="line_items.component_id.name"/></td>
                                         <td><t t-esc="line_items.serial_no"/></td>
                                        <td><t t-esc="line_items.uom"/></td>
                                        <td><t t-esc="line_items.qty"/></td>
                                    </tr>
                                </t>
                            </tbody>
                        </table>
                        </t>
                         <br/>
                        <t t-if="len(o.line_ids_materials) > 0">
                        <table class="table table-bordered">
                            <tbody>
                            <tr><td colspan="4" class="column" style="background-color:#ccc">Materials</td></tr>
                                <tr class="column">
                                    <td>S.No</td>
                                    <td>Name</td>
                                    <td>UOM</td>
                                    <td>Qty</td>
                                </tr>
                                <t t-foreach="o.line_ids_materials" t-as="line_items" t-index="index">
                                    <tr>
                                        <td><t t-esc="line_items_index + 1"/></td>
                                        <td><t t-esc="line_items.display_name"/></td>
                                        <td><t t-esc="line_items.uom"/></td>
                                        <td><t t-esc="line_items.qty"/></td>
                                    </tr>
                                </t>
                            </tbody>
                        </table>
                        </t>
                         <br/>
                          <t t-if="len(o.line_ids_sfg) > 0">
                        <table class="table table-bordered">
                            <tbody>
                            <tr><td colspan="4" class="column" style="background-color:#ccc">Accessories</td></tr>
                                <tr class="column">
                                    <td>S.No</td>
                                    <td>Name</td>
                                    <td>UOM</td>
                                    <td>Qty</td>
                                </tr>
                                <t t-foreach="o.line_ids_sfg" t-as="line_items" t-index="index">
                                    <tr>
                                        <td><t t-esc="line_items_index + 1"/></td>
                                        <td><t t-esc="line_items.component_id.name"/></td>
                                        <td><t t-esc="line_items.uom"/></td>
                                        <td><t t-esc="line_items.qty"/></td>
                                    </tr>
                                </t>
                            </tbody>
                        </table>
                        </t>
                        <br/>
                        
                        <t t-if="len(o.line_ids) > 0">
                        <table class="table table-bordered">
                            <tbody>
                            <tr><td colspan="4" class="column" style="background-color:#ccc">Materials</td></tr>
                                <tr class="column">
                                    <td>S.No</td>
                                    <td>Name</td>
                                    <td>UOM</td>
                                    <td>Given Qty</td>
                                </tr>
                                <t t-foreach="o.line_ids" t-as="line_items" t-index="index">
                                    <tr>
                                        <td><t t-esc="line_items_index + 1"/></td>
                                        <td><t t-esc="line_items.display_name"/></td>
                                        <td><t t-esc="line_items.uom"/></td>
                                        <td><t t-esc="line_items.given_qty"/></td>
                                    </tr>
                                </t>
                            </tbody>
                        </table>
                        </t>
                        <br/>
                        <t t-if="len(o.line_ids_miscellaneous) > 0">
                        <table class="table table-bordered">
                            <tbody>
                             <tr><td colspan="4" class="column" style="background-color:#ccc">Miscellaneous</td></tr>

                                <tr class="column">
                                    <td>S.No</td>
                                    <td>Description</td>
                                    <td>Qty</td>
                                    <td>UOM</td>
                                </tr>
                                <t t-foreach="o.line_ids_miscellaneous" t-as="line_items" t-index="index">
                                    <tr>
                                        <td><t t-esc="line_items_index + 1"/></td>
                                        <td><t t-esc="line_items.description"/></td>
                                        <td><t t-esc="line_items.qty"/></td>
                                        <td><t t-esc="line_items.uom"/></td>
                                    </tr>
                                </t>
                            </tbody>
                        </table>
                          </t>
                        <div style="overflow: auto; width: 100%;">
                            <div style="float: left; width: 50%; padding: 10px; box-sizing: border-box;">
                                GSTIN: <t t-esc="o.sosaley_gst_no"/>
                                <br></br><br></br>
                                 <p><t t-esc="copy_label"/></p>
                            </div>
                            <div style="float: right; width: 50%; padding: 10px; box-sizing: border-box;">
                            <t t-if="o.remarks">
                            <u><b>Remarks:</b></u><br></br> <p><t t-esc="o.remarks"/></p>
                            <br></br><br></br>
                            </t>
                                For Sosaley Technologies Private Limited
                                <br/><br/>
                                <img t-if="o.top_management_approval_image" t-att-src="'data:image/png;base64,%s' % (o.top_management_approval_image.decode())" alt="Approved By Sign"/>
                                <br/><br/>
                                Authorised Signatory
                            </div>
                        </div>
                        <div style="page-break-after: always;">
</div>

                        <!-- Page break after each copy except the last one -->
                        <t t-if="copy_label != 'Duplicate Copy'">
                            <div style="page-break-after: always;"></div>
                        </t>
                    </div>
                    <div class="footer"> </div>
                </t>
            </t>
        </t>
    </t>
</template>


</odoo>
