<?php 
ob_start(); session_start();

// error_reporting(E_ALL);
// ini_set('display_errors',1);

require('includes/initialize.php');

//echo "opoo: ".$_SESSION['stdid'];
if (!isset($_SESSION['stdid'])) {
    redirect_to("index.php");
}else{
    $stdid = $_SESSION['stdid'];
}
$msg='';$data=''; $data2=''; $type='';$s=array();$s1=array();$s2=array();$s3=array();$s4=array();

//echo $stdid;

//report($table, $id='');
$data = Biodata::report('form_data',$stdid);
//echo "Passport:  ".$data->id;
//  Passport:  ".$data->passport;
 
 
// if (!isset($data->id)){
    
//     $data = Biodata::report('form_data22',$stdid);
    
//   print_r($data);
// } 


if (!isset($data->id)){
    
    $data = Biodata::reportonline('form_data22',$stdid);
    
//   echo $data->passport;
} 


if (!isset($data->id)){
    
    $data = Biodata::reportonline('form_data21',$stdid);
    
   
}



if (!isset($data->id)){
    
    $data = Biodata::reportonline('form_data',$stdid);
    
   
}



//echo $data->passport;

if (!isset($data->passport)){
    // $data =Biodata::report1('form_data',$stdid);
    
   
    
}
///echo $data->formno;
if (!isset($data->passport)){
    
     
    //   $data =Biodata::report1('form_data22',$stdid);
    //   echo $stdid;
    //  echo  "Passport:  ".$data->passport;
}
//$form =substr($data->formno, 0,2);
//echo $stdid;
if (isset($data->formno)){
    
    
   
     $data2 =Biodata::report2($stdid);
     
     //echo $data2->acc_id;
}else if (!isset($data->formno)){
    
  
}
  //echo "STUD: ".$data->surname;
  
//   $form=substr($data->formno, 2,2);
  
//   if ($form=='21'){
      
//          $kpp =  Biodata::restrictB();
     
//      //echo "Here";
//      $data2 =Biodata::report22('form_data21',14057); 
//   }
$type=substr($data->formno, 0,2);

//echo "Form: ".$type.' '.substr($data->formno, 2,2);

$s=explode(':',$data2->sub1);
$s1=explode(':',$data2->sub2);
$s2=explode(':',$data2->sub3);
$s3=explode(':',$data2->sub4);
$s4=explode(':',$data2->sub5);
//print_r($s);



//  function truncateString($str, $chars, $to_space, $replacement="...") {
//   if($chars > strlen($str)) return $str;

//   $str = substr($str, 0, $chars);
//   $space_pos = strrpos($str, " ");
//   if($to_space && $space_pos >= 0) 
//       $str = substr($str, 0, strrpos($str, " "));

//   return($str . $replacement);
// }
    
?>


<?php require('includes/fpdf/fpdf.php');

class PDF extends FPDF
{
    
   
    
    
  function Header()
    {
    	
     global $msg;
      $this->SetFont('Helvetica','B',19);
     // $this->SetFillColor('224','224','224');
      
      
      $this->Cell(0,10,'OSUN STATE COLLEGE OF TECHNOLOGY, ESA-OKE.',0,1,'R');



      $this->Image('images/img2.jpg',10,24,20);

      $this->SetFont('Helvetica','B',13);

      $this->Cell(0, 14, 'P.M.B 1011, ESA-OKE, OSUN STATE.', 0, 1, 'C');

     


      $this->Line(10, 50,210-10,50);

      $this->SetFont('courier','BI',12);
      $this->Cell(0,10,$msg,0,1,'C');

     }

