<?php


session_start();


//call the session start

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=my_profile");
}


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

//$session = 4;
$st = get_session_title($session);

$st = strval($st); 


// 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, 'NIGER STATE COLLEGE OF EDUCATION MINNA.', 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/eportal NCE- ePortal,  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_application_number($u)). '-PROFILE';
$title =strtoupper($title);
$author = get_user_fullname($u).'_ COEMINNA';


// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor($author);
$pdf->SetTitle($title);
$pdf->SetSubject('Bio - data ');
$pdf->SetKeywords('COEMINNA, PDF, biodata, slip, '.$session.'');


// 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', '', 12);

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



//for imge
$image = get_user_image($u);//get image
if($image != '')
{
	$passport = '../uploads/'.$image;

}
else
{
	$passport = '../uploads/img.jpg';

	
}



//set the content //this is my own function
$output = '';
$output .= '<h5 class="text-info"  style="color:#468C00; font-weight:normal">A C K N O W L E D G E M E N T - S L I P  </h5>';
$output  .= '<h6 class="text-info"  style="color:#9999; font-weight:normal"> '. $st .' SESSION.</h6>';
 
 //$output  .= '<span align="right"  style="border:#9999 2px solid;"> <img  src="'.$passport.'" border="0" height="71" width="61" /></span>';
	  
//collect other dinfo
$dept_id = get_department_id($u);
$fname = get_user_first_name($u);
$midname = get_user_middle_name($u);
$other_name = get_user_other_names($u);

$full_name =  strtoupper ($fname .' '.$midname.' '.$other_name);
$application_no = strtoupper (get_user_application_number($u));
$gender =  strtoupper (get_user_gender($u));
$pob = strtoupper(get_user_pob($u));
$dob = get_user_day($u) .'/'.get_user_month($u).'/'.get_user_year($u);
$ms = strtoupper(get_user_ms($u));
$religion = strtoupper(show_religion(get_user_religion($u)));
$nationality = strtoupper(show_nationality(get_user_nationality($u)));
$country = strtoupper(show_country(get_user_country_id($u)));
$so = strtoupper(show_state(get_user_state_id($u)));
$lo = strtoupper(show_lga(get_user_lga_id($u)));

//contact info
$pn = get_user_phone_no($u);
$email = get_user_email($u);
$address = get_user_address($u);
$p_address = strtoupper(get_user_permanent_address($u));
$nok_name = strtoupper(get_user_guardian_name($u));
$nok_r = strtoupper(get_user_guardian_relationship($u));
$nok_tel = get_user_guardian_tel($u);
$nok_add = strtoupper(get_user_guardian_address($u));
$sp_t = strtoupper(show_sponsorship_type(get_user_sponsorship_type($u)));
$sp_n = strtoupper(get_user_sponsorhip_name($u));
$sp_add =   strtoupper(get_user_sponsorship_address($u));

//collect academic info
$pt = strtoupper(show_programme_type(get_user_programme_type_applied_for($u)));


//$entry_year = get_user_entry_year($u);
//$faculty = strtoupper(get_faculty_title(get_faculty_id($u)));
$school = strtoupper(get_school_title(get_user_school_applied_for($u)));
$department = strtoupper(get_department_title(get_user_department_applied_for($u)));
$programme = strtoupper(get_programme_title(get_user_programme_applied_for($u)));




//health info
$hs = strtoupper(get_user_h_status($u));
$dis =  strtoupper(get_user_disability($u));
$bg = strtoupper(get_user_bg($u));
$medi = strtoupper(get_user_medication($u));

$pre_nce = '';
$pre_no = get_user_prence_no($u); 

if ($pre_no) {
	$pre_nce =  '<tr><td width="100%">PRE-NCE Reg Number: <b>'.$pre_no.'</b></td></tr>'; 
}

$utme = '';
$utme_no = get_user_jamb_no($u); 
$utme_score = get_user_jamb_score($u); 

if ($utme_no) {
	$utme = '<tr>
			<td width="50%">UTME Reg Number: <b>'.$utme_no.'</b></td>
			<td width="50%">UTME Score: <b>'.$utme_score.'</b></td>
		</tr>'; 
}







// set some text to print
$txt = <<<EOD
<div align="center"> $string_ </div> 

