<?php

include "../app.siakad-akperpasarrebo.ac.id/jangan_dibuka/perhatian.php";
$petugas = $_COOKIE['namalengkap'];
$id = $_GET['id'];
$no_pendaftaran = $_GET['no_pendaftaran'];


require('../fpdf17/fpdf.php');
//Menampilkan data dari tabel di database

$result=mysqli_query($conn,"select
                                            a.id,a.no_pendaftaran,a.nama_lengkap,a.jenis_kelamin,
                                       a.tinggi_badan,a.berat_badan,a.tempat_lahir,a.tanggal_lahir,a.alamat,a.telepon1,a.telepon2,a.asal_sekolah,a.email,a.nik,a.kota,a.kecamatan,a.kelurahan,a.rt,a.rw,a.agama,a.nama_ibu,a.id_identitas,a.fupload,b.nama_kec,c.nama_kel,d.nama_kab,a.tanggal,a.jam,e.nama_website,
                                       a.tahun_ajaran
                                        from
                                            data_pendaftar a
                                            inner join m_kec b on a.kecamatan = b.id_kec
                                            inner join m_kel c on a.kelurahan = c.id_kel
                                            inner join m_kabkot d on a.kota = d.id_kab
                                            inner join identitas e on a.id_identitas = e.id_identitas
                                        where
                                            a.id = '$id' AND a.no_pendaftaran = '$no_pendaftaran'");

//Inisiasi untuk membuat header kolom
$column_tahun_ajaran = "";
$column_id_identitas = "";
$column_no_pendaftaran = "";
$column_nama_lengkap = "";
$column_jenis_kelamin = "";
$column_tinggi_badan = "";
$column_berat_badan = "";
$column_tempat_lahir = "";
$column_tanggal_lahir = "";
$column_alamat = "";
$column_telepon1 = "";
$column_telepon2 = "";
$column_asal_sekolah = "";
$column_email = "";
$column_nama_kab = "";
$column_nama_kec = "";
$column_nama_kel = "";
$column_rt = "";
$column_rw = "";
$column_agama = "";
$column_nama_ibu = "";
$column_tanggal = "";
$column_fupload = "";
$column_nama_website = "";
$column_petugas = "";


//For each row, add the field to the corresponding column
while($row = mysqli_fetch_array($result))
{
    switch($row['jenis_kelamin']){
        case "1":
            $jk = "Laki-Laki";
        break;
        case "2":
            $jk = "Perempuan";
        break;
    }
	$tahun_ajaran = $row["tahun_ajaran"];
    $id_identitas = $row["nik"];
    $no_pendaftaran = $row["no_pendaftaran"];
    $nama_lengkap = $row["nama_lengkap"];
    $jenis_kelamin = $jk;
    $tinggi_badan = $row["tinggi_badan"];
    $berat_badan = $row["berat_badan"];
    $tempat_lahir = $row["tempat_lahir"];
    $tanggal_lahir = $row["tanggal_lahir"];
    $alamat = $row["alamat"];
	$telepon1 = $row["telepon1"];
    $telepon2 = $row["telepon2"];
    $asal_sekolah = $row["asal_sekolah"];
    $email = $row["email"];
    $nama_kab = $row["nama_kab"];
    $nama_kec = $row["nama_kec"];
    $nama_kel = $row["nama_kel"];
    $rt = $row["rt"];
    $rw = $row["rw"];
    $agama = $row["agama"];
    $nama_ibu = $row["nama_ibu"];
    $tanggal = $row["tanggal"];
    $fupload = $row["fupload"];
    $nama_website = $row["nama_website"];
    $petugas_daftar = $petugas;
 

    $column_tahun_ajaran = $column_tahun_ajaran.$tahun_ajaran."\n";
    $column_id_identitas = $column_id_identitas.$id_identitas."\n";
    $column_no_pendaftaran = $column_no_pendaftaran.$no_pendaftaran."\n";
    $column_nama_lengkap = $column_nama_lengkap.$nama_lengkap."\n";
    $column_jenis_kelamin = $column_jenis_kelamin.$jenis_kelamin."\n";
    $column_tinggi_badan = $column_tinggi_badan.$tinggi_badan."\n";
    $column_berat_badan = $column_berat_badan.$berat_badan."\n";
    $column_tempat_lahir = $column_tempat_lahir.$tempat_lahir."\n";
    $column_tanggal_lahir = $column_tanggal_lahir.$tanggal_lahir."\n";
    $column_alamat = $column_alamat.$alamat."\n";
    $column_telepon1 = $column_telepon1.$telepon1."\n";
    $column_telepon2 = $column_telepon2.$telepon2."\n";
    $column_asal_sekolah = $column_asal_sekolah.$asal_sekolah."\n";
    $column_email = $column_email.$email."\n";
    $column_nama_kab = $column_nama_kab.$nama_kab."\n";
    $column_nama_kec = $column_nama_kec.$nama_kec."\n";
    $column_nama_kel = $column_nama_kel.$nama_kel."\n";
    $column_rt = $column_rt.$rt."\n";
    $column_rw = $column_rw.$rw."\n";
    $column_agama = $column_agama.$agama."\n";
    $column_nama_ibu = $column_nama_ibu.$nama_ibu."\n";
    $column_tanggal = $column_tanggal.$tanggal."\n";
    $column_fupload = $column_fupload.$fupload."\n";
    $column_nama_website = $column_nama_website.$nama_website."\n";
    $column_petugas = $column_petugas.$petugas_daftar."\n";
    

//Create a new PDF file
$pdf = new FPDF('P','mm',array(215,330)); //L For Landscape / P For Portrait
$pdf->AddPage();
$pdf->setLeftMargin(20);

//Menambahkan Gambar
//$pdf->Image('../foto/logo.png',10,10,-175);

$pdf->SetFont('Arial','B',13);
$pdf->SetY(35);
$pdf->Cell(80);
$pdf->Cell(30,5,'Formulir Pendaftaran',0,0,'C');
$pdf->Ln();
$pdf->Cell(80);
$pdf->Cell(30,5,'Seleksi Penerimaan Mahasiswa Baru',0,0,'C');
$pdf->Ln();
$pdf->Cell(80);
$pdf->Cell(30,5,$nama_website,0,0,'C');
$pdf->Ln();
$pdf->Cell(80);
$pdf->Cell(30,5,'TAHUN AJARAN '.$tahun_ajaran,0,0,'C');
$pdf->Ln();
}
//Fields Name position
$Y_Fields_Name_position = 60;

//First create each Field Name
//Gray color filling each Field Name box
//$pdf->SetFillColor(0,0,0);
//Bold Font for Field Name
$pdf->SetFont('Arial','B',10);
$pdf->SetY($Y_Fields_Name_position);
$pdf->SetY(60);
$pdf->Cell(25,8,'Nomor Pendaftaran',0,0,'L');
$pdf->SetY(70);
$pdf->Cell(40,8,'Nama',0,0,'L');
$pdf->SetY(80);
$pdf->Cell(25,8,'Nomor Induk Kependudukan',0,0,'L');
$pdf->SetY(90);
$pdf->Cell(25,8,'Tempat Lahir',0,0,'L');
$pdf->SetY(100);
$pdf->Cell(50,8,'Tanggal Lahir',0,0,'L');
$pdf->SetY(110);
$pdf->Cell(35,8,'Agama',0,0,'L');
$pdf->SetY(120);
$pdf->Cell(35,8,'Nama Ibu Kandung',0,0,'L');
$pdf->SetY(130);
$pdf->Cell(50,8,'Tinggi Badan',0,0,'L');
$pdf->SetY(140);
$pdf->Cell(50,8,'Berat Badan',0,0,'L');
$pdf->SetY(150);
$pdf->Cell(35,8,'Jenis Kelamin',0,0,'L');
$pdf->SetY(160);
$pdf->Cell(35,8,'Alamat',0,0,'L');
$pdf->SetY(170);
$pdf->SetX(80);
$pdf->Cell(35,8,'Rt',0,0,'L');
$pdf->SetY(170);
$pdf->SetX(110);
$pdf->Cell(35,8,'Rw',0,0,'L');
$pdf->SetY(170);
$pdf->SetX(140);
$pdf->Cell(35,8,'Kelurahan',0,0,'L');
$pdf->SetY(180);
$pdf->SetX(80);
$pdf->Cell(35,8,'Kecamatan',0,0,'L');
$pdf->SetY(190);
$pdf->SetX(80);
$pdf->Cell(35,8,'Kota',0,0,'L');
$pdf->SetY(200);
$pdf->Cell(35,8,'No Telpon',0,0,'L');
$pdf->SetY(200);
$pdf->SetX(115);
$pdf->Cell(35,8,'dan',0,0,'L');
$pdf->SetY(210);
$pdf->Cell(35,8,'Alamat Email',0,0,'L');
$pdf->SetY(220);
$pdf->Cell(35,8,'Asal Sekolah',0,0,'L');
$pdf->SetY(230);
$pdf->SetX(140);
$pdf->Cell(50,8,'Jakarta,',0,0,'L');
$pdf->SetY(255);
$pdf->SetX(30);
$pdf->Cell(80,8,'Foto 4x6,',0,0,'L');
$pdf->SetY(240);
$pdf->SetX(80);
$pdf->Cell(80,8,'Pendaftar,',0,0,'L');
$pdf->SetY(240);
$pdf->SetX(150);
$pdf->Cell(80,8,'Petugas,',0,0,'L');

$pdf->Ln();

//Table position, under Fields Name
$Y_Table_Position = 60;

//Now show the columns
$pdf->SetFont('Arial','',10);

$pdf->SetY($Y_Table_Position);
$pdf->SetX(80);
$pdf->MultiCell(25,8,': '.$column_no_pendaftaran,0,'L');

$pdf->SetY(70);
$pdf->SetX(80); 
$pdf->MultiCell(40,8,': '.$column_nama_lengkap,0,'L');

$pdf->SetY(80);
$pdf->SetX(80);
$pdf->MultiCell(25,8,': '.$column_id_identitas,0,'L');

$pdf->SetY(90);
$pdf->SetX(80);
$pdf->MultiCell(25,8,': '.$column_tempat_lahir,0,'L');

$pdf->SetY(100);
$pdf->SetX(80);
$pdf->MultiCell(100,8,': '.$column_tanggal_lahir,0,'L');

$pdf->SetY(110);
$pdf->SetX(80);
$pdf->MultiCell(35,8,': '.$column_agama,0,'L');

$pdf->SetY(120);
$pdf->SetX(80);
$pdf->MultiCell(35,8,': '.$column_nama_ibu,0,'L');

$pdf->SetY(130);
$pdf->SetX(80);
$pdf->MultiCell(100,8,': '.$column_tinggi_badan,0,'L');

$pdf->SetY(140);
$pdf->SetX(80);
$pdf->MultiCell(100,8,': '.$column_berat_badan,0,'L');

$pdf->SetY(150);
$pdf->SetX(80);
$pdf->MultiCell(35,8,': '.$column_jenis_kelamin,0,'L');

$pdf->SetY(160);
$pdf->SetX(80);
$pdf->MultiCell(150,8,': '.$column_alamat,0,'L');

$pdf->SetY(170);
$pdf->SetX(90);
$pdf->MultiCell(35,8,': '.$column_rt,0,'L');

$pdf->SetY(170);
$pdf->SetX(120);
$pdf->MultiCell(35,8,' : '.$column_rw,0,'L');

$pdf->SetY(170);
$pdf->SetX(160);
$pdf->MultiCell(35,8,' : '.$column_nama_kel,0,'L');

$pdf->SetY(180);
$pdf->SetX(100);
$pdf->MultiCell(35,8,': '.$column_nama_kec,0,'L');

$pdf->SetY(190);
$pdf->SetX(100);
$pdf->MultiCell(35,8,': '.$column_nama_kab,0,'L');

$pdf->SetY(200);
$pdf->SetX(80);
$pdf->MultiCell(35,8,': '.$column_telepon1,0,'L');

$pdf->SetY(200);
$pdf->SetX(130);
$pdf->MultiCell(35,8,' '.$column_telepon2,0,'L');

$pdf->SetY(210);
$pdf->SetX(80);
$pdf->MultiCell(100,8,': '.$column_email,0,'L');

$pdf->SetY(220);
$pdf->SetX(80);
$pdf->MultiCell(100,8,': '.$column_asal_sekolah,0,'L');

$pdf->SetY(230);
$pdf->SetX(155);
$pdf->MultiCell(100,8,' '.$column_tanggal,0,'L');

$pdf->SetY(275);
$pdf->SetX(80);
$pdf->Cell(80,8,$nama_lengkap,0,0,'L');

$pdf->SetY(275);
$pdf->SetX(150);
$pdf->Cell(80,8,$petugas_daftar,0,0,'L');
$pdf->Output();
?>
