{% 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 style="font-family:'Arial'; font-size:15px;padding:80px;">
    <p style="font-size:15px; margin-left: 5px; "><strong>PURCHASE ORDER</strong></p>
    <table style="width: 100%">
        <tr>
            <td style="width: 50%" valign="top">
                <table style="width: 100%">
                    <tr>
                        <td><b>VENDOR</b></td>
                        <td style="color:#366289;">{{ supplier.description|default('') }} {{ supplier.code|default('') }}</td>
                    </tr>
                    <tr>
                        <td><b>ADDRESS</b></td>
                        <td>{{ supplier.address|default('') }}</td>
                    </tr>
                </table>
            </td>
            <td style="width: 25%" valign="top">
                <table style="width: 100%">
                    <tr>
                        <td><b>TERMS</b></td>
                        <td>
                            {% if purchaseOrder.paymentMode == 'Term' %}
                                {{ purchaseOrder.term ~ ' days' }}
                            {% else %}
                                {{ purchaseOrder.paymentMode }}
                            {% endif %}
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 25%" valign="top">
                <table style="width: 100%">
                    <tr>
                        <td><b>P.O #</b></td>
                        <td style="text-align: right;">{{ purchaseOrderBreakdown.poNo|default('') }}</td>
                    </tr>
                    <tr>
                        <td><b>DATE</b></td>
                        <td style="text-align: right;">{{ purchaseOrderBreakdown.poDate|date('F j, Y') }}</td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <br>
    <br>
    <br>
    <table width="100%" style="border-collapse: collapse; margin-top: 20px;">
        <thead>
        <tr style="border-bottom: 1px solid #000;">
            <td style="font-size:12px; padding: 5px; text-align: left;"><strong>Item Code</strong></td>
            <td style="font-size:12px; padding: 5px; text-align: left;"><strong>Item Description</strong></td>
            <td style="font-size:12px; padding: 5px; text-align: left;"><strong>Unit</strong></td>
            <td style="font-size:12px; padding: 5px; text-align: left;"><strong>Qty</strong></td>
            <td style="font-size:12px; padding: 5px; text-align: right;"><strong>Unit Price</strong></td>
            <td style="font-size:12px; padding: 5px; text-align: right;"><strong>Amount</strong></td>
        </tr>
        </thead>
        <tbody>
            {% 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 style="padding: 5px; text-align: left;">{{ itm.code }}</td>
                    <td style="padding: 5px; text-align: left;">{{ itm.description }}</td>
                    <td style="padding: 5px; text-align: left;">{{ itm.itemunit.description|default('') }}</td>
                    <td style="padding: 5px; text-align: left;">{{ item.quantity|number_format(0, '.', ',') }}</td>
                    <td style="padding: 5px; text-align: right;">{{ price|number_format(2, '.', ',') }}</td>
                    <td style="padding: 5px; text-align: right;">{{ amount|number_format(2, '.', ',') }}</td>
                </tr>
            {% endfor %}
            <tr>
                <td style="padding: 5px; text-align: center;" colspan="6"><br/><br/>* * * Nothing Follows * * *</td>
            </tr>
            {% set itemCtr = purchaseOrderBreakdown.purchaseorderbreakdownitems.count %}
        </tbody>
    </table>

    <br>
    <br>
    <br>
    <br>
    <table width="100%" style="border-collapse: collapse; margin-top: 20px;">
        <tbody>
        <tr>
            <td width="60%" valign="top" >
                REMARKS: {{ purchaseOrder.materialRequisition.purpose.description|default('') }} <br/>
                {{ purchaseOrder.materialRequisition.specificPurpose }}
            </td>
            <td colspan="4"   >
                <table width="100%">
                    <tr>
                        <td style="padding: 5px; text-align: left;">TOTAL AMOUNT:</td>
                        <td style="padding: 5px; text-align: right;">{{ totalAmount|number_format(2, '.', ',') }}</td>
                    </tr>
                </table>
            </td>
        </tr>
        </tbody>
    </table>

    {#<br>
    <br>
    <hr>
    <br>
    <table width="100%" style="width: 100%; font-size: 11px; ">
        <tr style="font-style: italic;">
            <td width="20%" style="padding: 5px;">Prepared By:</td>
            <td style="padding: 5px;">Checked / Noted By:</td>
            <td width="20%" style="padding: 5px;">Approved By:</td>
            <td width="20%" style="padding: 5px;">With Our Conformity</td>
        </tr>
        <tr>
            <td style="padding:5px; text-align:center" >
                <div style="height:75px;"></div>
                <div style="border-top:1px solid black; margin-top: 3px; padding-top:3px">Purchasing Officer</div>
            </td>
            <td style="padding:5px; text-align:center">
                <table width="100%">
                    <tr>
                        <td>
                            <div style="height:75px;"></div>
                            <div style="border-top:1px solid black; margin-top: 3px; padding-top:3px">Officer</div>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="padding:5px; text-align:center">
                <div style="height:75px;"></div>
                <div style="border-top:1px solid black; margin-top: 3px; padding-top:3px">Approver</div>
            </td>
            <td style="padding:5px; text-align:center">
                <div style="height:75px;position: relative;"><span style="position: absolute; bottom: 0;">{{ supplier.description }}</span></div>
                <div style="border-top:1px solid black; margin-top: 3px; padding-top:3px">Supplier Name</div>
            </td>
        </tr>
    </table>#}

</body>
</html>