<?php
// Start session if needed
session_start();


require_once ("connection_sql.php");

?>

<section class="content">
    <div class="box box-primary">
        <div class="box-header with-border">
            <h3 class="box-title">Barcode List</h3>
        </div>

        <form role="form" class="form-horizontal">
            <div class="box-body">
                <div class="panel-body">
                    <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>Ref No</th>
                                <th>Stk No</th>
                                <th>Serino</th>
                                <th>Seri DateTime</th>
                            </tr>
                        </thead>
                        <tbody>
                           <?php

$sql = "SELECT `id`, `serino`, `seri_datetime`, `refno`, `stk_no` FROM `s_purtrn_barcode`";


 
    $stmt = $conn->query($sql); 

   
    if ($stmt->rowCount() > 0) {
        $i = 1;
        
        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
            ?>
            <tr>
                <td><?php echo $i; ?></td>
                <td><?php echo htmlspecialchars($row['refno']); ?></td>  <!-- Sanitize output -->
                <td><?php echo htmlspecialchars($row['stk_no']); ?></td>
                <td><?php echo htmlspecialchars($row['serino']); ?></td>
                <td><?php echo htmlspecialchars($row['seri_datetime']); ?></td>
            </tr>
            <?php
            $i++;
        }
    } else {
        echo "<tr><td colspan='5'>No records found.</td></tr>";
    }
 
?>


                        </tbody>
                    </table>
                </div>
            </div>
        </form>
    </div>
</section>
