<?php
require_once('../lib/dbclass.php');








$mobileno = $_POST['mobileno'];




$checking = findQuery("SELECT * FROM `tbl_candidates` where Regno='$mobileno'");

if (!$checking) {
    $checking = findQuery("SELECT * FROM `tbl_candidates` where mobile='$mobileno'");
}





if (!$checking) {
    echo "<script src='../sweetalert.js'></script>";
    echo "<script>
        document.addEventListener('DOMContentLoaded', function() {
            swal({
                icon: 'error',
                title: 'No Records Found!',
                text: 'No Records Found,Please try again.',
                showConfirmButton: true,   // Hides the OK button
                timer: 3000                // Set timer in milliseconds (3000ms = 3 seconds)
            }).then(function() {
                window.location = 'login.php';  // Redirect after the timer expires
            });
        });
      </script>";

    exit;
}



?>



<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Exam Result</title>
     <link rel="shortcut icon" href="../../logo.png" type="image/x-icon" sizes="16x16">
</head>
<style>
    @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f8f9fa;
    font-family: 'Poppins', sans-serif;
    padding: 20px;
    position: relative;
}



table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    border: 2px solid black;
}

td {
    padding: 10px;
    border: 1px solid black;
    word-wrap: break-word;
}


.logo-container td {
    border: none !important;
    padding: 10px 80px 10px 80px;
}


.center-text {
    text-align: center;
    font-weight: bold;
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }


    table {
        font-size: 14px;
    }

    .logo-container {
        flex-wrap: wrap;
        text-align: center;
        justify-content: center;
    }

    .logo-container img {
        max-height: 80px; 
    }

    .logo-container h2 {
        font-size: 16px;
    }


}

@media screen and (max-width: 480px) {
    table {
        font-size: 12px;
    }

    td {
        padding: 8px;
    }

 

    .logo-container td {
    border: none !important;
    padding: 10px;
}
.logo1 {
    max-height: 60px; 
    
}

.logo2{
    max-width: 100px;
}
.logo-container h2 {
    font-size: 14px; 
    text-align: center;
}




@media print, screen and (min-width: 0px) {
    .pdf-wrapper {
        width: 794px; 
        max-width: none;
        margin: 0 auto;
    }

    .table-container {
        width: 100% !important;
        max-width: none !important;
        box-sizing: border-box;
    }

    table, td {
        box-sizing: border-box;
    }
}

}

</style> 
<body>
    <div class="pdf-wrapper">
        <div class="table-container">
        <form action="" method="post">
            <table>
  
                <tr class="logo-container">
                    <td style="text-align: left;">
                        <img class="logo1" src="NEET GALA Logo.png" alt="NEET GALA Logo" height="150px" width="auto" style="margin-top: 10px;">
                    </td>
                    <td colspan="2" style="text-align: center;">
                        <h2><b> DOPA NEET GALA 2024 <br> All INDIA NEET MODEL <br> EXAM RESULT </b></h2>
                    </td>
                    <td style="text-align: right;">
                        <img class="logo2" src="DOPA by Bhatia.png" alt="DOPA by Bhatia Logo" width="200px">
                    </td>
                </tr>


                <tr>
                    <td colspan="4" style="text-align: center; padding: 10px;">
                        <p>This result is alloted to those whose who appeared under <br> <b>ALL INDIA NEET MODEL EXAM</b> by <b>DOPA NEET COACHING PLATFORM</b> </p>
                    </td>
                </tr>

             
                <tr>
                    <td colspan="4" style="text-align: center;"><b>PERSONAL DETAILS</b></td>
                </tr>
                <tr>
                    <td><b>Name of Candidate</b></td>
                    <td colspan="3"><?php echo $checking[0]['name'] ?></td>
                </tr>
                <tr>
                    <td><b>Register Number</b></td>
                    <td colspan="3"><?php echo $checking[0]['Regno'] ?></td>
                </tr>
                

                <tr>
                    <td colspan="4"></td>
                </tr>

                <tr>
                    <td colspan="4" style="text-align: center;">
                        <b>RESULT</b>
                    </td>
                </tr>
                <tr>
                    <td>PHYSICS</td>
                    <td>CHEMISTRY</td>
                    <td>BOTANY</td>
                    <td>ZOOLOGY</td>
                </tr>
                <tr>
                    <td><?php echo $checking[0]['physics'] ?></td>
                      <td><?php echo $checking[0]['chemistry'] ?></td> 
                      <td><?php echo $checking[0]['botany'] ?></td> 
                      <td><?php echo $checking[0]['zoology'] ?></td>
                </tr>
                <tr>
                    <td>Total</td>
                      <td><?php echo $checking[0]['Total'] ?></td>
                    <td>Rank</td>
                      <td><?php echo $checking[0]['ranked'] ?></td>
                </tr>

            </table>
        </form>

        </div>
    </div>    
</body>
<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>
   window.onload = function () {
        const { jsPDF } = window.jspdf;
        const doc = new jsPDF({
            orientation: 'portrait',
            unit: 'mm',
            format: 'a4'
        });

        const element = document.querySelector('.table-container');

        html2canvas(element, {
            scale: 2, 
            useCORS: true
        }).then(canvas => {
            const imgData = canvas.toDataURL('image/png');
            const imgWidth = 190; 
            const pageHeight = 297;
            const imgHeight = (canvas.height * imgWidth) / canvas.width;
            const marginX = 10;
            const marginY = 10;

            doc.addImage(imgData, 'PNG', marginX, marginY, imgWidth, imgHeight);
            doc.save('result.pdf');
        });
    }

    
    
    
</script>


</html>