<!DOCTYPE html>
<html>
<head>
    <title><?php echo @$title ?></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<style type="text/css">
    @page {
        margin: 10px 10px 10px 10px;
        page-break-inside: avoid;
    }
    * {
        box-sizing: border-box;
    }

    /* Create three equal columns that floats next to each other */
    .col {
        float: left;
        width: 25%;
        padding: 4px;
        border: 1px solid;
        display: block;
        border-radius: 6px;
    }

    .row {
        display: flex;
        flex-wrap: wrap;
        margin-top: calc(-1 * var(--bs-gutter-y));
        margin-right: calc(-.5 * var(--bs-gutter-x));
        margin-left: calc(-.5 * var(--bs-gutter-x));
    }
</style>
<body>
<div class="row">
    <?php
    $x=1;
    foreach ($databarang as $hasil) {
        for ($i=1; $i<=$hasil->jumlah_cetak; $i++) {
            ?>
            <div class="col">
                <span style="font-size: 8pt;"><b><?php echo @$toko ?></b></span>
                <?php
                if ($hasil->harga_diskon) {
                    echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt;"><b>HARGA PROMO<b></span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span></b><del><sup style="font-size: 8pt;">Rp</sup> '.number_format($hasil->harga_jual,0,',','.').'</del></b></span><br>
                        <center>
                            <span style="font-size: 25pt;"><b><sup style="font-size: 10pt;">Rp</sup>'.number_format($hasil->harga_diskon,0,',','.').'</b></span>';
                    if (strtotime($hasil->tgl_akhirdiskon)>=strtotime(date('Y-m-d'))) {
                            echo '<br>s/d: '.tanggalindo($hasil->tgl_akhirdiskon);
                     }
                    echo '</center>';
                } else if ($hasil->harga_diskon==0) {
                    if ($hasil->satuan) {
                        $sat='<sub>/ '.strtolower($hasil->satuan).'<sub>';
                    } else {
                        $sat='';
                    }
                    echo '<center>
                            <span>&nbsp;</span><br>
                            <span style="font-size: 25pt;"><b><sup style="font-size: 10pt;">Rp</sup>'.number_format($hasil->harga_jual,0,',','.').'</b></span>'.$sat.'<br>&nbsp;
                        </center>';
                }
                echo '<center><span style="font-size: 9pt;">'.substr($hasil->barang,0,30).'</span></center>';
                ?>
                <div style="text-align: left; width: 50%; font-size: 7pt; float: left;">
                    <?php
                    if ($hasil->tgl_akhirdiskon) {
                        if (strtotime($hasil->tgl_akhirdiskon)>=strtotime(date('Y-m-d'))) {
                            ?>
                            <?php  echo '&nbsp;';//echo 's/d : '.date('d/m/Y',strtotime($hasil->tgl_akhirdiskon)) ?>
                            <?php
                        } else {
                            echo '&nbsp;';
                        }
                    } else {
                        echo '&nbsp;';
                    }
                    ?>
                </div>
                <div style="text-align: right; width: 50%; font-size: 7pt; float: left;">
                    <?php echo date('d/m/Y',strtotime($hasil->tanggal)) ?>
                </div>
                <div style="width: 50%; float: left; font-size: 7pt;">
                    <?php echo $hasil->kode_barang ?>
                </div>
                <div style="width: 50%; float: left; font-size: 7pt; text-align: right;">
                    <?php echo $hasil->barcode.' - '.$x ?>
                </div>
            </div>
            <?php
            if ($x%32==0) {
                ?>
                </div>
                    <div style="page-break-after:always;"></div>
                <div class="row">
                <?php
            }
            $x++;
        }
    }
    ?>
</div>
<script type="text/javascript">
    window.print();
</script>
</body>
</html>