     function HeaderTable(){

     	global $data;
     	global $data2;
     
      global $s;
      global $s1;
      global $s2;
      global $s3;
      global $s4;
      
      
      
  function truncateString($str, $chars, $to_space, $replacement="...") {
  if($chars > strlen($str)) return $str;

  $str = substr($str, 0, $chars);
  $space_pos = strrpos($str, " ");
  if($to_space && $space_pos >= 0) 
      $str = substr($str, 0, strrpos($str, " "));

  return($str . $replacement);
}




     	$this->Ln(7);
     	$this->SetFont('Helvetica','B',17);
      //$this->SetXY(5, 10);
      if (substr($data->passport,2,2)=='22'){
          
        echo $this->Image('passport22/'.$data->passport,170, 24, 25, 25);
         
      }else if (substr($data->passport,2,2)=='21'){
          
         $this->Image('passport/'.$data->passport,170, 24, 25, 25);
      }
     	$this->SetFont('courier','BI',16);

      $this->SetFillColor(27,73,15);
      $this->SetTextColor(255,255,255,255);
      $this->Cell(0,10,"ADMISSION SCREENING RECEIPT",0,1,'C',TRUE);

          $this->SetFont('Helvetica','B',17);
          $this->SetTextColor(0,0,0,0);
          $this->Ln(5);
      
      $this->Cell(0,10,strtoupper($data->surname.' '.$data->othernames),0,1,'C');
         
         
    //  $this->SetFont('courier','B',12);

    //  $this->Cell(35,10,'Date ',1,0,'L'); 
      
      $this->SetFont('courier','',12);

       $this->cell(0,10,'Printed on: '.date('m/d/Y h:i:s a', time()),0,1,'C');

        
        //HND First two lines
        
        
                  $this->Ln(4);
      $this->SetFont('courier','B',12);
     	$this->Cell(30,10,'Form No ',1,0,'L');
       $this->SetFont('courier','',12);
      $this->Cell(35,10,$data->formno, 1, 0,'L');

     	$this->SetFont('courier','B',12);

      $this->SetFont('courier','B',12);
     	$this->Cell(35,10,'Phone No ',1,0,'L');
       $this->SetFont('courier','',12);
      $this->Cell(40,10,$data->phone, 1, 0,'L');

        

      //$this->Ln(0);




        $this->SetFont('courier','B',12);
      $this->Cell(15,10,'Level: ',1,0,'L');

        $this->SetFont('courier','',12);
      $this->Cell(0,10,$data->level, 1, 1,'L');


     
      
     

      $this->Ln(0);

        
        
        
        
    

        

      





       






        


      






       
         


        $this->SetFont('courier','B',12);

      
          
        $this->Cell(30,10,'Department ',1,0,'L'); 
      
      $this->SetFont('courier','',12);

      $this->Cell(0,10,$data->department, 1, 1,'L');



    $this->SetFont('courier','B',12);

      
          
        $this->Cell(30,10,'Session ',1,0,'L'); 
      
      $this->SetFont('courier','',12);

      $this->Cell(35,10,'2022/2023', 1, 0,'L');

      $this->SetFont('courier','B',12);

      $this->Cell(30,10,'Trans. ref ',1,0,'L'); 
      
      $this->SetFont('courier','',12);

      $this->Cell(0,10,$data->txt_ref, 1, 1,'L');
      
      
       $this->SetFont('courier','B',12);
          
    $this->Cell(30,10,'Amount ',1,0,'L'); 
      
      $this->SetFont('courier','',12);

      $this->Cell(35,10,'#5000', 1, 0,'L');
    
      $this->Cell(0,10,'Five Thousand Naira Only', 1, 1,'L');

    

     
      
      $this->SetFont('courier','B',12);

     $this->Cell(65,10,'Payment mode ',1,0,'L'); 
      
      $this->SetFont('courier','',12);

      $this->Cell(0,10,'Online', 1, 1,'L');



///////////////////////////////////////////////////////////////////////////////


  $this->Ln(3);
         $this->Line(10, 165,210-10,165);

    

      $this->SetFont('courier','BI',16);

      $this->SetFillColor(27,73,15);
      $this->SetTextColor(255,255,255,255);
      


            $this->ln(70);


            $this->SetFont('Helvetica','B',10);
     // $this->SetFillColor('224','224','224');
      
      
     
     

    

      $this->Line(10, 50,210-10,50);

      // $this->ln(5);

       $this->cell(0,10,'Printed on: '.date('m/d/Y h:i:s a', time()),0,1,'R');

      $this->SetFont('courier','BI',12);
      $this->Cell(0,10,'',0,1,'C');

      // $this->ln(5);
     
      
        
          }
// Screening page generation ends here ...................
    
           
   



     }
  function Footer()
    {
      $this->SetXY(80,-15);
      $this->SetFont('Helvetica','I',10);
      $this->Write (5, 'OSCOTECH Admission Portal');
    }


$pdf=new PDF();
$pdf->AddPage();
 
$pdf->headerTable();


$pdf->Output('I','OscotechApplicationPortal.pdf');
?>
