<?php
include "../../../koneksi.php";
require('../fpdf17/fpdf.php');
/**
 Judul  : Laporan PDF (portait):
 Level  : Menengah
 Author : Hakko Bio Richard
 Blog   : www.hakkoblogs.com
 Web    : www.niqoweb.com
 Email  : hakkobiorichard@ygmail.com
 
 Untuk tutorial yang lainnya silahkan berkunjung ke www.hakkoblogs.com
 
 Butuh jasa pembuatan website, aplikasi, pembuatan program TA dan Skripsi.? Hubungi NiqoWeb ==>> 085694984803
 
 **/
//Menampilkan data dari tabel di database

$result=mysql_query("SELECT * FROM hasil order by hasil desc") or die(mysql_error());

//Inisiasi untuk membuat header kolom
$no="";
$colomid_wilayah = "";
$colomnama_wilayah = "";
$colomhasil = "";
$colomket = "";
$i=1;
//For each row, add the field to the corresponding column
while($row = mysql_fetch_array($result))
{

$id_wilayah=$row['id_wilayah'];
$hasil =$row['hasil'];
$hasil= round($hasil,4);
$ket=$row['keterangan'];

$query2 = mysql_query("(SELECT * FROM wilayah where id_wilayah='$id_wilayah')");
while($row2 = mysql_fetch_array($query2)){

	//$id_kriteria = $row["id_kriteria"];
    $nama_wilayah = $row2["nama_wilayah"];
	
	$no = $no.$i."\n";
	$colomid_wilayah = $colomid_wilayah.$id_wilayah."\n";
    $colomnama_wilayah = $colomnama_wilayah.$nama_wilayah."\n";
    $colomhasil = $colomhasil.$hasil."\n";
    $colomket = $colomket.$ket."\n";

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

//Menambahkan Gambar
$pdf->Image('logo.png',7,7,-175);
$pdf->Ln();
$pdf->Ln();
$pdf->Cell(10);
$pdf->SetFont('Arial','B',13);
$pdf->Cell(80);
$pdf->Cell(30,10,'KEMENTRIAN PERTANIAN',0,0,'C');
$pdf->Ln();
$pdf->Cell(80);
$pdf->Cell(30,10,'DINAS PERTANIAN DAN PETERNAKAN GORONTALO ',0,0,'C');
$pdf->Ln();
$pdf->SetFont('Arial','',10);
$pdf->Cell(10);
$pdf->Cell(115,15,'RANGKING WILAYAH BERPOTENSI DI BIDANG PERTANIAN BERDASARKAN HASIL',0,0,'L');
$pdf->Ln();
$pdf->Cell(10);
$pdf->Cell(115,0,'AKHIR DARI PROSES PENILAIAN :',0,0,'L');
$pdf->Ln();
$i=$i+1;
}}
//Fields Name position
$Y_Fields_Name_position = 50;

//First create each Field Name
//Gray color filling each Field Name box
$pdf->SetFillColor(110,180,230);
//Bold Font for Field Name
$pdf->SetFont('Arial','B',10);
$pdf->SetY($Y_Fields_Name_position);
$pdf->SetX(5);
$pdf->Cell(25,8,'Rangking',1,0,'C',1);
$pdf->SetX(30);
$pdf->Cell(25,8,'ID Wilayah',1,0,'C',1);
$pdf->SetX(55);
$pdf->Cell(50,8,'Nama Wilayah',1,0,'C',1);
$pdf->SetX(105);
$pdf->Cell(65,8,'Hasil',1,0,'C',1);
$pdf->SetX(165);
$pdf->Cell(40,8,'Ket',1,0,'C',1);
$pdf->SetX(165);
$pdf->Ln();

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

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

$pdf->SetY($Y_Table_Position);
$pdf->SetX(5);
$pdf->MultiCell(25,6,$no,1,'C');

$pdf->SetY($Y_Table_Position);
$pdf->SetX(30);
$pdf->MultiCell(25,6,$colomid_wilayah,1,'C');

$pdf->SetY($Y_Table_Position);
$pdf->SetX(55);
$pdf->MultiCell(50,6,$colomnama_wilayah,1,'L');

$pdf->SetY($Y_Table_Position);
$pdf->SetX(105);
$pdf->MultiCell(60,6,$colomhasil,1,'C');

$pdf->SetY($Y_Table_Position);
$pdf->SetX(165);
$pdf->MultiCell(40,6,$colomket,1,'C');

$pdf->Output();
?>
