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

if (isset($_POST['trolleymid'])) {
    $delete_checkbox_array = $_POST['trolleymid'];

    echo "<div style='display: flex;  flex-wrap: wrap; justify-content: center;'>"; // Flexbox layout for horizontal alignment

    $count = 0;
    
    foreach ($delete_checkbox_array as $one_by_one_sid) {
        $eve = "select trolleyno, trolleynumber from res_trolley_master where trolleymid=$one_by_one_sid";
        $re = mysqli_query($conn, $eve);
        $rate = 123;

        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

                QRcode::png(stripcslashes($trolleynumber), $qrCodeImagePath, QR_ECLEVEL_L,5);

                echo "<div style='text-align: center; margin: 10px;'>";
                echo "<img src='$qrCodeImagePath' alt='QR Code'>";
                echo "<p><b>Trolley: $trolleynumber</b></p>";
                echo "</div>";

                $count++;
                if ($count >= 4) {
                    break; // Display only four QR codes per row
                }
            }
        }
    }

    echo "</div>"; // Close the flex container
}

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



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