<?php
include('config.php');
$appid = $_GET['appid'];
$newsql = "SELECT * FROM aref_2024 WHERE appid='$appid' ";
$newquery=mysqli_query($conn, $newsql);
while( $rows=mysqli_fetch_array($newquery) ) {
   
	$name = $rows['name'];  
    $slot = $rows['slot'];
	$parent = $rows['parent'];  
	$mother = $rows['mother'];  
	$dob = $rows['dob'];  
	$age = $rows['age'];  
	$gender = $rows['gender'];  
	$mobile = $rows['mobile'];  
	$email = $rows['email'];  
	$address_1 = $rows['address_1'];  
	$address_2 = $rows['address_2'];  
	$religion = $rows['religion'];  
	$community = $rows['community'];  
	$city = $rows['city'];  
	$pincode = $rows['pincode'];  
	$state = $rows['state'];  
	$stream = $rows['stream'];  
	$course_type = $rows['course_type'];  	
	$medium = $rows['medium'];  	
	$aadharnumber = $rows['aadharnumber'];  	
	$photo = $rows['photo'];  	
	$parentscontact = $rows['parentscontact'];  	
	$parentsemail = $rows['parentsemail'];  	
	$schoolname = $rows['schoolname'];  	
	$boardofexam = $rows['boardofexam'];   	
	$signature = $rows['signature'];   	
	$othercommunity = $rows['othercommunity'];   	
	$otherreligion = $rows['otherreligion']; 
	$othermedium = $rows['othermedium'];
  	$transdate = $rows['modified'];
  	$paymentstatus = $rows['paymentstatus'];
  	$paymentid = $rows['paymentid'];
  
  
}

if($religion == "Others"){$religion = $religion."(".$otherreligion.")";}
if($community == "Others"){$community = $community."(".$othercommunity.")";}
if($medium == "Others"){$medium = $medium."(".$othermedium.")";}
if($dob !== ""){
	$dob = date("d-M-Y", $dob);
}

// Include the main TCPDF library (search for installation path).
require_once('tcpdf_include.php');

// create new PDF document
//$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

class MYPDF extends TCPDF {
	
      // Page footer
    function Footer(){
		$footer_html = '<hr><br><table width="100%"> <tr> <td><img src="img/footerlogos.jpg" /></td>  </tr> </table> ';
		
		$this->setY(-30);
		$this->writeHTML($footer_html);
	}
}

$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Aarush Infotech');
$pdf->SetTitle('Details');
$pdf->SetSubject('Details');
$pdf->SetKeywords('Details, Details, Details');

// set default header data
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 006', PDF_HEADER_STRING);

// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, 10, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
	require_once(dirname(__FILE__).'/lang/eng.php');
	$pdf->setLanguageArray($l);
}
// remove default header/footer
$pdf->setPrintHeader(false);
// ---------------------------------------------------------

// set font
$pdf->SetFont('dejavusans', '', 9);

// add a page
$pdf->AddPage();
$dob = date("d-M-Y", strtotime($dob));
$html = '';
$html .= '<table>
				<tbody>
					<tr>
						<td align="left"><img src="img/avitlogo.jpg" style="width:200px;" /></td>
						<td align="right"><img src="img/vmlogo.jpg" style="width:200px;" /></td>
					</tr>
				</tbody>
			</table>';

$html .= '<hr><table>
				<tbody>
					<tr>
						<td align="center">&nbsp;</td>
					</tr>
					
					<tr>
						<td align="center"><h1 class="card-title"> Application Form For VMRF SMART 2024-25 </h1></td>
					</tr>
					<tr>
						<td align="center">&nbsp;</td>
					</tr>
				</tbody>
			</table>';
			

