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

$kode = 'AKD190002';
$qrKode = '../img/1117031061.png';

class PDF extends FPDF
{
    // Page header
    function Header()
    {
        if($this->page == 1)
        {
        // Logo
        $this->Image('../img/Logo-unila.png',15,10,23);
        // Arial bold 15
        $this->SetFont('Times','B',14);
        // Move to the right
        //$this->Cell(30);
        $this->SetXY(40, 10);
        // Title
        
        $this->Cell(155,4,'KEMENTERIAN RISET, TEKNOLOGI DAN PENDIDIKAN TINGGI',0,1,'C');
        $this->SetFont('Times','B',18);
        $this->SetX(40);
        $this->Cell(155,7,'UNIVERSITAS LAMPUNG',0,1,'C');
        $this->SetFont('Times','B',14);
        $this->SetX(40);
        $this->Cell(155,4,'FAKULTAS MATEMATIKA DAN ILMU PENGETAHUAN ALAM',0,1,'C');
        $this->SetFont('Times','',10);
        $this->SetX(40);
        $this->Cell(155,4,'Jl. Prof. Dr. Sumantri Brojonegoro No. 1 Bandar Lampung 35145',0,1,'C');
        $this->SetFont('Times','',10);
        $this->SetX(40);
        $this->Cell(155,3,'Telp. (0721) 704625 Fax. (0721) 704625 - https://fmipa.unila.ac.id',0,1,'C');
        // Line break
        $this->SetDrawColor(0, 0, 255);
        $this->Line(10, $this->GetY()+3, 200, $this->GetY()+3);
        $this->Line(10, $this->GetY()+4, 200, $this->GetY()+4);
        
        }
        $this->Ln(8);
    }
    
    // Page footer
    function Footer()
    {
        global $kode;
        global $qrKode;
        // Position at 1.5 cm from bottom
        $this->SetY(-15);
        $this->SetX(15);
        // Arial italic 8
        $this->SetFont('Times','',11);
        // Page number
        $this->Cell(90,5,'F-0'.$this->PageNo().'/PM/MIPA/I/16',0,0,'L');
        $this->Cell(90,5,$kode,0,1,'R');
        // QR-Code
        $this->SetY(-35);
        $this->Image($qrKode,174,$this->GetY(),20);
        
    }
    
    // Wrapping Cell
    
    // 
    var $widths;
    var $aligns;
    
    function SetWidths($w)
    {
        //Set the array of column widths
        $this->widths=$w;
    }
    
    function SetAligns($a)
    {
        //Set the array of column alignments
        $this->aligns=$a;
    }
    
    function TableTitle($data)
    {
        $this->SetFont('Times','B',14);
        $this->Cell(190, 5, $data, 0, 1, 'C');
        $this->Ln();
        $this->SetFont('Times','',11);
    }

    function TableHeader1($data)
    {
        $this->Cell(28, 8, 'Fakultas/Jurusan', 'LTB', 0, 'L', true);
        $this->Cell(3, 8, ':', 'TB', 0, 'L', true);
        $this->Cell(72, 8, $data[0], 'RTB', 0, 'L', true);
        $this->Cell(30, 8, 'Nama Mahasiswa', 'LTB', 0, 'L', true);
        $this->Cell(3, 8, ':', 'TB', 0, 'L', true);
        $this->Cell(54, 8, $data[1], 'RTB', 0, 'L', true);
        $this->Ln();
    }
    
    function TableHeader2($data)
    {
        $this->Cell(28, 8, 'Jenis Layanan', 'LTB', 0, 'L', true);
        $this->Cell(3, 8, ':', 'TB', 0, 'L', true);
        $this->SetFont('Times','B',11);
        $this->Cell(72, 8, $data[0], 'RTB', 0, 'L', true);
        $this->SetFont('Times','',11);
        $this->Cell(30, 8, 'NPM', 'LTB', 0, 'L', true);
        $this->Cell(3, 8, ':', 'TB', 0, 'L', true);
        $this->Cell(54, 8, $data[1], 'RTB', 0, 'L', true);
        $this->Ln();
    }
    
    function SubHeader($data)
    {
        for($i=0;$i<count($data);$i++)
        {
            $this->Cell($this->widths[$i], 8, $data[$i], 1, 0, 'C', true);
        }
        $this->Ln();
    }
    
    function Row($data)
    {
        //Calculate the height of the row
        $nb=0;
        for($i=0;$i<count($data);$i++)
            $nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
        $h=5*$nb;
        //Issue a page break first if needed
        $this->CheckPageBreak($h);
        //Draw the cells of the row
        for($i=0;$i<count($data);$i++)
        {
            $w=$this->widths[$i];
            $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
            //Save the current position
            $x=$this->GetX();
            $y=$this->GetY();
            //Draw the border
            $this->Rect($x,$y,$w,$h);
            //Print the text
            $this->MultiCell($w,5,$data[$i],0,$a);
            //Put the position to the right of the cell
            $this->SetXY($x+$w,$y);
        }
        //Go to the next line
        $this->Ln($h);
    }
    
