<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: 0.1mm solid #000000;
    }
</style>

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

        <td width="50%" style="text-align: right;">
            <div><?= $currentDateTimeByZone; ?></div>
            <div><?= $posTranslate['branch'] ?>: <?= $posInfo['pos_name']; ?></div>
            <div><?= $posTranslate['from_date'] ?>: <?= $start_date_format; ?></div>
            <div><?= $posTranslate['to_date'] ?>: <?= $end_date_format; ?></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-size: 16px; border-collapse: collapse;">
    <tr>
        <td width="100%" style="text-align: center; font-weight: bold;">
            <div><?= strtoupper($posTranslate['sales_report']); ?></div>
        </td>
    </tr>
</table>

<br />

<table width="100%">
    <tr>
        <td width="33.33%" style="text-align: center;">
            <div><?= $cashierInfo; ?></div>
        </td>

        <td width="33.33%" style="text-align: center;">
            <div><?= $saleTypeInfo; ?></div>
        </td>

        <td width="33.33%" style="text-align: center;">
            <div><?= $paymentTypeInfo; ?></div>
        </td>
    </tr>
</table>

<br />

<?php

$posCurrency = $posInfo['pos_currency'];
$grandTotal = 0;

if ($paymentDetails['status'] == "success") {
?>

    <table class="items" width="100%" style="font-size: 12px; border-collapse: collapse; text-align: right;" cellpadding="8">
        <thead>
            <tr>
                <td width="19%" style="font-weight: bold; text-align: left;"><?= strtoupper($posTranslate['date']) ?></td>
                <td width="19%" style="font-weight: bold; text-align: left;"><?= mb_strtoupper($posTranslate['payment_type']) ?></td>
                <td width="19%" style="font-weight: bold; text-align: left;"><?= mb_strtoupper($posTranslate['sale']) ?></td>
                <td width="19%" style="font-weight: bold; text-align: left;"><?= mb_strtoupper($posTranslate['debt_collected']) ?></td>
                <td width="24%" style="font-weight: bold; text-align: left;"><?= mb_strtoupper($posTranslate['total_income']) ?></td>
            </tr>
        </thead>
        <tbody>

            <!-- LOOP ITEMS HERE -->

            <?php

            if ($posCurrency == "USD") $posCurrency = "$";
            if ($posCurrency == "EUR") $posCurrency = "€";
            if ($posCurrency == "HTG") $posCurrency = "G";
            if ($posCurrency == "DOP") $posCurrency = "RD$";
            if ($posCurrency == "AUD") $posCurrency = "A$";

            foreach ($paymentDetails['data'] as $key => $value) {

                $sale_pay_type = $value['pay_det_payment_type'];
                if ($value['pay_det_sale_type'] == "Uber Eats") $sale_pay_type = "Uber Eats";

                $grandTotal += $value['total_pay_det_income'];
            ?>

                <tr>
                    <td style="font-size: 13px; text-align: left;"><?= $value['pay_det_period']; ?></td>
                    <td style="font-size: 13px; text-align: left;"><?= $sale_pay_type; ?></td>
                    <td style="font-size: 13px; text-align: left;"><?= $posCurrency . ' ' . number_format($value['pay_det_income'], 2, '.', ','); ?></td>
                    <td style="font-size: 13px; text-align: left;"><?= $posCurrency . ' ' . number_format($value['pay_det_debt_collect'], 2, '.', ','); ?></td>
                    <td style="font-size: 13px; text-align: left;"><?= $posCurrency . ' ' . number_format($value['total_pay_det_income'], 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="76%"><?= mb_strtoupper($posTranslate['grand_total']) ?> &nbsp;</td>
                <td style="font-weight: bold; font-size: 14px; border: 1px solid #000000;" height="20%" width="24%"><?= $posCurrency . ' ' . number_format($grandTotal, 2); ?></td>
            </tr>
        </tbody>
    </table>

<?php } else if ($paymentDetails['status'] == "warning") { ?>

    <table width="100%" style="font-size: 16px; border-collapse: collapse; margin-top: 80px;">
        <tr>
            <td width="100%" style="text-align: center; font-weight: bold;">
                <div><?= strtoupper($posTranslate['we_are_sorry_there_is_no_data_to_display']); ?>.</div>
            </td>
        </tr>
    </table>

<?php } else { ?>
    <div><?= strtoupper($posTranslate['data_could_not_be_loaded_please_contact_the_system_vendor_for_technical_assistance']); ?></div>
<?php } ?>

<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>