{% set absUrl = app.request.getSchemeAndHttpHost() ~ app.request.baseUrl|replace({'/app_dev.php': ''}) %}
{% set purchaseOrder = purchaseOrderBreakdown.purchaseOrder %}
{% set supplier = purchaseOrder.supplier %}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="{{ absUrl ~ asset('bundles/rxconnexion/admin/css/report/report_wkpdf.css') }}" />
</head>
<body>
    <table width="100%">
        <tr>
            <td>
                <table width="100%">
                    <tr>
                        <td width="60"  >VENDOR</td>
                        <td   >{{ supplier.description|default('') }}</td>
                    </tr>
                    <tr>
                        <td  >ADDRESS</td>
                        <td  >{{ supplier.address|default('') }}</td>
                    </tr>
                    <tr>
                        <td  >CODE</td>
                        <td  >{{ supplier.code|default('') }}</td>
                    </tr>
                </table>
            </td>
            <td width="100" >
                Terms
                <br/>
                <br/>
                {% if purchaseOrder.paymentMode == 'Term' %}
                    {{ purchaseOrder.term ~ ' days' }}
                {% else %}
                    {{ purchaseOrder.paymentMode }}
                {% endif %}
            </td>
            <td width="150" >Terms</td>
        </tr>
    </table>
    <table>
        <tr >
            <td  width="75">Item Code</td>
            <td >Item Description</td>
            <td  width="40">Unit</td>
            <td   width="40">Qty</td>
            <td   width="100">Unit Price</td>
            <td   width="100">Amount</td>
        </tr>
        {% set totalAmount = 0 %}
        {% for item in purchaseOrderBreakdown.purchaseorderbreakdownitems %}
            {% set itm = item.purchaseorderitem.materialrequisitionitem.item %}
            {% set price = item.purchaseorderitem.price %}
            {% set amount = item.quantity * price %}
            {% set totalAmount = totalAmount + amount %}
            <tr>
                <td  >{{ itm.code }}</td>
                <td  >{{ itm.description }}</td>
                <td  >{{ itm.itemunit.description|default('') }}</td>
                <td   >{{ item.quantity|number_format(0, '.', ',') }}</td>
                {% if loop.first %}
                    <td >
                        <table width="100%">
                            <tr>
                                <td    width="35">{{ purchaseOrder.currency.code|default('') }}</td>
                                <td   >{{ price|number_format(2, '.', ',') }}</td>
                            </tr>
                        </table>
                    </td>
                    <td >
                        <table width="100%">
                            <tr>
                                <td    width="35">{{ purchaseOrder.currency.code|default('') }}</td>
                                <td   >{{ amount|number_format(2, '.', ',') }}</td>
                            </tr>
                        </table>
                    </td>
                {% else %}
                    <td   >{{ price|number_format(2, '.', ',') }}</td>
                    <td   >{{ amount|number_format(2, '.', ',') }}</td>
                {% endif %}
            </tr>
            {% if loop.last %}
                <tr>
                    <td    colspan="6">* * * Nothing Follows * * *</td>
                </tr>
            {% endif %}
        {% endfor %}
        {% set itemCtr = purchaseOrderBreakdown.purchaseorderbreakdownitems.count %}
        {% if itemCtr < 29 %}
            {% for i in itemCtr..29 %}
                <tr>
                    <td colspan="6" >
                        <br/>
                        <br/>
                    </td>
                </tr>
            {% endfor %}
        {% endif %}
        <tr>
            <td colspan="2"  >
                REMARKS: {{ purchaseOrder.materialRequisition.purpose.description|default('') }} <br/>
                {{ purchaseOrder.materialRequisition.specificPurpose }}
            </td>
            <td colspan="4"   >
                <table width="100%">
                    <tr>
                        <td width="120"  >TOTAL AMOUNT:</td>
                        <td width="30"  >{{ purchaseOrder.currency.code|default('') }}</td>
                        <td  >{{ totalAmount|number_format(2, '.', ',') }}</td>
                    </tr>
                    <tr>
                        <td   >LESS: DISCOUNT:</td>
                        <td  ></td>
                        <td   >0.00</td>
                    </tr>
                    <tr>
                        <td   >NET AMOUNT:</td>
                        <td   >{{ purchaseOrder.currency.code|default('') }}</td>
                        <td   >{{ totalAmount|number_format(2, '.', ',') }}</td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>