<?php 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

require_once "labClass.php";
require_once "phpqrcode/qrlib.php"; // include QR library (download phpqrcode.php)

// Generate QR code inline as base64
ob_start();
QRcode::png("ROMBO STAR COMPANY LTD", null, QR_ECLEVEL_L, 4, 2);
$imageString = ob_get_contents();
ob_end_clean();
$qrCode = "data:image/png;base64," . base64_encode($imageString);

$sdate = $_POST['sdate'];
$con = new labClass();
$chkp = $con->getOthersourceEntrymoneyR($sdate);

if ($chkp->rowCount() > 0) {
    $chp = $chkp->fetchAll();
    $tex = 0;
    ?>
    <div class="container-fluid" id="co">
        <div class="container-fluid " id="dpl" style="width:40%;">
            <table class="table table-bordered" style="width:100%; background-color:#e6f2ff;">
                <tr>
                    <td colspan="4" align="center">
                        <h6>ROMBO STAR AUTO SPARE PARTS & LUBRICANTS</h6> 
                        <small>P.O.BOX 629</small><br>
                        <small>MWANZA-TANZANIA</small>
                    </td> 
                </tr>
                <tr>
                    <td colspan="4">
                        <img src="assets/logo.png" style="width:100%;height:120px;" >
                    </td> 
                </tr>
                <tr>
                    <td colspan="4">
                        Date :<?php echo $sdate; ?>
                    </td> 
                </tr>
                <tr> 
                    <td><small><h6>S/N- DESCRIPTION</h6></small></td>
                    <td><small><h6>AMOUNT</h6></small></td>
                    <td><small><h6>DATE</h6></small></td>
                    <td><small><h6>TIME</h6></small></td>
                <tr>
                <tbody>
                <?php
                $cc = 0;
                foreach ($chp as $p) {
                    $cc++;
                    $tex += $p['amount'];
                    ?>
                    <tr>
                        <td><?php echo $p['recID'] . ". " . $p['descrip']; ?></td>
                        <td><?php echo $p['amount']; ?></td> 
                        <td><?php echo $p['dateR']; ?></td> 
                        <td><?php echo $p['timeAt']; ?></td>  
                    </tr>
                    <?php
                }
                ?>
                <tr>
                    <td colspan="3">Total:</td>
                    <td><?php echo $tex; ?></td>
                    
                </tr>
                <tr>
                    <td colspan="3">Signature:...........................</td> 
                    <td rowspan="3" align="center">
                        <img src="<?php echo $qrCode; ?>" alt="QR Code"><br>
                         
                    </td>  
                </tr>
                <tr>
                    <td colspan="3">Received by:..........................</td> 
                </tr>
                <tr>
                    <td colspan="3">Signature:...........................</td> 
                </tr>
                </tbody>
            </table>
           
        </div>
    </div>
<?php } ?>

 