<div align="center"> $output </div>
 
 
 <h6 style="border-bottom:solid thin #CCC; margin-bottom:3px;">BIODATA</h6>
 
 <table cellspacing="1"  border="1" cellpadding="1" style="font-size:11px;">
			  
			  <tr><td width="50%">NAME : $full_name</td>
			  <td width="30%"> APPLICATION No. :<b> $application_no  </b></td>
			  <td width="20%"> GENDER : $gender</td>
			  </tr> 
			
			   <tr>
			   
			   <td width="50%">DATE OF BIRTH: $dob</td>
			   <td width="50%">PLACE OF BIRTH: $pob</td>
			  
			  </tr> 
			  
			  <tr>
			  <td width="25%"> MARITAL STATUS: $ms</td>
			  <td width="25%"> RELIGION : $religion</td>
			  <td width="50%">NATIONALITY: $nationality</td>
			  </tr> 
		
			  
			  <tr>
			  <td width="50%"> COUNTRY OF ORIGIN: $country</td>
			  <td width="50%"> STATE / L.G.A:  $so  /  $lo</td>
			  </tr> 
		
 </table>
 
 <br><br>
 
 <h6 style="border-bottom:solid thin #CCC">CONTACT INFORMATION</h6>
 <table cellspacing="1"  border="1" cellpadding="1" style="font-size:11px;">
			  
			  <tr>
			  <td width="50%">PHONE NO. : $pn</td>
			  <td width="50%"> EMAIL : $email</td>
			  </tr> 
			  
			  <tr>
			  <td width="100%">PRESENT CONTACT ADD. : $address</td>
			  </tr>
			  
			   <tr>
			  <td width="100%">PERM. CONTACT ADD. : $p_address</td>
			  </tr> 
			
			
			  <tr>
			  <td width="100%">PARENT / GUARDIAN : </td>
			  </tr> 
			
			  <tr>
			  <td width="50%">NAME : $nok_name</td>
			  <td width="50%"> R/SHIP : $nok_r</td>
			  </tr> 
			  
			  <tr>
			  <td width="30%">TEL: $nok_tel</td>
			  <td width="70%">ADDRESS : $nok_add</td>
			  </tr> 
			
			  <tr>
			  <td width="100%">SPONSORSHIP: </td>
			  </tr>
			  
			   <tr>
			  <td width="35%">TYPE: $sp_t</td>
			  <td width="65%">NAME: $sp_n</td>
			  </tr> 
			  <tr>
			  <td width="100%">ADDRESS: $sp_add</td>
			  </tr> 
		
			
		
 </table>
 <br><br>
 
  <h6 style="border-bottom:solid thin #CCC">ACADEMIC INFORMATION</h6>
 <table cellspacing="1"  border="1" cellpadding="1" style="font-size:11px;">
			  
 			$pre_nce
 			$utme
			  <tr><td width="100%">PROGRAMME TYPE : $pt</td>
			 
			  </tr> 
			
			   <tr>
			   
			  <td width="50%"> APPLIED SCHOOL: $school</td>
			   <td width="50%"> APPLIED PROGRAMME : $programme</td>
			 
			  </tr> 
			  
			 
			
		
 </table>

 
 
 
 
<br><br>
 
		
		
<h6 style="border-bottom:solid thin #CCC">HEALTH  INFORMATION</h6>
 <table cellspacing="1"  border="1" cellpadding="1" style="font-size:11px;">
			  
			  <tr><td width="35%">HEALTH STATUS : $hs</td>
			  <td width="35%"> DISABILITY : $dis </td>
			  <td width="30%"> BLOOD GROUP : $bg </td>
			  </tr> 
			
			   <tr><td width="100%">MEDICATIONS: $medi </td>
			  </tr> 
			  
			 
 </table>
 
 
 
 <br><br>
 <table cellspacing="1"  border="1" cellpadding="1" style="font-size:11px;">
			  
			  <tr>
			  <td width="100%">I certify that the information entered herein is to the best of my knowledge & belief, correct & complete. <br><br>
			  ..................................................................................................................................................................................</td>  
			  </tr> 
			
			   <tr><td width="100%">(SIGNATURE OF APPLICANT's & DATE)</td></tr> 
			  
			 
 </table>
		  


EOD;

// print a block of text using Write()
//$pdf->Write(0, $txt, '', 0, 'C', true, 0, false, false, 0);

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

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






// -- set new background ---

//// get the current page break margin
//$bMargin = $pdf->getBreakMargin();
//// get current auto-page-break mode
//$auto_page_break = $pdf->getAutoPageBreak();
//// disable auto-page-break
//$pdf->SetAutoPageBreak(false, 0);
//// set bacground image
//$img_file = K_PATH_IMAGES.'bg.jpg';
//$pdf->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
//// restore auto-page-break status
//$pdf->SetAutoPageBreak($auto_page_break, $bMargin);
//// set the starting point for the page content
//$pdf->setPageMark();


$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
//============================================================+
