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

$pay_settings = Pay_settings::authenticate(2);


//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, 10, 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(9);
//$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, 'Certificate Fees Payment Receipt', 1, 1, 'C', true);


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

    }

    function Footer()
    {
        $this->Cell(189, 5, '', 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.jpg', 60, 35, 100, 100);
$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(40, 5, strtoupper($biodata->courses), 0, 0);

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


//$pdf->Cell(120, 5,'',0,0);
$pdf->Cell(20, 5, 'Level: ', 0);
$pdf->Cell(49, 5, strtoupper($transact_feedback->programme), 0, 1);//end of line

$pdf->Cell(30, 5, 'Phone: ', 0, 0);
$pdf->Cell(90, 5, $biodata->phone, 0, 0);
$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->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, 'Certificate fees', 1, 0);
$pdf->Cell(25, 5, '', 1, 0);
$pdf->Cell(34, 5, $pay_settings->amount, 1, 0, 'R');
$pdf->Cell(20, 5, '', 0, 1);

//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);

//end of line
//$pay_settings->charge_interswitch + $pay_settings->charge_omoluabi

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

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


$pdf->Output();
?>