<?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:index.php");
}


$session = get_current_session($id = '1'); //current session is always
$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 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);

$mat_no = strtoupper (get_user_mat_no($u));

//customly collect the title
$title = str_replace ('/','_',$mat_no). '-Admission Letter';
$title =strtoupper($title);
$author = get_user_fullname($u).'_ COE NCE';


// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor($author);
$pdf->SetTitle($title);
$pdf->SetSubject('Admission Letter ');
$pdf->SetKeywords('COE NCE, PDF, admission, letter, '.$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', '', 16);

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



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

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


//get signage <span align="left" style="position:absolute;top:700px;"> 

$signage = 'images/signage2.png';
//$output2  .= '<img  src="'.$signage.'" border="0" height="36" width="150" />';


$serial_no = put_admission_serial_no($u);//serial no
$name = strtoupper (get_user_fullname($u));
$gender =  strtoupper (get_user_gender($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)));





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


//$entry_year = get_user_entry_year($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)));

//$today_date = date('Y-m-d-His');
$today_date = '2nd January, 2019';

//set the content //this is my own function
$output = '';


 $output  .= '<span align="center"> <img  src="'.$logo.'" border="0" height="79" width="80" /></span>';
 $output .= '<h5>NIGER STATE COLLEGE OF EDUCATION, MINNA</h5>';
 $output .= '<h6 style="color:#468C00;font-size:10px;">P.M.B 39 Niger State | Tel: 066 223260, 066 222205  | Website: coeminna.edu.ng | Email: info@coeminna.edu.ng </h6>';
// $output .= '<h4><i>NIGERIA CERTIFICATE IN EDUCATION</i></h4>';
 //$output .= '<h5  style="color:#468C00; font-weight:normal" >ADMISSION LETTER</h5><p align="right" style="color:#468C00;font-size:10px;margin-top:-30px;"  > P.M.B 39 Niger State <br/>Tel: 066 223260, 066 222205 <br/>Website: coeminna.edu.ng <br/>Email: info@coeminna.edu.ng </p>';
 $output .= '
 <p  align="left" style="font-size:10px;"  >Provost: Professor Yakubu M. Auna <br/>B.Sc, M.Agric, Ph.D, PGDE, PGDM 
			  <br/><br/>
			  Registrar: Mall. Yaabagi A. Alfa <br/>NCE, B.Ed
			 
			  </p> ';


 
 //$output .= '<h5  style="color:#FF0000; font-weight:normal" >ADMISSION LETTER</h5>';
 $output  .= '<span style="font-size:13px; font-weight:bold;" align="right"> <i>Serial No..:'.$serial_no.' </i></span> <br/>'; 
 
  $output  .= '<span style="font-size:10px; font-weight:bold;" align="left">Dear '.$name.', ('.$mat_no.')'.'</span>';

 
	
 $output  .= '<h5 align="center" style="font-weight:bold;color:#FF0000;"> '. $st .' PROVISIONAL ADMISSION INTO NCE PROGRAMME.</h5>';
 

 
 





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

<div align="center"> $output </div>
 
 
 <span style="font-size:12px;">After due consideration of your recent application, seeking admission into this college, I am pleased to inform you that you have been offered Provisional
 Admission for a period of three (3) Academic session(s) for <strong>$pt</strong> in <strong>$programme</strong> </span><br/>
  
 <span style="font-size:12px;">You are expected to report in the college immediately with the following documents to present during registration: </span>
 
 <p>
  <br><span style="font-size:12px;">a. This letter of offer of Provisional Admission.</span>
  <br><span style="font-size:12px;">b. Original copies of Certificates of Statement of Results upon which this admission is based.</span>
  <br><span style="font-size:12px;">c. Original Birth Certificate or Declaration of Age.</span>
  <br><span style="font-size:12px;">d. Medical Certificate of fitness duly signed by personnel of Government Medical Center.</span>
  <br><span style="font-size:12px;">e. Proof of State of Origin.</span>
  <br><span style="font-size:12px;">f. Six (6) Passport size photographs.</span>
  <br><span style="font-size:12px;">g. Four (4) File Jackets (Available in the College).</span>
  
  </p>
  
  <span style="font-size:12px;">In the absence of any response from you within two weeks of this offer, the college will assume that you are not interested in the
  offer and may proceed to fill your place. </span>
  
  <br><span style="font-size:12px;">Note also that if at any time it is discovered that you have made false declaration in any form or participated in anti-social activities,
  this offer of admission will be withdrawn and  be expelled from the college. </span>
  
    <br><span style="font-size:12px;">No change of names will be allowed once a student has been admitted and registered. </span>

    <br><span style="font-size:12px;">All Students admitted into this college must arrange to pay the required registration fee and other charges immediately. </span>
 
 
EOD;


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

//set this to show scanned image
$output2 = '';
$output2  .= '<span align="left" style="position:absolute;top:700px;"> <img  src="'.$signage.'" border="0" height="36" width="150" /></span>';

$txt2 = <<<EOD
<table cellspacing="1"  border="0" cellpadding="1" style="font-size:10px;margin-top:0px;">
			  
			  <tr><td width="35%"><strong>Congratulations!</strong> </td>
			  <td width="30%">   </td>
			  <td width="30%">$output2</td>
			  </tr> 
			  
			  
			  <tr><td width="35%">  </td>
			  <td width="30%">  </td>
			  <td width="30%"><strong>Academic Secretary for Registrar<br/>$today_date</strong></td>
			  </tr> 
			  
</table>

EOD;

//show the message
$pdf->writeHTML($txt2, true, false, false, false, '');



//set this to show remaining string

$txt3 = <<<EOD





EOD;

//show the message
$pdf->writeHTML($txt3, true, false, false, false, '');

 
 
 //
// <table cellspacing="1"  border="0" cellpadding="1" style="font-size:16px;">
//			  
//			  <tr><td width="35%">____________________ </td>
//			  <td width="30%">   </td>
//			  <td width="30%"></td>
//			  </tr> 
//			  
//			   <tr><td width="35%"><strong>Dr Nuhu Ango </strong></td>
//			  <td width="30%">   </td>
//			  <td width="30%"><strong><i>Date</i></strong></td>
//			  </tr> 
//			  
//			  
//			   <tr><td width="35%"><strong><i>Deputy Director</i></strong></td>
//			  <td width="30%">   </td>
//			  <td width="30%">$today_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
//============================================================+
