<?php
session_start();

	if(!isset($_SESSION['linkarisesuloginsesion']))
	{
		header('Location: index.php');
		return;
	}
	include("connect.php");
		
	date_default_timezone_set("Asia/Kolkata");
	$mdate= date('Y-m-d H:i:s');
	
	?>
	<html>
<head>
 <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=all" rel="stylesheet" type="text/css" />
        <link href="../assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
        <link href="../assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css" />
		
       
<style>
p.inline {display: inline-block; margin-left: 50px;margin-right: 50px;}
span { font-size: 13px;}
</style>
<style type="text/css" media="print">
    @page 
    {
        size: auto;   /* auto is the initial value */
        margin: 0mm;  /* this affects the margin in the printer settings */

    }
	</style>
	</head>
<body onload="window.print();">
	<div style="margin-left: 5%">
		
	<?php
	// Include the QR code generation library
include 'phpqrcode/qrlib.php'; // Assuming 'qrlib.php' is the QR code library file



        $eve = "select trolleyno, trolleynumber from res_trolley_master";
        $re = mysqli_query($conn, $eve);
        $rate = 123;

       echo '<table>'; // Start a table to organize QR codes

    if (mysqli_num_rows($re) > 0) {
        $i = 1;
        while ($rt = mysqli_fetch_assoc($re)) {

            $trolleyno = $rt['trolleyno'];
            $trolleynumber = $rt['trolleynumber'];

            // Generate QR code image
            $qrCodeImagePath = "images/$trolleynumber.png"; // Provide a suitable path

            if ($i % 7 == 1) {
                echo '<tr>'; // Start a new row for every 4 QR codes
            }

            echo '<td>'; // Start a table cell for each QR code
            echo "<div style='text-align: center; margin: 10px;'>";
            echo "<img src='$qrCodeImagePath' alt='QR Code'>";
            echo "<p><b>Trolley: $trolleynumber</b></p>";
            echo "</div>";
            echo '</td>'; // End the table cell

            if ($i % 7 == 0) {
                echo '</tr>'; // Close the row after 4 QR codes
            }

            $i++;
        }
    }

    if ($i % 7 != 1) {
        // If there are remaining QR codes to close the last row
        echo '</tr>';
    }

    echo '</table>'; // Close the table


// Close the database connection
mysqli_close($conn);
?>
<div >



							   
							   </div>
</div>
</body>
</html>