Current File : /home/inlingua/www/dwarka/icentex/admin_fd/certificates.php
<?php
session_start();
if(in_array("fd",$_SESSION['allowed_modules']))
{
$allow="Yes";
}
else
{
$allow="No";
}

if($_SESSION['id']=="" || $allow!="Yes")
{
header("Location: ../index.php");
}
require('../dbConnection.php');

// Include common functions
require('../commonFunc.php');

// Include common functions
require('../globalVars.php');
require('../dbHandler.class.php');
$dbObject = new dbHandler();
$dbObject->connect();
//ob_start();
//include("header.php");
?>
<?php
require_once('../tcpdf/config/lang/eng.php');
require_once('../tcpdf/tcpdf.php');

if($_REQUEST[student])
{
 //$query="select * from level_2 where student_recNo='$_REQUEST[student]'";
 $query="select a.*, s.studentName,s.ref_No,s.course_type from $_REQUEST[tab] a left join ingl_student s on  s.recNo=a.student_recNo where a.student_recNo='$_REQUEST[student]'";
}
else
{
//$query="select * from level_2 where courseId='$_REQUEST[courseId]'";
 $query="select a.*, s.studentName,s.ref_No,s.course_type from $_REQUEST[tab] a left join ingl_student s on  s.recNo=a.student_recNo where a.courseId='$_REQUEST[courseId]'";
}

$result=mysqli_query($conn,$query);
//$num=mysqli_fetch_array($result);
//echo '<pre>'; print_r($num); exit;

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

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Inlingua');
$pdf->SetTitle('Inlingua');
$pdf->SetSubject('Inlingua');
$pdf->SetKeywords('Inlingua Certificates');

// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);

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

//set margins
$pdf->SetMargins('25', '70', '25');

//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
$pdf->setLanguageArray($l);

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


