<?php

session_start();


//call the session start

ob_start();




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



//$r = '';

//customly collect the id and session
if (!isset($_SESSION['rrr']) == 'myrrr'){
	header("Location: /autorize_message");

}

//unset the session if the candidate is actually logged in
unset($_SESSION['rrr']);


// if(isset($_GET['r']) && isset($_GET['qlk']) && isset($_GET['u']) )

//validating parameters
if(isset($_GET['r'],$_GET['qlk'],$_GET['u']) )
{
	$r = $_GET['r'];
	$u = $_GET['u'];

}
else
{
	header("Location: /autorize_message");

}


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

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

//echo  $st;
//exit();


// 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.- (DUAP ABU)', 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_matric_no($u)). '-RRR';
$title =strtoupper($title);
$author = get_user_fullname($u).'_ COEMINNA';


// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor($author);
$pdf->SetTitle($title);
$pdf->SetSubject('RRR ');
$pdf->SetKeywords('COEMINNA, PDF, RRR, 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();







//set the content //this is my own function
$output = '';
$output .= '<h5 class="text-info"  style="color:#468C00; font-weight:normal">RRR - 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
$name = strtoupper (get_user_fullname($u));
$matric_no = strtoupper (get_matric_no($u));
$pn = get_user_phone_no($u);
$email = get_user_email($u);
$address = get_user_address($u);
$level = get_user_level($u);
$p_address = strtoupper(get_user_permanent_address($u));

$t_ref = $_SESSION['txnref'];
$invoice_id =  $_SESSION['iida'] ;
$total_amt =   'N'.number_format($_SESSION['amnttr']  +  $_SESSION['amtextra']);

$pay_info = "
			<ol>
				<li>Visit the Student Portal via www.coeminna-edu.ng</li>
				<li>Click on payments on the Main Menu</li>
				<li>Click on School Fees, then click on the Green (+) plus sign
					to generate invoice for payments</li>
				<li>Click on Pay via Remita, here you can choose to pay online or visit
					any Bank Branch to make payment using the RRR Code</li>
				<li>If the payment is successful, logon back into the Portal and print
				your e-Receipt.
				</li>


			</ol>
			<br>

	";
$banks = '<tr>
		  	<td width="33%">ACCESS BANK PLC</td>  <td width="33%">CITI BANK</td>  <td width="34%">DIAMOND BANK PLC</td>
		  </tr>
		  <tr>
		  	<td width="33%">ECOBANK NIGERIA PLC</td>  <td width="33%">FIDELITY BANK PLC</td>  <td width="34%">FIRST BANK OF NIGERIA PLC</td>
		  </tr>
		  <tr>
		  	<td width="33%">FIRST CITY MONUMENT BANK PLC</td>  <td width="33%">GUARANTY TRUST BANK PLC</td>  <td width="34%">HERITAGE BANK</td>
		  </tr>
		  <tr>
		  	<td width="33%">ZENITH BANK PLC</td>  <td width="33%">KEYSTONE BANK</td>  <td width="34%">SKYE BANK PLC</td>
		  </tr>
		  <tr>
		  	<td width="33%">STERLING BANK PLC</td>  <td width="33%">UNION BANK OF NIGERIA PLC</td>  <td width="34%">UNITY BANK PLC</td>
		  </tr>
		  <tr>
		  	<td width="33%">JAIZ BANK</td>  <td width="33%">STANDARD CHARTERED</td>  <td width="34%">WEMA BANK PLC</td>
		  </tr>
		  <tr>
		  	<td width="33%">STANBIC-IBTC BANK PLC</td>  <td width="33%">UNITED BANK FOR AFRICA PLC</td>  <td width="34%">COE-MINNA MICROFINANCE BANK</td>
		  </tr>

';

$pay_is = 'For payment issues, kindly text your Matric Number,  Transaction Reference and RRR to this Phone Number<br>
		08142411717 (Text Only!)';


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

 	<div align="center">
		<h2 style="border:solid thin #CCC; font-size:35px;"><b>RRR: $r</b></h2>
	</div>

 <h3 style="border-bottom:solid thin #CCC; margin-top:5px ">STUDENT INFORMATION</h3>
 <table cellspacing="1"  border="1" cellpadding="1" style="font-size:11px;">
			  <tr>
				  <td width="50%">NAME : $name</td>
				  <td width="50%"> Matric No. :<b> $matric_no  </b></td>
			</tr>
			  <tr>
			  <td width="50%">LEVEL: $level </td>
			  <td width="50%">PHONE NO. : $pn</td>
			  </tr>

			  <tr>
			  <td width="100%">EMAIL : $email</td>
			  </tr>

			  <tr>
			  <td width="100%">PRESENT CONTACT ADDRESS. : $address</td>
			  </tr>


 </table>


 <h3 style="border-bottom:solid thin #CCC">PAYMENT DETAILS</h3>
 <table cellspacing="1"  border="1" cellpadding="1" style="font-size:15px;">
	  <tr >
		  <td width="70%">
			 <b>Trans. Reference: $t_ref</b>
		  </td>

		  <td width="30%">
		  	<b>Invoice Id: $invoice_id</b>
		  </td>
	</tr>
	<tr  >
	   <td width="100%">
		  <b>Amount: $total_amt </b> <i style="font-size:12px;">(No Refund After Payment)</i><br>
		  	<b>Note: Online Payment via ATM Card attract an extra Service Charge of N100 </b>
		  </td>

	</tr>


 </table>

  <h3 style="border-bottom:solid thin #CCC">PAYMENT INSTRUCTIONS</h3>
 <table cellspacing="1"  border="1" cellpadding="1" style="font-size:11px;">
	  <tr>
		  <td width="100%">
		  $pay_info
		  </td>

	</tr>
 </table>

 <h3 style="border-bottom:solid thin #CCC">SUPPORTED BANKS FOR PAYMENTS</h3>
 <table cellspacing="1"  border="1" cellpadding="1" style="font-size:10px;">
	 $banks
 </table>


 	<div align="center">
		<h1 style="border:solid thin #CCC; font-size:10px;">
			<b>$pay_is</b>
		</h1>
	</div>








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

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


// Debug the content of some variable



//temporarily use it
ob_end_clean();

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


//ob_end_flush();

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