<odoo>
  <record id="action_report_iqi" model="ir.actions.report">
        <field name="name">IQI Form</field>
        <field name="model">sos_iqi</field>
        <field name="report_type">qweb-pdf</field>
        <field name="report_name">sos_inventory.report_iqi</field>
        <field name="report_file">sos_inventory.report_iqi</field>
        <field name="print_report_name">"Report _ %s" % object.iqi_no</field>
        <field name="binding_model_id" eval="False"/>
        <field name="binding_type">report</field>
    </record>

<template id="report_iqi">
    <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" />
                <div class="page">

                    <h2 style="text-align:center">Incoming Quality Inspection</h2>
                    <br></br>
                    <!-- HTML Table -->
                    <table class="table table-bordered">
                        <tbody>
                            <tr>
                    
                                <td class="column">IQI No</td><td><t t-esc="o.iqi_no"/></td>
                            
                                <td class="column">IQI Date</td><td><t t-esc="o.iqi_date"/></td>
                            </tr>
                            <tr>
                                <t t-if="o.sfg_option == True">
                                <td class="column">SFG Name</td><td><t t-esc="o.sfg_name.name"/></td>
                                <td class="column">Service Provider Name</td><td><t t-esc="o.service_provider_name.service_provider_name"/></td>
                            </t>
                            <t t-if="o.material_option  == True">
                                <td class="column">Material Name</td><td><t t-esc="o.material_name.part_no"/></td>
                                <td class="column">Supplier Name</td><td><t t-esc="o.supplier_name.supplier_name"/></td>
                            </t>
                            </tr>
                            <tr>
                                
                                <td class="column">Batch No</td><td><t t-esc="o.batch_no"/></td>
                                <td class="column">Serial No</td><td><t t-esc="o.serial_no"/></td>
                            
                           
                            </tr>

                        </tbody>
                    </table>
                  <br></br>
<table class="table table-bordered">
    <tbody>
<tr style="background-color:#ccc"><td colspan="7" class="column"><h5>Summary Report</h5></td></tr>

      <tr class="column">
                <td>Received Quantity</td>
                <td>Approved Quantity</td>
                <td>Rejected Quantity</td>
                <td>Rejection Percentage</td>
            </tr>
  
<tr>
<td><t t-esc="o.received_qty"/></td>
<td><t t-esc="o.approved_qty"/></td>
<td><t t-esc="o.rejected_qty"/></td>
<td><t t-esc="o.rejection_percentage_display"/></td>
</tr>

        </tbody>
    </table>
    <br></br>

<table class="table table-bordered">
    <tbody>
<tr style="background-color:#ccc"><td colspan="7" class="column"><h5>Monitoring &amp; Measuring Equipment Details</h5></td></tr>

      <tr class="column">
      <td>S.No</td>
                <td>Equipment Name</td>
                <td>Identification No</td>
                <td>Certification No</td>
                <td>Calibrated On</td>
                <td>Calibrated Due</td>
          
            </tr>
  
<t t-foreach="o.calibration_line_ids" t-as="line_items">
<tr>
<td><t t-esc="line_items_index + 1"/></td>
<td><t t-esc="line_items.name.name"/></td>
<td><t t-esc="line_items.identification_no"/></td>
<td><t t-esc="line_items.certification_no"/></td>
<td><t t-esc="line_items.calibrated_on"/></td>
<td><t t-esc="line_items.calibrated_due"/></td>
</tr>
</t>

        </tbody>
    </table>
<br></br>

<table class="table table-bordered">
    <tbody>
<tr style="background-color:#ccc"><td colspan="8" class="column"><h5>Inspection Details</h5></td></tr>

      <tr class="column">
                <td>S.No</td>
                <td>QP #</td>
                <td>Testing parameter</td>
                <td>Obtained Readings</td>
                <td>Inspection Remarks</td>
                
                <td>Sampled Qty</td>
                <td>Accepted Qty</td>
                <td>Rejected Qty</td>
            </tr>
  
<t t-foreach="o.testing_line_ids" t-as="line_items">
<tr>
<td><t t-esc="line_items_index + 1"/></td>
<td><t t-esc="line_items.qp_no"/></td>
<td><t t-esc="line_items.testing_parameter"/></td>
<td><t t-esc="line_items.obtained_readings"/></td>
<td><t t-esc="line_items.inspection_remark"/></td>
<td><t t-esc="line_items.sampled_qty"/></td>
<td><t t-esc="line_items.accepted_qty"/></td>
<td><t t-esc="line_items.rejected_qty"/></td>
</tr>
</t>

        </tbody>
    </table>
                        <!-- <div style="page-break-after: always;">
</div> -->

  <div style="width: 100%; display: flex; justify-content: space-between; margin-top: 50px;">

<table class="table table-bordered">

        <tr style="background-color:#ccc">
        <td style="padding: 8px;" class="column"><b>Department </b></td>
            <td style="padding: 8px;" class="column"><b>Authorized Signatory </b></td>
            <td style="padding: 8px;" class="column"><b>Authorized On</b></td>
            <td style="padding: 8px;" class="column"><b>Authorized By</b></td>
        </tr>
        <tr>
        <td>QC</td>
            <td><img style="height:80px;width:100px" t-if="o.qc_by_image" t-att-src="'data:image/png;base64,%s' % (o.qc_by_image.decode())" alt="Tested By"/></td>

            <td><t t-esc="o.qc_tested_on"/></td>
             <td><t t-esc="o.qc_by_name.name"/></td>
        </tr>
        <tr>
        <td>QA</td>
            <td><img style="height:80px;width:100px" t-if="o.qa_by_image" t-att-src="'data:image/png;base64,%s' % (o.qa_by_image.decode())" alt="Tested By"/></td>

            <td><t t-esc="o.qa_tested_on"/></td>
             <td><t t-esc="o.qa_by_name.name"/></td>
        </tr>
      
    </table>

</div>
                </div>
            </t>
        </t>
    </t>
</template>

</odoo>
