<?php

ob_start();


//include my own function
include 'includes/functions.php';



//customly collect the id and session
if(isset($_GET['u']))
{
	$u = $_GET['u'];
	$s = $_GET['s'];
}
else
{
	header("Location:dashboard.php?act=excard&qlk=".md5(8));
}
//collect other dinfo
$school_id = get_user_school_id($u);
$dept_id = get_user_department_id($u);
$programme_id = get_user_programme_id($u); //get programme if for a suer
$level = get_user_level($u); //get user level 
$programme_type = get_user_programme_type_id($user); //programme type


$session = get_current_session($id = '1'); //current session is always
$semester = get_current_semester($id = '1'); //current session is always

//for imge
$image = get_user_image($u);//get image
if($image != '')
{
	$passport = '<img  src="../uploads/'.$image.'" border="0" height="71" width="61" />';
	
	

}
else
{
	$passport = '<img  src="../uploads/img.jpg" border="0" height="71" width="61" />';


	
}

//get logo
$logo = 'images/coe.png';



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


// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF {

	//Page header
	public function Header() {
		// Logo
		//$image_file = K_PATH_IMAGES.'logo.jpg';
		//$this->Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
		// Set font
		//$this->SetFont('helvetica', 'B', 14);
		// Title
		//$this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M'); original commented 
		//$this->Cell(0, 15, 'IBBU CONSULT & SERVICES', 0, false, 'C', 0, '', 0, false, 'M', 'M');
	}

	// Page footer
	public function Footer() {
		// Position at 15 mm from bottom
		$this->SetY(-15);
		// Set font
		$this->SetFont('helvetica', 'I', 8);
		// Page number
		$this->Cell(0, 10, "SOURCE: www.coeminna.edu.ng NIGER STATE COLLEGE OF EDUCATION MINNA - STUDENT Portal,  Page ".$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
	}
}

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


//customly collect the title
$title = str_replace ('/','_',get_user_mat_no($u)). '-EC';
$title =strtoupper($title);
$author = get_user_fullname($u).'_ COEMINNA';


// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor($author);
$pdf->SetTitle($title);
$pdf->SetSubject('Course Form');
$pdf->SetKeywords('COEMINNA, PDF, course, slip, '.$s.'');


// set default header data
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, 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, PDF_MARGIN_TOP, 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);
}

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

// set font
//$pdf->SetFont('times', 'BI', 12) original;
$pdf->SetFont('times', '', 13);

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




//collect other dinfo
$dept_id = get_user_department_id($u);
$level = get_user_level($u); //get user level 
$name = strtoupper (get_user_fullname($u));
$mat_no = strtoupper (get_user_mat_no($u));


//collect academic info
$pt = strtoupper(show_programme_type(get_user_programme_type($u)));
$study_mode = strtoupper(show_study_mode(get_user_study_mode($u)));
$school = strtoupper(get_school_title(get_user_school_id($u)));
$department = strtoupper(get_department_title(get_user_department_id($u)));
$programme = strtoupper(get_programme_title(get_user_programme_id($u)));

$st =  get_session_title($session);
$smt =  get_semester_title($semester);



//set the content //this is my own function
$output0 = '';
  //$output = '<div class="text-center"><img src="../images/logo.png" height="80"  width="80"/></div>';
  
  $output0  .= '<span align="center"> <img  src="'.$logo.'" border="0" height="79" width="80" /></span>';
 
  $output0 .= '<br/><h5  style="color:#00000; font-weight:normal" ><i>P.M.B 39, MINNA, NIGER STATE</i></h5>';
 //$output0 .= '<h3>NON-DEGREE PROGRAMME UNIT</h3>';
 $output0  .= '<h6   style="color:#00000; font-weight:normal"> '. $st .' ACADEMIC SESSION.</h6>';
 $output0 .= '<h5  style="color:#FFFFFF; font-weight:bold;background-color:#3A8252;"  > EXAMINATION CARD  </h5>'; 

  $output ='';


  //view the temporary table and show the preview for first semester
  $q3 = " SELECT `id`, `student_id`, `programme_id`, `course_id`, `course_unit`, `seen_as_elective`, `session_id`, 
		 `semester`, `level`, `add_drop_status`, `delete_token`,  `date_added` 
		 FROM `students_courses_nce`
		 WHERE  student_id ='$u'
		 AND session_id = '$session' 
		 ORDER BY date_added
		 "; //semester = '$semester'  AND
	  
	  $r3 = mysqli_query(dbc(),$q3);
	  $sn = 0 ;
	  if(mysqli_num_rows($r3) > 0)
	  {//show table
	  
    	  	
            //$output .= '<h5 id="list" class="btn btn-primary">FIRST SEMESTER</h5> <br>';
  
		  
	        $output .=	'<table cellspacing="1"  border="1" cellpadding="3" style="font-size:8px;">
			 				 <thead>
						  <tr>
						  <th width="20%"><b>S/N</b></th>
						  <th width="30%"><b>CODE</b></th>
						  
						  </tr>
						  
			   				</thead>
			  			<tbody>';
	  
		  while($row = mysqli_fetch_array($r3, MYSQLI_ASSOC))
		  {
			  
			  
			  $output .= "<tr>";
			  $output .= '<td width="20%">'.$sn = $sn+1 .'</td>';
			  $output .= '<td width="30%">'.get_course_code($row['course_id'])."</td>";
			  $output .= '<td width="50%">'.strtoupper(get_course_name($row['course_id']))."</td>";
			   $output .= "</tr>";
			  
		  }
	  }
	  else
	  {//show the msg 
	  
			  $output .='No record found.';
		  
		  
	  }
	  
	  
	  
	  $output .=
	  '</tbody>
	  </table>';
	  
	  
	  

  
 

