<?php
require_once("./includes/initialize.php");
global $database;
// include('pdf_mc_table.php');

session_start();
$allsession = ONLINEPAY:: showsession();
// $adm_list =ONLINEPAY::showpayment_online("admitted_students");

    // $department = $_SESSION['department'];
    // $level = $_SESSION['level'];
    // $session = $_SESSION['session'];
    // $start_date = $_SESSION['start_date'];
    // $end_date = $_SESSION['end_date'];
    // if(isset($_POST['department']))
    // {
        $department = $_POST['department'];
        $level = $_POST['level'];
        $session = $_POST['session'];
        $start_date = $_POST['start_date'];
        $end_date = $_POST['end_date'];
    // // }

$count=0;

$output = '';



class coursePDF extends FPDF
{	
public $start_date;
public $end_date;
public $department;
public $session;
public $level;
	function Head()
	{
// 		$this->department = trim(strtoupper($department));
		$this->Image('images/icon.png',10,15);
		$this->SetFont('Arial','B',14);
		$this->Cell(189,5,'OSUN STATE COLLEGE OF TECHNOLOGY, ESA-OKE.',0,0,'C');
		$this->Ln();
		$this->SetFont('Times','',12);
		$this->Cell(189,5,'P.M.B 1011, ESA-OKE, OSUN STATE.',0,0,'C');
		$this->Ln(20);
	}
	function Background(){
          $this->Image('images/img2.png',0,0,210,300);
   }

	function footer()
	{
		$this->SetY(-15);
		$this->SetFont('Times','',10);
		$this->Cell(189,2,'Directorate of ICT, Esa-Oke Copyright © 2018. All Rights Reserved.',0,0,'C');
		$this->Ln();
		$this->SetFont('Arial','',8);
		$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
	}
	function headerTable($department, $level, $session)  //, $start_date, $end_date)
	{
	    $this->Image('images/img2.png',0,0,210,300);
	   // $adm_list = ONLINEPAY:: search_all($department, $level, $session, $start_date, $end_date);
	    $adm_list = ONLINEPAY::search_session($department, $level, $session);
		$this->SetFont('Times','BU',14);
		$this->Cell(189,20,'ADMITTED LIST',0,0,'C');
		$this->Ln(10);
		$this->SetFont('Times','',10);
		$this->Cell(189,10,'Admitted Session: 2018/2019',0,1,'L');
		$this->Cell(189,10,'Admitted Date: 19/10/2018',0,1,'R');
		$this->SetFont('Times','B',10);
		$this->SetFillColor(150,255,150);
		$this->Cell(10,10,'S/N',1,0,'C',true);
		$this->Cell(20,10,"Form No.",1,0,"C",true);
		$this->Cell(30,10,"Surname",1,0,"C",true);
		$this->Cell(40,10,"Other Names",1,0,"C",true);
		$this->Cell(50,10,"Department",1,0,"C",true);
// 		$this->MultiCell(50,10,'Department',1,0,'C',true);
		$this->Cell(20,10,"Level",1,0,"C",true);
		$this->Cell(20,10,"Session",1,1,"C",true);
		$total = 0;
		foreach ($adm_list as $list)
		{
// 			$count += 1;;
			$this->SetFont('Times','',12);
			$this->Cell(10,10,++$count,1,0,'C');
			$this->Cell(20,10,$list->formno,1,0,'C');
			$this->Cell(30,10,trim(strtolower($list->surname)),1,0,'C');
			$this->Cell(40,10,trim(strtolower($list->othernames)),1,0,'C');
// 			$this ->MultiCell(40,5,trim(strtolower($list->othernames)),1,'C',0);
			$this->Cell(50,10,trim(strtolower($list->department)),1,0,'C');
// 			$this ->MultiCell(50,5,trim(strtolower($list->department)),1,'C',0);
			$this->Cell(20,10,$list->level,1,0,'C');
			$this->Cell(20,10,$list->session,1,1,'C');
		}
	}

	function body()
	{
		$this->SetFont('Times','B',12);
		$this->SetFillColor(255,0,0);
		$this->Cell(276,5,'Welcome $surname',0,1);
		$this->Cell(50,5,$matricno,0,0,"C");
		$this->Cell(50,5, $smester,0,0,"C");
		$this->Cell(50,5,$session,0,0,"C");
		$this->Ln(20);
	}
}


$pdf = new coursePDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->Head();

// $pdf->Background();

$pdf->Ln(8);
// $pdf->headerTable('Power/Machine(Option)', 'HND', '2018/2019', '', '');
$pdf->headerTable($department, $level, $session);
// $x=$pdf->GetX();

$pdf->Output();
?>