 
<?php 
session_start(); 
include ('../includes/connection.php');   
if (isset($_POST['down_form'])){ 
$code = $_POST['code']; 
$i = 1;
$selected = mysqli_query($conn,"SELECT * FROM student_srms,subject,course_work AS s WHERE  student_srms.student_roll_no = s.student_roll_no AND subject.code = s.code AND s.code ='$code';");
$row = mysqli_fetch_array($selected); 

 
$html .= '<style>
 table{ 
     margin-right: 40px;
} 
 table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
    padding: 8px;
}  
</style>';
$html .= '  
	<p style="font-size: 12px;"><b>NACTE FORM EXAM 01 </b> <b style="float: right;">Sheet No.....of....</b></p>
	<br>
	<center><h3>LANDMARK INSTITUTE OF EDUCATION SCIENCE AND TECHNOLOGY<br>......................................................................................................... <br>NAME OF THE TECHNICAL INSTITUTE</h3></center>
	<center><h3>Depertment of '. $row['department'] . '<br>......................................................................................................... <br>NAME OF DEPERTMENT</h3>
    <h4>NTA Level O'. $row['class_id'] . '</h4> 
    <h3><b>Field of Study: Basic Technician Certificate in '. $row['department'] . '</b><br></h3>
	<h4>Academic years: '. $row['year_of_study'] . ' <br>Date of Assessment: '.$date=date("d/m/Y").'</h4></center>
	<p style="margin-left: 100px; font-size: 14px;"><b>Title:</b> '. $row['program'] . '<br><b>Module Code:</b> '. $row['code'] . '</p>
		<center> <table >
        <thead>
        <tr> 
            <th style="width: 10px;font-size: 12px;">S/N</th>
            <th  style="width: 150px;font-size: 12px;">Name of Cndidate</th>
            <th  style="width: 150px;font-size: 12px;">Reg. No.</th>
            <th style="width: 10px; font-size: 12px;">T1</th> 
            <th style="width: 10px; font-size: 12px;">T2</th> 
            <th style="width: 10px; font-size: 12px;">ASS1</th> 
            <th style="width: 10px; font-size: 12px;">ASS2</th> 
            <th style="width: 10px; font-size: 12px;">PORT/<br>QUIZ</th> 
            <th style="width: 10px; font-size: 12px;">TOTAL</th> 
            <th style="width: 20px; font-size: 12px;">SIGNATURE</th> 
        </tr>
        </thead>
          <tbody> ';
          $course = mysqli_query($conn,"SELECT * FROM student_srms,subject,course_work AS s WHERE  student_srms.student_roll_no = s.student_roll_no AND subject.code = s.code AND s.code ='$code';");
           $row2 = mysqli_fetch_array($course); 
          $selected1 = mysqli_query($conn,"SELECT * FROM student_srms,subject,course_work AS s WHERE  student_srms.student_roll_no = s.student_roll_no AND subject.code = s.code AND s.code ='$code' GROUP BY s.student_roll_no HAVING s.code ='$code';"); 
            while($row1 = mysqli_fetch_array($selected1)){ 
            $type=$row1['exam_type']; 
              if ($type=="Test One") {   
                  $test_1=$row1['course_work'];
              }
               if ($type=="Test Two") {   
                  $test_2=$row1['course_work'];
              }
               if ($type=="Individual") {   
                  $indiv=$row1['course_work'];
              }
               if ($type=="Group") {   
                  $group=$row1['course_work'];
              }
               if ($type=="Quiz") {   
                  $quiz=$row1['course_work'];
              }
              $html .='<tr> 
				<td>'.$i++ .'</td> 
				<td>'.$row1['student_name'].'</td> 
				<td>'.$row1['student_roll_no'].'</td> 
				<td>'. $test_1.'</td> 
				<td>'. $test_2.'</td> 
				<td>'. $indiv.'</td> 
				<td>'. $group.'</td> 
				<td>'. $quiz.'</td> 
				<td>'. $test_1.'</td>
				<td></td> 
			  </tr>'; }} 

$html .= ' 	</tbody>
 </table> 
 </center>
 <br><br>
     <p style="margin-left: 150px;"> Signature of Examiner: ................................................<br><br> Name of Examiner: ......................................................</p>  '; 
  
 
require_once '../dompdf/autoload.inc.php';
use Dompdf\Dompdf;
$dompdf = new Dompdf();

$dompdf->loadHtml($html);

$dompdf->setPaper('A4', 'portrait');

$dompdf->render();
$dompdf->stream(' '. $row['code'] . '.pdf');