    <?php
$conn=new mysqli("localhost","root","","threads");
$error_message='';
$id=0;
if(isset($_GET['search']))
{
$id=$_GET['id'];
}
?>


    <?php
$sql="select * from dunees where COUR_NO='$id'";
$row=$conn->query($sql);
if($row->num_rows>0)
{
	?>

    <?php
	while($data=$row->fetch_assoc())
	{
		?>


<!DOCTYPE html>
 <link rel="icon" type="image/png" sizes="16x16" href="assets/img/logo.png">
<html lang="en">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
    href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&family=Open+Sans:ital,wght@0,300..800;1,300..800&family=Quicksand:wght@300..700&display=swap"
    rel="stylesheet">

<head>
    <meta charset="UTF-8">
    <title>User Dashboard</title>


    <style>
    table {
        border: 1px solid black;

    }
    </style>

    <style>
    button {

        padding: 8px 14px;
        border: none;
        border-radius: 5px;
        cursor: pointer;
        color: white;
    }

    .print {
        background: #ff9800;
    }

    .pdf {
        background: #4CAF50;
    }

    .jpg {
        background: #2196F3;
    }

    .logout {
        background: #f44336;
    }
    </style>
</head>

<body>
    <div style="background-color:#ffffe6;width:1200px;margin-left:60px;margin-top:30px;">
        <div style="height:40px;"></div>
        <title>Way Bill For: <?php print_r($data['Receiver']);?></title>
        <table style="width:90%;border: 1px solid black;background-color:#ffffff;margin-left:60px;">
            <tr>
                <th
                    style="collage_bg;height:70px;width:500px;background-color:white; border: 1px solid white;border: 1px solid white; text-align:left;border: 1px solid black;">
                    <nav>
                        &nbsp &nbsp <a href="#"> <img src="assets/img/logo.png" style="width:30px;height:30px;"></a>
                        <a><span
                                style=' font-size:30px;font-family: "DM Sans" , sans-serif; font-optical-sizing: auto;
                            font-weight: <weight>; font-style: normal;color:#1a75ff;'>Gent
                            World
                            Express</span></a> <br>
                            &nbsp &nbsp <a style="text-indent:4em"> <span
                                    style='font-size:13px;font-family: "DM Sans", sans-serif; font-optical-sizing: auto; '>Address:
                                    41 Maiden
                                    Lane, London WCZE 7U, United Kingdom</span></a> <br>
                            &nbsp &nbsp <a href="mailto:csu-department@gent-wrld.com" style="text-decoration:none"><span
                                    style='font-size:13px;font-family: "DM Sans", sans-serif; font-optical-sizing: auto;color:black;'>Email:
                                    csu-department@gent-wrld.com</span></a>
                </nav>
                </th>
                <th rowspan="2"
                    style="height:70px;width:150px;border: 1px solid white;background-color:#ffffff;border: 1px solid #94b8b8;">
                    <span stype="font-size:13px"><img src="assets/img/Gent.png"
                            style="width:150px;height:120px;text-indent:3em;">
                </th>
                <th colspan="2" style="height:70px;width:100px;border: 1px solid black;">
                    <table style=" margin-left: auto; margin-right: auto;">
                        <tr>
                            <th
                                style="height:30px;width:300px;background-color:#00b33c;background-color:#ffff00;text-align:left; margin: 20px;order: 1;font-family:tahoma;color:#000000;font-size:15px;">
                                Tracking Number: <?php print_r($data['Cour_No']);?></th>
                        </tr>
                        <tr>
                            <td
                                style="height:30px;width:300px;background-color:#ffff00;border: 1px solid #ffffffc;text-align:left;font-family:tahoma;color:#000000;font-size:15px;">
                                Way Bill Number: <?php print_r($data['Bill']);?></td>

                        </tr>
                    </table>
                </th>
                </tr>
                </table>

                <table style="width:90%;border: 1px solid black;background-color:#ffffff;margin-left:60px;">
                    <tr>
                        <td
                            style="height:10px;width:300px;background-color:#ffff00;border: 1px solid #ffffffc;text-align:left;font-family:tahoma;color:#000000;text-indent:2em;">
                            Sender's Details:</td>
                        <td
                            style="height:10px;width:400px;background-color:#ffff00;border: 1px solid #ffffffc;text-align:left;font-family:tahoma;color:#000000;text-indent:2em;">
                            Details Of Goods:</td>
                        <td
                            style="height:10px;width:400px;background-color:#ffff00;border: 1px solid #ffffffc;text-align:left;font-family:tahoma;color:#000000;text-indent:2em;">
                            Items Of <?php print_r($data['Name_Item']);?>:</td>
                    </tr>
                    <tr>
                        <td
                            style="height:10px;width:700px;background-color:#ffffff;border: 1px solid #000000;text-align:left;font-family:tahoma;color:#000000;">
                            <p style="text-align: justify;"> Sender Name:
                                <?php print_r($data['Sender']);?> <br>
                                Sender Address:
                                <?php print_r($data['Sender_Address']);?></br>
                                Sender Email:
                                <?php print_r($data['Sender_Email']);?><br>
                                Sender Number:
                                <?php print_r($data['Sender_Number']);?></p>
                        </td>
                        <td
                            style="height:10px;width:300px;background-color:#ffffff;border: 1px solid #000000;text-align:left;font-family:tahoma;color:#000000;">
                            &nbsp Name Of Item: <?php print_r($data['Name_Item']);?><br>
                            &nbsp <span style="text-indent:2em"> Color Of
                                <?php print_r($data['Name_Item']);?>:
                                <?php print_r($data['Color_Item']);?></span><br>
                            &nbsp <span style="text-indent:2em"> Weight Of
                                <?php print_r($data['Name_Item']);?>:
                                <?php print_r($data['Weight']);?></span>
                        </td>
                        <td
                            style="height:10px;width:300px;background-color:#ffffff;border: 1px solid #000000;text-align:left;font-family:tahoma;color:#000000;">
                            Lists Of <?php print_r($data['Name_Item']);?>:
                            <?php print_r($data['List_Item']);?></td>
                    </tr>
                </table>
                <table style="width:90%;border: 1px solid black;background-color:#ffffff;;margin-left:60px;">
                    <tr>
                        <td
                            style="height:10px;width:700px;background-color:#ffff00;border: 1px solid #ffffffc;text-align:left;font-family:tahoma;color:#000000;text-indent:2em;">
                            Receiver Details:</td>
                        <td
                            style="height:10px;width:600px;background-color:#ffff00;border: 1px solid #ffffffc;text-align:left;font-family:tahoma;color:#000000;text-indent:2em;">
                            Shipping Details:</td>
                    </tr>
                    <tr>
                        <td
                            style="height:10px;width:700px;background-color:#fffff;border: 1px solid #000000;font-family:tahoma;color:#000000;">
                            <p style="text-align: justify;"> Receiver Name:
                                <?php print_r($data['Receiver']);?><br>
                                Receiver Address:
                                <?php print_r($data['Receiver_Address']);?></br>
                                Receiver Email:
                                <?php print_r($data['Receiver_Email']);?><br>
                                <span style="text-indent:2em"> Receiver Number:
                                    <?php print_r($data['Receiver_Number']);?>
                            </p>
                        </td>
                        <td
                            style="height:10px;width:700px;background-color:#ffffff;border: 1px solid #000000;text-align:left;font-family:tahoma;color:#000000;">
                            &nbsp Date Of Departure of <?php print_r($data['Name_Item']);?>:
                            <?php print_r($data['Sent']);?><br>
                            &nbsp <span style="text-indent:2em"> Date Of Arrival of
                                <?php print_r($data['Name_Item']);?>:
                                <?php print_r($data['Delivery']);?></span></br>
                            &nbsp <span style="text-indent:2em">
                                <?php print_r($data['Name_Item']);?>
                                Destination:
                                <?php print_r($data['Destination']);?></span><br></td>
                    </tr>
                </table>
                <table style="width:90%;border: 1px solid black;background-color:#ffffe6;margin-left:60px;">
                    <tr>
                        <td
                            style="height:10px;width:700px;background-color:#ffff00;border: 1px solid #ffffffc;text-align:left;font-family:tahoma;color:#000000;text-indent:2em;">
                            Terms and Conditions:</td>
                        <td
                            style="height:10px;width:600px;background-color:#ffff00;border: 1px solid #ffffffc;text-align:left;font-family:tahoma;color:#000000;text-indent:2em;">
                            Official Company Authorization And Seal:</td>
                    </tr>
                    <tr>
                        <td
                            style="height:10px;width:700px;background-color:#ffffff;border: 1px solid #000000;text-align:left;font-family:tahoma;color:#000000;">
                            The terms and conditions of Carrier’s applicable tariff are incorporated herein, including
                            but not
                            limited to the terms and conditions relating to demurrage and detention.Carrier’s
                            standard tariff can be accessed online at <a href="https://gent-wrld.com/"
                                style="text-decoration:none"> Gent World Express </a>.
                        </td>
                        <td
                            style="height:10px;width:700px;background-color:#ffffff;border: 1px solid #000000;text-align:left;font-family:tahoma;color:#000000;text-indent:2em;">
                            <img src="assets/img/globs-log.png" style="width:30%">
                            &nbsp &nbsp &nbsp <span style="text-indent:2em"> &nbsp &nbsp <img
                                    src="assets/img/signture.png" style="width:50%"></span></br>
                        </td>
                    </tr>
                </table>
                </table>
                <div style="margin-left: 500px;margin-top:40px;">                  
                  
                    <button class="jpg" onclick="downloadImage()">🖼️ Save Your Way Bill</button>
                     <button type="button" style="width:300px;height:40px;border-radius:20px;"><a href="bill.php?id=<?=$id;?>&search=generated-bill" class="btn btn-success" style="text-decoration: none;"
                                            >Print Out  <?php print_r($data['Name_Item']);?> Way Bill
                                            </a></button>

                    <form action="http://localhost/gent-wrld/" style="display:inline;">
                        <button class="logout">🚪 Logout</button>
                    </form>
                </div>
            </div>


       <?php	
        }
    
    }	
    ?>


            <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>

            <script>
            async function downloadPDF() {
                const {
                    jsPDF
                } = window.jspdf;
                const pdf = new jsPDF();
                pdf.text("<h2 style='color:blue'>User Information</h2>", 20, 20);
                pdf.text("Name: <?php print_r($data['Cour_No']);?>", 20, 40);
                pdf.text("Email: <?php print_r($data['Sender']);?>", 20, 50);
                pdf.text("Number: <?php print_r($data['Weight']);?>", 20, 60);
                pdf.text("Zip Code: <?php print_r($data['Bill']);?>", 20, 70);
                pdf.save("user_data.pdf");
            }

            function downloadImage() {
                html2canvas(document.body).then(canvas => {
                    const link = document.createElement('a');
                    link.download = 'user_data.jpg';
                    link.href = canvas.toDataURL("image/jpeg");
                    link.click();
                });
            }
            </script>

</body>

</html>