<?php
/* ******************************************************
    Sertifikat TOEFL
    Created By: ardiansyah@fmipa.unila.ac.id
    Created Date: 30/03/2020
    Last Edit: 30/03/2020
    
    ***************************************************** */
    
include "header.php";

$spasi = 5;

$pdf = new PDF('L', 'mm', array(210, 170));

$pdf->setBgSertifikat('../images/sertifikat-toefl.jpg', 1);

$pdf->SetLeftMargin(25);
$pdf->SetTopMargin(19);

$pdf->AddFont('MonotypeCorsiva', '', 'MonotypeCorsiva.php');
$pdf->AddFont('ComicSans', '', 'COMIC.php');
$pdf->AddFont('Script', '', 'SCRIPTBL.php');

$pdf->AddPage();

$pdf->SetFont('Arial', '', 12);
$pdf->Cell(160, $spasi, 'MINISTRY OF EDUCATION AND CULTURE', 0, 1, 'C');
$pdf->Cell(160, $spasi, 'UNIVERSITY OF LAMPUNG', 0, 1, 'C');

$pdf->SetFont('Times', 'B', 18);
$pdf->Cell(160, $spasi+2, 'UPT BAHASA', 0, 1, 'C');

$pdf->SetFont('MonotypeCorsiva', '', 11);
$pdf->Cell(160, $spasi-1, 'Jl. Sumantri Brojonegoro No. 1 Bandar Lampung 35145', 0, 1, 'C');
$pdf->Cell(160, $spasi-1, 'Phone & Fax: (0721) 770844, email: uptbahasa@kpa.unila.ac.id', 0, 1, 'C');
$pdf->Line(25, $pdf->GetY()+2, 185, $pdf->Gety()+2);
$pdf->Line(25, $pdf->GetY()+3, 185, $pdf->Gety()+3);

$pdf->Ln();
$pdf->SetFont('MonotypeCorsiva', '', 12);
$pdf->Cell(160, $spasi, 'Number: '.$sertifikat_number, 0, 1, 'R');

$pdf->SetFont('Arial', 'BU', 14);
$pdf->Cell(160, $spasi, 'TEST SCORE RECORD', 0, 1, 'C');


$pdf->SetFont('ComicSans', '', 11);
$pdf->Write($spasi, 'Name');
$pdf->SetX(80);
$pdf->Write($spasi, ':');
$pdf->SetX(83);
$pdf->SetFont('Script', '', 13);
$pdf->Write($spasi, $nama);
$pdf->Ln();

$pdf->SetFont('ComicSans', '', 11);
$pdf->Write($spasi, 'NPM/NIP/Other');
$pdf->SetX(80);
$pdf->Write($spasi, ':');
$pdf->SetX(83);
$pdf->Write($spasi, $ID);
$pdf->Ln();

$pdf->Write($spasi, 'Date of Birth');
$pdf->SetX(80);
$pdf->Write($spasi, ':');
$pdf->SetX(83);
if(strpos($tgl_lahir, '/')  == true)
{
    $birth_date = $tgl_lahir;
}
else
{
    $unix_date = ($tgl_lahir - 25569) * 86400;
    $birth_date = gmdate("d/m/Y", $unix_date);
}
$pdf->Write($spasi, $birth_date);
$pdf->Ln();

$pdf->Write($spasi, 'Times Taken');
$pdf->SetX(80);
$pdf->Write($spasi, ':');
$pdf->SetX(83);
$pdf->Write($spasi, $tes_ke);
$pdf->Ln();

$pdf->Write($spasi, 'Test Date');
$pdf->SetX(80);
$pdf->Write($spasi, ':');
$pdf->SetX(83);
$pdf->SetFont('MonotypeCorsiva', '', 15);
$pdf->Write($spasi, date_format($date_tes, "F j"));
$pdf->SubWrite($spasi, ordinal(date_format($date_tes, "j")),'', 10, 4);
$pdf->Write($spasi, ', '. date_format($date_tes, "Y"));
$pdf->Ln();

$pdf->SetFont('ComicSans', '', 11);
$pdf->Write($spasi, 'Scaled Scores');
$pdf->SetX(80);
$pdf->Write($spasi, ':');
$pdf->Ln();

$pdf->SetX(40);
$pdf->Write($spasi, '* Listening Comprehension');
$pdf->SetX(120);
$pdf->Write($spasi, ':');
$pdf->SetX(123);
$pdf->Write($spasi, strtoupper($lis));
$pdf->Ln();

$pdf->SetX(40);
$pdf->Write($spasi, '* Structure and Written Expression');
$pdf->SetX(120);
$pdf->Write($spasi, ':');
$pdf->SetX(123);
$pdf->Write($spasi, strtoupper($str));
$pdf->Ln();

$pdf->SetX(40);
$pdf->Write($spasi, '* Reading Comprehension');
$pdf->SetX(120);
$pdf->Write($spasi, ':');
$pdf->SetX(123);
$pdf->Write($spasi, strtoupper($rv));
$pdf->Ln();

$pdf->SetX(70);
$pdf->Write($spasi, 'Total Score');
$pdf->SetX(120);
$pdf->Write($spasi, ':');
$pdf->SetX(123);
$pdf->Write($spasi, $skor);
$pdf->Ln();

$pdf->SetFont('MonotypeCorsiva', '', 10);
$pdf->MultiCell(150, $spasi-1, '* This test is an English Proficiency Test (EPT) and administrated by Language Center Univerisity of Lampung.' , 0, 'J');
$pdf->MultiCell(150, $spasi-1, '* It is not endorsed by the Educational Testing Service.' , 0, 'J');
$pdf->MultiCell(150, $spasi-1, '* Certificate is Valid for one year after issued date.' , 0, 'J');

$pdf->SetX(115);
$qrY = $pdf->GetY();
$pdf->SetFont('ComicSans', '', 11);
$pdf->Write($spasi, 'Bandar Lampung, ');
$pdf->SetFont('MonotypeCorsiva', '', 15);
$pdf->Write($spasi, date_format($date_ttd, "F j"));
$pdf->SubWrite($spasi,ordinal(date_format($date_ttd, "j")),'', 10, 4);
$pdf->Write($spasi, ' '.date_format($date_ttd, "Y"));

$pdf->Ln();
$pdf->SetX(115);
$pdf->SetFont('ComicSans', '', 11);
$pdf->Write($spasi, 'Head, ');

$pdf->Ln();
$pdf->Image('../images/ttd-pak-kirlan.png', 115, 129, 45);


$pdf->Ln(10);
$pdf->SetXY(115, 139);
$pdf->Write($spasi, $nama_ka_upt);

$pdf->Ln();
$pdf->SetXY(115, 144);
$pdf->Write($spasi, 'NIP '.$nip_ka_upt);

$pdf->SetAlpha(0.75);
$pdf->Image('../images/cap-upt-bahasa.png', 90, 115, 45);
$pdf->SetAlpha(1);


$pdf->Image('../images/qrcode/'.$ID.'.png', 25, $qrY+1, 35);
$dt_ts2 = date_format($date_tes, "Y-m-d");
if($dt_ts2 < '2021-04-01') {
$pdf->Image('../images/paraf-kasubag.png', 167, 143.5, 2.5);
}


$pdf->Output('D', 'eSertifikatTOEFL-'.$ID.".pdf");

?>