<?php
	include_once('includes/connect_database.php'); 
	 	if(isset($_GET['id'])){
			$ID = $_GET['id'];
		}else{
			$ID = "";
		}

		
		// create array variable to store data from database
		
		// get all data from menu table and category table
		$sql_query = "SELECT id,student_name,
		student_dob,
		mobile,
		email,
		guardian,
		mobile_guardian,
		email_guardian,
		address,
		city,state,other,
		ten_board,
		ten_studyyear,
		ten_schoolname,
		ten_marks,
		twelve_studyyear,
		twelve_schoolname,
		twelve_marks,twelve_board,twelve_result,course,mode,looking_for_scholarship,remark,created FROM tbl_student
					WHERE id = ? ";
		
		$stmt = $connect->stmt_init();
		if($stmt->prepare($sql_query)) {	
			// Bind your variables to replace the ?s
			$stmt->bind_param('s', $ID);
			// Execute query
			$stmt->execute();
			// store result 
			$stmt->store_result();
			$stmt->bind_result($data['id'], 
					$data['student_name'], 
					$data['student_dob'], 
					$data['mobile'], 
					$data['email'],
					$data['guardian'],
					$data['mobile_guardian'],
					$data['email_guardian'],
					$data['address'],
					$data['city'],$data['state'],$data['other'],
					$data['ten_board'],
					$data['ten_studyyear'],
					$data['ten_schoolname'],
					$data['ten_marks'],
					$data['twelve_studyyear'],
					$data['twelve_schoolname'],
					$data['twelve_marks'],
					$data['twelve_board'],
					$data['twelve_result'],
					$data['course'],
					$data['mode'],
					$data['looking_for_scholarship'],$data['remark'],$data['created']
					);
			$stmt->fetch();
			$stmt->close();
		}
	
		include("mpdf/mpdf.php");
		$html="<div style='text-align:center;'><img src='".$site_url."' style='width:200px;' /></div>";
		
		$html.="<table class='tallcells' style='width:100%;border:1px solid'><tr><td style='    background-color: #ff0000;color:#FFFFFF;font-size:20px;text-align:center;'>Admission Enquiry Form: 2020-23 Batch</td></tr></table>";
		$html.="<p style='font-size:15pt; color:#440066'>Student Information</p>";
$html.="<table class='tallcells' style='width:100%;border:1px solid;'>
		<tr><th style='width:30%'>ID</th><td>"."FW202023".str_pad($data['id'],3,'0',STR_PAD_LEFT)."</td>
			</tr>
			<tr>
				<th>Student Name</th>
				<td>".$data['student_name']."</td>
			</tr>
				<tr>
				<th>student D.O.B</th>
				<td>".date('Y-m-d',strtotime($data['student_dob']))."</td>
			</tr>
			<tr>
				<th>Mobile no</th>
				<td>".$data['mobile']."</td>
			</tr>

			<tr>
				<th>Email Id</th>
				<td>".$data['email']."</td>
			</tr>

			<tr>
				<th>Guardian Name</th>
				<td>".$data['guardian']."</td>
			</tr>
			<tr>
				<th>Mobile - Guardian</th>
				<td>".$data['mobile_guardian']."</td>
			</tr>
			<tr>
				<th>Email Id - Guardian</th>
				<td>".$data['email_guardian']."</td>
			</tr>
			<tr>
				<th>Address</th>
			    <td>".$data['address']."</td>
			</tr>
			<tr>
				<th>City</th>
			    <td>".$data['city']."</td>
			</tr>
			<tr>
				<th>State</th>
			    <td>".(!empty($data['state'])?$data['state']:'-')."</td>
			</tr>
			<tr>
				<th>Other</th>
			    <td>".(!empty($data['other'])?$data['other']:'-')."</td>
			</tr>
			<tr><th>Walk-In Date</th><td>".date('d-m-Y',strtotime($data['created']))."</td></tr>
			
	</table>";
	$html.="<p style='font-size:15pt; color:#440066'>Education Qualification</p>";
$html.="	<table  class='tallcells' style='width:100%;border:1px solid;'>
     			<tr><td colspan='2'> <h4><b>Class 10th</b></h4></td></tr>
     		<tr>
				<th style='width:30%'>Board</th>
			    <td>".$data['ten_board']."</td>
			</tr>
			<tr>
				<th >Year of Study</th>
			    <td >".$data['ten_studyyear']."</td>
			</tr>
			<tr>
				<th >School Name</th>
			    <td >".$data['ten_schoolname']."</td>
			</tr>
			<tr>
				<th>Marks/Grade</th>
			    <td>".$data['ten_marks']."</td>
			</tr>
				<tr><td colspan='2'> <h4><b>Class 12th</b></h4></td></tr>
     		<tr>
				<th >Board</th>
			    <td>".$data['twelve_board']."</td>
			</tr>
			
     		<tr>
				<th>Year of Study</th>
			    <td>".$data['twelve_studyyear']."</td>
			</tr>
			<tr>
				<th>School Name</th>
			    <td>".$data['twelve_schoolname']."</td>
			</tr>
			
			<tr>
				<th>Marks/Grade</th>
			    <td>".$data['twelve_marks']."</td>
			</tr>
			
<tr>
				<th>12th Standard Result</th>
			    <td>".$data['twelve_result']."</td>
			</tr>
			
	</table>
";
	$html.="<p style='font-size:15pt; color:#440066'>Your Interest In NSIC</p>";
$html.="<table class='tallcells' style='width:100%;border:1px solid;'>
			<tr>
				<th style='width:30%'>Course</th>
			    <td >".$data['course']."</td>
			</tr>
			<tr>
				<th>Looking For Scholarship</th>
			    <td>".$data['looking_for_scholarship']."</td>
			</tr>
	<tr>
				<th style='width:30%'>Mode</th>
			    <td >".$data['mode']."</td>
			</tr>
<tr>
				<th style='width:30%'>Remark</th>
			    <td >".$data['remark']."</td>
			</tr></table>";

//$mpdf=new mPDF('c','A4','','',32,25,27,25,16,13); 
$mpdf=new mPDF(); 

$mpdf->SetDisplayMode('fullpage');
$file="FW202023".str_pad($data['id'],3,'0',STR_PAD_LEFT).".pdf";
$mpdf->list_indent_first_level = 0;	// 1 or 0 - whether to indent the first level of a list

// LOAD a stylesheet
$stylesheet = file_get_contents('public/mpdfstyletables.css');
$mpdf->WriteHTML($stylesheet,1);	// The parameter 1 tells that this is css/style only and no body/html/text

$mpdf->WriteHTML($html,2);

$mpdf->Output($file,'D');
exit;
?>