    function CheckPageBreak($h)
    {
        //If the height h would cause an overflow, add a new page immediately
        if($this->GetY()+$h>$this->PageBreakTrigger)
            $this->AddPage($this->CurOrientation);
    }
    
    function NbLines($w,$txt)
    {
        //Computes the number of lines a MultiCell of width w will take
        $cw=&$this->CurrentFont['cw'];
        if($w==0)
            $w=$this->w-$this->rMargin-$this->x;
        $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
        $s=str_replace("\r",'',$txt);
        $nb=strlen($s);
        if($nb>0 and $s[$nb-1]=="\n")
            $nb--;
        $sep=-1;
        $i=0;
        $j=0;
        $l=0;
        $nl=1;
        while($i<$nb)
        {
            $c=$s[$i];
            if($c=="\n")
            {
                $i++;
                $sep=-1;
                $j=$i;
                $l=0;
                $nl++;
                continue;
            }
            if($c==' ')
                $sep=$i;
            $l+=$cw[$c];
            if($l>$wmax)
            {
                if($sep==-1)
                {
                    if($i==$j)
                        $i++;
                }
                else
                    $i=$sep+1;
                $sep=-1;
                $j=$i;
                $l=0;
                $nl++;
            }
            else
                $i++;
        }
        return $nl;
    }
}

function setData($pdf, $attr, $val) {
    $pdf->SetX(15);
    $pdf->Cell(40, 5,$attr, 0, 0, 'L');
    $pdf->Cell(3, 5,':', 0, 0, 'L');
    $pdf->Cell(100, 5,$val, 0, 1, 'L');
    
    return $pdf;
}

function setSignLab($pdf, $labName, $labPerson, $labNip, $labName2, $labPerson2, $labNip2) {
    $pdf->SetX(15);
    $pdf->Rect($pdf->GetX(), $pdf->GetY(), 90, 23);
    $pdf->Rect($pdf->GetX()+90, $pdf->GetY(), 90, 23);
    $pdf->Cell(90, 5, $labName, 0, 0, 'L');
    $pdf->Cell(90, 5, $labName2, 0, 1, 'L');
    $pdf->Ln(8);
    $pdf->SetX(15);
    $pdf->Cell(90, 5, $labPerson, 0, 0, 'L');
    $pdf->Cell(90, 5, $labPerson2, 0, 1, 'L');
    $pdf->SetX(15);
    $pdf->Cell(90, 5, $labNip, 0, 0, 'L');
    $pdf->Cell(90, 5, $labNip2, 0, 1, 'L');
    
    return $pdf;
}


// $pdf = new FPDF('P','mm','A4');
$pdf = new PDF('P','mm',array(210,330));
$pdf->AddPage();
$pdf->SetFont('Times','BU',14);
$pdf->Cell(190, 5,'FORMULIR BEBAS LABORATORIUM', 0, 1, 'C');
$pdf->SetFont('Times','',11);
$pdf->Cell(190, 5,'Nomor:         /UN26.17/DT/20   ', 0, 1, 'C');
$pdf->Ln(2);
$pdf->SetX(15);
$pdf->MultiCell(180, 5,'Mahasiswa yang tercantum di bawah ini telah menyelesaikan semua administrasi laboratorium (peminjaman alat/beban)', 0, 'J');