// set some text to print
$txt = <<<EOD


<br/>
<div align="center"> $output0 </div>

 <div align="right">$passport </div>

 
 <table cellspacing="1"  border="1" cellpadding="3" style="font-size:8px;">
			  
			  <tr>
			  <td width="30%"> <b>MATRIC No. :</b> $mat_no</td>
			  <td width="50%"> <b>NAME :</b> $name</td>
			 <td width="20%"> <b>LEVEL :</b> $level</td>
			   
			  </tr> 
			
			  
			  <tr>
			  
			  <td width="50%"><b>PROGRAMME TYPE :</b> $pt</td>
			  <td width="50%"> <b>PROGRAMME :</b> $programme</td>

			  
			  </tr> 
			
			  
			 
		
 </table>
 
 <br>


$output


<br><br><br/><br/>



<table style="font-size:9px;" border="0" cellspacing="0" cellpadding="1">


<br>

<tr>
<td width="20%">
</td>
<td width="60%">
................................................................................................................................. <br>
 ______________ Examination Officer's Signature, Stamp & Date _________________
</td>
<td width="20%">
</td>
</tr>

<br/><br/>

<table style="font-size:8px;" border="0" cellspacing="0" cellpadding="1">

<tr>
<td width="50%" style="color:red;">
**** Note:You will not be allowed to sit for any paper without the presentation of this card.
This card must be printed in colors to make it valid. Black & white copy will not be accepted. ****
</td>
</tr>


</table>

<br/><br/><br/>



<strong>EXAMINATION RULES. </strong><br/>
<strong>1.</strong> Students shall be at Examination venue at least 30 minutes before the advertised
commencement time of examination. <br/>
<strong>2.</strong> A Student shall bring examination card and I.D card to be displayed in a prominent
position on the desk in the examination venue.<br/>
<strong>3.</strong> No book, printed paper, programmed calculator, GSM(hanset) shall be taken into any
examination venue by any student.<br/>
<strong>4.</strong> A student must not, during examination, directly or indirectly give any form of assistance
to any other student or permit any other student to copy from, or use his/her papers during
examination. Similarly, a student must not directly or indirectly accept any form of
assistance from other students. <br/>
<strong>5.</strong> If a student needs anything, the Invigilator should be called upon by the student by raising
up his/her hand. <br/>
<strong>6.</strong> A student may only be permitted by an Invigilator to leave the examination room during
the course of an examination provided he/she:<br/>
<strong>(a.)</strong> has stayed up to 1 hour in the examination hall.<br/>
<strong>(b.)</strong> has handed over his/her script to the Invigilator.<br/>
<strong>7.</strong> A student who leaves the examination room shall not be readmitted unless throughout the
period of his/her absence he/she has been continually under the supervision of an Invigilator
or Assistant Invigilator. <br/>
<strong>8.</strong> A student who arrives 15 minutes late after the start of an examination paper may be
allowed to enter into the examination venue but shall not be given extra time to take the
examination paper. However, a student who arrives 30 minutes late after the start of any
examination paper may not be allowed to enter the examination venue to take the
examination. <br/>


EOD;



$pdf->writeHTML($txt, true, false, false, false, '');

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



//temporarily use it 
ob_end_clean();


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

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