<style>
    body {
        font-family: sans-serif;
        font-size: 14px;
    }

    table.items {
        border: 0.1mm solid #000000;
    }

    td {
        vertical-align: top;
    }

    table thead td {
        background-color: #e1e1e1;
        text-align: center;
        border: 0.1mm solid #000000;
        text-transform: uppercase;
    }

    .items tbody td {
        border-left: 0.1mm solid #000000;
        border-right: 0.1mm solid #000000;
    }
</style>

<!-- <htmlpageheader name="myheader"> -->
<table width="100%">
    <tr>
        <td width="50%">
            <div style="font-weight: bold; font-size: 15pt;"><?= $purchaseInfo['ent_name']; ?></div>
            <div><?= $purchaseInfo['pos_address']; ?></div>
            <div><?= $purchaseInfo['pos_city']; ?></div>
            <div><?= $purchaseInfo['ent_document']; ?>: <?= $purchaseInfo['ent_document_number']; ?></div>
            <div style="font-family:dejavusanscondensed;">&#9742; <?= $purchaseInfo['pos_phone']; ?></div>
        </td>

        <td width="50%" style="text-align: right;">
            <div>Purchase No. <?= $purchaseInfo['pur_id']; ?></div>
            <div>Printed: <?= $currentDateTimeByZone; ?></div>
            <div>Purchase Date: <?= $purDate; ?></div>
            <div>POS: <?= $purchaseInfo['pos_name']; ?></div>
        </td>
    </tr>
</table>
<!-- </htmlpageheader> -->

<!-- <sethtmlpageheader name="myheader" value="on" show-this-page="1" /> -->
<sethtmlpagefooter name="myfooter" value="on" />


<div style="text-align: right;">&nbsp;</div>

<table width="100%" style="font-family: sans-serif;">
    <tr>
        <td width="45%">
            <br />
            <div><span>Provider</span>: <?= $purchaseInfo['prov_name']; ?></div>
            <div><span>RNC/NIF</span>: <?= $purchaseInfo['prov_fiscal_number']; ?></div>
        </td>

        <!-- <td width="10%">&nbsp;</td>

        <td width="45%" style="text-align: right;">
            <br /><span style="font-weight: bold;">Purchase No.</span> <?= $purchaseInfo['pur_id']; ?>
            <br /><span style="font-weight: bold;">Purchase Date:</span> <?= $purDate; ?>
        </td> -->
    </tr>
</table>

<br />

<table class="items" width="100%" style="font-size: 12px; border-collapse: collapse; text-align: right;" cellpadding="8">
    <thead>
        <tr>
            <td width="50%" style="font-weight: bold;">Description</td>
            <td width="15%" style="font-weight: bold;">Quantity</td>
            <td width="15%" style="font-weight: bold;">Cost Price</td>
            <td width="20%" style="font-weight: bold;">Amount</td>
        </tr>
    </thead>
    <tbody>

        <!-- LOOP ITEMS HERE -->

        <?php
        foreach ($purchaseDetailsInfo as $key => $purDetInfo) {
            $purchaseTotal += $purDetInfo['pur_det_pro_cost'] * $purDetInfo['pur_det_pro_qty'];
        ?>

            <tr>
                <td style="font-size: 15px; text-align: center;"><?= $purDetInfo['pro_description']; ?></td>
                <td style="font-size: 14px;"><?= $purDetInfo['pur_det_pro_qty']; ?></td>
                <td style="font-size: 14px;"><?= number_format($purDetInfo['pur_det_pro_cost'], 2); ?></td>
                <td style="font-size: 14px;"><?= number_format($purDetInfo['pur_det_pro_cost'] * $purDetInfo['pur_det_pro_qty'], 2); ?></td>
            </tr>

        <?php } ?>

        <!-- END LOOP ITEMS HERE -->

    </tbody>
</table>

<div style="margin-bottom: 30px"></div>

<table width="100%" style="text-align: right; border-collapse: collapse;" cellpadding="8">
    <tbody>
        <tr>
            <td style="font-weight: bold; font-size: 14px; text-transform: uppercase;" height="20%" width="80%">Grand total &nbsp;</td>
            <td style="font-weight: bold; font-size: 14px; border: 1px solid #000000;" height="20%" width="20%"><?= $purchaseInfo['pos_currency']; ?> <?= number_format($purchaseTotal, 2) ?></td>
        </tr>
    </tbody>
</table>

<htmlpagefooter name="myfooter">
    <div style="border-top: 1px solid #000000; font-size: 9pt; text-align: center; padding-top: 3mm; ">
        Page {PAGENO} of {nb}
    </div>
</htmlpagefooter>