while($num=mysqli_fetch_array($result))
{

 $queryCourse="select courseid,startdate,enddate,mid_enddate,language,level from ingl_course where courseid='".$num[courseId]."'";
$resultCourse=mysqli_query($conn,$queryCourse) or die("Error:There is some ploblem");
$numCourse=mysqli_fetch_array($resultCourse);


if($num['course_type']=='part1'){
	
	$toDate=$numCourse['mid_enddate'];
	$fromDate=$numCourse['startdate'];
	
}
else if($num['course_type']=='part2'){
	
	$fromDate=$numCourse['mid_enddate'];
	$toDate=$numCourse['enddate'];
	
}
else {
$fromDate=$numCourse['startdate'];	
$toDate=$numCourse['enddate'];	
}
$newlevel=explode('-',$numCourse['level']);


if($newlevel[1]=='Basic Proficiency'){
	
	$Basic = array('part1' => 'English 1 Step 1', 'part2' => 'English 1 Step 2', 'complete' => 'Basic proficiency');
	
	$coursetitle=$Basic[$num['course_type']];
	
}

if($newlevel[1]=='Pre Intermediate Proficiency'){
	
	$PreIntermediate = array('part1' => 'English 1 Step 2', 'part2' => 'English 2 Step 1', 'complete' => 'Pre-Intermediate Proficiency');
	
	$coursetitle=$PreIntermediate[$num['course_type']];
	
}
if($newlevel[1]=='Pre-Intermediate Proficiency'){
	
	$PreIntermediate = array('part1' => 'English 1 Step 2', 'part2' => 'English 2 Step 1', 'complete' => 'Pre-Intermediate Proficiency');
	
	$coursetitle=$PreIntermediate[$num['course_type']];
	
}

if($newlevel[1]=='Intermediate Proficiency'){
	
	$IntermediateProficiency = array('part1' => 'English 2 Step 1', 'part2' => 'English 2 Step 2', 'complete' => 'Intermediate Proficiency');
	
	$coursetitle=$IntermediateProficiency[$num['course_type']];
	
}

if($newlevel[1]=='Pre-Advanced Proficiency'){
	
	$PreAdvanced = array('part1' => 'English 2 Step 2', 'part2' => 'English 3 Step 1', 'complete' => 'Pre-Advanced Proficiency');
	
	$coursetitle=$PreAdvanced[$num['course_type']];
	
}
if($newlevel[1]=='Advanced proficiency'){
	
	$Advancedproficiency = array('part1' => 'English 3 Step 1', 'part2' => 'English 3 Step 1', 'complete' => 'Advanced proficiency');
	
	$coursetitle=$Advancedproficiency[$num['course_type']];
	
}


$pdf->SetFont('times', '', 11);

$fromdate1=explode("-",$fromDate);
$todate1=explode("-",$toDate);
$fdate1= date("d F Y", mktime(0, 0, 0, $fromdate1[1], $fromdate1[2], $fromdate1[0]));
$tdate1= date("d F Y", mktime(0, 0, 0, $todate1[1], $todate1[2], $todate1[0]));

$content="";
$content.='<table border="0" width="100%"><tr><td valign="center" align="center"><em><u>'.$coursetitle.' General English Language Course</u></em></td></tr>';
	
   /* <p align="center"><em><u>8<sup>th</sup> February &ndash; 22<sup>nd</sup> November 2010</u></em></p>*/
   
   $content.='<tr><td align="center"><em><u> '.$fdate1.' &ndash; '.$tdate1.' </u></em></td></tr><tr><td>&nbsp;</td></tr>';
	
	$content.='<tr><td align="center" width="100%" style="text-align:center;font-size:20;">This is to certify that </td></tr>';
	$content.='<tr><td align="center" width="100%" style="text-align:center;font-size:24;font-family: Monotype Corsiva;"><strong>'.ucfirst($num[studentName]).'</strong></td></tr>';
	
	if($num[eligibility]=='Yes')
{
$cer_comment="successfully completed the ".$coursetitle." course on the above dates and can communicate effectively in ".$numCourse[language]." at this level.";	
$status='';	
}else {
$queryg="select gender from ingl_admission where ref_No='".$num[ref_No]."'";
$resultg=mysqli_query($conn,$queryg) or die("Error:There is some ploblem");
$g=mysqli_fetch_array($resultg);

if($g['gender']=='Male')
{
$gender='he';	
}	
if($g['gender']=='Female')
{
$gender='she';	
}	
$cer_comment="attended the ".$coursetitle." course on the above dates. However, ". $gender." is unable to communicate effectively in ".$numCourse[language]." at this level.";	
}
$content.='<tr><td align="center" width="100%" style="text-align:center;font-size:20;">'.$cer_comment.'</td></tr>';
	 
$content.="<tr><td>&nbsp;</td></tr>";
$content.="<tr><td>&nbsp;</td></tr>";
$content.='<tr><td style="padding:5px;"><table border="0"><tr><td width="25%" ></td><td width="24%" border="2" bgcolor="#FFFF66" align="center" style="height:50px; "><div style=" padding:30px;"><br><b>Overall Grade</b></div ></td><td width="20%"></td><td width="15%" border="2" bgcolor="#FFFF66" align="center" ><div style=" padding:30px;"><br><b >'.nl2br ($num[overall_grade]).'</b></div></td></tr></table></td></tr>';
$content.="<tr><td>&nbsp;</td></tr>";
$content.='<tr><td width="100%" style="text-align:center;font-size:14;"><b>Eligibility for the next level:</b> '.$num[eligibility].'</td>'.'</tr></table>';

//echo $content; exit;
// add a page
$pdf->AddPage();


// set some text to print
$html = <<<EOD
 $content
EOD;
$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);

}
// print a block of text using Write()
//$pdf->Write($h=0, $txt, $link='', $fill=0, $align='C', $ln=true, $stretch=0, $firstline=false, $firstblock=false, $maxh=0);

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

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

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


?>