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

set_time_limit(0);
 ignore_user_abort(true);
session_start();

//require_once("../../student_portal/includes/user_data.php");
//global $database;

date_default_timezone_set('Africa/Lagos');


   $department = $_SESSION['department'];
    $level = $_SESSION['level'];
    $session = $_SESSION['session'];
    $semester = $_SESSION['semester'];
//   $batch = $_SESSION['batch'];

$all_student = $_SESSION['all_stu_data'];
    
    //print_r($all_student);
   
// foreach ($all_student as $st){
//     echo "Mn:".$st[0]."  Ku: ".$st[1]. "  Kp: ".$st[2]."  Pl: ".$st[3]."  Wr: ".$st[4]."<br>";
// }

//$count=0;

$output = '';



class coursePDF extends PDF_MC_TABLE
{
    	





        
       
    
    
	function Head()
	{


        global $session;
        global $level;
        global $semester;
        global $department;


        global $all_student;

     }


}
       






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

$pdf->AddPage();

$pdf->Head();

 if (isset($all_student)){
            
        	foreach($all_student as $pay)
        {	
            
           $matric = $pay[0];
           $fullname = $pay[1]." ".$pay[2];
            $dept = $pay[3];
            $pix = $pay[4];
            $sex = $pay[5];
           
           
        //   echo "Mat: ". $matric = $pay[0];
        //   echo "Full:". $fullname = $pay[1]." ".$pay[2];
        //   echo "Dept: ". $dept = $pay[3];
        //   echo "Pix: ". $pix = $pay[4];
        //   echo "Sex: ". $sex = $pay[5]."<br>";
           
           
           //echo "Mn:".$pay[0]."  Ku: ".$pay[1]. "  Kp: ".$pay[2]."  Pl: ".$pay[3]."  Wr: ".$pay[4]."<br>"; 
           // $format = substr($pix, -4);
            
            
       $Qimg = substr_replace($pix ,"", -4);
         $Qr = "../student_portal/qrFolder/".$Qimg.'.png';   
        $path='../application_account/passport/'.$pix;
        $img ='images/icon.png';
        $pdf->Ln(5);
        
       
        $xpos=$pdf->GetX();
        $ypos=$pdf->GetY();
		$pdf->Image($img,$xpos+5,$ypos+5);
		
		
		//$this->Image($Qr, $xpos+60,$ypos+5);
		//echo $Qr;
		if (file_exists($Qr)){
		   $pdf->image($Qr,165,19,30,30,'png'); 
		}
		 
		$pdf->SetFont('Arial','B',14);
		$pdf->Cell(189,5,'OSUN STATE COLLEGE OF TECHNOLOGY, ESA-OKE.',0,0,'C');
		$pdf->Ln();
		$pdf->SetFont('Times','',12);
		$pdf->Cell(189,5,'P.M.B 1011, ESA-OKE, OSUN STATE.',0,0,'C');
		
		$pdf->Ln(10);
		$pdf->SetFont('Times','BUI',12);
		$pdf->Cell(189,5,'FIRST SEMESTER EXAM PASS',0,0,'C');
		$pdf->Ln(10);
		
	
		$pdf->Cell(189,5,'Department: '.$department,0,0,'C');
		$pdf->Ln(6);
	
	
	
	$pdf->SetFont('Times','B',13);
		$pdf->Cell(35,10,'',0,0);
		$pdf->Cell(50,10,'Session: '.$session,0,0,'C');
		$pdf->Cell(30,10,'Level: '.$level.'  I',0,0,'C');
		
		$pdf->SetFont('Times','I',10);
		$pdf->Cell(79,10,'Printed Date: '.date('d/m/Y h:i a'),0,1,'R');
		$pdf->SetFont('Times','B',10);
		$pdf->SetFillColor(150,255,150);
		$pdf->SetFillColor(0,0,0);
        $pdf->Cell(195,1.5,"",1,1,'B',true,"C");
      
      
      $xpos2=$pdf->GetX();
        $ypos2=$pdf->GetY();
        if (file_exists($path)){
            $pdf->Image($path,$xpos2+155,$xpos2+60,30,30);
       //echo $path;
        }
    
      



        $pdf->SetFont('Times', 'B', 12);
        $pdf->SetFillColor(255, 0, 0);
        $pdf->Ln(5);
        $pdf->Cell(40, 5, 'Matric No: ', 0, 0);
        $pdf->Cell(60, 5, $matric, 0, 1);
        
        $pdf->Ln(5);
        $pdf->Cell(40, 5, 'Full Name: ', 0, 0);
        $pdf->Cell(120, 5, strtoupper($fullname), 0, 1);
        
        $pdf->Ln(5);
        $pdf->Cell(35, 5, 'Sex: ', 0, 0, 'C');
        $pdf->Cell(28, 5, $sex, 0, 1, 'C');


        $pdf->Ln(15);
        $pdf->Cell(120, 5,'----------------------------------------------', 0, 1, 'C');
        $pdf->Cell(120, 5, "H.O.D's Signature & Date ", 0, 0, 'C');
        


        $pdf->Ln(180);
       // $this->Cell(199,5,'-------------------------------------------------------------------------------------------------------',0,0,'C');
        
        	$pdf->SetFillColor(0,100,0);
        $pdf->Cell(195,0.5,'',1,1,'C',true);
            
         // $path='../application_account/passport/'.$pay[4]; 

        }
        
         $pdf->SetY(-15);
		$pdf->SetFont('Times','',10);
		$pdf->Cell(189,2,'Directorate of ICLSTS, Esa-Oke Copyright © 2018. All Rights Reserved.',0,0,'C');
		$pdf->Ln();
		$pdf->SetFont('Arial','',8);
		//$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
		
		$pdf->Ln(9);
		$pdf->Cell(189,10,'-------------------------------------------------------------------------------------------------------',0,0,'C');

        }


$pdf->Output('OSCOTECH EXAM PASS','I');
?>