$pdf = setData($pdf, 'Nama', 'Ardiansyah');
$pdf = setData($pdf, 'NPM', '0517032014');
$pdf = setData($pdf, 'Jurusan/Program Studi', 'Ilmu Komputer / S1 Ilmu Komputer');
$pdf->SetY($pdf->GetY()+2);
$pdf = setSignLab($pdf, 'Ka. Lab. Kimia Dasar', 'Dr. Zipora Sembiring, M.S.', 'NIP. 195901061986032001', 'Ka. Lab. Biokimia', 'Dr. Heri Satria, S.Si., M.Si.', 'NIP 197110012005011002');
$pdf = setSignLab($pdf, 'Ka. Lab. Kimia Dasar', 'Dr. Zipora Sembiring, M.S.', 'NIP. 195901061986032001', 'Ka. Lab. Biokimia', 'Dr. Heri Satria, S.Si., M.Si.', 'NIP 197110012005011002');
$pdf = setSignLab($pdf, 'Ka. Lab. Kimia Dasar', 'Dr. Zipora Sembiring, M.S.', 'NIP. 195901061986032001', 'Ka. Lab. Biokimia', 'Dr. Heri Satria, S.Si., M.Si.', 'NIP 197110012005011002');
$pdf = setSignLab($pdf, 'Ka. Lab. Kimia Dasar', 'Dr. Zipora Sembiring, M.S.', 'NIP. 195901061986032001', 'Ka. Lab. Biokimia', 'Dr. Heri Satria, S.Si., M.Si.', 'NIP 197110012005011002');
$pdf = setSignLab($pdf, 'Ka. Lab. Kimia Dasar', 'Dr. Zipora Sembiring, M.S.', 'NIP. 195901061986032001', 'Ka. Lab. Biokimia', 'Dr. Heri Satria, S.Si., M.Si.', 'NIP 197110012005011002');
$pdf = setSignLab($pdf, 'Ka. Lab. Kimia Dasar', 'Dr. Zipora Sembiring, M.S.', 'NIP. 195901061986032001', 'Ka. Lab. Biokimia', 'Dr. Heri Satria, S.Si., M.Si.', 'NIP 197110012005011002');
$pdf = setSignLab($pdf, 'Ka. Lab. Kimia Dasar', 'Dr. Zipora Sembiring, M.S.', 'NIP. 195901061986032001', 'Ka. Lab. Biokimia', 'Dr. Heri Satria, S.Si., M.Si.', 'NIP 197110012005011002');
$pdf = setSignLab($pdf, 'Ka. Lab. Kimia Dasar', 'Dr. Zipora Sembiring, M.S.', 'NIP. 195901061986032001', 'Ka. Lab. Biokimia', 'Dr. Heri Satria, S.Si., M.Si.', 'NIP 197110012005011002');


$pdf->SetY(265);
$pdf->SetX(110);
$pdf->MultiCell(85, 5, "Bandar Lampung, ......................\na.n. Dekan,\nWakil Dekan Bid. Akademik dan Kerjasama\n\n\n\nProf. Dr. Sutopo Hadi, M.Sc.\nNIP. 197104201996011001,", 0, 'L');

$pdf->SetFont('Times','',10);
$pdf->SetY(265);
$pdf->SetX(15);
$pdf->Cell(90, 4, 'Catatan:',0,1,'L');
$pdf->SetX(15);
$pdf->Cell(5, 4, '1)',0,0,'L');
$pdf->MultiCell(85, 4, 'Semua calon lulusan S1 harus mendapatkan Bebas Lab. dari semua lab yang ada di FMIPA (untuk D3 hanya lab. di jurusan masing-masing).  Tanda tangan semua kalab harus dilakukan sebelum ujian skripsi dan tanggal penandatangan', 0, 'L');
$pdf->SetX(15);
$pdf->Cell(5, 4, '2)',0,0,'L');
$pdf->MultiCell(85, 4, 'Lampirkan fotocopy berita acara seminar hasil.', 0, 'L');


// LEMBAR VERIFIKASI
$pdf->AddPage('P');
$pdf->SetFillColor(205,205,205);

// Title
$pdf->TableTitle('VERIFIKASI PERSYARATAN LAYANAN');
// Header
$pdf->TableHeader1(array('MIPA / Ilmu Komputer', 'Ardiansyah'));
$pdf->TableHeader2(array('PERMOHONAN STUDI TERBIMBING', '0517032014'));
// SubHeader
$pdf->SetWidths(array(8,69,13,13,20,30,22,15));
$pdf->SubHeader(array('No', 'Jenis Persyaratan', 'Sah', 'Benar', 'Lengkap', 'Tgl Penyelesaian', 'Verifikasi', 'Paraf'));

// Isi
$pdf->SetAligns(array('C','L'));
$pdf->Row(array('1',"Form bebas Laboratorium Hasil unduhan dari Website FMIPA unila yang sudah di tanda tangani semua Kepala Laboratorium\n(10 Lembar)",'','','','','',''));
$pdf->Row(array('2',"Fotocopy berita acara seminar hasil (khusus mahasiswa S1 dan S2)\n(2 lembar)
",'','','','','',''));

// CAP FAKULTAS
$pdf->Ln(10);
// Title
$pdf->TableTitle('VERIFIKASI PERSYARATAN LAYANAN');
// Header
$pdf->TableHeader1(array('MIPA / Ilmu Komputer', 'Ardiansyah'));
$pdf->TableHeader2(array('CAP FAKULTAS', '0517032014'));
// SubHeader
$pdf->SetWidths(array(8,69,13,13,20,30,22,15));
$pdf->SubHeader(array('No', 'Jenis Persyaratan', 'Sah', 'Benar', 'Lengkap', 'Tgl Penyelesaian', 'Verifikasi', 'Paraf'));

// Isi
$pdf->SetWidths(array(8,69,13,13,20,30,22,15));
$pdf->SetAligns(array('C','L'));
$pdf->Row(array('1',"Dokumen yang telah ditandatangani oleh pejabat yang berwenang",'','','','','',''));

$pdf->Output();



?>