<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <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=Dancing+Script:wght@700&family=Roboto&display=swap" rel="stylesheet">
    <title>Hall Ticket</title>
</head>
<?php 
    $this->db->select('user_id, user_atp, user_name, user_reg_id, user_photo');
    $this->db->where('user_reg_id', $reg_id);
    $st_id = $this->db->get('users')->row();

    $this->db->where('user_id', $st_id->user_atp);
    $atp = $this->db->get('users')->row();
    
     $this->db->select('a.*, b.title, b.exam_time, b.course_duration, b.total_questions, b.exam_time, b.online_exam_marks, b.practical_exam_marks, b.viva_exam_marks, b.course_duration_in_month, c.*');
    $this->db->from('student_course a');
    $this->db->join('course b', 'b.id = a.st_course_course_id', 'left');
    $this->db->join('users c', 'c.user_id = a.st_course_student_id', 'left');
    $this->db->where('a.st_course_course_id', $course_id);
    $this->db->where('st_course_student_id', $st_id->user_id);
    $exam_data = $this->db->get()->row();

    $imagePath = base_url().$st_id->user_photo;

    // Read the image file
    $imageData = file_get_contents($imagePath);

    // Encode the image data as base64
    $base64Image = base64_encode($imageData);

    // Create a data URI for use in HTML or CSS
    $dataImg = 'data:image/jpeg;base64,' . $base64Image;

    ?>
<style type="text/css">
    body
    {
        font-family: 'arial';
font-family: 'arial', sans-serif;
    }
</style>
    <body>
        <table width="100%" border="2" style="border-collapse: collapse;">
            <tr>
                <td colspan="3">
                    <h1 id="center" class="text-center text-primary"><center><?php echo strtoupper(atp_details()->user_business_name); ?></center></h1>
                    <h3><center><?php echo atp_details()->user_reg_id; ?></center></h3>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <h3><center>Online Copy</center></h3>
                </td>
            </tr>
            <tr>
                <td width="20%">
                    <b>ROLL NUMBER</b>
                </td>
                <td width="60%">
                    <?=$st_id->user_reg_id  ?>
                </td>
                <td rowspan="4" style="text-align: center;"><img src="<?php echo $dataImg; ?>" alt=""style="height: 150px;"></td>
            </tr>
            <tr>
                <td>
                   <b> NAME</b>
                </td>
                <td>
                    <?=$st_id->user_name;?>
                </td>
            </tr>
            <tr>
                <td>
                    <b>EXAM DATE</b>
                </td>
                <td>
                    <?=$exam_data->st_student_exam_date  ?>
                </td>
            </tr>
            <tr>
                <td>
                    <b>CENTER NAME</b>
                </td>
                <td>
                    <?=strtoupper($atp->user_business_name)?>
                </td>
            </tr>
            <tr>
                <td style="padding-top: 12px;padding-bottom: 12px;">
                    <b>CENTER CODE
                </td>
                <td colspan="2">
                    <?=$atp->user_reg_id?>
                </td>
            </tr>
            <tr>
                <td style="padding-top: 12px;padding-bottom: 12px;">
                    <b>COURSE
                </td>
                <td colspan="2">
                    <?=$exam_data->title  ?>
                </td>
            </tr>

            <?php 
            if($exam_data->st_course_wpm > 29)
            {
                $grade = 'A';
            }
            elseif($exam_data->st_course_wpm < 30)
            {
                $grade = '-';
            }
            
            ?>

            <tr >
                <td colspan="3" style="text-align: center;padding: 30px; justify-content: center;">
                    <table border="2" style="border-collapse: collapse;" class="accuracy center">
                        <tr>
                            <td>Accuracy</td>
                            <td>Gross Speed</td>
                            <td>Net Speed</td>
                            <td>Grade</td>
                        </tr>
                        <tr>
                            <th><?=$exam_data->st_course_accuracy?>%</th>
                            <th><?=$exam_data->st_course_wpm; ?> WPM</th>
                            <th>30 WPM</th>
                            <th><?php echo $grade; ?></th>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>

        <table border="2" width="100%" style="border-collapse: collapse;margin-top: 20px;">
            <tr>
                <td width="70%">PRACTICAL</td>
                <td style="text-align: center;"><?=$exam_data->prc_obtained_marks?></td>
            </tr>
            <tr>
                <td width="70%">ORAL</td>
                <td style="text-align: center;"><?=$exam_data->viva_obtained_marks?></td>
            </tr>
            <tr>
                <td width="70%">TOTAL MARKS</td>
                <td style="text-align: center;"><?php echo $exam_data->prc_obtained_marks + $exam_data->viva_obtained_marks?></td>
            </tr>
            <tr>
                <td width="70%">OUT OF</td>
                <td style="text-align: center;">100</td>
            </tr>
        </table>


    </body>
</html>
<style type="text/css">
h1
{
    margin-bottom: 0;
}
h3
{
    margin-top: 10px;
}
.greade
{
    font-size: 10px;
}
.greade td
{
    padding-top: 10px;
    padding-bottom: 10px;
}
.accuracy th, .accuracy td
{
    padding: 10px;
    text-align: center;
}
.center {
  margin-left: auto;
  margin-right: auto;
}
</style>