<?php require_once("includes/initialize.php"); 
require_once("phpqrcode/qrlib.php");
if (!$session->is_logged_in()) {
    redirect_to("index.php");
}
$user_data = Userdata::find_by_id($session->user_id);
$biodata = Biodata::find_by_id($user_data->formno, $user_data->email);
$transact_feedback = Transaction::authenticate($biodata->formno, $biodata->email);
$id=$session->user_id;
$user_data = User::find_by_id($session->user_id);

$dp = DEPARTMENTCLASS::department_authenticate($biodata->courses);

$alldp = DEPARTMENTCLASS::find_all($dp->faculty);
foreach ($alldp as $aldp) {
    $faculty = $aldp->faculty;
}
$pay_cat = '';
if ($faculty == 'Engineering' or $faculty == 'Applied Sciences' or $faculty == 'Enviromental Studies') {
    $pay_cat = 'science';
} elseif ($faculty == 'Management Sciences') {
    $pay_cat = 'nonscience';
}
$level = $biodata->programme;
$level = $level . " " . "I";
$pay_settings = Pay_settings::authenticate(1, $level, $pay_cat);
if ($user_data->std_process_id < 2){
  if ((substr($biodata->formno,0,2))=="PU"){
 			$user_level = $user_data->std_process_id + 2; 
		 }else {
 		 $user_level = $user_data->std_process_id + 1;
 		 }
		 Userdata::update($id, $user_level);
		 
}
$output = $transact_feedback->txt_ref.'- '.$biodata->formno.' '.$biodata->surname .' '.$biodata->othernames.'  Acceptance Fees: PAID';

QRcode::png($output,$biodata->formno.'.png');
//A4 width: 219mm
//default margin : 10mm each side
//writable horizontal : 219 - (10*2)=189mm
class PDF extends FPDF
{

    function Header()
    {

        $this->SetFont('Arial', 'B', 16);

        $this->Cell(12);
        $this->Image('images/icon.png', 10, 15, 20, 20);
        $this->Cell(189, 5, 'OSUN STATE COLLEGE OF TECHNOLOGY, ESA OKE.', 0, 1, 'C');
        $this->Ln(1);
        $this->SetFont('Arial', 'B', 12);
        $this->Cell(189, 5, 'P.M.B 1011, ESA-OKE, OSUN STATE.', 0, 1, 'C');
        $this->Ln(20);
//$this->Cell(189,1,'',0,1);
//$this->Cell(189,5,'',0,1);

        $this->SetTextColor(255, 255, 255);
        $this->SetFillColor(0, 0, 0);
        $this->SetFont('Courier', 'B', 14);
        
        $this->Cell(189, 5, 'Acceptance Fees Payment Receipt', 1, 1, 'C', true);


        $this->Cell(189, 5, "", 0, 1);

    }

    function Footer()
    {
        $this->Cell(189, 20, '', 0, 1);//end of line
        $this->Cell(189, 5, '', 0, 1);//end of line
        $this->Cell(189, 5, '', 0, 1);//end of line
        $this->Cell(189, 2, '', 0, 1);//end of line
        $this->SetTextColor(255, 255, 255);
        $this->SetFillColor(0, 0, 0);
        $this->SetFont('Courier', 'B', 7);
        $this->Cell(189, 5, 'Directorate of ICT, ESA OKE. ' . date('Y', time()) . ' All Rights Reserved.', 1, 1, 'C', true);

    }

    function Footer2()
    {
        $this->SetFont('Arial', '', 8);
        $this->Cell(0, 10, 'Page ' . $this->PageNo() . '/{nb}', 0, 1, 'C');
    }

}


$pdf = new PDF('p', 'mm', 'A4');

$pdf->AddPage();


$pdf->Image('images/img2.png', 70, 50, 80, 80);
$pdf->Cell(189, 5, '', 0, 1);

$pdf->SetFont('Arial', '', 12);

$pdf->Cell(30, 5, 'Form no: ', 0, 0);
$pdf->Cell(40, 5, strtoupper($biodata->formno), 0, 0);

$pdf->Cell(50, 5, '', 0, 0);//end of line

//$pdf->Cell(80 ,5,'',0,0);
$pdf->Cell(20, 5, 'Date: ', 0);
$pdf->Cell(49, 5, date('d/m/Y h:i a'), 0, 1);//end of line


$pdf->Cell(30, 5, 'Department: ', 0, 0);
$pdf->Cell(159, 5, strtoupper($biodata->courses), 0, 1);

//$pdf->Cell(50, 5, '', 0, 0);//end of line


//$pdf->Cell(120, 5,'',0,0);
$pdf->Cell(30, 5, 'Level: ', 0);
$pdf->Cell(50, 5, strtoupper($level), 0, 0);//end of line
$pdf->Cell(40, 5, '', 0, 0);
$pdf->Cell(20, 5, 'Phone: ', 0, 0);
$pdf->Cell(30, 5, $biodata->phone, 0, 1);
// $pdf->Cell(30, 5, 'Transaction ID: ', 0);
// $pdf->Cell(44, 5, strtoupper($transact_feedback->txt_ref), 0, 1);//end


//make a dummy empty cell as a vertical spacer
$pdf->Cell(189, 5, '', 0, 1);//end of line


$pdf->Cell(189, 5, 'FULLNAME: ' . strtoupper($biodata->surname . ' ' . $biodata->othernames), 0, 1, 'C');
//$pdf->Cell(189, 3, '', 0, 1);

$pdf->ln(5);
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(20, 5, '', 0, 0);

$pdf->Cell(90, 5, 'Description', 1, 0);
$pdf->Cell(25, 5, '', 1, 0);
$pdf->Cell(34, 5, 'Amount', 1, 0);//end of line
$pdf->Cell(20, 5, '', 0, 1);

$pdf->SetFont('Arial', '', 12);

//Numbers are right-aligned so we give 'R' after new line parameter
$pdf->Cell(20, 5, '', 0, 0);

$pdf->Cell(90, 5, 'Acceptance fees', 1, 0);
$pdf->Cell(25, 5, '', 1, 0);
$pdf->Cell(34, 5, $pay_settings->amount, 1, 0, 'L');
// $pdf->Cell(20, 5, '', 0, 1);
// $pdf->Cell(185, 25, $datetime, 1, 0);
//end of line

/*$pdf->Cell(20 ,5,'',0,0);
$pdf->Cell(90 ,5,'Additional charges',1,0);
$pdf->Cell(25  ,5,'',1,0);
$pdf->Cell(34 ,5,'0.00',1,1,'R');
$pdf->Cell(20 ,5,'',0,0);*/
//$pay_settings->charge_interswitch + $pay_settings->charge_omoluabi
//end of line


$pdf->Cell(120, 5, '', 0, 0);
$pdf->Cell(25, 5, 'Total Due', 1, 0);
$pdf->Cell(4, 5, 'N', 1, 0);
$pdf->Cell(20, 5, $pay_settings->amount, 1, 1, 'R');//end of line

//+$pay_settings->charge_interswitch + $pay_settings->charge_omoluabi

$pdf->image($biodata->formno.'.png',185,15,25,25,'png');

$pdf->Output();
?>