$html .= '<table width="100%" cellpadding="2" border="0" collapse="collapse">
				<tr>
					<td>
						<table width="100%" cellpadding="2" border="0" collapse="collapse">
							<tbody>
                             
								<tr><td width="200px">Application No.</td><td width="10px">:</td><td width="400px">'.$appid.'</td></tr>
                                <tr><td width="200px">Slot</td><td width="10px">:</td><td width="400px">'.$slot.'</td></tr>
								<tr><td>Applicant Name</td><td>:</td><td>'.$name.'</td></tr>
								<tr><td>Date of Birth</td><td>:</td><td>'.$dob.'</td></tr>
								<tr><td>Age</td><td>:</td><td>'.$age.'</td></tr>
								<tr><td>Gender</td><td>:</td><td>'.$gender.'</td></tr>
								<tr><td>Mobile</td><td>:</td><td>'.$mobile.'</td></tr>
								<tr><td>Email</td><td>:</td><td>'.$email.'</td></tr>
							</tbody>
						</table>
						<table width="100%" cellpadding="2" border="0" collapse="collapse">
							<tbody>
								<tr><td width="200px">Father / Guardian Name</td><td width="10px">:</td><td width="400px">'.$parent.'</td></tr>
								<tr><td>Mother Name</td><td>:</td><td>'.$mother.'</td></tr>
								<tr><td>Contact Number</td><td>:</td><td>'.$parentscontact.'</td></tr>
								<tr><td>Email</td><td>:</td><td>'.$parentsemail.'</td></tr>
								<tr><td>Address</td><td>:</td><td>'.$address_1.'<br>'.$address_2.'</td></tr>
								<tr><td>City</td><td>:</td><td>'.$city.'</td></tr>
								<tr><td>State</td><td>:</td><td>'.$state.' - '.$pincode.'</td></tr>
								<tr><td>Aadhar Number</td><td>:</td><td>'.$aadharnumber.'</td></tr>
								<tr><td>Religion</td><td>:</td><td>'.$religion.'</td></tr>
								<tr><td>Community</td><td>:</td><td>'.$community.'</td></tr>
							</tbody>
						</table>
						<table width="100%" cellpadding="2" border="0" collapse="collapse">
							<tbody>
								
								<tr><td width="200px">Course Stream</td><td width="10px">:</td><td width="400px">'.$stream.'</td></tr>
								<tr><td>Branch of Study</td><td>:</td><td>'.$course_type.'</td></tr>
								<tr><td>School/Junior college name</td><td>:</td><td>'.$schoolname.'</td></tr>
								<tr><td>Board of Examination</td><td>:</td><td>'.$boardofexam.'</td></tr>
								<tr><td>Medium of Instruction</td><td>:</td><td>'.$medium.'</td></tr>
                                <tr><td>Transaction Date</td><td>:</td><td>'.$transdate.'</td></tr>
                                <tr><td>Payment Status</td><td>:</td><td>'.$paymentstatus.'</td></tr>
                                <tr><td>Payment ID</td><td>:</td><td>'.$paymentid.'</td></tr>
                                
							</tbody>
						</table>
					</td>
					<td align="right">
						<img src="photo/'.$photo.'" style="width:100px;" /><br>
						<img src="signature/'.$signature.'" style="width:100px;" />
					</td>
				</tr>
			</table><br>';
								
/* $html .= '<h4 class="card-title">Parents details</h4>			
			<table width="100%" cellpadding="2" border="0" collapse="collapse">
				<tbody>
					<tr><td width="200px">Father / Guardian Name</td><td width="10px">:</td><td width="400px">'.$parent.'</td></tr>
					<tr><td>Mother Name</td><td>:</td><td>'.$mother.'</td></tr>
					<tr><td>Contact Number</td><td>:</td><td>'.$parentscontact.'</td></tr>
					<tr><td>Email</td><td>:</td><td>'.$parentsemail.'</td></tr>
					<tr><td>Address</td><td>:</td><td>'.$address_1.'<br>'.$address_2.'</td></tr>
					<tr><td>City</td><td>:</td><td>'.$city.'</td></tr>
					<tr><td>State</td><td>:</td><td>'.$state.' - '.$pincode.'</td></tr>
					<tr><td>Aadhar Number</td><td>:</td><td>'.$aadharnumber.'</td></tr>
					<tr><td>Religion</td><td>:</td><td>'.$religion.'</td></tr>
					<tr><td>Community</td><td>:</td><td>'.$community.'</td></tr>
				</tbody>
			</table><br>';
			
$html .= '<h4 class="card-title">Choice of Programme </h4>			
			<table width="100%" cellpadding="2" border="0" collapse="collapse">
				<tbody>
					
					<tr><td width="200px">Course Stream</td><td width="10px">:</td><td width="400px">'.$stream.'</td></tr>
					<tr><td>Branch of Study</td><td>:</td><td>'.$course_type.'</td></tr>
					<tr><td>School/Junior college name</td><td>:</td><td>'.$schoolname.'</td></tr>
					<tr><td>Board of Examination</td><td>:</td><td>'.$boardofexam.'</td></tr>
					<tr><td>Medium of Instruction</td><td>:</td><td>'.$medium.'</td></tr>
				</tbody>
			</table>'; */
//echo $html;
// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

// reset pointer to the last page
$pdf->lastPage();

// ---------------------------------------------------------

//Close and output PDF document
$pdf->Output($name.'-'.$parent.'.pdf', 'I');

//============================================================+
// END OF FILE
//============================================================+
